import { b as e, h as t } from "./chunk.BlbRoQQ3.js";
import { useCallback as n, useEffect as r, useLayoutEffect as i, useMemo as a, useRef as o, useState as s } from "react";
var c = /* @__PURE__ */ e(((exports, t) => {
	var n = "Expected a function", r = NaN, i = "[object Symbol]", a = /^\s+|\s+$/g, o = /^[-+]0x[0-9a-f]+$/i, s = /^0b[01]+$/i, c = /^0o[0-7]+$/i, l = parseInt, u = typeof global == "object" && global && global.Object === Object && global, d = typeof self == "object" && self && self.Object === Object && self, f = u || d || Function("return this")(), p = Object.prototype, m = p.toString, h = Math.max, g = Math.min, _ = function() {
		return f.Date.now();
	};
	function v(e, t, r) {
		var i, a, o, s, c, l, u = 0, d = !1, f = !1, p = !0;
		if (typeof e != "function") throw TypeError(n);
		t = S(t) || 0, y(r) && (d = !!r.leading, f = "maxWait" in r, o = f ? h(S(r.maxWait) || 0, t) : o, p = "trailing" in r ? !!r.trailing : p);
		function m(t) {
			var n = i, r = a;
			return i = a = void 0, u = t, s = e.apply(r, n), s;
		}
		function v(e) {
			return u = e, c = setTimeout(C, t), d ? m(e) : s;
		}
		function b(e) {
			var n = e - l, r = e - u, i = t - n;
			return f ? g(i, o - r) : i;
		}
		function x(e) {
			var n = e - l, r = e - u;
			return l === void 0 || n >= t || n < 0 || f && r >= o;
		}
		function C() {
			var e = _();
			if (x(e)) return w(e);
			c = setTimeout(C, b(e));
		}
		function w(e) {
			return c = void 0, p && i ? m(e) : (i = a = void 0, s);
		}
		function T() {
			c !== void 0 && clearTimeout(c), u = 0, i = l = a = c = void 0;
		}
		function E() {
			return c === void 0 ? s : w(_());
		}
		function D() {
			var e = _(), n = x(e);
			if (i = arguments, a = this, l = e, n) {
				if (c === void 0) return v(l);
				if (f) return c = setTimeout(C, t), m(l);
			}
			return c === void 0 && (c = setTimeout(C, t)), s;
		}
		return D.cancel = T, D.flush = E, D;
	}
	function y(e) {
		var t = typeof e;
		return !!e && (t == "object" || t == "function");
	}
	function b(e) {
		return !!e && typeof e == "object";
	}
	function x(e) {
		return typeof e == "symbol" || b(e) && m.call(e) == i;
	}
	function S(e) {
		if (typeof e == "number") return e;
		if (x(e)) return r;
		if (y(e)) {
			var t = typeof e.valueOf == "function" ? e.valueOf() : e;
			e = y(t) ? t + "" : t;
		}
		if (typeof e != "string") return e === 0 ? e : +e;
		e = e.replace(a, "");
		var n = s.test(e);
		return n || c.test(e) ? l(e.slice(2), n ? 2 : 8) : o.test(e) ? r : +e;
	}
	t.exports = v;
})), l = /* @__PURE__ */ t(c()), u = typeof window < "u" ? i : r;
function d(e, t, n, i) {
	let a = o(t);
	u(() => {
		a.current = t;
	}, [t]), r(() => {
		let t = n?.current ?? window;
		if (!(t && t.addEventListener)) return;
		let r = (e) => {
			a.current(e);
		};
		return t.addEventListener(e, r, i), () => {
			t.removeEventListener(e, r, i);
		};
	}, [
		e,
		n,
		i
	]);
}
function f(e) {
	let t = o(() => {
		throw Error("Cannot call an event handler while rendering.");
	});
	return u(() => {
		t.current = e;
	}, [e]), n((...e) => {
		var n;
		return (n = t.current)?.call(t, ...e);
	}, [t]);
}
var p = typeof window > "u";
function m(e, t, i = {}) {
	let { initializeWithValue: a = !0 } = i, o = n((e) => i.serializer ? i.serializer(e) : JSON.stringify(e), [i]), c = n((e) => {
		if (i.deserializer) return i.deserializer(e);
		if (e === "undefined") return;
		let n = t instanceof Function ? t() : t, r;
		try {
			r = JSON.parse(e);
		} catch (e) {
			return console.error("Error parsing JSON:", e), n;
		}
		return r;
	}, [i, t]), l = n(() => {
		let n = t instanceof Function ? t() : t;
		if (p) return n;
		try {
			let t = window.localStorage.getItem(e);
			return t ? c(t) : n;
		} catch (t) {
			return console.warn(`Error reading localStorage key \u201C${e}\u201D:`, t), n;
		}
	}, [
		t,
		e,
		c
	]), [u, m] = s(() => a ? l() : t instanceof Function ? t() : t), h = f((t) => {
		p && console.warn(`Tried setting localStorage key \u201C${e}\u201D even though environment is not a client`);
		try {
			let n = t instanceof Function ? t(l()) : t;
			window.localStorage.setItem(e, o(n)), m(n), window.dispatchEvent(new StorageEvent("local-storage", { key: e }));
		} catch (t) {
			console.warn(`Error setting localStorage key \u201C${e}\u201D:`, t);
		}
	}), g = f(() => {
		p && console.warn(`Tried removing localStorage key \u201C${e}\u201D even though environment is not a client`);
		let n = t instanceof Function ? t() : t;
		window.localStorage.removeItem(e), m(n), window.dispatchEvent(new StorageEvent("local-storage", { key: e }));
	});
	r(() => {
		m(l());
	}, [e]);
	let _ = n((t) => {
		t.key && t.key !== e || m(l());
	}, [e, l]);
	return d("storage", _), d("local-storage", _), [
		u,
		h,
		g
	];
}
var h = typeof window > "u";
function g(e, { defaultValue: t = !1, initializeWithValue: n = !0 } = {}) {
	let r = (e) => h ? t : window.matchMedia(e).matches, [i, a] = s(() => n ? r(e) : t);
	function o() {
		a(r(e));
	}
	return u(() => {
		let t = window.matchMedia(e);
		return o(), t.addListener ? t.addListener(o) : t.addEventListener("change", o), () => {
			t.removeListener ? t.removeListener(o) : t.removeEventListener("change", o);
		};
	}, [e]), i;
}
var _ = "(prefers-color-scheme: dark)", v = "usehooks-ts-dark-mode";
function y(e = {}) {
	let { defaultValue: t, localStorageKey: n = v, initializeWithValue: r = !0 } = e, i = g(_, {
		initializeWithValue: r,
		defaultValue: t
	}), [a, o] = m(n, t ?? i ?? !1, { initializeWithValue: r });
	return u(() => {
		i !== a && o(i);
	}, [i]), {
		isDarkMode: a,
		toggle: () => {
			o((e) => !e);
		},
		enable: () => {
			o(!0);
		},
		disable: () => {
			o(!1);
		},
		set: (e) => {
			o(e);
		}
	};
}
function b(e) {
	let t = o(e);
	t.current = e, r(() => () => {
		t.current();
	}, []);
}
function x(e, t = 500, n) {
	let i = o();
	b(() => {
		i.current && i.current.cancel();
	});
	let s = a(() => {
		let r = (0, l.default)(e, t, n), a = (...e) => r(...e);
		return a.cancel = () => {
			r.cancel();
		}, a.isPending = () => !!i.current, a.flush = () => r.flush(), a;
	}, [
		e,
		t,
		n
	]);
	return r(() => {
		i.current = (0, l.default)(e, t, n);
	}, [
		e,
		t,
		n
	]), s;
}
export { y as b, x as c, m as d, g as e };

//# sourceMappingURL=dist.ccQGo6gv.js.map