@ndriadev/react-tools
Version:
A React library of hooks, components, utils and types ready to use
1,389 lines • 112 kB
JavaScript
var ue = (e, r, t) => {
if (!r.has(e))
throw TypeError("Cannot " + t);
};
var z = (e, r, t) => (ue(e, r, "read from private field"), t ? t.call(e) : r.get(e)), se = (e, r, t) => {
if (r.has(e))
throw TypeError("Cannot add the same private member more than once");
r instanceof WeakSet ? r.add(e) : r.set(e, t);
}, ie = (e, r, t, n) => (ue(e, r, "write to private field"), n ? n.call(e, t) : r.set(e, t), t);
import { useRef as d, useEffect as M, useLayoutEffect as q, useReducer as B, useCallback as m, useDeferredValue as oe, useState as C, useMemo as L, useId as ae, useSyncExternalStore as re, createElement as Fe } from "react";
import { createPortal as ze } from "react-dom";
import { a as U, h as Ve, c as le, b as We, i as He, d as de } from "./detectBrowser-BNhxl8AF.js";
import { j as je } from "./jsx-runtime-jRCOe3WA.js";
var N;
class ke {
constructor() {
se(this, N, void 0);
ie(this, N, /* @__PURE__ */ new Map());
}
subscribe(r, t) {
z(this, N).has(r) || z(this, N).set(r, []);
const n = z(this, N).get(r);
n.push(t), z(this, N).set(r, n);
}
unsubscribe(r, t) {
if (!z(this, N).has(r))
return !1;
const n = z(this, N).get(r).filter((c) => c !== t);
return z(this, N).set(r, n), !0;
}
publish(r, t) {
(z(this, N).get(r) ?? []).forEach((c) => c(t));
}
async publishAsync(r, t) {
const n = z(this, N).get(r) ?? [], c = [];
n.forEach((i) => c.push(i(t))), await Promise.allSettled(c);
}
}
N = new WeakMap();
class qe extends EventTarget {
constructor() {
super();
}
dispatch(r) {
this.dispatchEvent(r);
}
listen(r, t, n) {
return this.addEventListener(r, t, n), () => {
this.removeEventListener(r, t, n);
};
}
}
const ee = new ke(), Sr = (e) => {
const r = d(async (c) => await ee.publish(e, c)), t = d(/* @__PURE__ */ new Set()), n = d((c) => {
ee.subscribe(e, c);
const i = () => ee.unsubscribe(e, c);
return t.current.add(i), () => {
t.current.delete(i), ee.unsubscribe(e, c);
};
});
return M(() => () => {
t.current.forEach((c) => c());
}, [e]), [
n.current,
r.current
];
}, Er = (e, r, t) => {
const n = d();
(!n.current || !t || t(n.current, r)) && (n.current = r), M(e, n.current);
}, br = (e, r) => {
const t = d();
(!t.current || !U(t.current, r)) && (t.current = r), M(e, t.current);
}, O = (e) => {
const r = d(!1), t = d(), n = d(!1);
M(() => (r.current || (t.current = e(), r.current = !0, setTimeout(() => n.current = !0, 1)), () => {
n.current && (t.current && t.current(), r.current = !1);
}), []);
}, Rr = (e, r, t) => {
const n = d();
(!n.current || !t || t(n.current, r)) && (n.current = r), q(e, n.current);
}, Pr = (e, r) => {
const t = d();
(!t.current || !U(t.current, r)) && (t.current = r), q(e, t.current);
};
function De(e) {
const r = B((t) => t + 1e-11, 0);
return e ? r : r[1];
}
const Lr = (e) => {
const r = De(), t = d(e), n = d(), c = d(!1), i = d(!1);
c.current && (i.current = !0), q(() => (c.current || (n.current = t.current(), c.current = !0, r()), () => {
i.current && (n.current && n.current(), c.current = !1);
}), []);
}, Tr = () => {
const e = d(!1);
return O(() => (e.current = !0, () => {
e.current = !1;
})), m(() => e.current, []);
};
function Ue(e) {
const [r, t] = C(e), n = d();
return e !== r && (n.current !== null && clearTimeout(n.current), n.current = setTimeout(() => t(e))), r;
}
const Ge = oe !== void 0 ? oe : Ue, kr = (e, r) => {
const t = d();
M(() => {
if (!t.current)
t.current = r;
else {
const n = Reflect.ownKeys(r);
for (const c of n)
Reflect.get(r, c) !== Reflect.get(t.current, c) && console.log(e + " component updated", t, r);
}
}, [e, r]), M(() => (console.log(e + " component mounted"), () => {
console.log(e + " component unmounted");
}), []);
}, Dr = (e) => {
const r = d(), t = d(!0), n = d(e), c = m((i) => t.current = i, []);
return M(() => {
t.current ? r.current = e : n.current = e;
}, [e]), t.current && n.current && (r.current = n.current, n.current = null), [r.current, c];
}, xr = (e, r, t) => {
const n = d();
return (!n.current || !t || t(n.current, r)) && (n.current = r), m(e, n.current);
}, Ir = (e, r) => {
const t = d();
return (!t.current || !U(t.current, r)) && (t.current = r), m(e, t.current);
}, H = (e) => {
const r = d(e), t = m((...n) => r.current(...n), []);
return q(() => {
r.current = e;
}), t;
}, Cr = (e, r, t) => {
const n = d();
return (!n.current || !t || t(n.current, r)) && (n.current = r), L(e, n.current);
}, Ar = (e, r) => {
const t = d();
return (!t.current || !U(t.current, r)) && (t.current = r), L(e, t.current);
}, $e = (...e) => {
const r = d(null);
return L(() => Object.defineProperty({}, "current", {
get() {
return r.current;
},
set(t) {
r.current = t, e.forEach((n) => typeof n == "function" ? n(r.current) : n.current = r.current);
},
enumerable: !1,
configurable: !1
}), [e]);
}, fe = Symbol("useLazyRef.noValue"), xe = (e) => {
const r = d(fe);
return r.current === fe && (r.current = e()), r;
};
let Be = 0;
const Je = () => `:${(Be++).toString(32)}:`;
function Ye() {
return xe(Je).current;
}
const Xe = ae === void 0 ? Ye : ae;
function Mr(e) {
const [r, t] = C(e), n = H(() => r), c = m(() => t(e), [e]);
return [
r,
t,
n,
c
];
}
const _e = (e, r = "no-limit") => {
const [t, n] = C(e), [, c] = C(0), i = d([t]), u = d(r === "no-limit" ? 1 / 0 : r), s = d(0), o = d(!0), a = m((h) => o.current = h, []), f = m((h) => {
const E = h instanceof Function ? h(i.current[s.current]) : h;
i.current = i.current.slice(0, s.current + 1), !o.current && i.current.pop(), i.current.push(E), i.current.length > u.current ? i.current.shift() : o.current && s.current++, n(E), c((S) => S + 1);
}, [u]), v = m(() => {
s.current !== 0 && (s.current--, n(i.current[s.current]), c((h) => h + 1));
}, []), g = m(() => {
s.current !== i.current.length - 1 && (s.current++, n(i.current[s.current]), c((h) => h + 1));
}, []), p = m((h) => {
h < 0 || h > i.current.length - 1 || (s.current = h, n(i.current[s.current]), c((E) => E + 1));
}, []), y = m((h) => {
const E = h || i.current[s.current];
i.current = [E], s.current = 0, n(i.current[s.current]), c((S) => S + 1);
}, []), l = s.current > 0, w = s.current < i.current.length - 1;
return [
t,
f,
{
history: Object.seal([...i.current]),
presentPointer: s.current,
trackUpdate: a,
canUndo: l,
canRedo: w,
undo: v,
redo: g,
go: p,
clear: y
}
];
}, Or = (e, r = "no-limit") => {
const [t, n, c] = _e(e, r), i = H(() => t);
return [
t,
n,
i,
c
];
}, Nr = (e, r, t) => {
const [n, c] = B(e, r, t), i = H(() => n), u = d(void 0), s = m(() => c(u.current), []);
return u.current === void 0 && (u.current = n), [
n,
c,
i,
s
];
}, Ke = (e, r, t, n = "no-limit") => {
const [c, i] = C(() => t ? t(r) : r), [, u] = C(0), s = d([c]), o = d(n === "no-limit" ? 1 / 0 : n), a = d(0), f = d(!0), v = m((S) => f.current = S, []), g = m((S) => {
const R = e(s.current[a.current], S);
s.current = s.current.slice(0, a.current + 1), !f.current && s.current.pop(), s.current.push(R), s.current.length > o.current ? s.current.shift() : f.current && a.current++, i(S), u((k) => k + 1);
}, [o, e]), p = m(() => {
a.current !== 0 && (a.current--, i(s.current[a.current]), u((S) => S + 1));
}, []), y = m(() => {
a.current !== s.current.length - 1 && (a.current++, i(s.current[a.current]), u((S) => S + 1));
}, []), l = m((S) => {
S < 0 || S > s.current.length - 1 || (a.current = S, i(s.current[a.current]), u((R) => R + 1));
}, []), w = m((S) => {
const R = S ? e(s.current[a.current], S) : s.current[a.current];
s.current = [R], a.current = 0, i(s.current[a.current]), u((k) => k + 1);
}, [e]), h = a.current > 0, E = a.current < s.current.length - 1;
return [
c,
g,
{
history: Object.seal([...s.current]),
presentPointer: a.current,
trackUpdate: v,
canUndo: h,
canRedo: E,
undo: p,
redo: y,
go: l,
clear: w
}
];
}, Fr = (e, r, t, n = "no-limit") => {
const [c, i, u] = Ke(e, r, t, n), s = H(() => c);
return [
c,
i,
s,
u
];
}, ve = new qe(), Ie = () => {
const e = d([]), r = d((n, c, i) => {
const u = ve.listen(n, c, i);
return e.current.push(u), u;
}), t = d((n) => {
ve.dispatch(n);
});
return M(() => () => {
e.current.forEach((n) => n());
}, []), [r.current, t.current];
};
function A({ type: e, listener: r, element: t = window, listenerOpts: n, effectType: c = "normal" }) {
const i = d(n), u = d(), s = c === "layout" ? q : M, o = d(Array.isArray(e) ? e : [e]);
return s(() => {
const f = i.current;
return u.current = Reflect.has(t, "current") ? (t == null ? void 0 : t.current) !== null ? t.current : null : t, u.current && o.current.forEach((v) => u.current.addEventListener(v, r, f)), () => {
u.current && o.current.forEach((v) => u.current.removeEventListener(v, r, f));
};
}, [t, r]), H(() => {
u.current && o.current.forEach((f) => u.current.removeEventListener(f, r, i.current));
});
}
const zr = (e = window) => H((t) => {
(Reflect.has(e, "current") ? e.current : e).dispatchEvent(t);
}), Vr = (e) => {
const [r, t] = B((s) => s + 1e-4, 0), n = Ge(r), c = d(e), i = d();
return M(() => {
n !== 0 && (i.current ? c.current(...i.current) : c.current());
}, [n]), m((...s) => {
i.current = s, t();
}, []);
}, Wr = () => T(
m((e) => (document.addEventListener("visibilitychange", e, { passive: !0 }), () => {
document.removeEventListener("visibilitychange", e);
}), []),
m(() => document.visibilityState, [])
);
function Hr(e, r) {
const t = d({ current: !1, previous: !1 }), n = L(() => r == null ? void 0 : r.onEnter, [r == null ? void 0 : r.onEnter]), c = L(() => r == null ? void 0 : r.onLeave, [r == null ? void 0 : r.onLeave]), i = L(() => r == null ? void 0 : r.onChange, [r == null ? void 0 : r.onChange]), u = T(
m((s) => {
const o = e != null && e.current ? e.current : e, a = (v) => {
t.current.current = !0, n && n(v), i && i(!0), s();
}, f = (v) => {
t.current.current = !1, c && c(v), i && i(!1), s();
};
return o == null || o.addEventListener("pointerenter", a, { passive: !0 }), o == null || o.addEventListener("pointerleave", f, { passive: !0 }), () => {
o == null || o.removeEventListener("pointerenter", a), o == null || o.removeEventListener("pointerleave", f);
};
}, [i, n, c, e]),
m(() => (t.current.current !== t.current.previous && (t.current.previous = t.current.current), t.current.previous), [])
);
if (!r || r.returnValue === !0)
return u;
}
const _ = /* @__PURE__ */ new Set(), me = () => _.forEach((e) => e()), Ce = {
xs: {
value: 576,
condition: "<"
},
sm: {
value: 576,
condition: ">="
},
md: {
value: 768,
condition: ">="
},
lg: {
value: 992,
condition: ">="
},
xl: {
value: 1200,
condition: ">="
}
};
function he(e) {
const r = window.innerWidth, t = {}, n = e ?? Ce, c = Object.keys(n);
for (const i of c)
if (Reflect.get(n, i)) {
const u = Reflect.get(n, i), { value: s, condition: o } = typeof u == "number" ? { value: u, condition: ">" } : u;
Reflect.set(t, i, Function(`return ${r}${o}${s}`)());
}
return t;
}
function jr(e) {
const r = d(() => he(e === void 0 ? Ce : e));
return T(
m((t) => (_.size === 0 && window.addEventListener("resize", me, { passive: !0 }), _.add(t), () => {
_.delete(t), _.size === 0 && window.removeEventListener("resize", me);
}), []),
L(() => {
let t = r.current();
return () => {
const n = r.current(), c = Object.keys(n);
for (const i of c)
if (Reflect.get(t, i) !== Reflect.get(n, i)) {
t = n;
break;
}
return t;
};
}, [])
);
}
const Ae = (e, r) => {
if (!e || !r)
return !1;
if (e.contains(r))
return !0;
if (e.children.length > 0) {
for (let t = 0, n = e.children.length; t < n; t++)
if (Ae(e.children[t], r))
return !0;
}
return !1;
}, qr = (e, r) => {
const t = m((n) => {
const c = e != null && e.current ? e.current : e;
Ae(c, n.target) || r(n);
}, [e, r]);
A({
type: "pointerdown",
listener: t
});
}, K = /* @__PURE__ */ new Set(), j = () => K.forEach((e) => e()), ge = () => {
const e = Reflect.get(navigator, "connection"), r = {
isSupported: !!e,
isOnline: navigator.onLine
};
return e && (r.isSupported = !0, r.downlink = e.downlink, r.downlinkMax = e.downlinkMax, r.effectiveType = e.effectiveType, r.rtt = e.rtt, r.saveData = e.saveData, r.type = e.type), r;
};
function Qe(e) {
const r = d(e ?? ["isSupported", "isOnline", "since", "downlink", "downlinkMax", "effectiveType", "rtt", "saveData", "type"]);
return T(
m((t) => {
const n = Reflect.get(navigator, "connection");
return K.size === 0 && (window.addEventListener("online", j, { passive: !0 }), window.addEventListener("offline", j, { passive: !0 }), n && n.addEventListener("change", j)), K.add(t), () => {
K.delete(j), K.size === 0 && (window.removeEventListener("online", j), window.removeEventListener("offline", j), n && n.removeEventListener("change", j));
};
}, []),
L(() => {
let t = ge();
return () => {
const n = ge();
for (const c of r.current)
if (n[c] !== t[c]) {
t = {
...n,
...t.isOnline !== n.isOnline && { since: (/* @__PURE__ */ new Date()).getTime() }
};
break;
}
return t;
};
}, [])
);
}
const Ur = () => Qe(["isOnline"]).isOnline, Ze = (e, r) => {
const t = d(), n = d(!0), c = d(), i = d(e);
return O(() => () => {
var u;
c.current = void 0, (u = t.current) == null || u.disconnect(), t.current = void 0;
}), [
m((u) => {
var s;
!n.current || !u || (u && (!c.current || c.current !== u) && (c.current = u, t.current = new ResizeObserver(e), t.current.observe(u, r)), i.current !== e && t.current && u && (i.current = e, (s = t.current) == null || s.disconnect(), t.current = void 0, t.current = new ResizeObserver(e), t.current.observe(u, r)));
}, [e, r]),
m(() => {
n.current && (n.current = !1, t.current && c.current && t.current.unobserve(c.current));
}, []),
m(() => {
var u;
n.current || (n.current = !0, t.current && c.current && ((u = t.current) == null || u.observe(c.current, r)));
}, [r])
];
}, Gr = (e, r) => {
const t = d(), n = d(!0), c = d(), i = d(e);
return O(() => () => {
var u;
c.current = void 0, (u = t.current) == null || u.disconnect(), t.current = void 0;
}), [
m((u) => {
var s;
!n.current || !u || (u && (!c.current || c.current !== u) && (c.current = u, t.current = new IntersectionObserver(e, r), t.current.observe(u)), i.current !== e && t.current && u && (i.current = e, (s = t.current) == null || s.disconnect(), t.current = void 0, t.current = new IntersectionObserver(e, r), t.current.observe(u)));
}, [e, r]),
m(() => {
n.current && (n.current = !1, t.current && c.current && t.current.unobserve(c.current));
}, []),
m(() => {
var u;
n.current || (n.current = !0, t.current && c.current && ((u = t.current) == null || u.observe(c.current)));
}, [])
];
}, $r = (e, r) => {
const t = d(), n = d(!0), c = d();
return O(() => () => {
var i;
c.current = void 0, (i = t.current) == null || i.disconnect(), t.current = void 0;
}), [
m((i) => {
!n.current || !i || i && (!c.current || c.current !== i) && (c.current = i, t.current = new MutationObserver(e), t.current.observe(i, r));
}, [e, r]),
m(() => {
n.current && (n.current = !1, t.current && c.current && t.current.disconnect());
}, []),
m(() => {
n.current || (n.current = !0, t.current && c.current && t.current.observe(c.current, r));
}, [r]),
m(() => {
var i;
return (i = t.current) == null ? void 0 : i.takeRecords();
}, [])
];
}, Br = () => {
const [e, r] = C(() => new DOMRect()), [t] = Ze(m((n) => {
r((c) => {
const i = n[0].target.getBoundingClientRect();
return i.top !== c.top || i.left !== c.left || i.right !== (c == null ? void 0 : c.right) || i.bottom !== c.bottom ? i : c;
});
}, []));
return [
t,
e
];
};
function Jr(e) {
const r = d(), t = d(), n = d(), c = d({ isVisible: !1, ratio: 0 }), i = d({ isVisible: !1, ratio: 0 });
O(() => () => {
var o;
r.current = void 0, (o = t.current) == null || o.disconnect(), t.current = void 0;
});
const u = m((o) => {
o && o && (!r.current || r.current !== o) && (r.current = o, t.current = new IntersectionObserver((a) => {
const { isIntersecting: f, intersectionRatio: v } = a[0];
i.current = {
isVisible: f,
ratio: v
}, (f !== c.current.isVisible || v !== c.current.ratio) && n.current && n.current();
}, { root: e == null ? void 0 : e.root, rootMargin: e == null ? void 0 : e.rootMargin, threshold: e == null ? void 0 : e.threshold }), t.current.observe(o));
}, [e == null ? void 0 : e.root, e == null ? void 0 : e.rootMargin, e == null ? void 0 : e.threshold]), s = T(
m((o) => (n.current = o, () => {
n.current = void 0;
}), []),
m(() => ((i.current.isVisible !== c.current.isVisible || i.current.ratio !== c.current.ratio) && (c.current = i.current), e != null && e.withRatio ? c.current : c.current.isVisible), [e == null ? void 0 : e.withRatio])
);
return e != null && e.withRatio ? [
u,
s.isVisible,
s.ratio
] : [
u,
s
];
}
const er = (e, r) => {
const t = d(L(() => {
const { media: n, matches: c } = window.matchMedia(e);
return {
matches: c,
media: n
};
}, []));
return T(
m((n) => {
const c = window.matchMedia(e), i = (u) => {
r && r(u), n();
};
return c.addEventListener("change", i, { passive: !0 }), () => {
c.removeEventListener("change", i);
};
}, [e, r]),
m(() => {
const { media: n, matches: c } = window.matchMedia(e);
return c !== t.current.matches && (t.current = {
matches: c,
media: n
}), t.current;
}, [e])
);
}, rr = () => er("(prefers-reduced-motion: reduce)").matches;
function tr(e) {
return -(Math.cos(Math.PI * e) - 1) / 2;
}
function nr(e, r) {
const t = r === "x" ? "scrollLeft" : "scrollTop";
return (e ? e[t] : document.body[t] + document.documentElement[t]) ?? 0;
}
function cr(e, r, t, n, c) {
if (!r)
return 0;
const u = (t || document.body).getBoundingClientRect(), s = r.getBoundingClientRect(), o = (a) => s[a] - u[a];
if (e === "y") {
const a = o("top");
if (a === 0)
return 0;
if (n === "start")
return a - c;
const f = t ? u.height : window.innerHeight;
return n === "end" ? a + c - f + s.height : n === "center" ? a - f / 2 + s.height / 2 : 0;
} else {
const a = o("left");
if (a === 0)
return 0;
if (n === "start")
return a - c;
const f = t ? u.width : window.innerWidth;
return n === "end" ? a + c - f + s.width : n === "center" ? a - f / 2 + s.width / 2 : 0;
}
}
const Yr = ({ duration: e = 1e3, axis: r = "y", animation: t = tr, offset: n = 0, cancelable: c = !1, onFinish: i, scrollableElement: u }) => {
const s = d(), o = d(0), a = d(!1), f = d(null), v = rr(), g = m(() => s.current && cancelAnimationFrame(s.current), []), p = m(() => c && (a.current = !0), [c]);
A({ type: "wheel", listener: p, listenerOpts: { passive: !0 } }), A({ type: "touchmove", listener: p, listenerOpts: { passive: !0 } });
const y = m((l = "start") => {
a.current = !1, g();
const w = typeof u == "function" ? u() : u != null && u.current ? u.current : u, h = nr(w, r), E = cr(r, f.current, w, l, n);
function S() {
o.current === 0 && (o.current = performance.now());
const k = performance.now() - o.current, D = v || e === 0 ? 1 : k / e, b = h + E * t(D), P = r === "x" ? "scrollLeft" : "scrollTop";
w ? w[P] = b : (document.body[P] = b, document.documentElement[P] = b), !a.current && D < 1 ? s.current = requestAnimationFrame(S) : (i && i(), o.current = 0, s.current = void 0, g());
}
S();
}, [t, r, g, e, n, i, v, u]);
return {
targetRef: f,
scroll: y,
cancel: g
};
}, J = /* @__PURE__ */ new Set();
function Xr(e = { type: "client" }) {
const r = d({ x: null, y: null }), t = d({ x: null, y: null });
return T(
m((n) => {
const c = (i) => {
var l;
const { screenX: u, screenY: s, clientX: o, clientY: a, pageX: f, pageY: v } = i;
let g = null, p = null, y;
e.type === "client" ? (g = o, p = a) : e.type === "page" ? (g = f, p = v) : (g = u, p = s), (e.relativeElement && "current" in e.relativeElement ? e.relativeElement.current : e.relativeElement) && (y = ((l = e.relativeElement) != null && l.current ? e.relativeElement.current : e.relativeElement).getBoundingClientRect(), g = f - (y.left + window.scrollX), p = v - (y.top + window.scrollY)), t.current = { x: g, y: p, relativeElementDim: y }, J.forEach((w) => w());
};
return J.size === 0 && (window.addEventListener("pointerdown", c), window.addEventListener("pointermove", c), window.addEventListener("pointerup", c)), J.add(n), () => {
J.delete(n), J.size === 0 && (window.removeEventListener("pointerdown", c), window.removeEventListener("pointermove", c), window.removeEventListener("pointerup", c));
};
}, [e.relativeElement, e.type]),
m(() => ((r.current.x !== t.current.x || r.current.y !== t.current.y) && (r.current = t.current), r.current), [])
);
}
const _r = (e, { duration: r = 1e3, normalPress: t, onStart: n, onFinish: c }) => {
const i = d(), u = d(), s = d(!1), o = d(), a = m(() => {
clearTimeout(u.current), c && c(i.current), !s.current && t && t(i.current);
}, [t, c]), f = m((v) => {
s.current = !1, i.current = v, n && n(v), u.current = setTimeout(async () => {
s.current = !0, await e(v);
}, r);
}, [e, r, n]);
return m((v) => {
var g, p;
v ? (v.addEventListener("pointerdown", f), v.addEventListener("pointerup", a), o.current = v) : ((g = o.current) == null || g.removeEventListener("pointerdown", f), (p = o.current) == null || p.removeEventListener("pointerup", a), o.current = void 0);
}, [f, a]);
}, Kr = (e) => {
const r = d(0), t = d("tolerance" in e ? e.tolerance : 300), n = d();
return m((c) => {
"persist" in c && c.persist(), n.current && clearTimeout(n.current), r.current++, r.current === 1 && "singleClick" in e && e.singleClick && (n.current = setTimeout(() => {
e.singleClick(c), r.current = 0;
}, t.current)), r.current === 2 && ("doubleClick" in e ? e.doubleClick(c) : e(c), r.current = 0);
}, [e]);
}, Qr = ({ element: e, listener: r, opts: t }) => A({
type: "beforeunload",
element: e,
listener: r,
listenerOpts: t
}), Y = /* @__PURE__ */ new Set(), Zr = (e) => {
const r = d(), t = d(!1), n = T(
m((u) => {
const s = () => {
console.log("orientation"), t.current = !0, Y.forEach((a) => a());
};
Y.add(u);
let o = !1;
return Y.size === 1 && (screen.orientation.onchange = s, window && "getScreenDetails" in window && (o = !0, window.getScreenDetails().then((a) => {
o && (a.addEventListener("currentscreenchange", s), e && a.addEventListener("screenschange", s), r.current = a, u());
}).catch(() => {
}))), () => {
Y.delete(u), Y.size === 0 && (r.current && (r.current.removeEventListener("currentscreenchange", s), e && r.current.removeEventListener("screenschange", s)), o = !1, screen.orientation.onchange = null);
};
}, [e]),
L(() => {
let u = {
currentScreen: {
availHeight: screen.availWidth,
availWidth: screen.availWidth,
height: screen.height,
width: screen.width,
colorDepth: screen.colorDepth,
pixelDepth: screen.pixelDepth,
orientation: {
angle: screen.orientation.angle,
type: screen.orientation.type
},
availLeft: void 0,
availTop: void 0,
left: void 0,
top: void 0,
devicePixelRatio: void 0,
isInternal: void 0,
isPrimary: void 0,
label: void 0
},
screens: void 0
};
return () => {
var a, f;
const s = Reflect.ownKeys(u.currentScreen);
u.currentScreen.isPrimary === void 0 && r.current && (u = {
currentScreen: {
...u.currentScreen,
availLeft: r.current.currentScreen.availLeft,
availTop: r.current.currentScreen.availTop,
left: r.current.currentScreen.left,
top: r.current.currentScreen.top,
devicePixelRatio: r.current.currentScreen.devicePixelRatio,
isInternal: r.current.currentScreen.isInternal,
isPrimary: r.current.currentScreen.isPrimary,
label: r.current.currentScreen.label
},
screens: e && ((a = r.current) != null && a.screens) ? r.current.screens : void 0
});
let o = !1;
if (t.current) {
t.current = !1;
for (let v = 0, g = s.length; v < g; v++)
if (s[v] === "orientation" ? (u.currentScreen.orientation.angle !== screen.orientation.angle || u.currentScreen.orientation.type !== screen.orientation.type) && (o = !0) : s[v] in screen && u.currentScreen[s[v]] !== screen[s[v]] && (o = !0), o) {
u = {
currentScreen: {
availHeight: screen.availWidth,
availWidth: screen.availWidth,
height: screen.height,
width: screen.width,
colorDepth: screen.colorDepth,
pixelDepth: screen.pixelDepth,
orientation: {
angle: screen.orientation.angle,
type: screen.orientation.type
},
availLeft: r.current ? r.current.currentScreen.availLeft : void 0,
availTop: r.current ? r.current.currentScreen.availTop : void 0,
left: r.current ? r.current.currentScreen.left : void 0,
top: r.current ? r.current.currentScreen.top : void 0,
devicePixelRatio: r.current ? r.current.currentScreen.devicePixelRatio : void 0,
isInternal: r.current ? r.current.currentScreen.isInternal : void 0,
isPrimary: r.current ? r.current.currentScreen.isPrimary : void 0,
label: r.current ? r.current.currentScreen.label : void 0
},
screens: e && ((f = r.current) != null && f.screens) ? r.current.screens : void 0
};
break;
}
}
return u;
};
}, [e])
), c = d((u) => screen.orientation.lock(u)), i = d(() => screen.orientation.unlock());
return [
n,
c.current,
i.current
];
}, et = ({ hotKey: e, type: r = "keydown", target: t = window, listener: n, listenerOpts: c }) => {
const i = L(() => Ve(e, n), [e, n]);
return A({
type: r,
listener: i,
listenerOpts: c,
element: t,
effectType: "normal"
});
}, rt = ({ target: e = window, listener: r }) => {
const t = d([]), n = d(-1), c = d([]), i = d((o) => {
t.current.push(o);
}), u = d((o) => {
const a = t.current.findIndex(
(f) => f.pointerId === o.pointerId
);
t.current.splice(a, 1), t.current.length < 2 && (n.current = -1);
}), s = m((o) => {
const a = t.current.findIndex(
(f) => f.pointerId === o.pointerId
);
if (t.current[a] = o, t.current.length === 2) {
const f = Math.abs(t.current[0].clientX - t.current[1].clientX);
n.current > 0 && (f > n.current && r(o, "zoomIn"), f < n.current && r(o, "zoomOut")), n.current = f;
}
}, [r]);
return c.current[0] = A({
type: "pointerdown",
listener: i.current,
effectType: "normal",
element: e
}), c.current[1] = A({
type: "pointermove",
listener: s,
effectType: "normal",
element: e
}), c.current[2] = A({
type: "pointerup",
listener: u.current,
effectType: "normal",
element: e
}), c.current[3] = A({
type: "pointercancel",
listener: u.current,
effectType: "normal",
element: e
}), c.current[4] = A({
type: "pointerout",
listener: u.current,
effectType: "normal",
element: e
}), c.current[5] = A({
type: "pointerleave",
listener: u.current,
effectType: "normal",
element: e
}), m(() => {
c.current.forEach((o) => o());
}, []);
}, tt = ({ target: e, unadjustedMovement: r, onLock: t, onUnlock: n, onError: c }) => {
const i = d(!1), u = m(() => {
document.pointerLockElement ? t && t(document.pointerLockElement) : (i.current = !1, document.removeEventListener("pointerlockerror", c, !1), document.removeEventListener("pointerlockchange", u), n && n(e != null && e.current ? e.current : e));
}, [c, t, n, e]), s = m(async () => {
i.current = !1, await document.exitPointerLock(), n && n(e != null && e.current ? e.current : e);
}, [e, n]);
return { lock: m(() => {
const a = e != null && e.current ? e.current : e;
return new Promise((f) => !a || i.current ? f() : (document.addEventListener("pointerlockerror", c, !1), document.addEventListener("pointerlockchange", u), a.requestPointerLock({
unadjustedMovement: !!r
}).then(() => {
i.current = !0;
}).catch((v) => {
c(v);
}).finally(() => {
f();
})));
}, [e, c, r, u]), unlock: s };
}, nt = ({ element: e, listener: r, effectType: t, listenerOpts: n }) => {
A({
type: "contextmenu",
listener: r,
effectType: t,
listenerOpts: n,
element: e
});
}, ct = ({ target: e, onSwipeStart: r, onSwipe: t, onSwipeEnd: n, options: c }) => {
const i = d((y, l) => Math.max(Math.abs(y), Math.abs(l)) >= ((c == null ? void 0 : c.threshold) ?? 0)), u = d(), s = d((y, l) => i.current(y, l) ? Math.abs(y) > Math.abs(l) ? y > 0 ? "right" : "left" : l > 0 ? "down" : "up" : "none"), o = d(!1), a = d({
target: {
x: 0,
y: 0
},
start: {
x: 0,
y: 0
},
end: {
x: 0,
y: 0
}
}), f = A({
type: ["mousedown", "touchstart"],
element: e,
listener: m((y) => {
var S;
o.current = !0, u.current = y.target, y.target && y.target.style.setProperty("touch-action", "none"), y.target && y.target.style.setProperty("-webkit-user-select", "none"), y.target && y.target.style.setProperty("-ms-user-select", "none"), y.target && y.target.style.setProperty("user-select", "none");
const { x: l, y: w } = ((S = y.target) == null ? void 0 : S.getBoundingClientRect()) ?? { x: 0, y: 0 }, { clientX: h, clientY: E } = le(y) ? y.touches[0] : y;
a.current = {
target: {
x: l,
y: w
},
start: {
x: h,
y: E
},
end: {
x: h,
y: E
}
}, r && r(y);
}, [r]),
listenerOpts: {
capture: !0,
passive: (c == null ? void 0 : c.passive) !== void 0 ? c.passive : !0
}
}), v = A({
type: ["mousemove", "touchmove"],
element: window,
listener: m((y) => {
const { clientX: l, clientY: w } = le(y) ? y.touches[0] : y;
a.current.end = {
x: l,
y: w
};
const h = a.current.end.x - a.current.start.x, E = a.current.end.y - a.current.start.y;
o.current && i.current(h, E) && t && t(y, s.current(h, E), { x: h, y: E });
}, [t]),
listenerOpts: {
capture: !0,
passive: (c == null ? void 0 : c.passive) !== void 0 ? c.passive : !0
}
}), g = A({
type: ["mouseup", "mouseleave", "touchend", "touchcancel"],
element: window,
listener: m((y) => {
const l = a.current.end.x - a.current.start.x, w = a.current.end.y - a.current.start.y;
o.current && n && n(y, s.current(l, w), { x: l, y: w }), o.current = !1, u.current && u.current.style.removeProperty("touch-action"), u.current && u.current.style.removeProperty("-webkit-user-select"), u.current && u.current.style.removeProperty("-ms-user-select"), u.current && u.current.style.removeProperty("user-select"), u.current = null;
}, [n]),
listenerOpts: {
capture: !0,
passive: (c == null ? void 0 : c.passive) !== void 0 ? c.passive : !0
}
});
return m(() => {
f(), v(), g();
}, [f, v, g]);
}, ut = ({ request: e, ref: r, hasMoreData: t, threshold: n, onBefore: c, onError: i, onSuccess: u }) => {
const s = d(), o = d({
data: void 0,
loading: !0,
fullData: !t()
}), a = m(() => o.current.loading ? Promise.resolve() : (o.current.loading = !0, s.current && s.current(), c && c(), e(o.current.data).then((p) => {
o.current.data = p, o.current.loading = !1, o.current.fullData = !t(p), s.current && s.current(), u && u();
}).catch((p) => {
o.current.loading = !1, s.current && s.current(), i && i(p);
})), [c, u, i, e, t]), f = m((p) => {
if (o.current.loading || o.current.fullData)
return;
const y = p === document.documentElement ? Math.max(
window.scrollY,
document.documentElement.scrollTop,
document.body.scrollTop
) : p.scrollTop, l = p.scrollHeight || Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), w = p.clientHeight || Math.max(document.documentElement.clientHeight, document.body.clientHeight);
l - y <= w + (n ?? 0) && a();
}, [a, n]), v = m((p) => {
o.current.data = p instanceof Function ? p(o.current.data) : p, s.current && s.current();
}, []), g = T(
m((p) => {
s.current = p;
const y = r.current, l = () => f(y);
return y && y.addEventListener("scroll", l, { passive: !0 }), () => {
s.current = void 0, y && y.removeEventListener("scroll", l);
};
}, [f, r]),
L(() => {
let p = {
loading: !0,
fullData: o.current.fullData
};
return () => (p.data !== o.current.data && (p.data = o.current.data === void 0 ? void 0 : Array.isArray(o.current.data) ? [...o.current.data] : typeof o.current.data == "object" ? { ...o.current.data } : o.current.data, p = { ...o.current }), (p.loading !== o.current.loading || p.fullData !== o.current.fullData) && (p = { ...o.current }), p);
}, [])
);
return M(() => {
c && c(), o.current.loading = !0, e().then((p) => {
o.current.data = p, o.current.loading = !1, o.current.fullData = !t(p), s.current && s.current(), u && u();
}).catch((p) => {
o.current.loading = !1, s.current && s.current(), i && i(p);
});
}, [e, i, c, u, t]), {
data: g.data,
loading: g.loading,
fullData: g.fullData,
updateData: v,
loadData: a
};
};
function st({ key: e, initialState: r, opts: t }) {
const [n, c] = Ie(), i = d((t == null ? void 0 : t.serializer) || JSON.stringify), u = d((t == null ? void 0 : t.deserializer) || JSON.parse), s = d((t == null ? void 0 : t.mode) || "read/write"), o = d(L(() => {
if (s.current === "write")
return null;
const l = localStorage.getItem(e);
if (l != null)
return u.current(l);
if (r) {
const w = r instanceof Function ? r() : r;
return localStorage.setItem(e, i.current(w)), w;
} else
return null;
}, [])), a = d((l) => {
const w = (E) => {
E.type === "storage" && E.storageArea !== localStorage || s.current === "write" || (E instanceof CustomEvent ? E.detail.key === e && l() : E.key === e && l());
};
window.addEventListener("storage", w, { passive: !0 });
const h = n("local-strg", w);
return () => {
window.removeEventListener("storage", w), h();
};
}), f = d(() => {
const l = localStorage.getItem(e) ?? "null", w = i.current(o.current);
return l !== w && (o.current = l !== null ? u.current(l) : null), o.current;
}), v = re(
a.current,
f.current
), g = d((l) => {
const w = i.current(l instanceof Function ? l(o.current) : l);
localStorage.setItem(e, w), c(new CustomEvent(
"local-strg",
{
detail: {
key: e
}
}
));
}), p = H(() => o.current), y = d(() => {
localStorage.removeItem(e), c(new CustomEvent(
"local-strg",
{
detail: {
key: e
}
}
));
});
return s.current === "read" ? [
v,
p,
y.current
] : s.current === "write" ? [
g.current,
p,
y.current
] : [
v,
g.current,
p,
y.current
];
}
function it({ key: e, initialState: r, opts: t }) {
const [n, c] = Ie(), i = d((t == null ? void 0 : t.serializer) || JSON.stringify), u = d((t == null ? void 0 : t.deserializer) || JSON.parse), s = d((t == null ? void 0 : t.mode) || "read/write"), o = d(L(() => {
if (s.current === "write")
return null;
const l = sessionStorage.getItem(e);
if (l != null)
return u.current(l);
if (r) {
const w = r instanceof Function ? r() : r;
return sessionStorage.setItem(e, i.current(w)), w;
} else
return null;
}, [])), a = d((l) => {
const w = (E) => {
E.type === "storage" && E.storageArea !== sessionStorage || s.current === "write" || (E instanceof CustomEvent ? E.detail.key === e && l() : E.key === e && l());
};
window.addEventListener("storage", w, { passive: !0 });
const h = n("ssn-strg", w);
return () => {
window.removeEventListener("storage", w), h();
};
}), f = d(() => {
const l = sessionStorage.getItem(e) ?? "null", w = i.current(o.current);
return l !== w && (o.current = l !== null ? u.current(l) : null), o.current;
}), v = re(
a.current,
f.current
), g = d((l) => {
const w = i.current(l instanceof Function ? l(o.current) : l);
sessionStorage.setItem(e, w), c(new CustomEvent(
"ssn-strg",
{
detail: {
key: e
}
}
));
}), p = d(() => {
sessionStorage.removeItem(e), c(new CustomEvent(
"ssn-strg",
{
detail: {
key: e
}
}
));
}), y = H(() => o.current);
return s.current === "read" ? [
v,
y,
p.current
] : s.current === "write" ? [
g.current,
y,
p.current
] : [
v,
g.current,
y,
p.current
];
}
const ot = (e) => {
const [r, t] = C(() => new Map(e instanceof Function ? e() : e));
return r.set = (n, c) => {
const i = new Map(r);
return i.set(n, c), t(i), i;
}, r.clear = () => {
t((n) => {
const c = new Map(n);
return c.clear(), c;
});
}, r.delete = (n) => {
const c = r.has(n);
return t((i) => {
const u = new Map(i);
return u.delete(n), u;
}), c;
}, r;
}, at = (e) => {
const [r, t] = C(() => new Set(e instanceof Function ? e() : e));
return r.add = (n) => {
const c = new Set(r);
return c.add(n), t(c), c;
}, r.clear = () => {
t((n) => {
const c = new Set(n);
return c.clear(), c;
});
}, r.delete = (n) => {
const c = r.has(n);
return t((i) => {
const u = new Set(i);
return u.delete(n), u;
}), c;
}, r;
}, lt = (e) => {
const [r, t] = C(() => e instanceof Function ? e() : e || new Array());
return r.copyWithin = (n, c, i) => {
const u = [...r].copyWithin(n, c, i);
return t(u), u;
}, r.fill = (n, c, i) => {
const u = [...r].fill(n, c, i);
return t(u), u;
}, r.pop = () => {
const n = [...r], c = n.pop();
return t(n), c;
}, r.push = (...n) => {
const c = [...r], i = c.push(...n);
return t(c), i;
}, r.reverse = () => {
const n = [...r].reverse();
return t(n), n;
}, r.shift = () => {
const n = [...r], c = n.shift();
return t(n), c;
}, r.sort = (n) => {
const c = [...r].sort(n);
return t(c), c;
}, r.splice = (n, c, ...i) => {
const u = [...r].splice(n, c, ...i);
return t(u), u;
}, r.unshift = (...n) => {
const c = [...r], i = c.unshift(...n);
return t(c), i;
}, r;
}, dt = (e, r = !1) => {
const t = d(e instanceof Function ? e() : e), [, n] = B((u) => u + 1, 0), c = d((u) => {
let s = {};
if (!r)
s = u;
else {
const o = Reflect.ownKeys(u);
for (const a of o)
s[a] = t.current[a] instanceof Date || t.current[a] instanceof RegExp || Array.isArray(t.current[a]) || typeof t.current[a] != "object" ? t.current[a] : c.current(t.current[a]);
}
return new Proxy(s, {
set(o, a, f, v) {
return Reflect.set(o, a, f, v), n(), !0;
}
});
});
return d(c.current(t.current)).current;
};
function ur(e, r) {
const [t, n] = C(r()), c = m(() => {
n(r());
}, [r]);
return M(() => (c(), e(c)), [c, e]), t;
}
const T = re === void 0 ? ur : re, ft = (e, r, t) => {
const [, n] = B((s) => s + 1e-6, 0), c = d({
localState: typeof e == "function" ? e() : e,
deps: r
});
let i;
We(c.current.deps, r) ? i = c.current.localState : (i = typeof e == "function" ? e() : e, c.current = {
localState: i,
deps: r
}, n());
const u = m((s) => {
const o = typeof s == "function" ? s(c.current.localState) : s;
c.current.localState = o, n();
}, []);
return M(() => {
let s;
return t && (s = t()), () => s && s();
}, [t]), [i, u];
}, vt = (e, r) => {
const t = d(), [n, c] = C(() => {
let u;
e instanceof Function ? u = e() : u = e;
let s = {};
return !Array.isArray(u) && !(u instanceof Date) && !(u instanceof RegExp) && typeof u == "object" ? Reflect.ownKeys(u).forEach((a) => {
Reflect.set(s, a, { invalid: !1 });
}) : s = { invalid: !1 }, t.current = s, {
state: u,
validation: s
};
}), i = H((u) => {
const s = u instanceof Function ? u(n.state) : u, o = r(s, JSON.parse(JSON.stringify(t.current)));
c({ state: s, validation: o });
});
return [n.state, i, n.validation];
};
let pe = 0;
function Me(e) {
return {
get(r, t) {
e.push(t);
const n = Reflect.get(r, t);
return n == null || n instanceof Blob || n instanceof Date || n instanceof RegExp || n instanceof Map || n instanceof Set || typeof n != "object" ? n : new Proxy(n, Me(e));
}
};
}
function Oe(e, r, t, n) {
if (e === r) {
e[t] = n;
return;
}
for (const c in e)
if (e[c] === r) {
Array.isArray(e[c]) ? e[c] = [...e[c]] : e[c] = { ...e[c] }, e[c][t] = n;
return;
} else if (Array.isArray(e[c]) || typeof e[c] == "object")
return Oe(e[c], r, t, n);
}
const mt = (e, r, t) => {
const n = new ke(), c = "pub_Sub_str-" + pe;
pe++;
let i;
const u = {}, s = t === "localStorage" ? localStorage : sessionStorage;
if (t) {
const v = s.getItem(c);
v ? i = JSON.parse(v) : (i = { ...e }, s.setItem(c, JSON.stringify(i)));
} else
i = { ...e };
if (r)
for (const v in r)
u[v] = (...g) => {
const p = o();
r[v](p, ...g), t && s.setItem(c, JSON.stringify(p)), n.publish(c, p);
};
n.subscribe(c, (v) => {
i = v;
});
function o() {
return i;
}
function a(v) {
const g = o();
v(g), t && s.setItem(c, JSON.stringify(g)), n.publish(c, g);
}
function f(v) {
const g = d([]), p = xe(() => {
if (v) {
let h = new Proxy(o(), Me(g.current));
return v(h), h = null, v(o());
} else
return o();
}), y = T(
m((h) => {
const E = (S) => {
const R = v ? v(S) : S;
U(p.current, R) || (p.current = R, h());
};
return n.subscribe(c, E), () => {
n.unsubscribe(c, E);
};
}, [v, p]),
m(() => p.current, [p])
), l = d(() => p.current), w = d((h) => {
if (v) {
const E = h instanceof Function ? h(p.current) : h;
let S = o();
for (let R = 0; R < g.current.length - 1; R++)
!(g.current[R] in S) && (S[g.current[R]] = o()[g.current[R]]), S = S[g.current[R]];
if (Array.isArray(E) || typeof E == "object")
S[g.current[g.current.length - 1]] = E, t && s.setItem(c, JSON.stringify(o())), n.publish(c, o());
else {
const R = o();
Oe(R, S, g.current[g.current.length - 1], E), S = R, t && s.setItem(c, JSON.stringify(S)), n.publish(c, S);
}
} else {
const E = h instanceof Function ? h(p.current) : h;
t && s.setItem(c, JSON.stringify(E)), n.publish(c, E);
}
});
return [y, w.current, l.current, u];
}
return {
getStore: o,
mutateStore: a,
mutators: u,
usePubSubStore: f
};
}, X = (e) => {
let r = "script";
for (const [t, n] of Object.entries(e))
n && (r += `[${t}${typeof n == "boolean" ? "" : `="${n}"`}]`);
return document.querySelector(r);
}, sr = (e) => {
const r = document.createElement("script");
return e.src && (r.src = e.src), e.async && (r.async = !0), e.defer && (r.defer = !0), e.type && r.setAttribute("type", e.type), e.crossorigin && r.setAttribute("crossorigin", e.crossorigin), e.fetchpriority && r.setAttribute("fetchpriority", e.fetchpriority), e.integrity && r.setAttribute("integrity", e.integrity), e.nonce && r.setAttribute("nonce", e.nonce), e.nomodule && r.setAttribute("nomodule", e.nomodule.toString()), e.referrerpolicy && r.setAttribute("referrerpolicy", e.referrerpolicy), r.setAttribute("data-status", "loading"), r;
}, ht = function(e, r) {
const t = d(r), n = d(e), [c, i] = C(t.current.handleAppending ? 1 : 0), u = m((a, f) => {
a && (n.current = a), f && (t.current.iframe = f), i((v) => v + 1);
}, []), s = m(() => {
var f;
const a = X(n.current);
(f = a == null ? void 0 : a.parentElement) == null || f.removeChild(a);
}, []);
return O(() => () => {
t.current.removeOnUnmount && s();
}), [
T(
m((a) => {
var f, v;
if (c % 2 === 0) {
let g, p = !0;
g = X(n.current), g || (p = !1, g = sr(n.current));
const y = (l) => {
const w = X(n.current);
w == null || w.setAttribute("data-status", l.type === "load" ? "ready" : "error"), a();
};
return g.addEventListener("load", y, { passive: !0 }), g.addEventListener("error", y, { passive: !0 }), !p && (((v = (f = t.current.iframe) == null ? void 0 : f.contentWindow) == null ? void 0 : v.document) || document).body.appendChild(g), () => {
const l = X(n.current);
l == null || l.removeEventListener("load", y), l == null || l.removeEventListener("error", y);
};
} else
return () => {
};
}, [c]),
m(() => {
var f;
return ((f = X(n.current)) == null ? void 0 : f.getAttribute("data-status")) ?? (t.current.handleAppending ? "idle" : "loading");
}, [])
),
u,
s
];
}, ir = (e, r, t = !1) => {
if (!t || typeof requestAnimationFrame > "u")
return {
id: setTimeout(e, r)
};
const n = { id: 0 }, c = (/* @__PURE__ */ new Date()).getTime(), i = () => {
const u = (/* @__PURE__ */ new Date()).getTime();
console.log(((u - c) / 1e3).toFixed(0)), u - c >= r ? e() : n.id = requestAnimationFrame(i);
};
return n.id = requestAnimationFrame(i), n;
}, te = (e, r = !1) => {
if (!r || typeof cancelAnimationFrame > "u")
return clearTimeout(e.id);
cancelAnimationFrame(e.id);
}, gt = (e, r) => {
const t = d({ id: 0 }), n = d(r), c = m((...s) => {
te(t.current, n.current.focusedWindow), t.current = ir(() => e(...s), n.current.delay, n.current.focusedWindow);
}, [e]), i = m(() => {
te(t.current, n.current.focusedWindow);
}, []), u = m((...s) => {
te(t.current, n.current.focusedWindow), e(...s);
}, [e]);
return [
c,
i,
u
];
}, pt = (e, r) => {
const t = d(r), n = d(!1), c = d(), i = m((...o) => {
if (!n.current)
if (n.current = !0, t.current.delay)
e(...o), c.current = setTimeout(() => n.current = !1, t.current.delay);
else if (t.current.waitFn) {
const a = e(...o);
He(a) ? a.finally(() => n.current = !1) : n.current = !1;
} else
throw Error("useThrottled: options aren't setted correctly.");
}, [e]), u = m(() => {
n.current = !1;
}, []), s = m((...o) => {
n.current = !1, e(...o);
}, [e]);
return [
i,
u,
s
];
}, wt = () => {
const e = d(null);
return T(
m((r) => {
e.current = document.activeElement;
const t = { id: 0 }, n = (c) => {
c.type === "focusout" ? t.id = setTimeout(() => {
r();
}, 0) : (clearTimeout(t.id), r());
};
if (typeof addEventListener > "u")
throw Error("useActiveElement: hook works only in browser context.");
return addEventListener("focusin", n, { capture: !0, passive: !0 }), addEventListener("focusout", n, { capture: !0, passive: !0 }), () => {
removeEventListener("focusin", n, !0), removeEventListener("focusout", n, !0), e.current = null;
};
}, []),
m(() => {
const r = document.activeElement;
return e.current !== r && (e.current = r), e.current;
}, [])
);
}, or = (e) => {
const r = d();
return [
m((...t) => {
const n = () => {
r.current = requestAnimationFrame((c) => e(c, n, ...t));
};
r.current = requestAnimationFrame((c) => e(c, n, ...t));
}, [e]),
m(() => {
r.current && cancelAnimationFrame(r.current);
}, [])
];
}, yt = (e, r) => {
const t = d(),