import { ACCENT_PALETTES as e, getTheme as t, setThemePartial as n } from "../../services/theme-engine/index.js";
//#region src/components/theme/accent-switcher.ts
var r = [
	{
		id: "orange",
		label: "Orange",
		color: e.orange.brand
	},
	{
		id: "cyan",
		label: "Cyan",
		color: e.cyan.brand
	},
	{
		id: "violet",
		label: "Violet",
		color: e.violet.brand
	},
	{
		id: "rose",
		label: "Rose",
		color: e.rose.brand
	},
	{
		id: "emerald",
		label: "Emerald",
		color: e.emerald.brand
	},
	{
		id: "amber",
		label: "Amber",
		color: e.amber.brand
	}
];
function i(e) {
	return r.some((t) => t.id === e);
}
function a() {
	return t().accent;
}
function o(e) {
	n({ accent: e }), typeof document < "u" && document.dispatchEvent(new CustomEvent("preview:accent-change", { detail: { accent: e } }));
}
function s() {
	if (typeof window > "u") return;
	let e = new URLSearchParams(window.location.search).get("accent");
	i(e) && o(e);
}
var c = class {
	el;
	constructor() {
		this.el = document.createElement("div"), this.el.className = "preview-accent-switcher";
		let e = document.createElement("span");
		e.className = "preview-accent-switcher__label", e.textContent = "Accent", this.el.appendChild(e);
		let t = document.createElement("div");
		t.className = "preview-accent-switcher__buttons";
		for (let e of r) {
			let n = document.createElement("button");
			n.type = "button", n.className = "preview-accent-switcher__btn", n.dataset.accent = e.id, n.title = e.label, n.setAttribute("aria-label", `Use ${e.label} accent`);
			let r = document.createElement("span");
			r.className = "preview-accent-swatch", r.style.background = e.color, n.appendChild(r), n.addEventListener("click", () => {
				o(e.id);
			}), t.appendChild(n);
		}
		this.el.appendChild(t), document.addEventListener("preview:accent-change", () => this.updateActive()), document.addEventListener("cm:theme-change", () => this.updateActive()), this.updateActive();
	}
	updateActive() {
		let e = a(), t = this.el.querySelectorAll(".preview-accent-switcher__btn");
		for (let n of t) {
			let t = n.dataset.accent === e;
			n.classList.toggle("preview-accent-switcher__btn--active", t), n.setAttribute("aria-pressed", String(t));
		}
	}
};
//#endregion
export { c as AccentSwitcher, s as applyAccentFromUrl, a as getCurrentAccent, o as setPreviewAccent };

//# sourceMappingURL=accent-switcher.js.map