import{d as v,M as D,b as C,bi as x,f as k,u as e,c as w,i as c,a as g,j as E,a1 as V,o as F,m as s,bB as I,bC as M,bw as N,bx as P,bu as S,b0 as p,ae as T}from"./index-bD6G21oH.js";import{u as j}from"./usePageTitle-27XdpEbQ.js";const U=v({__name:"BlockEdit",async setup(A){let t,l;const n=D(),u=V(),r=C("blockDocumentId"),o=([t,l]=x(()=>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(T.block(r.value))}).catch(a=>{p("Failed to update block","error"),console.error(a)})}function y(){u.back()}return j(`Edit Block: ${m.value}`),(b,a)=>{const B=E("p-layout-default");return e(o)?(F(),w(B,{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]=h=>d.value=h)},{name:m.value,blockSchema:e(_)},P({submit:f,cancel:y})),null,16,["data"])]),_:1},8,["block-type"])]),_:1})):g("",!0)}}});export{U as default};
