import{d as C,M as x,I as A,U as j,g as c,aA as m,c as r,j as u,a as n,l as w,a2 as I,o as p,n as P,u as k,bv as V,bw as D,bx as F,by as M,bz as N,b2 as y,bA as U,af as z}from"./index-bJiZR03d.js";import{u as G}from"./usePageTitle-wT6f1BZv.js";const Y=C({__name:"BlocksCatalogCreate",setup(H){const s=x(),a=I(),b=A("redirect"),i=j("blockTypeSlug"),f=c(()=>i.value?[i.value]:null),d=m(s.blockTypes.getBlockTypeBySlug,f),e=c(()=>d.response),v=c(()=>e.value?[e.value.id]:null),_=m(s.blockSchemas.getBlockSchemaForBlockType,v),l=c(()=>_.response);function h(t){s.blockDocuments.createBlockDocument(t).then(({id:o})=>g(o)).catch(o=>{y("Failed to create block","error"),console.error(o)})}function S(){a.back()}function g(t){if(y("Block created successfully","success"),b.value){const o=a.resolve(U(b.value));a.push(o);return}a.push(z.block(t))}const B=c(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return G(B),(t,o)=>{const T=w("p-layout-default");return e.value?(p(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[P(k(V),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(p(),r(k(D),{key:0,"block-type":e.value},{default:u(()=>[l.value?(p(),r(k(F),M({key:l.value.id,"block-schema":l.value},N({submit:h,cancel:S})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{Y as default};
