import{F as A,r as u,aE as V,c1 as K,cj as L,ck as N,cl as R,ah as B,aI as E,m as p,bW as U,Q as M,W as P,R as T,X as W,e as _,c2 as x}from"./vendor-BmRNukEL.js";import{g as Q,a7 as j,bp as z,Q as F}from"./index-CfcNWeCf.js";import{b as G}from"./customComponents-CaXRpCVD.js";const D=A({__name:"builder-io",props:{apiKey:{},isVisible:{type:Boolean}},emits:["setState"],setup(s,{emit:m}){const v=m,c=s,t=u(!1),e=u(null),n=u(!1),{storeId:f,cultureName:h,organizationId:y}=Q,{isAuthenticated:g,userGroups:b}=j(),{getUrlWithoutLocale:k}=z();function w(){e.value=null,t.value=!1,n.value=!1}V(()=>{r(window.location.pathname)}),K((a,o)=>{a.path!==o.path&&(w(),r(a.path))});async function r(a){if(c.apiKey){n.value=!0,l("loading");const o=k(a);e.value=await L({model:"page",apiKey:c.apiKey,options:N(new URLSearchParams(location.search)),userAttributes:{urlPath:o,locale:h,organizationId:y,isAuthenticated:g.value,storeId:f,groupName:b.value}}),n.value=!1,t.value=!!e.value||R(),t.value?l("ready"):l("empty")}}function l(a){v("setState",{state:a})}const d=B(null),I=E(d),i=p(()=>!!I.value&&!!e.value?.data),S=p(()=>F(e.value?.data?.title).title.value);U({title:()=>i.value?S.value:void 0,keywords:()=>i.value?e.value?.data?.keywords:void 0,description:()=>i.value?e.value?.data?.description:void 0});const C=()=>G;return(a,o)=>s.isVisible&&t.value?(T(),M("div",{key:0,ref_key:"builderIoAnchor",ref:d},[W(_(x),{model:"page",content:e.value,"api-key":s.apiKey,"custom-components":C()},null,8,["content","api-key","custom-components"])],512)):P("",!0)}});export{D as default};
//# sourceMappingURL=builder-io-oHkBKIjm.js.map
