import{d as v,D as B,b as C,bj as x,f as k,u as e,c as w,h as c,a as g,i as E,a1 as T,o as I,k as s,bC as N,bD as P,bx as S,by as V,bv as j,b1 as p,ae as A}from"./index-WCZ_4nWW.js";import{u as F}from"./usePageTitle-Y7n4a-YH.js";const Q=v({__name:"BlockEdit",async setup(H){let t,l;const n=B(),u=T(),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(A.block(r.value))}).catch(a=>{p("Failed to update block","error"),console.error(a)})}function y(){u.back()}return F(`Edit Block: ${m.value}`),(b,a)=>{const D=E("p-layout-default");return e(o)?(I(),w(D,{key:0,class:"block-edit"},{header:c(()=>[s(e(N),{"block-document":e(o)},null,8,["block-document"])]),default:c(()=>[s(e(j),{"block-type":e(i)},{default:c(()=>[s(e(P),S({data:d.value,"onUpdate:data":a[0]||(a[0]=h=>d.value=h)},{name:m.value,blockSchema:e(_)},V({submit:f,cancel:y})),null,16,["data"])]),_:1},8,["block-type"])]),_:1})):g("",!0)}}});export{Q as default};
