var d=null;function Z(e=!1){if(e)return"dev-token";if(d!==null)return d;if(typeof window>"u"||typeof location>"u")throw new Error("getToken() is only available in browser environments");let t=location.hash.slice(1);if(!t)throw new Error("No token found in URL hash");let n=new URLSearchParams(t).get("mb_token");if(!n)throw new Error('Token "mb_token" not found in URL hash');return d=decodeURIComponent(n),d}function y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function D(e){return y(e)&&e.type==="adapt-darkMode"&&typeof e.darkMode=="boolean"}function I(e){return y(e)&&e.type==="adapt-autoResizing"&&typeof e.autoResizing=="boolean"}function R(e){return Number.isFinite(e)&&e>=1}function P(e){return y(e)&&typeof e.postMessage=="function"}function T(){return typeof window<"u"&&typeof document<"u"&&typeof window.postMessage=="function"}function l(){try{if(window.self!==window.top)return window.parent}catch{return window.parent}return window}var u=-1,a=-1,h=-1,g=-1,f=null,U=16,m=0,_=5;function v(){let{body:e,documentElement:t}=document;if(!e)return null;let n=getComputedStyle(e),o=parseFloat(n.marginTop)||0,r=parseFloat(n.marginBottom)||0,E=parseFloat(n.marginLeft)||0,L=parseFloat(n.marginRight)||0,i=getComputedStyle(t),W=parseFloat(i.paddingTop)||0,B=parseFloat(i.paddingBottom)||0,F=parseFloat(i.paddingLeft)||0,A=parseFloat(i.paddingRight)||0,S=parseFloat(i.borderTopWidth)||0,x=parseFloat(i.borderBottomWidth)||0,H=parseFloat(i.borderLeftWidth)||0,O=parseFloat(i.borderRightWidth)||0,c=Math.max(e.scrollHeight,e.offsetHeight),C=Math.max(e.scrollWidth,e.offsetWidth),w=c+o+r+W+B+S+x,M=C+E+L+F+A+H+O,k=t.scrollWidth>t.clientWidth?Math.max(0,window.innerHeight-t.clientHeight):0;return!R(M)||!R(w+k)||m>=_&&g>0&&Math.abs(c-a)<=2?null:(g=c,{width:M,height:w+k+2})}function s(){if(!T())return;let e=l();if(!P(e))return;let t=document.body?Math.max(document.body.scrollWidth,document.body.offsetWidth):0;t!==h&&h!==-1&&(m=0,g=-1),h=t;let n=v();if(!n)return;let{width:o,height:r}=n;if(!(o===u&&r===a)){u=o,a=r,m++;try{e.postMessage({type:"adapt-resize",width:o,height:r},"*")}catch{}}}function p(){f===null&&(f=setTimeout(()=>{f=null,s()},U))}function N(){let e=v();if(!e){if(a>0)try{l().postMessage({type:"adapt-resize",width:u,height:a},"*")}catch{}return}let{width:t,height:n}=e;u=t,a=n;try{l().postMessage({type:"adapt-resize",width:t,height:n},"*")}catch{}}var b=null;function j(e){let t;try{t=e.data}catch{return}if(D(t)&&b)try{b(t.darkMode)}catch{}I(t)&&t.autoResizing&&N()}var z=!1;function q(e={}){if(z)throw new Error("init() has already been called");if(z=!0,!T())return;let t=e.resize!==!1;b=e.onDarkMode??null,window.addEventListener("message",j);try{l().postMessage({type:"adapt-init",resize:t},"*")}catch{}if(t){let n=document.createElement("style");n.textContent=`
      html, body {
        box-sizing: border-box;
      }
      *, *::before, *::after {
        box-sizing: inherit;
      }
    `,document.head.appendChild(n);let o=new ResizeObserver(p);document.body&&o.observe(document.body),document.documentElement&&o.observe(document.documentElement),document.body&&new MutationObserver(p).observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),document.addEventListener("load",p,!0),document.fonts?.ready?.then(()=>{s()}),document.readyState==="complete"?s():window.addEventListener("load",()=>{s()}),setTimeout(s,50),setTimeout(s,150)}}export{Z as getToken,q as init};
//# sourceMappingURL=browser.mjs.map
