import{d as B,u as T,c as a,e as C,r as v,g as e,o as t,f as s,w as l,k as A,aI as w,aJ as P,aK as $,aL as x,aM as D,h as r,aF as F,aN as N,aC as K,a4 as i,t as R}from"./index.52551726.js";import{u as V}from"./useRouteParam.4bc8e74f.js";import{u as m}from"./useSubscriptionWithDependencies.769857cf.js";const M=B({__name:"BlocksCatalogCreate",setup(H){const u=T(),n=V("blockTypeSlug"),b=a(()=>n.value?[n.value]:null),f=m(F.getBlockTypeBySlug,b),o=a(()=>f.response),_=a(()=>o.value?[o.value.id]:null),y=m(N.getBlockSchemaForBlockType,_),p=a(()=>y.response);function d(k){K.createBlockDocument(k).then(({id:c})=>{i("Block created successfully","success"),u.push(R.block(c))}).catch(c=>{i("Failed to create block","error"),console.error(c)})}function h(){u.back()}const S=a(()=>o.value?`Create ${o.value.name} Block`:"Create Block");return C(S),(k,c)=>{const g=v("p-layout-default");return e(o)?(t(),s(g,{key:0,class:"blocks-catalog-create"},{header:l(()=>[A(e(w),{"block-type":e(o)},null,8,["block-type"])]),default:l(()=>[e(o)?(t(),s(e(P),{key:0,"block-type":e(o)},{default:l(()=>[e(p)?(t(),s(e($),x({key:0,"block-schema":e(p)},D({submit:d,cancel:h})),null,16,["block-schema"])):r("",!0)]),_:1},8,["block-type"])):r("",!0)]),_:1})):r("",!0)}}});export{M as default};
