import { t as e } from "../../utils-B7XIe3qq.js";
import { useEffect as t, useRef as n, useState as r, useSyncExternalStore as i } from "react";
import { jsx as a, jsxs as o } from "react/jsx-runtime";
//#region src/react/primitives/animated-counter.tsx
var s = "(prefers-reduced-motion: reduce)";
function c() {
	return typeof window > "u" ? !1 : window.matchMedia(s).matches;
}
function l() {
	return !1;
}
function u(e) {
	let t = window.matchMedia(s);
	return t.addEventListener("change", e), () => t.removeEventListener("change", e);
}
function d() {
	return i(u, c, l);
}
var f = (e) => 1 - (1 - e) ** 3;
function p(e, i = {}) {
	let { start: a = 0, duration: o = 1e3, delay: s = 0, decimals: c = 0, easing: l = f } = i, u = d(), p = n(void 0), m = n(void 0), [h, g] = r(u ? e : a);
	return t(() => {
		if (u) return;
		let t = setTimeout(() => {
			m.current = void 0;
			let t = (n) => {
				m.current ||= n;
				let r = n - m.current, i = Math.min(r / o, 1), s = l(i), u = a + (e - a) * s;
				g(c > 0 ? Math.round(u * 10 ** c) / 10 ** c : Math.round(u)), i < 1 && (p.current = requestAnimationFrame(t));
			};
			p.current = requestAnimationFrame(t);
		}, s);
		return () => {
			clearTimeout(t), p.current && cancelAnimationFrame(p.current);
		};
	}, [
		e,
		a,
		o,
		s,
		c,
		l,
		u
	]), h;
}
function m({ value: t, duration: n = 1e3, delay: r = 0, decimals: i = 0, prefix: a = "", suffix: s = "", className: c }) {
	let l = p(t, {
		duration: n,
		delay: r,
		decimals: i
	}), u = i > 0 ? l.toFixed(i) : l.toLocaleString();
	return /* @__PURE__ */ o("span", {
		className: e("tabular-nums", c),
		"aria-live": "polite",
		"aria-atomic": "true",
		children: [
			a,
			u,
			s
		]
	});
}
function h({ value: e, duration: t = 1e3, delay: n = 0, className: r }) {
	return /* @__PURE__ */ a(m, {
		value: e,
		duration: t,
		delay: n,
		decimals: 0,
		suffix: "%",
		className: r
	});
}
function g({ value: t, duration: n = 1e3, delay: r = 0, className: i, showSuffix: o = !0 }) {
	return /* @__PURE__ */ a(m, {
		value: t,
		duration: n,
		delay: r,
		decimals: 0,
		suffix: o ? "%" : "",
		className: e(((e) => e >= 80 ? "text-emerald-400" : e >= 60 ? "text-amber-400" : e >= 40 ? "text-orange-400" : "text-rose-400")(t), i)
	});
}
//#endregion
export { m as AnimatedCounter, h as AnimatedPercentage, g as AnimatedScore };

//# sourceMappingURL=animated-counter.js.map