import{j as e,q as s,at as O,bx as I,ba as _,bp as b,w as l,gd as R,aA as L,aB as M,X as m,bF as U,L as G,f as W,bk as i,bz as w,bA as V,aJ as k,bB as B,h as q,x as H}from"./index-DHiyXWqE.js";import{u as K}from"./useScreenWithScroll-zcr7TMGO.js";import{D as X,A as $,S as z,R as J,K as Y}from"./ScalingConfigurationField-CLSzqPWR.js";import{N as Z}from"./NameField-B9S6INwx.js";import{s as o}from"./styles-Cck2dVpe.js";import"./index-BdIq0ego.js";import{v as Q,P as ee,a as oe,S as se,b as re,C as ie,M as te,c as d,d as u,e as ne,f as ae,g as le,h as de,T as ce,i as pe,j as me,A as ue}from"./PythonEnvField-DPH7js2h.js";import{c as xe}from"./utils-iWS1xq3i.js";import"./form-CrZPXKpD.js";import"./KubernetesProjectEdit-Dg3mVF7r.js";import"./index-5hEKE-oe.js";import"./SingleSelect-CAXL6nES.js";import"./getDefaultFormValues-DjHhdfri.js";import"./index-Bat3pAWW.js";const ge=()=>e.jsxs(s,{sx:o.defaultGap,children:[e.jsx(Z,{}),e.jsx(X,{})]}),x={scaleMetric:"CONCURRENCY",minInstances:0,maxInstances:te,target:ie,stableWindowSeconds:re,scaleToZeroRetentionSeconds:se,panicWindowPercentage:oe,panicThresholdPercentage:ee},g={deploymentUIType:"model",name:void 0,modelName:void 0,modelFramework:void 0,modelServer:void 0,artifactVersion:void 0,predictor:void 0,transformer:void 0,configFile:void 0,kserve:!0,kafkaTopicDTO:void 0,inferenceLogging:void 0,modelInput:void 0,predictions:void 0,predictorResources:{cores:[d.cores,u.cores],memory:[d.memory,u.memory],gpus:d.gpus},batchingConfiguration:{batchingEnabled:!1},requestedInstances:void 0,requestedTransformerInstances:0,predictorScalingConfig:x,transformerScalingConfig:x},Oe=()=>{const{id:f,project:j}=O(),F=K(),E=I(),C=_(),{state:c={}}=b(),[h,v]=l(),[S,y]=l(),[N,T]=l(),[P,{isLoading:t}]=R(),r=L({reValidateMode:"onChange",shouldUnregister:!1,mode:"onChange",resetOptions:{keepDefaultValues:!0},defaultValues:m(g,c??{}),values:m(g,c??{}),resolver:M(Q)}),A=async D=>{if(q(r.formState.errors))try{const a=xe({formValues:D,project:j});await P({projectId:f,formValues:a}).unwrap(),r.reset(),C(H.project.deployments.list)}catch(a){console.error(a)}},n=r.getValues("deploymentUIType"),p=n==="model";return e.jsxs(U,{...r,children:[t&&e.jsx(G,{}),e.jsxs("form",{onSubmit:r.handleSubmit(A,console.error),style:o.editForm,children:[e.jsx(s,{justifyContent:"center",sx:o.editFormWrapper,children:e.jsxs(s,{flexDirection:"column",sx:o.fieldsWrapper,children:[e.jsx(W,{title:`Create new ${n} deployment`,children:e.jsxs(s,{flexDirection:"column",sx:o.defaultGap,children:[e.jsx(ne,{}),p&&e.jsxs(s,{sx:o.defaultGap,children:[e.jsx(ae,{}),e.jsx(le,{})]}),e.jsx(ge,{})]})}),e.jsx(i,{title:"Environment configuration",children:e.jsxs(s,{flexDirection:"column",sx:o.defaultGap,children:[e.jsx(de,{isFileExplorerOpen:h,toggleFileExplorerPopup:v}),e.jsx(ce,{isFileExplorerOpen:S,toggleFileExplorerPopup:y}),e.jsx(pe,{}),e.jsx(me,{isFileExplorerOpen:N,toggleFileExplorerPopup:T})]})}),e.jsx(i,{title:"Advanced configuration",children:e.jsxs(s,{flexDirection:"column",sx:o.defaultGap,children:[e.jsx(ue,{}),p&&e.jsx($,{})]})}),e.jsx(i,{title:"Scaling configuration",children:e.jsx(z,{})}),e.jsx(i,{title:"Resources per Instance",children:e.jsx(J,{})}),e.jsx(Y,{prefix:[],init:!0})]})}),e.jsx(w,{sx:{maxWidth:`var(${V})`},hasScrollOnScreen:F,mainButton:e.jsxs(B,{type:"submit",intent:"primary",disabled:t,isLoading:t,children:["Create new ",n," deployment"]}),secondaryButton:e.jsx(k,{type:"button",intent:"secondary",onClick:()=>E(-1),children:"Back"})})]})]})};export{Oe as Create,Oe as default};
