import{d as C,k as x,ao as M,W as P,h as o,bK as m,c as r,i as u,a as n,j as A,g as D,o as k,l as F,m as p,cr as N,cs as V,ct as W,Y as j,cu as q,M as y,cv as w,bo as H}from"./index-7qezL2zM.js";import{u as I}from"./usePageTitle-k72s0--o.js";const R=C({__name:"BlocksCatalogCreate",setup(K){const s=x(),t=D(),i=M("redirect"),b=P("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})=>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(w(i.value));t.push(c);return}t.push(H.block(a))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return I(B),(a,c)=>{const T=A("p-layout-default");return e.value?(k(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[F(p(N),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(k(),r(p(V),{key:0,"block-type":e.value},{default:u(()=>[l.value?(k(),r(p(W),j({key:l.value.id,"block-schema":l.value},q({submit:_,cancel:S})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{R as default};
//# sourceMappingURL=BlocksCatalogCreate-ZXUiuP2b.js.map
