import{v as b,J as w,z as g,q as k,b as C}from"./customComponents-8Hj9M-RR.js";import{C as S,r as i,al as V,cc as I,x as K,aw as _,a8 as A,D as B,a3 as E,E as R,Q as L,u as q}from"./vendor-BGtMsOoo.js";import{i as z}from"./index-CRze-aDK.js";const U=S({__name:"builder-io",props:{apiKey:{},isVisible:{type:Boolean}},emits:["setState"],setup(p,{emit:m}){const s=m,l=p,o=i(!1),a=i(null),n=i(!1);function d(){a.value=null,o.value=!1,n.value=!1}V(()=>{r(window.location.pathname)}),I((e,t)=>{e.path!==t.path&&(d(),r(e.path))});async function r(e){l.apiKey&&(n.value=!0,s("setState","loading"),a.value=await b({model:"page",apiKey:l.apiKey,options:w(new URLSearchParams(location.search)),userAttributes:{urlPath:e}}),n.value=!1,o.value=!!a.value||g(),o.value?s("setState","ready"):s("setState","empty"))}const c=K(null),f=_(c);A(()=>{var t;const e=(t=a.value)==null?void 0:t.data;if(e&&f.value){const{title:u,keywords:y,description:h}=e;z({title:u,meta:{title:u,keywords:y,description:h}})}});const v=()=>C;return(e,t)=>e.isVisible&&o.value?(R(),B("div",{key:0,ref_key:"builderIoAnchor",ref:c},[L(q(k),{model:"page",content:a.value,"api-key":e.apiKey,"custom-components":v()},null,8,["content","api-key","custom-components"])],512)):E("",!0)}});export{U as default};
//# sourceMappingURL=builder-io-CmGtVPtO.js.map
