import{J as N,K as X,a as $,b as I,c as W}from"./chunk-hctcnj5d.js";import{U as K,V as F,X as Z}from"./chunk-vmf3nj8h.js";import{$ as j}from"./chunk-kmey03h3.js";class L{static async load(E){if(!("fonts"in document))return console.warn("Font Loading API not supported in this browser"),[];if(!E||E.length===0)return[];let z=E.map((M)=>{let H=`${M.style||"normal"} ${M.weight} 1em "${M.family}"`;return document.fonts.load(H)});try{let M=await Promise.all(z);if(K.IS_DEV)console.log(`✅ Loaded ${E.length} font(s)`);return M.flat()}catch(M){throw console.error("Font loading failed:",M),Error(`Font loading failed: ${M}`)}}static async loadWithTimeout(E,z=5000){let M=new Promise((U,H)=>{setTimeout(()=>{H(Error(`Font loading timeout after ${z}ms`))},z)});try{return await Promise.race([this.load(E),M])}catch(U){if(K.IS_DEV)console.warn("⚠️ Font loading timeout - continuing anyway");return[]}}static check(E,z=400){if(!("fonts"in document))return!1;return document.fonts.check(`${z} 1em "${E}"`)}static async ready(){if(!("fonts"in document))return;await document.fonts.ready}static get status(){if(!("fonts"in document))return"unsupported";return document.fonts.status}}var G='img[loading="lazy"][srcset]:not([data-auto-sizes="off"])',A="auto, 100vw";function B(E){let z=E.dataset.autoSizes?.trim();if(!z||z==="off")return A;return z}function O(E){if(!E.matches(G))return;let z=B(E);if(E.sizes===z)return;E.sizes=z}function Y(E){if(E instanceof HTMLImageElement){O(E);return}if(!(E instanceof Element)&&!(E instanceof Document))return;E.querySelectorAll(G).forEach(O)}class _{#E=null;#z=!1;init(){$((E)=>{if(this.#z=E,E){this.destroy();return}this.#M()})}#M(){if(this.#z||this.#E)return;Y(document),this.#E=new MutationObserver((E)=>{E.forEach((z)=>{if(z.type==="attributes"){let M=z.target;if(M instanceof HTMLImageElement)O(M);return}z.addedNodes.forEach((M)=>{if(M instanceof Element)Y(M)})})}),this.#E.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["loading","srcset","data-auto-sizes"]})}destroy(){this.#E?.disconnect(),this.#E=null}}var Q=new _;var C=300000;class D{#E=new Map;#z="idle";#M=null;#U=null;#H=null;#x=null;#I=null;constructor(){this.#M=performance.now(),this.#Z()}async#Z(){if(this.#z!=="idle")throw Error("App already initialized");this.#z="initializing";try{this.#q(),this.#f(),this.#J(),this.#K(),this.#E.set("scroll",W),this.#E.set("pages",X),Q.init(),this.#E.set("responsiveImages",Q),await this.#L(),await N(),this.#z="ready",this.#O(),this.#Q()}catch(E){this.#z="failed",this.#W(E)}}async#X(){return}async#q(){if(Z.EAGER.length===0)return;try{await L.loadWithTimeout(Z.EAGER,Z.OPTIONS.timeout)}catch(E){console.warn("⚠️ Font loading failed:",E)}}#f(){try{I.init(),this.#E.set("viewport",I)}catch(E){throw console.error("❌ Viewport initialization failed:",E),E}}#J(){let E=(z)=>z==="desktop"||z==="large";window.addEventListener("breakpoint:change",(z)=>{let{from:M,to:U}=z.detail;if(M===null)return;if(E(M)===E(U))return;window.location.reload()})}#K(){let E=()=>this.#H!==null&&Date.now()-this.#H>C;this.#x=()=>{if(document.visibilityState==="hidden"){this.#H=Date.now();return}let z=E();if(this.#H=null,z)window.location.reload()},this.#I=(z)=>{if(!z.persisted)return;let M=E();if(this.#H=null,M)window.location.reload()},document.addEventListener("visibilitychange",this.#x),window.addEventListener("pageshow",this.#I)}async#L(){return}#O(){document.documentElement.classList.add(F.READY),this.#U?.add("app-ready",!0),window.dispatchEvent(new CustomEvent("app:ready",{detail:{status:this.#z,modules:Array.from(this.#E.keys()),initTime:this.initTime}}))}#Q(){if(!this.#M)return;let E=(performance.now()-this.#M).toFixed(2)}get initTime(){return this.#M?performance.now()-this.#M:0}#W(E){console.error("❌ App initialization failed:",E),document.documentElement.classList.add("app-error"),window.dispatchEvent(new CustomEvent("app:error",{detail:{error:E}}))}#Y(E){let z=E instanceof Error?E.message:String(E),M=E instanceof Error?E.stack:"",U=document.createElement("div");U.style.cssText=` position: fixed; inset: 0; background: rgba(0, 0, 0, 0.95); color: #ff6b6b; display: flex; align-items: center; justify-content: center; z-index: 999999; font-family: 'Monaco', 'Courier New', monospace; font-size: 14px; padding: 2rem; `;let H=document.createElement("div");H.style.cssText="max-width: 800px; width: 100%;";let q=document.createElement("h1");q.style.cssText="color: #ff6b6b; margin: 0 0 1rem 0;",q.textContent="App Initialization Failed";let f=document.createElement("p");if(f.style.cssText="margin: 0 0 1rem 0; color: #fff;",f.textContent=z,H.append(q,f),M){let J=document.createElement("pre");J.style.cssText="background: rgba(255, 255, 255, 0.1); padding: 1rem; border-radius: 4px; overflow: auto; color: #fff;",J.textContent=M,H.appendChild(J)}let x=document.createElement("button");x.type="button",x.textContent="Reload Page",x.style.cssText=` margin-top: 1rem; padding: 0.75rem 1.5rem; background: #ff6b6b; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; `,x.addEventListener("click",()=>window.location.reload()),H.appendChild(x),U.appendChild(H),document.body.appendChild(U)}get(E){let z=this.#E.get(E);return z}get status(){return this.#z}get isReady(){return this.#z==="ready"}get scroll(){return W}get viewport(){return I}get pages(){return X}destroy(){if(this.#E.forEach((E,z)=>{try{if(typeof E.destroy==="function")E.destroy()}catch(M){console.error(`❌ Failed to destroy ${z}:`,M)}}),this.#U?.cleanup(),this.#U=null,this.#x)document.removeEventListener("visibilitychange",this.#x),this.#x=null;if(this.#I)window.removeEventListener("pageshow",this.#I),this.#I=null;this.#H=null,this.#E.clear(),this.#z="idle",this.#M=null}get performance(){let E=this.#U;return{getWebVitals:()=>E?.getWebVitals(),showWebVitals:()=>E?.showWebVitals(),getAnimationMetrics:()=>E?.getAnimationMetrics(),showAnimationMetrics:()=>E?.showAnimationMetrics(),resetAnimationMetrics:()=>E?.resetAnimationMetrics(),enableFrameDropDetection:()=>E?.enableFrameDropDetection(),disableFrameDropDetection:()=>E?.disableFrameDropDetection(),getFrameDropHistory:()=>E?.getFrameDropHistory(),toggleFpsDisplay:()=>E?.toggleFpsDisplay()}}}var V=new D;export{V as App};