import{d as O,i as P,a as S,V as W,X as D,r as b,o as a,f as _,g as r,t as I,x as V,z as y,y as F,A as N,W as M,$ as R,ax as j,_ as E,ap as q,c as w,w as A,b as p,aw as K,a1 as Q,S as h,bI as C,D as T,E as x,a3 as U}from"./index-D8-yxEbK.js";import{u as X}from"./BuilderApp-CSxWpWBo.js";import"./WdsCheckbox-BK6VI2BI.js";import"./marked.esm-273vDTCT.js";const G={class:"BuilderBlueprintLibraryItem"},H={class:"BuilderBlueprintLibraryItem__header"},J={class:"BuilderBlueprintLibraryItem__title"},Y={class:"BuilderBlueprintLibraryItem__description"},Z={class:"BuilderBlueprintLibraryItem__actions"},ee=O({__name:"BuilderBlueprintLibraryItem",props:{block:{}},emits:["installed"],setup(L,{emit:B}){const u=L,f=B,v=P(S.core),m=P(S.builderManager),{pushToast:i}=W(),{writerApi:d}=D(),{installSharedBlueprint:c}=j(v,m),o=b(!1);async function g(){const n=v.writerOrgId.value;if(!n){i({type:"error",message:"Organization ID is required. Please set up your environment variable."});return}o.value=!0;try{const l=await d.getSharedBlueprint(n,u.block.id),k=l.components,$=c({id:l.id,title:l.title,description:l.description||void 0,components:k}),s=v.writerAppId.value;s&&d.trackBlueprintInstallation(n,u.block.id,s).catch(R().error),i({type:"success",message:`Blueprint "${u.block.title}" installed successfully`}),f("installed")}catch(l){i({type:"error",message:`Failed to install blueprint: ${l instanceof Error?l.message:String(l)}`})}finally{o.value=!1}}return(n,l)=>(a(),_("div",G,[r("div",H,[r("h3",J,I(n.block.title),1)]),r("p",Y,I(n.block.description),1),r("div",Z,[V(M,{variant:"primary",size:"small",disabled:o.value,onClick:g},{default:y(()=>[V(F,{name:"download"}),N(" "+I(o.value?"Installing...":"Install"),1)]),_:1},8,["disabled"])])]))}}),z=E(ee,[["__scopeId","data-v-6bf01558"]]),te={class:"BuilderBlueprintLibraryPanel"},re={class:"BuilderBlueprintLibraryPanel__header"},le={class:"BuilderBlueprintLibraryPanel__search"},se={class:"BuilderBlueprintLibraryPanel__content"},ae={key:1,class:"BuilderBlueprintLibraryPanel__empty"},ie={key:0,class:"BuilderBlueprintLibraryPanel__empty__hint"},ne={key:2,class:"BuilderBlueprintLibraryPanel__sections"},oe={class:"BuilderBlueprintLibraryPanel__grid"},ue={class:"BuilderBlueprintLibraryPanel__grid"},de=O({__name:"BuilderBlueprintLibraryPanel",props:{modelValue:{type:Boolean},modelModifiers:{}},emits:["update:modelValue"],setup(L){const B=q(L,"modelValue"),u=P(S.core),{pushToast:f}=W(),{writerApi:v}=D(),m=w(()=>Array.isArray(u.featureFlags.value)&&u.featureFlags.value.includes("blueprint_library")),i=b(""),d=b([]),c=b(!1),o=b(!1),g=w(()=>d.value.filter(s=>s.isReadonly===!0)),n=w(()=>d.value.filter(s=>s.isReadonly!==!0));async function l(){if(!m.value)return;const s=u.writerOrgId.value;if(!s){f({type:"error",message:"Organization ID is required. Please set up your environment variable."}),c.value=!1;return}o.value||(c.value=!0);try{const e=await v.listSharedBlueprints(s,i.value||void 0);d.value=e.map(t=>({id:t.id,title:t.title,description:t.description,category:t.category||"Shared Blueprints",isReadonly:!!t.isReadonly,createdBy:t.createdBy})),o.value=!0}catch(e){f({type:"error",message:`Failed to load blueprints: ${e instanceof Error?e.message:String(e)}`})}finally{c.value=!1}}const k=X(l,300);A(i,k);function $(){B.value=!1,o.value=!1,i.value=""}return A(B,s=>{s&&m.value&&l()}),(s,e)=>B.value&&m.value?(a(),p(U,{key:0,title:"Blueprint Library",size:"wide","display-close-button":"",onClose:$},{default:y(()=>[r("div",te,[r("div",re,[r("div",le,[V(K,{modelValue:i.value,"onUpdate:modelValue":e[0]||(e[0]=t=>i.value=t),placeholder:"Search blueprints...","left-icon":"search"},null,8,["modelValue"])])]),r("div",se,[c.value?(a(),p(Q,{key:0,class:"BuilderBlueprintLibraryPanel__loading"})):d.value.length===0?(a(),_("div",ae,[e[1]||(e[1]=r("p",null,"No blueprints found",-1)),i.value?(a(),_("p",ie," Try adjusting your search ")):h("",!0)])):(a(),_("div",ne,[g.value.length>0?(a(),p(C,{key:0,class:"BuilderBlueprintLibraryPanel__section",open:!0,icons:{open:"chevron-down",close:"chevron-right"}},{title:y(()=>e[2]||(e[2]=[r("span",{class:"BuilderBlueprintLibraryPanel__sectionTitle"}," Agents for everyone ",-1)])),content:y(()=>[r("div",oe,[(a(!0),_(T,null,x(g.value,t=>(a(),p(z,{key:t.id,block:t},null,8,["block"]))),128))])]),_:1})):h("",!0),n.value.length>0?(a(),p(C,{key:1,class:"BuilderBlueprintLibraryPanel__section",open:!0,icons:{open:"chevron-down",close:"chevron-right"}},{title:y(()=>e[3]||(e[3]=[r("span",{class:"BuilderBlueprintLibraryPanel__sectionTitle"}," Agents for your organization ",-1)])),content:y(()=>[r("div",ue,[(a(!0),_(T,null,x(n.value,t=>(a(),p(z,{key:t.id,block:t},null,8,["block"]))),128))])]),_:1})):h("",!0)]))])])]),_:1})):h("",!0)}}),Be=E(de,[["__scopeId","data-v-40462f9c"]]);export{Be as default};
//# sourceMappingURL=BuilderBlueprintLibraryPanel-DtYLa1xc.js.map
