(function () {
"use strict";
var KEY = "runique-admin-theme";
var btn = document.getElementById("themeToggle");
if (!btn) {
return;
}
function stored() {
try {
var t = localStorage.getItem(KEY);
return t === "light" || t === "dark" ? t : null;
} catch (e) {
return null;
}
}
function current() {
return document.documentElement.getAttribute("data-theme") === "light" ? "light" : "dark";
}
function apply(theme) {
document.documentElement.setAttribute("data-theme", theme);
btn.setAttribute("aria-pressed", theme === "light" ? "true" : "false");
try {
localStorage.setItem(KEY, theme);
} catch (e) {
}
}
apply(stored() || current());
btn.addEventListener("click", function () {
apply(current() === "dark" ? "light" : "dark");
});
})();