import{b1 as F,aS as k,b2 as N,jg as B,ji as W,u as L,jf as Q,b3 as U,cU as $,jh as O,an as z,iJ as f,r as i,g1 as A,j as e,aX as G,Q as v,fO as y,ec as H,aU as c,aT as J,c as R,b as l}from"./index-ea7817a2.js";import{u as X}from"./useProjectId-fe5627bf.js";import{g as _}from"./utils-cf9ea4a1.js";const q=()=>{const a=X(),m=F(),u=k(),T=N(),[M]=B(),[b]=W(),{mId:g,vId:p}=L(),s=`${g}_${p}`,[w,{isLoading:h}]=Q(),j=U($),{data:n=[]}=O({modelId:s,projectId:a}),o=z({defaultValues:{tags:f(n)},shouldUnregister:!1}),D=()=>u(-1),{handleDelete:S}=i.useContext(A),V=o.handleSubmit(async r=>{const x=_(r.tags,j);try{const d=j.map(t=>t.name),P=x.filter(({schema:t})=>!d.includes(t));await Promise.all([...P.map(async t=>await b({modelId:s,projectId:a,tagName:t.name}).unwrap()),...x.map(async t=>await M({modelId:s,projectId:a,tagName:t.schema,data:t.value}).unwrap())]),u(-1)}catch(d){console.warn(d)}}),E=async()=>{try{await w({projectId:a,mlId:s}).unwrap(),S(R(l.models.versionView,l.project.value,{id:a,mId:g,vId:p})),T(l.models.list)}catch(r){console.error(r)}};return i.useEffect(()=>{m.schematisedTags.fetch()},[m]),i.useEffect(()=>{n.length&&o.setValue("tags",f(n))},[n]),e.jsxs(G,{...o,children:[e.jsx(v,{sx:I.editFormWrapper,children:e.jsxs(v,{flexDirection:"column",sx:I.fieldsWrapper,children:[e.jsx(y,{title:"Meta data",mb:"20px",children:e.jsx(H,{isEdit:!0})}),e.jsx(y,{title:"Danger zone",mb:"20px",children:e.jsx(c,{type:"button",intent:"alert",disabled:h,onClick:E,isLoading:h,children:"Delete model version"})})]})}),e.jsx(J,{hasScrollOnScreen:!0,mainButton:e.jsx(c,{type:"button",intent:"primary",onClick:V,children:"Save"}),secondaryButton:e.jsx(c,{type:"button",intent:"secondary",onClick:D,children:"Back"})})]})},ee=q,I={editFormWrapper:{width:"100%",alignItems:"center",paddingBottom:"10vh",justifyContent:"center"},fieldsWrapper:{gap:"20px",width:"100%"}};export{ee as default};
