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