import{d as T,aF as F,an as P,W as x,f as o,bJ as m,c as u,g as r,a as n,h as A,u as D,o as k,j as X,k as p,cC as N,cD as V,cE as W,X as j,cF as w,L as y,cG as E,bo as G}from"./index-BqDjVCF_.js";import{u as H}from"./usePageTitle-CZh_IXm2.js";const Q=T({__name:"BlocksCatalogCreate",setup(I){const s=F(),a=D(),i=P("redirect"),b=x("blockTypeSlug"),f=o(()=>b.value?[b.value]:null),d=m(s.blockTypes.getBlockTypeBySlug,f),e=o(()=>d.response),v=o(()=>e.value?[e.value.id]:null),h=m(s.blockSchemas.getBlockSchemaForBlockType,v),l=o(()=>h.response);function _(t){s.blockDocuments.createBlockDocument(t).then(({id:c})=>g(c)).catch(c=>{y("Failed to create block","error"),console.error(c)})}function S(){a.back()}function g(t){if(y("Block created successfully","success"),i.value){const c=a.resolve(E(i.value));a.push(c);return}a.push(G.block(t))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return H(B),(t,c)=>{const C=A("p-layout-default");return e.value?(k(),u(C,{key:0,class:"blocks-catalog-create"},{header:r(()=>[X(p(N),{"block-type":e.value},null,8,["block-type"])]),default:r(()=>[e.value?(k(),u(p(V),{key:0,"block-type":e.value},{default:r(()=>[l.value?(k(),u(p(W),j({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{Q as default};
//# sourceMappingURL=BlocksCatalogCreate-BpWQ1b0R.js.map
