import { t as e } from "./clsx.js";
import { t } from "./resize-observer.js";
import { useEffect as n, useId as r, useMemo as i, useRef as a, useState as o } from "react";
import { jsx as s, jsxs as c } from "react/jsx-runtime";
//#region ../../node_modules/.pnpm/react-use-measure@2.1.7_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/react-use-measure/dist/index.js
function l(e, t) {
	let n;
	return (...r) => {
		window.clearTimeout(n), n = window.setTimeout(() => e(...r), t);
	};
}
function u({ debounce: e, scroll: t, polyfill: r, offsetSize: s } = {
	debounce: 0,
	scroll: !1,
	offsetSize: !1
}) {
	let c = r || (typeof window > "u" ? class {} : window.ResizeObserver);
	if (!c) throw Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");
	let [u, m] = o({
		left: 0,
		top: 0,
		width: 0,
		height: 0,
		bottom: 0,
		right: 0,
		x: 0,
		y: 0
	}), g = a({
		element: null,
		scrollContainers: null,
		resizeObserver: null,
		lastBounds: u,
		orientationHandler: null
	}), _ = e ? typeof e == "number" ? e : e.scroll : null, v = e ? typeof e == "number" ? e : e.resize : null, y = a(!1);
	n(() => (y.current = !0, () => void (y.current = !1)));
	let [b, x, S] = i(() => {
		let e = () => {
			if (!g.current.element) return;
			let { left: e, top: t, width: n, height: r, bottom: i, right: a, x: o, y: c } = g.current.element.getBoundingClientRect(), l = {
				left: e,
				top: t,
				width: n,
				height: r,
				bottom: i,
				right: a,
				x: o,
				y: c
			};
			g.current.element instanceof HTMLElement && s && (l.height = g.current.element.offsetHeight, l.width = g.current.element.offsetWidth), Object.freeze(l), y.current && !h(g.current.lastBounds, l) && m(g.current.lastBounds = l);
		};
		return [
			e,
			v ? l(e, v) : e,
			_ ? l(e, _) : e
		];
	}, [
		m,
		s,
		_,
		v
	]);
	function C() {
		g.current.scrollContainers && (g.current.scrollContainers.forEach((e) => e.removeEventListener("scroll", S, !0)), g.current.scrollContainers = null), g.current.resizeObserver && (g.current.resizeObserver.disconnect(), g.current.resizeObserver = null), g.current.orientationHandler && ("orientation" in screen && "removeEventListener" in screen.orientation ? screen.orientation.removeEventListener("change", g.current.orientationHandler) : "onorientationchange" in window && window.removeEventListener("orientationchange", g.current.orientationHandler));
	}
	function w() {
		g.current.element && (g.current.resizeObserver = new c(S), g.current.resizeObserver.observe(g.current.element), t && g.current.scrollContainers && g.current.scrollContainers.forEach((e) => e.addEventListener("scroll", S, {
			capture: !0,
			passive: !0
		})), g.current.orientationHandler = () => {
			S();
		}, "orientation" in screen && "addEventListener" in screen.orientation ? screen.orientation.addEventListener("change", g.current.orientationHandler) : "onorientationchange" in window && window.addEventListener("orientationchange", g.current.orientationHandler));
	}
	return f(S, !!t), d(x), n(() => {
		C(), w();
	}, [
		t,
		S,
		x
	]), n(() => C, []), [
		(e) => {
			!e || e === g.current.element || (C(), g.current.element = e, g.current.scrollContainers = p(e), w());
		},
		u,
		b
	];
}
function d(e) {
	n(() => {
		let t = e;
		return window.addEventListener("resize", t), () => void window.removeEventListener("resize", t);
	}, [e]);
}
function f(e, t) {
	n(() => {
		if (t) {
			let t = e;
			return window.addEventListener("scroll", t, {
				capture: !0,
				passive: !0
			}), () => void window.removeEventListener("scroll", t, !0);
		}
	}, [e, t]);
}
function p(e) {
	let t = [];
	if (!e || e === document.body) return t;
	let { overflow: n, overflowX: r, overflowY: i } = window.getComputedStyle(e);
	return [
		n,
		r,
		i
	].some((e) => e === "auto" || e === "scroll") && t.push(e), [...t, ...p(e.parentElement)];
}
var m = [
	"x",
	"y",
	"top",
	"bottom",
	"left",
	"right",
	"width",
	"height"
], h = (e, t) => m.every((n) => e[n] === t[n]), g = (n) => {
	let i = r(), { ariaLabel: a, className: l, dataTestId: d = "range", id: f = i, name: p = f, singleCursorMode: m = !1, min: h = 0, options: g = [], step: _ = 1, readOnly: v, disabled: y, onChange: b, ...x } = n, [S, C] = o(g.length - 1), [w, T] = o(h), [E, { width: D }] = u({ polyfill: t }), O = (e) => {
		if (!v) {
			e.persist();
			let t = Number(e.target.value), n = e.target.id[e.target.id.length - 1];
			n === "a" ? C(t) : T(t), b && b(e.nativeEvent, n === "a" ? [t, w] : [S, t]);
		}
	};
	return /* @__PURE__ */ c("div", {
		style: {
			"--min": h,
			"--max": g.length - 1,
			"--inputWidth": `${D}px`,
			"--inputHeight": "4px",
			"--thumbWidth": "32px",
			"--usefulWidth": "calc(var(--inputWidth) - var(--thumbWidth))",
			"--valueA": S,
			"--valueB": w
		},
		className: e("relative w-full", l),
		"data-testid": d,
		"data-name": "Range",
		ref: E,
		children: [
			/* @__PURE__ */ c("div", {
				className: "input-range-container",
				children: [/* @__PURE__ */ s("input", {
					...x,
					"aria-label": a,
					className: "input-range",
					id: `${f}-a`,
					max: g.length - 1,
					min: h,
					name: p,
					onChange: O,
					disabled: y,
					step: _,
					type: "range",
					value: S
				}), !m && /* @__PURE__ */ s("input", {
					...x,
					"aria-label": a,
					className: "input-range",
					disabled: y,
					id: `${f}-b`,
					max: g.length - 1,
					min: h,
					name: p,
					onChange: O,
					step: _,
					type: "range",
					value: w
				})]
			}),
			/* @__PURE__ */ s("output", {
				htmlFor: `${f}-a`,
				style: { "--value": S },
				className: "input-range-output",
				children: g[S].label
			}),
			!m && /* @__PURE__ */ s("output", {
				htmlFor: `${f}-b`,
				style: { "--value": w },
				className: "input-range-output",
				children: g[w].label
			})
		]
	});
};
//#endregion
export { g as t };

//# sourceMappingURL=Range.js.map