const d=()=>localStorage.getItem("theme"),u=e=>localStorage.setItem("theme",e),c=()=>{const e=d();return e||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")},o=e=>{e==="auto"?document.documentElement.setAttribute("data-bs-theme",window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"):document.documentElement.setAttribute("data-bs-theme",e)},n=(e,t=!1)=>{const a=document.querySelector("#bd-theme");if(!a)return;const m=document.querySelector("#bd-theme-text"),r=document.querySelector(".theme-icon-active i"),s=document.querySelector(`[data-bs-theme-value="${e}"]`),l=s.querySelector("i").classList;document.querySelectorAll("[data-bs-theme-value]").forEach(i=>{i.classList.remove("active"),i.setAttribute("aria-pressed","false")}),s.classList.add("active"),s.setAttribute("aria-pressed","true"),r.classList.remove(...r.classList.values()),r.classList.add(...l);const h=`${m.textContent} (${s.textContent.trim()})`;a.setAttribute("aria-label",h),t&&a.focus()};function f(){document.querySelectorAll("[data-bs-theme-value]").forEach(e=>{e.addEventListener("click",()=>{const t=e.getAttribute("data-bs-theme-value");u(t),o(t),n(t,!0)})}),n(c(),!1)}function b(){o(c()),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{const e=d();e!=="light"&&e!=="dark"&&o(c())}),window.addEventListener("DOMContentLoaded",()=>{n(c())})}export{b as l,f as s};
