import{a as v,x as D,b as x,aU as g,r as k,u as e,f as C,w as c,h as w,g as E,B as F,o as I,j as s,bb as M,bc as N,b6 as P,b7 as S,b4 as T,aB as p,X as U}from"./index-e7fdb3d4.js";import{u as V}from"./usePageTitle-df55e3a5.js";const K=v({__name:"BlockEdit",async setup(j){let t,l;const n=D(),u=F(),r=x("blockDocumentId"),o=([t,l]=g(()=>n.blockDocuments.getBlockDocument(r.value)),t=await t,l(),t),{blockType:i,blockSchema:_}=o,d=k(o.data),m=k(o.name);function f(b){n.blockDocuments.updateBlockDocument(o.id,b).then(()=>{p("Block updated successfully","success"),u.push(U.block(r.value))}).catch(a=>{p("Failed to update block","error"),console.error(a)})}function y(){u.back()}return V(`Edit Block: ${m.value}`),(b,a)=>{const B=E("p-layout-default");return e(o)?(I(),C(B,{key:0,class:"block-edit"},{header:c(()=>[s(e(M),{"block-document":e(o)},null,8,["block-document"])]),default:c(()=>[s(e(T),{"block-type":e(i)},{default:c(()=>[s(e(N),P({data:d.value,"onUpdate:data":a[0]||(a[0]=h=>d.value=h)},{name:m.value,blockSchema:e(_)},S({submit:f,cancel:y})),null,16,["data"])]),_:1},8,["block-type"])]),_:1})):w("",!0)}}});export{K as default};
