import{F as A,r as u,aR as R,c1 as V,cj as K,ck as L,cl as N,ai as B,aI as U,m as p,bW as E,Q as M,W as P,R as T,X as W,e as _,c2 as x}from"./vendor-sJIIH5Cr.js";import{g as j,a3 as z,bl as F,J as G}from"./index-BGo1APpE.js";import{b as J}from"./customComponents-D6ytTEvh.js";const q=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:y,organizationId:h}=j,{isAuthenticated:g,userGroups:b}=z(),{getUrlWithoutLocale:k}=F();function w(){e.value=null,t.value=!1,n.value=!1}R(()=>{r(window.location.pathname)}),V((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 K({model:"page",apiKey:c.apiKey,options:L(new URLSearchParams(location.search)),userAttributes:{urlPath:o,locale:y,organizationId:h,isAuthenticated:g.value,storeId:f,groupName:b.value}}),n.value=!1,t.value=!!e.value||N(),t.value?l("ready"):l("empty")}}function l(a){v("setState",{state:a})}const d=B(null),I=U(d),i=p(()=>!!I.value&&!!e.value?.data),S=p(()=>G(e.value?.data?.title).title.value);E({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=()=>J;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{q as default};
//# sourceMappingURL=builder-io-DPGUG6Ur.js.map
