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