import { t as e } from "./utils-B7XIe3qq.js";
import { n as t } from "./dist-CTlQcJNK.js";
import { a as n, o as r, t as i } from "./dist-koa_pEtu.js";
import { t as a } from "./dist-C0wG5dwG.js";
import { t as o } from "./dist-cMlzVrN6.js";
import { t as s } from "./dist-CVCn7F_m.js";
import { t as c } from "./dist-D5o6xae2.js";
import { t as l } from "./dist-Cao8o5bZ.js";
import { t as u } from "./dist-Dm7Xaded.js";
import * as d from "react";
import { jsx as f, jsxs as p } from "react/jsx-runtime";
//#region node_modules/@radix-ui/react-slider/dist/index.mjs
var m = ["PageUp", "PageDown"], h = [
	"ArrowUp",
	"ArrowDown",
	"ArrowLeft",
	"ArrowRight"
], g = {
	"from-left": [
		"Home",
		"PageDown",
		"ArrowDown",
		"ArrowLeft"
	],
	"from-right": [
		"Home",
		"PageDown",
		"ArrowDown",
		"ArrowRight"
	],
	"from-bottom": [
		"Home",
		"PageDown",
		"ArrowDown",
		"ArrowLeft"
	],
	"from-top": [
		"Home",
		"PageDown",
		"ArrowUp",
		"ArrowLeft"
	]
}, _ = "Slider", [v, y, b] = o(_), [x, S] = n(_, [b]), [C, w] = x(_), T = d.forwardRef((e, t) => {
	let { name: n, min: i = 0, max: o = 100, step: s = 1, orientation: c = "horizontal", disabled: l = !1, minStepsBetweenThumbs: p = 0, defaultValue: g = [i], value: _, onValueChange: y = () => {}, onValueCommit: b = () => {}, inverted: x = !1, form: S, ...w } = e, T = d.useRef(/* @__PURE__ */ new Set()), E = d.useRef(0), D = c === "horizontal" ? O : k, [A = [], j] = a({
		prop: _,
		defaultProp: g,
		onChange: (e) => {
			[...T.current][E.current]?.focus(), y(e);
		}
	}), M = d.useRef(A);
	function N(e) {
		I(e, U(A, e));
	}
	function P(e) {
		I(e, E.current);
	}
	function F() {
		let e = M.current[E.current];
		A[E.current] !== e && b(A);
	}
	function I(e, t, { commit: n } = { commit: !1 }) {
		let r = J(s), a = u(Y(Math.round((e - i) / s) * s + i, r), [i, o]);
		j((e = []) => {
			let r = B(e, a, t);
			if (K(r, p * s)) {
				E.current = r.indexOf(a);
				let t = String(r) !== String(e);
				return t && n && b(r), t ? r : e;
			} else return e;
		});
	}
	return /* @__PURE__ */ f(C, {
		scope: e.__scopeSlider,
		name: n,
		disabled: l,
		min: i,
		max: o,
		valueIndexToChangeRef: E,
		thumbs: T.current,
		values: A,
		orientation: c,
		form: S,
		children: /* @__PURE__ */ f(v.Provider, {
			scope: e.__scopeSlider,
			children: /* @__PURE__ */ f(v.Slot, {
				scope: e.__scopeSlider,
				children: /* @__PURE__ */ f(D, {
					"aria-disabled": l,
					"data-disabled": l ? "" : void 0,
					...w,
					ref: t,
					onPointerDown: r(w.onPointerDown, () => {
						l || (M.current = A);
					}),
					min: i,
					max: o,
					inverted: x,
					onSlideStart: l ? void 0 : N,
					onSlideMove: l ? void 0 : P,
					onSlideEnd: l ? void 0 : F,
					onHomeKeyDown: () => !l && I(i, 0, { commit: !0 }),
					onEndKeyDown: () => !l && I(o, A.length - 1, { commit: !0 }),
					onStepKeyDown: ({ event: e, direction: t }) => {
						if (!l) {
							let n = m.includes(e.key) || e.shiftKey && h.includes(e.key) ? 10 : 1, r = E.current, i = A[r];
							I(i + s * n * t, r, { commit: !0 });
						}
					}
				})
			})
		})
	});
});
T.displayName = _;
var [E, D] = x(_, {
	startEdge: "left",
	endEdge: "right",
	size: "width",
	direction: 1
}), O = d.forwardRef((e, n) => {
	let { min: r, max: i, dir: a, inverted: o, onSlideStart: c, onSlideMove: l, onSlideEnd: u, onStepKeyDown: p, ...m } = e, [h, _] = d.useState(null), v = t(n, (e) => _(e)), y = d.useRef(void 0), b = s(a), x = b === "ltr", S = x && !o || !x && o;
	function C(e) {
		let t = y.current || h.getBoundingClientRect(), n = q([0, t.width], S ? [r, i] : [i, r]);
		return y.current = t, n(e - t.left);
	}
	return /* @__PURE__ */ f(E, {
		scope: e.__scopeSlider,
		startEdge: S ? "left" : "right",
		endEdge: S ? "right" : "left",
		direction: S ? 1 : -1,
		size: "width",
		children: /* @__PURE__ */ f(A, {
			dir: b,
			"data-orientation": "horizontal",
			...m,
			ref: v,
			style: {
				...m.style,
				"--radix-slider-thumb-transform": "translateX(-50%)"
			},
			onSlideStart: (e) => {
				let t = C(e.clientX);
				c?.(t);
			},
			onSlideMove: (e) => {
				let t = C(e.clientX);
				l?.(t);
			},
			onSlideEnd: () => {
				y.current = void 0, u?.();
			},
			onStepKeyDown: (e) => {
				let t = g[S ? "from-left" : "from-right"].includes(e.key);
				p?.({
					event: e,
					direction: t ? -1 : 1
				});
			}
		})
	});
}), k = d.forwardRef((e, n) => {
	let { min: r, max: i, inverted: a, onSlideStart: o, onSlideMove: s, onSlideEnd: c, onStepKeyDown: l, ...u } = e, p = d.useRef(null), m = t(n, p), h = d.useRef(void 0), _ = !a;
	function v(e) {
		let t = h.current || p.current.getBoundingClientRect(), n = q([0, t.height], _ ? [i, r] : [r, i]);
		return h.current = t, n(e - t.top);
	}
	return /* @__PURE__ */ f(E, {
		scope: e.__scopeSlider,
		startEdge: _ ? "bottom" : "top",
		endEdge: _ ? "top" : "bottom",
		size: "height",
		direction: _ ? 1 : -1,
		children: /* @__PURE__ */ f(A, {
			"data-orientation": "vertical",
			...u,
			ref: m,
			style: {
				...u.style,
				"--radix-slider-thumb-transform": "translateY(50%)"
			},
			onSlideStart: (e) => {
				let t = v(e.clientY);
				o?.(t);
			},
			onSlideMove: (e) => {
				let t = v(e.clientY);
				s?.(t);
			},
			onSlideEnd: () => {
				h.current = void 0, c?.();
			},
			onStepKeyDown: (e) => {
				let t = g[_ ? "from-bottom" : "from-top"].includes(e.key);
				l?.({
					event: e,
					direction: t ? -1 : 1
				});
			}
		})
	});
}), A = d.forwardRef((e, t) => {
	let { __scopeSlider: n, onSlideStart: a, onSlideMove: o, onSlideEnd: s, onHomeKeyDown: c, onEndKeyDown: l, onStepKeyDown: u, ...d } = e, p = w(_, n);
	return /* @__PURE__ */ f(i.span, {
		...d,
		ref: t,
		onKeyDown: r(e.onKeyDown, (e) => {
			e.key === "Home" ? (c(e), e.preventDefault()) : e.key === "End" ? (l(e), e.preventDefault()) : m.concat(h).includes(e.key) && (u(e), e.preventDefault());
		}),
		onPointerDown: r(e.onPointerDown, (e) => {
			let t = e.target;
			t.setPointerCapture(e.pointerId), e.preventDefault(), p.thumbs.has(t) ? t.focus() : a(e);
		}),
		onPointerMove: r(e.onPointerMove, (e) => {
			e.target.hasPointerCapture(e.pointerId) && o(e);
		}),
		onPointerUp: r(e.onPointerUp, (e) => {
			let t = e.target;
			t.hasPointerCapture(e.pointerId) && (t.releasePointerCapture(e.pointerId), s(e));
		})
	});
}), j = "SliderTrack", M = d.forwardRef((e, t) => {
	let { __scopeSlider: n, ...r } = e, a = w(j, n);
	return /* @__PURE__ */ f(i.span, {
		"data-disabled": a.disabled ? "" : void 0,
		"data-orientation": a.orientation,
		...r,
		ref: t
	});
});
M.displayName = j;
var N = "SliderRange", P = d.forwardRef((e, n) => {
	let { __scopeSlider: r, ...a } = e, o = w(N, r), s = D(N, r), c = t(n, d.useRef(null)), l = o.values.length, u = o.values.map((e) => V(e, o.min, o.max)), p = l > 1 ? Math.min(...u) : 0, m = 100 - Math.max(...u);
	return /* @__PURE__ */ f(i.span, {
		"data-orientation": o.orientation,
		"data-disabled": o.disabled ? "" : void 0,
		...a,
		ref: c,
		style: {
			...e.style,
			[s.startEdge]: p + "%",
			[s.endEdge]: m + "%"
		}
	});
});
P.displayName = N;
var F = "SliderThumb", I = d.forwardRef((e, n) => {
	let r = y(e.__scopeSlider), [i, a] = d.useState(null), o = t(n, (e) => a(e)), s = d.useMemo(() => i ? r().findIndex((e) => e.ref.current === i) : -1, [r, i]);
	return /* @__PURE__ */ f(L, {
		...e,
		ref: o,
		index: s
	});
}), L = d.forwardRef((e, n) => {
	let { __scopeSlider: a, index: o, name: s, ...l } = e, u = w(F, a), m = D(F, a), [h, g] = d.useState(null), _ = t(n, (e) => g(e)), y = h ? u.form || !!h.closest("form") : !0, b = c(h), x = u.values[o], S = x === void 0 ? 0 : V(x, u.min, u.max), C = H(o, u.values.length), T = b?.[m.size], E = T ? W(T, S, m.direction) : 0;
	return d.useEffect(() => {
		if (h) return u.thumbs.add(h), () => {
			u.thumbs.delete(h);
		};
	}, [h, u.thumbs]), /* @__PURE__ */ p("span", {
		style: {
			transform: "var(--radix-slider-thumb-transform)",
			position: "absolute",
			[m.startEdge]: `calc(${S}% + ${E}px)`
		},
		children: [/* @__PURE__ */ f(v.ItemSlot, {
			scope: e.__scopeSlider,
			children: /* @__PURE__ */ f(i.span, {
				role: "slider",
				"aria-label": e["aria-label"] || C,
				"aria-valuemin": u.min,
				"aria-valuenow": x,
				"aria-valuemax": u.max,
				"aria-orientation": u.orientation,
				"data-orientation": u.orientation,
				"data-disabled": u.disabled ? "" : void 0,
				tabIndex: u.disabled ? void 0 : 0,
				...l,
				ref: _,
				style: x === void 0 ? { display: "none" } : e.style,
				onFocus: r(e.onFocus, () => {
					u.valueIndexToChangeRef.current = o;
				})
			})
		}), y && /* @__PURE__ */ f(z, {
			name: s ?? (u.name ? u.name + (u.values.length > 1 ? "[]" : "") : void 0),
			form: u.form,
			value: x
		}, o)]
	});
});
I.displayName = F;
var R = "RadioBubbleInput", z = d.forwardRef(({ __scopeSlider: e, value: n, ...r }, a) => {
	let o = d.useRef(null), s = t(o, a), c = l(n);
	return d.useEffect(() => {
		let e = o.current;
		if (!e) return;
		let t = window.HTMLInputElement.prototype, r = Object.getOwnPropertyDescriptor(t, "value").set;
		if (c !== n && r) {
			let t = new Event("input", { bubbles: !0 });
			r.call(e, n), e.dispatchEvent(t);
		}
	}, [c, n]), /* @__PURE__ */ f(i.input, {
		style: { display: "none" },
		...r,
		ref: s,
		defaultValue: n
	});
});
z.displayName = R;
function B(e = [], t, n) {
	let r = [...e];
	return r[n] = t, r.sort((e, t) => e - t);
}
function V(e, t, n) {
	return u(100 / (n - t) * (e - t), [0, 100]);
}
function H(e, t) {
	if (t > 2) return `Value ${e + 1} of ${t}`;
	if (t === 2) return ["Minimum", "Maximum"][e];
}
function U(e, t) {
	if (e.length === 1) return 0;
	let n = e.map((e) => Math.abs(e - t)), r = Math.min(...n);
	return n.indexOf(r);
}
function W(e, t, n) {
	let r = e / 2;
	return (r - q([0, 50], [0, r])(t) * n) * n;
}
function G(e) {
	return e.slice(0, -1).map((t, n) => e[n + 1] - t);
}
function K(e, t) {
	if (t > 0) {
		let n = G(e);
		return Math.min(...n) >= t;
	}
	return !0;
}
function q(e, t) {
	return (n) => {
		if (e[0] === e[1] || t[0] === t[1]) return t[0];
		let r = (t[1] - t[0]) / (e[1] - e[0]);
		return t[0] + r * (n - e[0]);
	};
}
function J(e) {
	return (String(e).split(".")[1] || "").length;
}
function Y(e, t) {
	let n = 10 ** t;
	return Math.round(e * n) / n;
}
var X = T, Z = M, Q = P, $ = I;
//#endregion
//#region src/react/primitives/slider.tsx
function ee({ className: t, defaultValue: n, value: r, min: i = 0, max: a = 100, ...o }) {
	let s = r ?? n ?? [i];
	return /* @__PURE__ */ p(X, {
		"data-slot": "slider",
		...n === void 0 ? {} : { defaultValue: n },
		...r === void 0 ? {} : { value: r },
		min: i,
		max: a,
		className: e("relative flex w-full touch-none select-none items-center", "disabled:cursor-not-allowed disabled:opacity-50", t),
		...o,
		children: [/* @__PURE__ */ f(Z, {
			"data-slot": "slider-track",
			className: "bg-accent relative h-1.5 w-full grow overflow-hidden rounded-full",
			children: /* @__PURE__ */ f(Q, {
				"data-slot": "slider-range",
				className: "bg-primary absolute h-full"
			})
		}), Array.from({ length: s.length }, (t, n) => /* @__PURE__ */ f($, {
			"data-slot": "slider-thumb",
			className: e("border-primary bg-background block h-4 w-4 rounded-full border-2 shadow-sm transition-colors", "focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none", "disabled:pointer-events-none")
		}, n))]
	});
}
//#endregion
export { ee as t };

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