import{j as e,q as o,at as I,bx as V,ba as O,bp as _,w as l,gc as R,aA as L,aB as M,X as m,gd as G,bF as U,L as W,f as w,bk as a,bz as k,bA as B,aJ as q,bB as H,h as K,x as X}from"./index-C6OVXshM.js";import{u as $}from"./useScreenWithScroll-zcr7TMGO.js";import{D as z,V as J,E as u,A as Y,S as Z,R as Q,K as ee}from"./VllmImageTagField-AN5H4n7T.js";import{N as se}from"./NameField-Bb4yDaKg.js";import{s}from"./styles-BPLr4oRJ.js";import"./index-KEKA6gJs.js";import{v as oe,P as re,a as ae,S as ie,b as te,C as ne,M as le,c as d,d as x,e as de,f as ce,g as pe,h as me,T as ue,i as xe,V as ge,j as fe,A as je}from"./PythonEnvField-B_tld6Kg.js";import{c as Ee}from"./utils-wf3IXyH3.js";import"./form-DrxIax0x.js";import"./KubernetesProjectEdit-CW1eW2Bv.js";import"./index-D-ycbDlq.js";import"./SingleSelect-7lunYcLR.js";import"./getDefaultFormValues-o5T6XyY0.js";import"./index-Clp3wC8S.js";import"./rcompare-Ofleby2D.js";const Fe=()=>e.jsxs(o,{sx:s.defaultGap,children:[e.jsx(se,{}),e.jsx(z,{})]}),g={scaleMetric:"CONCURRENCY",minInstances:0,maxInstances:le,target:ne,stableWindowSeconds:te,scaleToZeroRetentionSeconds:ie,panicWindowPercentage:ae,panicThresholdPercentage:re},f={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,vllmVariant:G.VLLM,vllmImageTag:null,kserve:!0,kafkaTopicDTO:void 0,inferenceLogging:void 0,modelInput:void 0,predictions:void 0,predictorResources:{cores:[d.cores,x.cores],memory:[d.memory,x.memory],gpus:d.gpus},batchingConfiguration:{batchingEnabled:!1},requestedInstances:void 0,requestedTransformerInstances:0,predictorScalingConfig:g,transformerScalingConfig:g,predictorEnvVars:[],transformerEnvVars:[]},Re=()=>{const{id:j,project:E}=I(),F=$(),v=V(),C=O(),{state:c={}}=_(),[h,T]=l(),[S,y]=l(),[N,P]=l(),[b,{isLoading:i}]=R(),r=L({reValidateMode:"onChange",shouldUnregister:!1,mode:"onChange",resetOptions:{keepDefaultValues:!0},defaultValues:m(f,c??{}),values:m(f,c??{}),resolver:M(oe)}),A=async D=>{if(K(r.formState.errors))try{const n=Ee({formValues:D,project:E});await b({projectId:j,formValues:n}).unwrap(),r.reset(),C(X.project.deployments.list)}catch(n){console.error(n)}},t=r.getValues("deploymentUIType"),p=t==="model";return e.jsxs(U,{...r,children:[i&&e.jsx(W,{}),e.jsxs("form",{onSubmit:r.handleSubmit(A,console.error),style:s.editForm,children:[e.jsx(o,{justifyContent:"center",sx:s.editFormWrapper,children:e.jsxs(o,{flexDirection:"column",sx:s.fieldsWrapper,children:[e.jsx(w,{title:`Create new ${t} deployment`,children:e.jsxs(o,{flexDirection:"column",sx:s.defaultGap,children:[e.jsx(de,{}),p&&e.jsxs(o,{sx:s.defaultGap,children:[e.jsx(ce,{}),e.jsx(pe,{})]}),e.jsx(Fe,{})]})}),e.jsx(a,{title:"Environment configuration",children:e.jsxs(o,{flexDirection:"column",sx:s.defaultGap,children:[e.jsx(me,{isFileExplorerOpen:h,toggleFileExplorerPopup:T}),e.jsx(ue,{isFileExplorerOpen:S,toggleFileExplorerPopup:y}),e.jsx(xe,{}),e.jsxs(o,{sx:s.defaultGap,alignSelf:"start",children:[e.jsx(ge,{}),e.jsx(J,{})]}),e.jsx(fe,{isFileExplorerOpen:N,toggleFileExplorerPopup:P}),e.jsx(u,{name:"predictorEnvVars",label:"Predictor environment variables"}),e.jsx(u,{name:"transformerEnvVars",label:"Transformer environment variables"})]})}),e.jsx(a,{title:"Advanced configuration",children:e.jsxs(o,{flexDirection:"column",sx:s.defaultGap,children:[e.jsx(je,{}),p&&e.jsx(Y,{})]})}),e.jsx(a,{title:"Scaling configuration",children:e.jsx(Z,{})}),e.jsx(a,{title:"Resources per Instance",children:e.jsx(Q,{})}),e.jsx(ee,{prefix:[],init:!0})]})}),e.jsx(k,{sx:{maxWidth:`var(${B})`},hasScrollOnScreen:F,mainButton:e.jsxs(H,{type:"submit",intent:"primary",disabled:i,isLoading:i,children:["Create new ",t," deployment"]}),secondaryButton:e.jsx(q,{type:"button",intent:"secondary",onClick:()=>v(-1),children:"Back"})})]})]})};export{Re as Create,Re as default};
