import{O as E,P as w,Q as v,c as P,d as u,e as H,f as L,g as R,h as C}from"./chunk-cfnbjgr1.js";class r{static async load(n){if(!("fonts"in document))return console.warn("Font Loading API not supported in this browser"),[];if(!n||n.length===0)return[];let t=n.map((e)=>{let c=`${e.style||"normal"} ${e.weight} 1em "${e.family}"`;return document.fonts.load(c)});try{let e=await Promise.all(t);if(document.documentElement.classList.add(R.FONTS_LOADED),L.IS_DEV)console.log(`✅ Loaded ${n.length} font(s)`);return e.flat()}catch(e){throw console.error("Font loading failed:",e),Error(`Font loading failed: ${e}`)}}static async loadWithTimeout(n,t=5000){let e=new Promise((i,c)=>{setTimeout(()=>{c(Error(`Font loading timeout after ${t}ms`))},t)});try{return await Promise.race([this.load(n),e])}catch(i){if(document.documentElement.classList.add(R.FONTS_LOADED),L.IS_DEV)console.warn("⚠️ Font loading timeout - continuing anyway");return[]}}static check(n,t=400){if(!("fonts"in document))return!1;return document.fonts.check(`${t} 1em "${n}"`)}static async ready(){if(!("fonts"in document))return;await document.fonts.ready,document.documentElement.classList.add(R.FONTS_LOADED)}static get status(){if(!("fonts"in document))return"unsupported";return document.fonts.status}}function x(){let n=Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue("--grid-columns"),10);return Number.isFinite(n)&&n>0?n:0}function U(n,t){let e=document.createElement("div");return e.className="grid_helper__col",e.style.backgroundColor=t,e.style.setProperty("--grid-helper-stagger-index",String(n)),e}function S(n){if(!(n instanceof HTMLElement))return!1;return n.isContentEditable||n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.tagName==="SELECT"}function O({rgbaColor:n="color-mix(in srgb, currentColor 10%, transparent)",toggleKey:t="g"}={}){let e=document.createElement("div");e.className="grid_helper",document.body.append(e);let i=!1,c=0,h=()=>{let d=x();e.style.setProperty("--grid-helper-column-count",String(d)),e.replaceChildren();for(let f=0;f{if(c)cancelAnimationFrame(c);c=window.requestAnimationFrame(()=>{c=0,h()})},_=()=>{i=!0,e.classList.add("is-active")},s=()=>{i=!1,e.classList.remove("is-active")},a=()=>{if(i){s();return}_()},D=()=>{I()},p=(d)=>{if(S(d.target))return;if(!(d.ctrlKey||d.metaKey))return;if(d.key.toLowerCase()!==t.toLowerCase())return;d.preventDefault(),a()};return h(),window.addEventListener("resize",D),document.addEventListener("keydown",p),{destroy(){if(c)cancelAnimationFrame(c);window.removeEventListener("resize",D),document.removeEventListener("keydown",p),e.remove()},hide:s,refresh:I,show:_,toggle:a}}class y{#n=null;async init(){try{this.#n=O({}),console.log("✅ DevTools initialized")}catch(n){throw console.warn("⚠️ DevTools initialization failed:",n),n}}destroy(){this.#n?.destroy(),this.#n=null}static logPerformance(n,t){let e=(performance.now()-t).toFixed(2);console.log(`⚡ ${n}: ${e}ms`)}static logModule(n,t,e){let i=t==="success"?"✅":t==="warning"?"⚠️":"❌",c=e?`: ${e}`:"";console.log(`${i} ${n}${c}`)}}var M='img[loading="lazy"][srcset]:not([data-auto-sizes="off"])',K="auto, 100vw";function b(n){let t=n.dataset.autoSizes?.trim();if(!t||t==="off")return K;return t}function A(n){if(!n.matches(M))return;let t=b(n);if(n.sizes===t)return;n.sizes=t}function z(n){if(n instanceof HTMLImageElement){A(n);return}if(!(n instanceof Element)&&!(n instanceof Document))return;n.querySelectorAll(M).forEach(A)}class l{#n=null;#e=!1;init(){P((n)=>{if(this.#e=n,n){this.destroy();return}this.#t()})}#t(){if(this.#e||this.#n)return;z(document),this.#n=new MutationObserver((n)=>{n.forEach((t)=>{if(t.type==="attributes"){let e=t.target;if(e instanceof HTMLImageElement)A(e);return}t.addedNodes.forEach((e)=>{if(e instanceof Element)z(e)})})}),this.#n.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["loading","srcset","data-auto-sizes"]})}destroy(){this.#n?.disconnect(),this.#n=null}}var G=new l;function q(){if(document.querySelector(".safari-toolbar-tint"))return;let n=document.createElement("div");n.className="safari-toolbar-tint is-base is-bottom",n.setAttribute("aria-hidden","true"),document.body.append(n)}class g{#n=new Map;#e="idle";#t=null;constructor(){if(this.#t=performance.now(),q(),L.IS_DEV)console.log("\uD83D\uDE80 App initializing...");this.#c()}async#c(){if(this.#e!=="idle")throw Error("App already initialized");this.#e="initializing";try{this.#E(),this.#i(),this.#n.set("scroll",H),this.#n.set("pages",v),G.init(),this.#n.set("responsiveImages",G),await this.#L(),await w(),this.#e="ready",this.#_(),this.#d()}catch(n){this.#e="failed",this.#R(n)}}async#E(){if(C.EAGER.length===0){if(L.IS_DEV)console.log("⏭️ Font loading skipped (no eager fonts configured)");document.documentElement.classList.add(R.FONTS_LOADED);return}try{if(await r.loadWithTimeout(C.EAGER,C.OPTIONS.timeout),L.IS_DEV)console.log("✅ Fonts loaded")}catch(n){console.warn("⚠️ Font loading failed:",n)}}#i(){try{if(u.init(),this.#n.set("viewport",u),L.IS_DEV)console.log("✅ Viewport initialized")}catch(n){throw console.error("❌ Viewport initialization failed:",n),n}}async#L(){if(L.IS_PROD)return;try{let n=new y;await n.init(),this.#n.set("devTools",n)}catch(n){console.warn("⚠️ DevTools initialization failed:",n)}}#_(){document.documentElement.classList.add(R.READY),E.add("app-ready",!0),window.dispatchEvent(new CustomEvent("app:ready",{detail:{status:this.#e,modules:Array.from(this.#n.keys()),initTime:this.initTime}}))}#d(){if(!this.#t)return;let n=(performance.now()-this.#t).toFixed(2);if(L.IS_DEV)console.log(`✅ App ready in ${n}ms`)}get initTime(){return this.#t?performance.now()-this.#t:0}#R(n){if(console.error("❌ App initialization failed:",n),document.documentElement.classList.add("app-error"),window.dispatchEvent(new CustomEvent("app:error",{detail:{error:n}})),L.IS_DEV)this.#h(n)}#h(n){let t=n instanceof Error?n.message:String(n),e=n instanceof Error?n.stack:"",i=document.createElement("div");i.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 c=document.createElement("div");c.style.cssText="max-width: 800px; width: 100%;";let h=document.createElement("h1");h.style.cssText="color: #ff6b6b; margin: 0 0 1rem 0;",h.textContent="App Initialization Failed";let I=document.createElement("p");if(I.style.cssText="margin: 0 0 1rem 0; color: #fff;",I.textContent=t,c.append(h,I),e){let s=document.createElement("pre");s.style.cssText="background: rgba(255, 255, 255, 0.1); padding: 1rem; border-radius: 4px; overflow: auto; color: #fff;",s.textContent=e,c.appendChild(s)}let _=document.createElement("button");_.type="button",_.textContent="Reload Page",_.style.cssText=` margin-top: 1rem; padding: 0.75rem 1.5rem; background: #ff6b6b; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; `,_.addEventListener("click",()=>window.location.reload()),c.appendChild(_),i.appendChild(c),document.body.appendChild(i)}get(n){let t=this.#n.get(n);if(!t&&L.IS_DEV)console.warn(`⚠️ Module "${n}" not found`);return t}get status(){return this.#e}get isReady(){return this.#e==="ready"}get scroll(){return H}get viewport(){return u}get pages(){return v}destroy(){console.log("\uD83E\uDDF9 Cleaning up app..."),this.#n.forEach((n,t)=>{try{if(typeof n.destroy==="function")n.destroy(),console.log(`✅ ${t} destroyed`)}catch(e){console.error(`❌ Failed to destroy ${t}:`,e)}}),E.cleanup(),this.#n.clear(),this.#e="idle",this.#t=null}get performance(){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 T=new g;if(typeof window<"u")window.app=T,window.tick=E;export{T as App};