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