const getStoredThemeStyle=()=>localStorage.getItem("theme"),setThemeStyle=e=>{localStorage.setItem("theme",e);const t=document.documentElement,n=[...t.classList].find(e=>e.match(/theme--(light|dark)/));n&&t.classList.remove(n),t.classList.add(`theme--${e}`)},setDarkTheme=()=>{setThemeStyle("dark")},setLightTheme=()=>{setThemeStyle("light")},switchTheme=()=>{const e=getStoredThemeStyle();switch(e){case"light":setDarkTheme();break;case"dark":setLightTheme();break;default:setLightTheme();break}};document.addEventListener("DOMContentLoaded",()=>{const e=document.querySelector(".themeswitch");e.addEventListener("click",switchTheme,!1)},!1),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e=>e.matches?setDarkTheme():setLightTheme(),!1);const currThemeStyle=getStoredThemeStyle();currThemeStyle?setThemeStyle(currThemeStyle):window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?setDarkTheme():setLightTheme()