import { ICON_SETS as e, getIconSvgInner as t } from "../icons/index.js";
import { configureTheme as n } from "../ui/index.js";
//#region src/appearance/index.ts
var r = "accent_theme", i = "typography", a = "icon_set", o = "quick_switcher_themes", s = [
	"light",
	"dark",
	"monokai",
	"glass"
], c = [
	"orange",
	"cyan",
	"violet",
	"rose",
	"emerald"
], l = [
	"sora",
	"inter",
	"roboto",
	"system",
	"jetbrains-mono"
], u = [
	"lucide",
	"heroicons",
	"phosphor",
	"material"
], d = "/api/v1/users/me/appearance";
function f(e) {
	return typeof e == "string" && c.includes(e);
}
function p(e) {
	return typeof e == "string" && l.includes(e);
}
function m() {
	let e = localStorage.getItem(r);
	return f(e) ? e : "orange";
}
function h() {
	let e = localStorage.getItem(i);
	return p(e) ? e : "sora";
}
function g(e) {
	e === "orange" ? document.documentElement.removeAttribute("data-accent") : document.documentElement.setAttribute("data-accent", e);
}
function _(e) {
	e === "sora" ? document.documentElement.removeAttribute("data-font") : document.documentElement.setAttribute("data-font", e);
}
function v(e) {
	localStorage.setItem(r, e), g(e);
}
function y(e) {
	localStorage.setItem(i, e), _(e);
}
function b(e) {
	return typeof e == "string" && u.includes(e);
}
function x() {
	let e = localStorage.getItem(a);
	return b(e) ? e : "lucide";
}
function S(e) {
	let n = document.querySelectorAll("[data-icon]");
	for (let r of n) {
		let n = r.getAttribute("data-icon");
		if (n === null || n.length === 0) continue;
		let i = t(e, n);
		i !== void 0 && (r.innerHTML = i);
	}
	e === "lucide" ? document.documentElement.removeAttribute("data-icon-set") : document.documentElement.setAttribute("data-icon-set", e);
}
function C(e) {
	localStorage.setItem(a, e), S(e);
}
function w() {
	let e = localStorage.getItem(o);
	if (e === null || e.length === 0) return [...s];
	try {
		let t = JSON.parse(e).filter((e) => s.includes(e));
		return t.length > 0 ? t : [...s];
	} catch {
		return [...s];
	}
}
function T(e) {
	localStorage.setItem(o, JSON.stringify(e));
}
function E(e) {
	g(m()), _(h()), S(x());
	let t = w();
	e?.onToggleCycleUpdate && e.onToggleCycleUpdate(t);
}
async function D(e) {
	let t = e?.endpoint ?? d, r = e?.getToken ? e.getToken() : null, i = {};
	r && (i.Authorization = `Bearer ${r}`);
	let a;
	try {
		let e = await fetch(t, { headers: i });
		if (!e.ok) return;
		a = await e.json();
	} catch {
		return;
	}
	if (f(a.accent) && a.accent !== m() && v(a.accent), p(a.font) && a.font !== h() && y(a.font), b(a.icon_set) && a.icon_set !== x() && C(a.icon_set), e?.onToggleCycleUpdate) {
		let t = w();
		n({ themes: t }), e.onToggleCycleUpdate(t);
	}
}
//#endregion
export { e as ICON_SETS, g as applyAccent, _ as applyFont, S as applyIconSet, t as getIconSvgInner, m as getStoredAccent, h as getStoredFont, x as getStoredIconSet, w as getStoredQuickSwitcherThemes, E as initAppearance, f as isValidAccent, p as isValidFont, b as isValidIconSet, v as setAccent, y as setFont, C as setIconSet, T as setQuickSwitcherThemes, D as syncAppearanceFromServer };

//# sourceMappingURL=index.js.map