import{i as d}from"./_virtual___federation_fn_import-DB-0B1B_.js";import{j as e}from"./jsx-runtime-u17CrQMm.js";import{H as $}from"./index-COBNNDEP.js";import{N as F}from"./sortable-list-BlHb6Qrt.js";import"./error-boundary-DgBD6_Zp.js";import{l as x}from"./error-formatter-B41KnHG1.js";import{U}from"./unmet-dependency-list-3dCQIFKG.js";import{R as f}from"./edit._key-vvQNagZX.js";const{buildEnabledPluginFqnSet:q,createPluginImplementationStoreWithNewPlugins:D,getUnmetPluginDependencies:A,PluginUtils:m,webConfigSpec:g}=await d("@baseplate-dev/project-builder-lib"),{useProjectDefinition:E}=await d("@baseplate-dev/project-builder-lib/web"),{Button:y,DropdownMenu:R,DropdownMenuContent:T,DropdownMenuGroup:V,DropdownMenuItem:W,DropdownMenuTrigger:z,useConfirmDialog:B}=await d("@baseplate-dev/ui-components"),{useNavigate:C}=await d("@tanstack/react-router"),{useMemo:P}=await d("react");function Y(){const{definitionContainer:t,pluginContainer:p,schemaParserContext:o,saveDefinitionWithFeedbackSync:v,isSavingDefinition:N}=E(),{key:s}=f.useParams(),{requestConfirm:h}=B(),b=C({from:f.fullPath}),{pluginMetadata:n}=f.useLoaderData(),c=m.byKey(t.definition,s),j=P(()=>{if(!s)return;const i=p.use(g).components.get(s);return i||D(o.pluginStore,[n],t.definition).use(g).components.get(s)},[s,o,t,p,n]),w=P(()=>{if(c)return[];const{pluginStore:r}=o,i=t.definition.plugins??[],u=q(r,i);return A(r,s,u).map(l=>{const M=D(r,[l],t.definition);return{metadata:l,hasWebConfig:M.use(g).components.has(l.key)}})},[c,o,t,s]);if(!j)return e.jsx(F,{});if(w.length>0)return e.jsx(H,{pluginMetadata:n,unmetDeps:w});function S(){const{pluginStore:r}=o,i=m.getDependentPlugins(t.definition,n.key,r),u=()=>{v(a=>{for(const l of i)m.disablePlugin(a,l.key,o);m.disablePlugin(a,n.key,o)},{successMessage:i.length>0?`Disabled ${n.displayName} and ${i.map(a=>a.displayName).join(", ")}!`:`Disabled ${n.displayName}!`,onSuccess:()=>{b({to:"/plugins"}).catch(x)}})};if(i.length>0){const a=i.map(l=>l.displayName).join(", ");h({title:"Disable Plugin",content:`Disabling ${n.displayName} will also disable ${a} which ${i.length===1?"depends":"depend"} on it. Continue?`,buttonConfirmText:"Disable All",buttonConfirmVariant:"destructive",buttonCancelText:"Cancel",onConfirm:u})}else h({title:"Disable Plugin",content:`Are you sure you want to disable the ${n.displayName} plugin?`,onConfirm:u})}function k(){c||b({to:"/plugins"}).catch(x)}return e.jsx("div",{className:"relative flex h-full flex-1 flex-col gap-4 overflow-hidden",children:e.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-4",children:[e.jsxs("div",{className:"flex max-w-6xl items-center justify-between",children:[e.jsxs("h1",{children:[n.displayName," Plugin"]}),c&&e.jsxs(R,{children:[e.jsx(z,{render:e.jsx(y,{variant:"ghost",size:"icon"}),children:e.jsx($,{"aria-label":"More Actions"})}),e.jsx(T,{children:e.jsx(V,{children:e.jsx(W,{disabled:N,onClick:S,children:"Disable Plugin"})})})]})]}),e.jsx(j,{definition:c,metadata:n,onSave:k})]})})}function H({pluginMetadata:t,unmetDeps:p}){const o=C({from:f.fullPath});return e.jsxs("div",{className:"flex h-full flex-1 flex-col gap-4 overflow-y-auto p-4",children:[e.jsxs("h1",{children:[t.displayName," Plugin"]}),e.jsxs("div",{className:"flex max-w-lg flex-col gap-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.displayName," requires the following plugins to be enabled and configured first:"]}),e.jsx(U,{dependencies:p}),e.jsx("div",{children:e.jsx(y,{variant:"secondary",size:"sm",onClick:()=>{o({to:"/plugins"}).catch(x)},children:"Back to Plugins"})})]})]})}export{Y as component};
//# sourceMappingURL=edit._key-BrcJIrA6.js.map
