import{h as b,b as B}from"./customComponents-twZNGYGk.js";import{K as _,B as f,D as v,av as S,ch as C,c3 as O,L as m,a7 as d,M as u,V as D,b as I,N as h,O as N,P as g,R as w,Q as K}from"./vendor-bSWkQivH.js";import{O as P}from"./index-Dqv5IkpS.js";const R={key:0},V=_({__name:"vp-builder-io",props:{content:{}},setup(i){const t=i,{modulesSettings:c}=P(),o=f(()=>{var n;return(n=c.value)==null?void 0:n.find(r=>r.moduleId==="VirtoCommerce.BuilderIO")}),e=f(()=>{var n,r;return((r=(n=o.value)==null?void 0:n.settings.find(k=>k.name==="BuilderIO.PublicApiKey"))==null?void 0:r.value)||"NO_KEY"}),p=v(!1),s=v(null);function l(){s.value=null,p.value=!1}S(t,()=>{a()}),C(()=>{t.content?a():l()});function a(){if(!t.content)return;const n=JSON.parse(t.content);s.value={data:{blocks:n}},p.value=!0}O((n,r)=>{n.path!==r.path&&(l(),a())});const y=()=>B;return(n,r)=>n.content?(u(),m("div",R,[D(I(b),{model:"page",content:s.value,"api-key":e.value,"custom-components":y()},null,8,["content","api-key","custom-components"])])):d("",!0)}}),$={key:0},x=_({__name:"vp-page-builder",props:{content:{}},setup(i){const t=i,c=v(!1),o=v(null);function e(){o.value=null,c.value=!1}C(()=>{t.content?p():e()});function p(){if(!t.content)return;const s=JSON.parse(t.content);o.value=s,c.value=!0}return(s,l)=>o.value?(u(),m("div",$,[(u(!0),m(h,null,N(o.value.content,a=>(u(),m(h,null,[a.hidden?d("",!0):(u(),g(w(a.type),K({key:a.id,ref_for:!0},a,{model:a,settings:o.value.settings}),null,16,["model","settings"]))],64))),256))])):d("",!0)}}),L=_({__name:"virto-pages",props:{pageDocument:{}},setup(i){const t=i,c=f(()=>{var e;return((e=t.pageDocument)==null?void 0:e.source)==="builder.io"}),o=f(()=>{var e;return((e=t.pageDocument)==null?void 0:e.source)==="page-builder"});return(e,p)=>{var s,l;return u(),m("div",null,[o.value?(u(),g(x,{key:0,content:(s=e.pageDocument)==null?void 0:s.content},null,8,["content"])):d("",!0),c.value?(u(),g(V,{key:1,content:(l=e.pageDocument)==null?void 0:l.content},null,8,["content"])):d("",!0)])}}});export{L as default};
//# sourceMappingURL=virto-pages-B2h38nu2.js.map
