import{i as a}from"./_virtual___federation_fn_import-DB-0B1B_.js";import{j as e}from"./jsx-runtime-u17CrQMm.js";import{c as j}from"./clsx-B-dksMZM.js";import{F as b,as as h}from"./index-KpBDpTrU.js";import{l as v}from"./error-formatter-B41KnHG1.js";import{u as g}from"./use-model-form-BPP1LIM-.js";import{M as y}from"./model-info-form-CeorchK4.js";const{Button:f,Dialog:D,DialogClose:M,DialogContent:C,DialogFooter:N,DialogHeader:S,DialogTitle:F,DialogTrigger:w,useControlledState:E}=await a("@baseplate-dev/ui-components");function I({open:n,onOpenChange:t,trigger:i,modelKey:r}){const[l,s]=E(n,t,!1),{form:{control:d,reset:c},onSubmit:m,defaultValues:u}=g({modelKey:r,onSubmitSuccess(){s(!1)}});return e.jsxs(D,{open:l,onOpenChange:o=>{s(o),o||c(u)},children:[i&&e.jsx(w,{render:i}),e.jsx(C,{"aria-describedby":void 0,children:e.jsxs("form",{onSubmit:m,className:"space-y-4",children:[e.jsx(S,{children:e.jsx(F,{children:"Edit Model Info"})}),e.jsx(y,{control:d}),e.jsxs(N,{children:[e.jsx(M,{render:e.jsx(f,{variant:"secondary"}),children:"Cancel"}),e.jsx(f,{type:"submit",children:"Save"})]})]})})]})}const{FeatureUtils:B,modelEntityType:k,ModelUtils:T}=await a("@baseplate-dev/project-builder-lib"),{useProjectDefinition:z}=await a("@baseplate-dev/project-builder-lib/web"),{Button:x,useConfirmDialog:O}=await a("@baseplate-dev/ui-components"),{useNavigate:R}=await a("@tanstack/react-router");function P({className:n,model:t}){const{definition:i,saveDefinitionWithFeedbackSync:r,isSavingDefinition:l}=z(),s=T.byId(i,t.id)??t,d=R(),{requestConfirm:c}=O(),m=u=>{r(o=>{o.models=o.models.filter(p=>p.id!==u)},{onSuccess:()=>{d({to:"/data/models"}).catch(v)},successMessage:"Successfully deleted model!"})};return e.jsxs("div",{className:j("flex items-center justify-between border-b py-4",n),children:[e.jsxs("div",{children:[e.jsxs("div",{className:"group flex items-center space-x-2",children:[e.jsx("h1",{children:s.name}),e.jsx(I,{modelKey:k.keyFromId(t.id),trigger:e.jsx(x,{variant:"ghost",size:"icon-sm",type:"button","aria-label":"Edit model info",className:"invisible group-hover:visible",children:e.jsx(b,{className:"size-4"})})})]}),s.featureRef&&e.jsx("div",{className:"text-xs text-muted-foreground",children:B.getFeatureById(i,s.featureRef)?.name})]}),e.jsx("div",{className:"flex gap-8",children:e.jsxs(x,{variant:"outline",size:"icon",disabled:l,onClick:()=>{c({title:"Confirm delete",content:`Are you sure you want to delete ${t.name}?`,buttonConfirmText:"Delete",buttonConfirmVariant:"destructive",onConfirm:()=>{m(t.id)}})},children:[e.jsx(h,{className:"text-destructive"}),e.jsx("div",{className:"sr-only",children:"Delete Model"})]})})]})}export{P as M};
//# sourceMappingURL=model-header-bar-CBex25WP.js.map
