import{r as f,bp as V,ay as L,u as M,w as K,fp as N,fq as W,fr as U,aD as q,fs as z,ft as D,j as e,s as c,bw as H,B as r,y as Q,dz as a,bs as b,bA as $,br as J,fu as d,b4 as X,c as v,aE as Y,h as Z,f6 as _,q as ee}from"./index-C1DmWO_C.js";import{R as E}from"./RedirectInProject-DyNX4L_7.js";import{u as se}from"./useScreenWithScroll-zcr7TMGO.js";import{u as te}from"./useProjectId-Cio5B8Wh.js";import{D as re,K as ie,T as ae,a as oe,I as ne,A as le,R as ce,b as de,v as ue}from"./validations-Bg4qD5Hi.js";import{a as xe,b as me,A as pe,P as fe,c as je,d as he}from"./PythonEnvField-Dwe2UtOV.js";import{s as t}from"./styles-C5ly0pQK.js";import"./SingleSelect-DvF8BLvQ.js";import"./index-CxmfBMSc.js";import"./KubernetesProjectEdit-O522bxXP.js";import"./index-Dub34MAX.js";import"./FileUploaderButton-BtxUzlTS.js";import"./index-DMOJMCC5.js";import"./cluster-utilization-Ci7AXjmO.js";import"./min-BJfYLHXY.js";const Be=()=>{var g;const[u,x]=f.useState(!1),F=V(),P=se(),o=te(),{project:S}=L(),{dId:n}=M(),[y,C]=K(),[I,{isLoading:m,isSuccess:k}]=N(),{data:s,isFetching:h}=W({projectId:o,id:n},{refetchOnMountOrArgChange:!0}),[A,{isLoading:O,isSuccess:w}]=U(),l=q({reValidateMode:"onChange",shouldUnregister:!1,mode:"onChange",resolver:Y(ue)}),B=async i=>{Z(l.formState.errors)&&await I({projectId:o,formValues:_({apiValues:D(s),formValues:i,project:S})})},{handleDelete:G}=f.useContext(z),R=async()=>{try{await A({projectId:+o,deploymentId:n}).unwrap(),G(ee(c.deployments.overview,c.project.value,{id:o,dId:n}))}catch(i){console.error(i)}},T=()=>F(-1),p=()=>x(i=>!i);return f.useEffect(()=>{l.reset({...D(s),kserve:(s==null?void 0:s.servingTool)==="KSERVE"})},[s]),k?e.jsx(E,{to:c.deployments.overview,params:{dId:n}}):w?e.jsx(E,{to:c.deployments.list}):e.jsx(H,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(B),style:t.editForm,children:[e.jsx(r,{sx:t.editFormWrapper,children:e.jsxs(r,{flexDirection:"column",sx:t.fieldsWrapper,children:[e.jsx(Q,{title:"Edit deployment",children:e.jsxs(r,{flexDirection:"column",sx:t.defaultGap,children:[e.jsxs(r,{sx:t.defaultGap,children:[e.jsx(j,{name:"name",value:s==null?void 0:s.name}),e.jsx(j,{name:"framework",value:s==null?void 0:s.modelFramework}),e.jsx(j,{name:"model server",value:s==null?void 0:s.modelServer})]}),e.jsxs(r,{sx:t.defaultGap,children:[e.jsx(xe,{}),e.jsx(me,{}),e.jsx(pe,{})]}),e.jsx(re,{})]})}),e.jsx(a,{title:"Environment configuration",children:e.jsxs(r,{flexDirection:"column",sx:t.defaultGap,children:[e.jsx(ie,{disabled:!0}),e.jsx(fe,{isFileExplorerOpen:y,toggleFileExplorerPopup:C}),e.jsx(ae,{}),e.jsx(je,{})]})}),e.jsx(a,{title:"Inference logging",children:e.jsxs(r,{flexDirection:"column",sx:t.defaultGap,children:[e.jsx(oe,{}),e.jsx(ne,{})]})}),e.jsx(a,{title:"Advanced configuration",children:e.jsxs(r,{flexDirection:"column",sx:t.defaultGap,children:[e.jsx(he,{apiProtocol:s==null?void 0:s.apiProtocol}),e.jsx(le,{batchingEnabled:(g=s==null?void 0:s.batchingConfiguration)==null?void 0:g.batchingEnabled})]})}),e.jsx(a,{title:"Resource allocation",children:e.jsx(ce,{})}),e.jsx(de,{prefix:[],init:!1}),e.jsxs(a,{title:"Danger zone",mb:"20px",children:[e.jsx(b,{intent:"alert",type:"button",disabled:m||h,onClick:p,children:"Delete deployment"}),e.jsx($,{title:`Delete ${s==null?void 0:s.name}`,secondaryText:"Once you delete a deployment, there is no going back. Please be certain.",isOpen:u,onClose:p,mainButtonProps:{children:"Delete deployment",isLoading:O,onClick:R},secondaryButtonProps:{children:"Back",onClick:p}})]})]})}),e.jsx(J,{hasScrollOnScreen:P,mainButton:e.jsx(b,{type:"submit",intent:"primary",disabled:m||h,isLoading:m,children:!s||(s==null?void 0:s.status)===d.CREATING||(s==null?void 0:s.status)===d.CREATED||(s==null?void 0:s.status)===d.STOPPED||(s==null?void 0:s.status)===d.STOPPING?"Save":"Save and restart"}),secondaryButton:e.jsx(X,{type:"button",intent:"secondary",onClick:T,children:"Back"})})]})})},j=({name:u,value:x})=>e.jsxs(r,{flexDirection:"column",justifyContent:"flex-start",children:[e.jsx(v,{bold:!0,gray:!0,mb:"4px",children:u}),e.jsx(v,{bold:!0,children:x})]});export{Be as Edit,Be as default};
