"use strict";var h=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},N=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of P(t))!U.call(e,o)&&o!==n&&h(e,o,{get:()=>t[o],enumerable:!(i=I(t,o))||i.enumerable});return e};var j=e=>N(h({},"__esModule",{value:!0}),e);var $={};_($,{getToken:()=>V,init:()=>Y});module.exports=j($);var d=null;function V(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 w(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Z(e){return w(e)&&e.type==="adapt-darkMode"&&typeof e.darkMode=="boolean"}function q(e){return w(e)&&e.type==="adapt-autoResizing"&&typeof e.autoResizing=="boolean"}function z(e){return Number.isFinite(e)&&e>=1}function G(e){return w(e)&&typeof e.postMessage=="function"}function v(){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,f=-1,m=-1,p=null,J=16,b=0,K=5;function E(){let{body:e,documentElement:t}=document;if(!e)return null;let n=getComputedStyle(e),i=parseFloat(n.marginTop)||0,o=parseFloat(n.marginBottom)||0,L=parseFloat(n.marginLeft)||0,W=parseFloat(n.marginRight)||0,r=getComputedStyle(t),B=parseFloat(r.paddingTop)||0,F=parseFloat(r.paddingBottom)||0,A=parseFloat(r.paddingLeft)||0,S=parseFloat(r.paddingRight)||0,x=parseFloat(r.borderTopWidth)||0,H=parseFloat(r.borderBottomWidth)||0,O=parseFloat(r.borderLeftWidth)||0,C=parseFloat(r.borderRightWidth)||0,c=Math.max(e.scrollHeight,e.offsetHeight),D=Math.max(e.scrollWidth,e.offsetWidth),M=c+i+o+B+F+x+H,k=D+L+W+A+S+O+C,R=t.scrollWidth>t.clientWidth?Math.max(0,window.innerHeight-t.clientHeight):0;return!z(k)||!z(M+R)||b>=K&&m>0&&Math.abs(c-a)<=2?null:(m=c,{width:k,height:M+R+2})}function s(){if(!v())return;let e=l();if(!G(e))return;let t=document.body?Math.max(document.body.scrollWidth,document.body.offsetWidth):0;t!==f&&f!==-1&&(b=0,m=-1),f=t;let n=E();if(!n)return;let{width:i,height:o}=n;if(!(i===u&&o===a)){u=i,a=o,b++;try{e.postMessage({type:"adapt-resize",width:i,height:o},"*")}catch{}}}function g(){p===null&&(p=setTimeout(()=>{p=null,s()},J))}function Q(){let e=E();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 y=null;function X(e){let t;try{t=e.data}catch{return}if(Z(t)&&y)try{y(t.darkMode)}catch{}q(t)&&t.autoResizing&&Q()}var T=!1;function Y(e={}){if(T)throw new Error("init() has already been called");if(T=!0,!v())return;let t=e.resize!==!1;y=e.onDarkMode??null,window.addEventListener("message",X);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 i=new ResizeObserver(g);document.body&&i.observe(document.body),document.documentElement&&i.observe(document.documentElement),document.body&&new MutationObserver(g).observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),document.addEventListener("load",g,!0),document.fonts?.ready?.then(()=>{s()}),document.readyState==="complete"?s():window.addEventListener("load",()=>{s()}),setTimeout(s,50),setTimeout(s,150)}}0&&(module.exports={getToken,init});
//# sourceMappingURL=browser.cjs.map
