import{d as B,X as D,a7 as d,e as a,a as w,w as c,g as x,b as C,a3 as p,r as g,o as $,j as s,am as j,an as A,ai as E,aj as I,ag as N,W as k,q as P}from"./index.4d314fbd.js";import{u as R}from"./useRouteParam.0009ec42.js";const W=B({__name:"BlockEdit",async setup(S){let o,n;const l=C(),u=R("blockDocumentId"),e=([o,n]=D(()=>p.getBlockDocument(u.value)),o=await o,n(),o),{blockType:_,blockSchema:i}=e,t=d(e.data),b=d(e.name);function f(){p.updateBlockDocument(e.id,{data:t.value}).then(()=>{k("Block updated successfully","success"),l.push(P.block(u.value))}).catch(r=>{k("Failed to update block","error"),console.error(r)})}function y(){l.back()}return(r,m)=>{const h=g("p-layout-default");return a(e)?($(),w(h,{key:0,class:"block-edit"},{header:c(()=>[s(a(j),{"block-document":a(e)},null,8,["block-document"])]),default:c(()=>[s(a(N),{"block-type":a(_)},{default:c(()=>[s(a(A),E({data:t.value,"onUpdate:data":m[0]||(m[0]=v=>t.value=v)},{name:b.value,blockSchema:a(i)},I({submit:f,cancel:y})),null,16,["data"])]),_:1},8,["block-type"])]),_:1})):x("",!0)}}});export{W as default};
