import{r as f,b4 as G,u as L,w as M,e$ as N,f0 as K,f1 as W,au as Q,f2 as U,j as e,q as l,ba as $,d as r,Q as q,d0 as c,be as z,b5 as H,f3 as d,b6 as J,y as D,av as X,g as Y,o as Z}from"./index-CK33qGU_.js";import{R as b}from"./RedirectInProject-DugBRkJr.js";import{u as _}from"./useScreenWithScroll-zcr7TMGO.js";import{u as ee}from"./useDownload-hrjXceJg.js";import{u as se}from"./useProjectId-CsRVHJQA.js";import{B as v}from"./ButtonWithRole-NHXEosto.js";import{D as te,K as re,T as oe,a as ae,I as ie,A as ne,R as le,v as ce}from"./validations-CoDvGmdx.js";import{a as de,b as ue,A as me,P as pe,d as xe}from"./PythonEnvField-CxRihNtd.js";import{a as E,s as t,g as fe}from"./utils-BLs53_9b.js";import"./useProject-BzBQtp4J.js";import"./length-fOfC3W0h.js";import"./SingleSelect-CV8k2k_j.js";import"./index-CBcuRugC.js";import"./FileUploaderButton-Bppadu35.js";import"./dumbPluralize-CcxDsNiu.js";import"./PrimaryIconButton-DQUEhx3G.js";import"./index-B4h3z62J.js";import"./cluster-utilization-DS4X6Ne5.js";import"./min-Esn8rYAn.js";import"./__-BIxbRvwe.js";const Ae=()=>{var g;const[u,m]=f.useState(!1),F=G(),P=_(),a=se(),{project:S}=ee(),{dId:i}=L(),[y,C]=M(),[I,{isLoading:p,isSuccess:k}]=N(),{data:s,isFetching:h}=K({projectId:a,id:i},{refetchOnMountOrArgChange:!0}),[O,{isLoading:w,isSuccess:R}]=W(),n=Q({reValidateMode:"onChange",shouldUnregister:!1,mode:"onChange",resolver:X(ce)}),B=async o=>{Y(n.formState.errors)&&await I({projectId:a,formValues:fe({apiValues:E(s),formValues:o,project:S})})},{handleDelete:T}=f.useContext(U),V=async()=>{try{await O({projectId:+a,deploymentId:i}).unwrap(),T(Z(l.deployments.overview,l.project.value,{id:a,dId:i}))}catch(o){console.error(o)}},A=()=>F(-1),x=()=>m(o=>!o);return f.useEffect(()=>{n.reset({...E(s),kserve:(s==null?void 0:s.servingTool)==="KSERVE"})},[s]),k?e.jsx(b,{to:l.deployments.overview,params:{dId:i}}):R?e.jsx(b,{to:l.deployments.list}):e.jsx($,{...n,children:e.jsxs("form",{onSubmit:n.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.jsx(te,{}),e.jsxs(r,{sx:t.defaultGap,children:[e.jsx(de,{}),e.jsx(ue,{}),e.jsx(me,{})]}),e.jsx(re,{disabled:!0}),e.jsx(pe,{isFileExplorerOpen:y,toggleFileExplorerPopup:C}),e.jsx(oe,{}),e.jsx(xe,{})]})}),e.jsx(c,{title:"Inference logging",children:e.jsxs(r,{flexDirection:"column",sx:t.defaultGap,children:[e.jsx(ae,{}),e.jsx(ie,{})]})}),e.jsx(c,{title:"Configuration",children:e.jsx(ne,{batchingEnabled:(g=s==null?void 0:s.batchingConfiguration)==null?void 0:g.batchingEnabled})}),e.jsx(c,{title:"Resource allocation",children:e.jsx(le,{})}),e.jsxs(c,{title:"Danger zone",mb:"20px",children:[e.jsx(v,{intent:"alert",type:"button",disabled:p||h,onClick:x,children:"Delete deployment"}),e.jsx(z,{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:x,mainButtonProps:{children:"Delete deployment",isLoading:w,onClick:V},secondaryButtonProps:{children:"Back",onClick:x}})]})]})}),e.jsx(H,{hasScrollOnScreen:P,mainButton:e.jsx(v,{type:"submit",intent:"primary",disabled:p||h,isLoading:p,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(J,{type:"button",intent:"secondary",onClick:A,children:"Back"})})]})})},j=({name:u,value:m})=>e.jsxs(r,{flexDirection:"column",justifyContent:"flex-start",children:[e.jsx(D,{bold:!0,gray:!0,mb:"4px",children:u}),e.jsx(D,{bold:!0,children:m})]});export{Ae as Edit,Ae as default};
