class i{constructor(){this.MODES=["light","dark","system"],this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.root=document.documentElement,this.applyMode(),document.body.style.visibility="visible",this.modeSwitchers=null}setupEventListeners(){this.modeSwitchers=document.querySelectorAll("[data-theme-switcher]"),this.modeSwitchers.forEach(e=>{e.addEventListener("click",()=>this.cycleMode())}),this.mediaQuery.addEventListener("change",()=>this.currentMode==="system"&&this.applyMode())}get currentMode(){return localStorage.getItem("theme-mode")||"system"}set currentMode(e){e==="system"?localStorage.removeItem("theme-mode"):localStorage.setItem("theme-mode",e)}getThemeValue(e){const s=getComputedStyle(this.root),r=s.getPropertyValue("--theme-light").trim().replace(/"/g,""),t=s.getPropertyValue("--theme-dark").trim().replace(/"/g,"");return e==="system"?this.mediaQuery.matches?t:r:e==="dark"?t:r}applyMode(){var t;const e=this.currentMode,s=this.getThemeValue(e),r={light:"Switch to dark mode (currently light)",dark:"Switch to system mode (currently dark)",system:"Switch to light mode (currently system)"};this.root.setAttribute("data-theme",s),(t=this.modeSwitchers)==null||t.forEach(o=>{o.setAttribute("aria-label",r[e])}),this.MODES.forEach(o=>{document.querySelectorAll(`[data-theme-icon="${o}"]`).forEach(h=>{h==null||h.setAttribute("opacity",o===e?"1":"0")})})}cycleMode(){this.currentMode=this.MODES[(this.MODES.indexOf(this.currentMode)+1)%this.MODES.length],this.applyMode()}}const c=new i;document.addEventListener("DOMContentLoaded",()=>{c.setupEventListeners()});
