import { getTheme as e, setThemePartial as t } from "../../services/theme-engine/index.js";
//#region src/components/theme/glass-slider.ts
var n = 0, r = .2, i = .01, a = class {
	el;
	input;
	value;
	constructor(a = {}) {
		let c = a.expanded === !0, l = o(e().transparency, n, r);
		if (this.el = document.createElement("div"), this.el.className = c ? "preview-glass-slider preview-glass-slider--expanded" : "preview-glass-slider", !c) {
			let e = document.createElement("span");
			e.className = "preview-glass-slider__label", e.textContent = "Glass", this.el.appendChild(e);
		}
		let u = document.createElement("div");
		if (u.className = "preview-glass-slider__row", c) {
			let e = document.createElement("span");
			e.className = "preview-glass-slider__edge", e.textContent = "Solid", u.appendChild(e);
		}
		if (this.input = document.createElement("input"), this.input.type = "range", this.input.min = String(n), this.input.max = String(r), this.input.step = String(i), this.input.value = String(l), this.input.className = "preview-glass-slider__input", this.input.setAttribute("aria-label", "Surface transparency"), u.appendChild(this.input), c) {
			let e = document.createElement("span");
			e.className = "preview-glass-slider__edge", e.textContent = "Frosted", u.appendChild(e);
		}
		this.value = document.createElement("span"), this.value.className = "preview-glass-slider__value", this.value.textContent = s(l), u.appendChild(this.value), this.el.appendChild(u), this.applySliderFill(l), this.input.addEventListener("input", () => {
			t({ transparency: o(Number(this.input.value), n, r) });
		}), document.addEventListener("cm:theme-change", () => {
			let t = o(e().transparency, n, r);
			Number(this.input.value) !== t && (this.input.value = String(t)), this.value.textContent = s(t), this.applySliderFill(t);
		});
	}
	applySliderFill(e) {
		let t = (e - n) / (r - n) * 100;
		this.input.style.setProperty("--slider-pct", `${t}%`);
	}
};
function o(e, t, n) {
	return Number.isFinite(e) ? Math.max(t, Math.min(n, e)) : t;
}
function s(e) {
	return `${Math.round(e * 100)}%`;
}
//#endregion
export { a as GlassSlider };

//# sourceMappingURL=glass-slider.js.map