import{a as C,x,aE as D,b as P,c as t,ad as m,u as e,f as u,w as n,h as p,g as w,B as A,o as k,j as F,b3 as K,b4 as N,b5 as V,b6 as j,b7 as q,aB as f,b8 as E,X as H}from"./index-e7fdb3d4.js";import{u as M}from"./usePageTitle-df55e3a5.js";const $=C({__name:"BlocksCatalogCreate",setup(R){const l=x(),s=A(),b=D("redirect"),i=P("blockTypeSlug"),y=t(()=>i.value?[i.value]:null),d=m(l.blockTypes.getBlockTypeBySlug,y),o=t(()=>d.response),h=t(()=>o.value?[o.value.id]:null),B=m(l.blockSchemas.getBlockSchemaForBlockType,h),r=t(()=>B.response);function _(a){l.blockDocuments.createBlockDocument(a).then(({id:c})=>S(c)).catch(c=>{f("Failed to create block","error"),console.error(c)})}function g(){s.back()}function S(a){if(f("Block created successfully","success"),b.value){const c=s.resolve(E(b.value));s.push(c);return}s.push(H.block(a))}const v=t(()=>o.value?`Create ${o.value.name} Block`:"Create Block");return M(v),(a,c)=>{const T=w("p-layout-default");return e(o)?(k(),u(T,{key:0,class:"blocks-catalog-create"},{header:n(()=>[F(e(K),{"block-type":e(o)},null,8,["block-type"])]),default:n(()=>[e(o)?(k(),u(e(N),{key:0,"block-type":e(o)},{default:n(()=>[e(r)?(k(),u(e(V),j({key:e(r).id,"block-schema":e(r)},q({submit:_,cancel:g})),null,16,["block-schema"])):p("",!0)]),_:1},8,["block-type"])):p("",!0)]),_:1})):p("",!0)}}});export{$ as default};
