import{d as C,f as x,ao as M,W as P,i as o,bK as m,c as r,j as u,a as n,k as w,h as A,o as k,l as D,m as p,cr as F,cs as I,ct as N,_ as V,cu as W,M as f,cv as j,bo as q}from"./index-CcVNxLw9.js";import{u as H}from"./usePageTitle-B0-KYjWV.js";const X=C({__name:"BlocksCatalogCreate",setup(K){const s=x(),t=A(),i=M("redirect"),b=P("blockTypeSlug"),y=o(()=>b.value?[b.value]:null),d=m(s.blockTypes.getBlockTypeBySlug,y),e=o(()=>d.response),v=o(()=>e.value?[e.value.id]:null),h=m(s.blockSchemas.getBlockSchemaForBlockType,v),l=o(()=>h.response);function _(a){s.blockDocuments.createBlockDocument(a).then(({id:c})=>g(c)).catch(c=>{f("Failed to create block","error"),console.error(c)})}function S(){t.back()}function g(a){if(f("Block created successfully","success"),i.value){const c=t.resolve(j(i.value));t.push(c);return}t.push(q.block(a))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return H(B),(a,c)=>{const T=w("p-layout-default");return e.value?(k(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[D(p(F),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(k(),r(p(I),{key:0,"block-type":e.value},{default:u(()=>[l.value?(k(),r(p(N),V({key:l.value.id,"block-schema":l.value},W({submit:_,cancel:S})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{X as default};
//# sourceMappingURL=BlocksCatalogCreate-CPLh-IfZ.js.map
