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