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