import{d as B,a as C,T as D,M as g,bb as w,r as k,b as x,u as e,e as T,w as c,f as E,o as I,h as s,bu as M,bv as N,bp as P,bq as S,bn as V,aW as p,ab as q}from"./index-562c8470.js";import{u as A}from"./usePageTitle-ad3dbf10.js";const R=B({__name:"BlockEdit",async setup(F){let o,n;const l=C(),u=D(),r=g("blockDocumentId"),t=([o,n]=w(()=>l.blockDocuments.getBlockDocument(r.value)),o=await o,n(),o),{blockType:i,blockSchema:_}=t,d=k(t.data),m=k(t.name);function f(b){l.blockDocuments.updateBlockDocument(t.id,b).then(()=>{p("Block updated successfully","success"),u.push(q.block(r.value))}).catch(a=>{p("Failed to update block","error"),console.error(a)})}function v(){u.back()}return A(`Edit Block: ${m.value}`),(b,a)=>{const y=x("p-layout-default");return e(t)?(I(),T(y,{key:0,class:"block-edit"},{header:c(()=>[s(e(M),{"block-document":e(t)},null,8,["block-document"])]),default:c(()=>[s(e(V),{"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:v})),null,16,["data"])]),_:1},8,["block-type"])]),_:1})):E("",!0)}}});export{R as default};
