tekivex-ui 2.5.10 → 2.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/TkxForm-1KDzoniV.cjs +12 -0
  2. package/dist/TkxForm-9-W3Nl6m.js +314 -0
  3. package/dist/charts.cjs +1 -1
  4. package/dist/charts.js +543 -507
  5. package/dist/chunk-Bmb41Sf3.cjs +1 -0
  6. package/dist/headless.cjs +1 -1
  7. package/dist/headless.js +428 -447
  8. package/dist/hooks-6pRsPOyG.js +58 -0
  9. package/dist/hooks-mivgRljH.cjs +1 -0
  10. package/dist/i18n.cjs +1 -1
  11. package/dist/i18n.js +728 -752
  12. package/dist/index.cjs +46 -23
  13. package/dist/index.d.ts +6 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +16103 -16237
  16. package/dist/quantum.cjs +14 -16
  17. package/dist/quantum.js +2473 -2279
  18. package/dist/realtime.cjs +4 -10
  19. package/dist/realtime.js +804 -958
  20. package/dist/src/components/TkxAIChatBubble.d.ts +24 -0
  21. package/dist/src/components/TkxAIChatBubble.d.ts.map +1 -0
  22. package/dist/src/components/TkxAIConfidenceBar.d.ts +17 -0
  23. package/dist/src/components/TkxAIConfidenceBar.d.ts.map +1 -0
  24. package/dist/src/components/TkxAIThinking.d.ts +17 -0
  25. package/dist/src/components/TkxAIThinking.d.ts.map +1 -0
  26. package/dist/src/components/TkxClock.d.ts.map +1 -1
  27. package/dist/src/components/TkxForm.d.ts.map +1 -1
  28. package/dist/src/components/TkxLiveFeed.d.ts +1 -1
  29. package/dist/src/components/TkxLiveLog.d.ts +1 -1
  30. package/dist/src/components/TkxRealTimeChart.d.ts +1 -1
  31. package/dist/src/components/TkxTooltip.d.ts.map +1 -1
  32. package/dist/src/components/TkxTypography.d.ts +5 -5
  33. package/dist/src/components/TkxTypography.d.ts.map +1 -1
  34. package/dist/src/components/index.d.ts +3 -0
  35. package/dist/src/components/index.d.ts.map +1 -1
  36. package/dist/tekivex-ui.css +2 -0
  37. package/dist/themes-BbJanqiC.js +498 -0
  38. package/dist/themes-CMq2vWXj.cjs +2 -0
  39. package/dist/tkx-0oAwZqgL.cjs +4 -0
  40. package/dist/tkx-DQkvHdE5.js +1172 -0
  41. package/package.json +16 -16
  42. package/src/components/TkxAIChatBubble.tsx +209 -0
  43. package/src/components/TkxAIConfidenceBar.tsx +131 -0
  44. package/src/components/TkxAIThinking.tsx +191 -0
  45. package/src/components/TkxClock.tsx +2 -2
  46. package/src/components/TkxForm.tsx +4 -2
  47. package/src/components/TkxTooltip.tsx +7 -5
  48. package/src/components/TkxTypography.tsx +2 -2
  49. package/src/components/index.ts +5 -0
  50. package/dist/TkxForm-2tGLCPH6.js +0 -326
  51. package/dist/TkxForm-C2VqR2wC.cjs +0 -12
  52. package/dist/index-BgHMZe4Z.js +0 -66
  53. package/dist/index-Bt5y50Qa.cjs +0 -1
  54. package/dist/index-DnqXtpwV.cjs +0 -2
  55. package/dist/index-iUUHRxqJ.js +0 -515
  56. package/dist/security-C-ZPGoyG.js +0 -97
  57. package/dist/security-Uf0mjv8o.cjs +0 -1
  58. package/dist/style.css +0 -1
  59. package/dist/tkx-BtHzWKTl.js +0 -1112
  60. package/dist/tkx-C7GvVUE9.cjs +0 -4
package/dist/headless.js CHANGED
@@ -1,460 +1,441 @@
1
- import { a as ge, d as me, c as he, b as ye, e as Se, u as pe } from "./index-BgHMZe4Z.js";
2
- import { u as ve } from "./TkxForm-2tGLCPH6.js";
3
- import { c as Ee, e as xe, r as Ie, b as Oe, d as De, f as Re } from "./tkx-BtHzWKTl.js";
4
- import { f as Ae, l as Ce, m as Me, q as ke, s as Fe, t as Le, F as Ve } from "./index-iUUHRxqJ.js";
5
- import { b as Ne, s as je } from "./security-C-ZPGoyG.js";
6
- import { useState as S, useCallback as a, useRef as g, useMemo as X, useEffect as z } from "react";
7
- function Z(e = !1) {
8
- const [c, t] = S(e), r = a(() => t(!0), []), n = a(() => t(!1), []), o = a(() => t((s) => !s), []);
9
- return { isOpen: c, open: r, close: n, toggle: o };
1
+ import { D as e, E as t, b as n, h as r, j as i, k as a, x as o } from "./themes-BbJanqiC.js";
2
+ import { c as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m } from "./tkx-DQkvHdE5.js";
3
+ import { a as h, i as g, n as _, o as v, r as y, t as b } from "./hooks-6pRsPOyG.js";
4
+ import { r as x } from "./TkxForm-9-W3Nl6m.js";
5
+ import { useCallback as S, useEffect as C, useMemo as w, useRef as T, useState as E } from "react";
6
+ //#region src/headless/useDisclosure.ts
7
+ function D(e = !1) {
8
+ let [t, n] = E(e);
9
+ return {
10
+ isOpen: t,
11
+ open: S(() => n(!0), []),
12
+ close: S(() => n(!1), []),
13
+ toggle: S(() => n((e) => !e), [])
14
+ };
10
15
  }
11
- function _({
12
- count: e,
13
- initialIndex: c = 0,
14
- orientation: t = "horizontal",
15
- loop: r = !0
16
- }) {
17
- const [n, o] = S(c), s = g([]), l = a(
18
- (i) => {
19
- o((d) => {
20
- let p = d + i;
21
- return r ? p = (p % e + e) % e : p = Math.max(0, Math.min(e - 1, p)), requestAnimationFrame(() => {
22
- var I;
23
- (I = s.current[p]) == null || I.focus();
24
- }), p;
25
- });
26
- },
27
- [e, r]
28
- ), m = a(
29
- (i) => ({
30
- tabIndex: i === n ? 0 : -1,
31
- "data-focused": i === n,
32
- onFocus: () => o(i),
33
- onKeyDown: (d) => {
34
- const p = t === "horizontal" || t === "both", I = t === "vertical" || t === "both";
35
- p && d.key === "ArrowRight" && (d.preventDefault(), l(1)), p && d.key === "ArrowLeft" && (d.preventDefault(), l(-1)), I && d.key === "ArrowDown" && (d.preventDefault(), l(1)), I && d.key === "ArrowUp" && (d.preventDefault(), l(-1)), d.key === "Home" && (d.preventDefault(), o(0), requestAnimationFrame(() => {
36
- var w;
37
- return (w = s.current[0]) == null ? void 0 : w.focus();
38
- })), d.key === "End" && (d.preventDefault(), o(e - 1), requestAnimationFrame(() => {
39
- var w;
40
- return (w = s.current[e - 1]) == null ? void 0 : w.focus();
41
- }));
42
- }
43
- }),
44
- [n, l, t, e]
45
- );
46
- return { focusedIndex: n, setFocusedIndex: o, getItemProps: m };
16
+ //#endregion
17
+ //#region src/headless/useRovingTabIndex.ts
18
+ function O({ count: e, initialIndex: t = 0, orientation: n = "horizontal", loop: r = !0 }) {
19
+ let [i, a] = E(t), o = T([]), s = S((t) => {
20
+ a((n) => {
21
+ let i = n + t;
22
+ return i = r ? (i % e + e) % e : Math.max(0, Math.min(e - 1, i)), requestAnimationFrame(() => {
23
+ o.current[i]?.focus();
24
+ }), i;
25
+ });
26
+ }, [e, r]);
27
+ return {
28
+ focusedIndex: i,
29
+ setFocusedIndex: a,
30
+ getItemProps: S((t) => ({
31
+ tabIndex: t === i ? 0 : -1,
32
+ "data-focused": t === i,
33
+ onFocus: () => a(t),
34
+ onKeyDown: (t) => {
35
+ let r = n === "horizontal" || n === "both", i = n === "vertical" || n === "both";
36
+ r && t.key === "ArrowRight" && (t.preventDefault(), s(1)), r && t.key === "ArrowLeft" && (t.preventDefault(), s(-1)), i && t.key === "ArrowDown" && (t.preventDefault(), s(1)), i && t.key === "ArrowUp" && (t.preventDefault(), s(-1)), t.key === "Home" && (t.preventDefault(), a(0), requestAnimationFrame(() => o.current[0]?.focus())), t.key === "End" && (t.preventDefault(), a(e - 1), requestAnimationFrame(() => o.current[e - 1]?.focus()));
37
+ }
38
+ }), [
39
+ i,
40
+ s,
41
+ n,
42
+ e
43
+ ])
44
+ };
47
45
  }
48
- function ee({
49
- initialValues: e,
50
- validate: c
51
- }) {
52
- const [t, r] = S({ ...e }), [n, o] = S({}), [s, l] = S({}), m = g(e), i = a((f, y) => {
53
- r((T) => ({ ...T, [f]: y }));
54
- }, []), d = a((f) => {
55
- r((y) => ({ ...y, ...f }));
56
- }, []), p = a((f) => {
57
- l((y) => ({ ...y, [f]: !0 }));
58
- }, []), I = a(() => {
59
- if (!c) return !0;
60
- const f = c(t), y = Object.fromEntries(
61
- Object.entries(f).filter(([, A]) => A != null)
62
- );
63
- o(y);
64
- const T = Object.fromEntries(
65
- Object.keys(t).map((A) => [A, !0])
66
- );
67
- return l(T), Object.keys(y).length === 0;
68
- }, [t, c]), w = a(() => {
69
- r({ ...m.current }), o({}), l({});
70
- }, []), h = Object.keys(t).some(
71
- (f) => t[f] !== m.current[f]
72
- ), b = Object.keys(n).length === 0, u = a(
73
- (f) => ({
74
- value: t[f],
75
- onChange: (y) => {
76
- i(f, y.target.value);
77
- },
78
- onBlur: () => p(f),
79
- "aria-invalid": s[f] && n[f] ? !0 : void 0,
80
- "aria-describedby": n[f] ? `${String(f)}-error` : void 0
81
- }),
82
- [t, n, s, i, p]
83
- );
84
- return { values: t, errors: n, touched: s, dirty: h, isValid: b, setValue: i, setValues: d, touchField: p, validate: I, reset: w, getFieldProps: u };
46
+ //#endregion
47
+ //#region src/headless/useFormState.ts
48
+ function k({ initialValues: e, validate: t }) {
49
+ let [n, r] = E({ ...e }), [i, a] = E({}), [o, s] = E({}), c = T(e), l = S((e, t) => {
50
+ r((n) => ({
51
+ ...n,
52
+ [e]: t
53
+ }));
54
+ }, []), u = S((e) => {
55
+ r((t) => ({
56
+ ...t,
57
+ ...e
58
+ }));
59
+ }, []), d = S((e) => {
60
+ s((t) => ({
61
+ ...t,
62
+ [e]: !0
63
+ }));
64
+ }, []), f = S(() => {
65
+ if (!t) return !0;
66
+ let e = t(n), r = Object.fromEntries(Object.entries(e).filter(([, e]) => e != null));
67
+ return a(r), s(Object.fromEntries(Object.keys(n).map((e) => [e, !0]))), Object.keys(r).length === 0;
68
+ }, [n, t]), p = S(() => {
69
+ r({ ...c.current }), a({}), s({});
70
+ }, []);
71
+ return {
72
+ values: n,
73
+ errors: i,
74
+ touched: o,
75
+ dirty: Object.keys(n).some((e) => n[e] !== c.current[e]),
76
+ isValid: Object.keys(i).length === 0,
77
+ setValue: l,
78
+ setValues: u,
79
+ touchField: d,
80
+ validate: f,
81
+ reset: p,
82
+ getFieldProps: S((e) => ({
83
+ value: n[e],
84
+ onChange: (t) => {
85
+ l(e, t.target.value);
86
+ },
87
+ onBlur: () => d(e),
88
+ "aria-invalid": o[e] && i[e] ? !0 : void 0,
89
+ "aria-describedby": i[e] ? `${String(e)}-error` : void 0
90
+ }), [
91
+ n,
92
+ i,
93
+ o,
94
+ l,
95
+ d
96
+ ])
97
+ };
85
98
  }
86
- function te({
87
- items: e,
88
- initialSelected: c = [],
89
- multiple: t = !0
90
- }) {
91
- const [r, n] = S(() => new Set(c)), o = a((h) => {
92
- n((b) => {
93
- const u = new Set(b);
94
- return u.has(h) ? u.delete(h) : (t || u.clear(), u.add(h)), u;
95
- });
96
- }, [t]), s = a((h) => {
97
- n((b) => {
98
- if (b.has(h)) return b;
99
- const u = t ? new Set(b) : /* @__PURE__ */ new Set();
100
- return u.add(h), u;
101
- });
102
- }, [t]), l = a((h) => {
103
- n((b) => {
104
- if (!b.has(h)) return b;
105
- const u = new Set(b);
106
- return u.delete(h), u;
107
- });
108
- }, []), m = a(() => {
109
- t && n(new Set(e));
110
- }, [e, t]), i = a(() => n(/* @__PURE__ */ new Set()), []), d = a(() => {
111
- n((h) => e.every((u) => h.has(u)) ? /* @__PURE__ */ new Set() : new Set(e));
112
- }, [e]), p = e.length > 0 && e.every((h) => r.has(h)), I = e.some((h) => r.has(h)), w = X(() => Array.from(r), [r]);
113
- return {
114
- selected: r,
115
- isSelected: a((h) => r.has(h), [r]),
116
- toggle: o,
117
- select: s,
118
- deselect: l,
119
- selectAll: m,
120
- deselectAll: i,
121
- toggleAll: d,
122
- allSelected: p,
123
- someSelected: I,
124
- selectedCount: r.size,
125
- selectedArray: w
126
- };
99
+ //#endregion
100
+ //#region src/headless/useListSelection.ts
101
+ function A({ items: e, initialSelected: t = [], multiple: n = !0 }) {
102
+ let [r, i] = E(() => new Set(t)), a = S((e) => {
103
+ i((t) => {
104
+ let r = new Set(t);
105
+ return r.has(e) ? r.delete(e) : (n || r.clear(), r.add(e)), r;
106
+ });
107
+ }, [n]), o = S((e) => {
108
+ i((t) => {
109
+ if (t.has(e)) return t;
110
+ let r = n ? new Set(t) : /* @__PURE__ */ new Set();
111
+ return r.add(e), r;
112
+ });
113
+ }, [n]), s = S((e) => {
114
+ i((t) => {
115
+ if (!t.has(e)) return t;
116
+ let n = new Set(t);
117
+ return n.delete(e), n;
118
+ });
119
+ }, []), c = S(() => {
120
+ n && i(new Set(e));
121
+ }, [e, n]), l = S(() => i(/* @__PURE__ */ new Set()), []), u = S(() => {
122
+ i((t) => e.every((e) => t.has(e)) ? /* @__PURE__ */ new Set() : new Set(e));
123
+ }, [e]), d = e.length > 0 && e.every((e) => r.has(e)), f = e.some((e) => r.has(e)), p = w(() => Array.from(r), [r]);
124
+ return {
125
+ selected: r,
126
+ isSelected: S((e) => r.has(e), [r]),
127
+ toggle: a,
128
+ select: o,
129
+ deselect: s,
130
+ selectAll: c,
131
+ deselectAll: l,
132
+ toggleAll: u,
133
+ allSelected: d,
134
+ someSelected: f,
135
+ selectedCount: r.size,
136
+ selectedArray: p
137
+ };
127
138
  }
128
- function ne(e, c) {
129
- const [t, r] = S(e);
130
- return z(() => {
131
- const n = setTimeout(() => r(e), c);
132
- return () => clearTimeout(n);
133
- }, [e, c]), t;
139
+ //#endregion
140
+ //#region src/headless/useDebounce.ts
141
+ function j(e, t) {
142
+ let [n, r] = E(e);
143
+ return C(() => {
144
+ let n = setTimeout(() => r(e), t);
145
+ return () => clearTimeout(n);
146
+ }, [e, t]), n;
134
147
  }
135
- function re(e, c) {
136
- const [t, r] = S(e), n = g(Date.now());
137
- return z(() => {
138
- const o = Date.now(), s = c - (o - n.current);
139
- if (s <= 0)
140
- n.current = o, r(e);
141
- else {
142
- const l = setTimeout(() => {
143
- n.current = Date.now(), r(e);
144
- }, s);
145
- return () => clearTimeout(l);
146
- }
147
- }, [e, c]), t;
148
+ //#endregion
149
+ //#region src/headless/useThrottle.ts
150
+ function M(e, t) {
151
+ let [n, r] = E(e), i = T(Date.now());
152
+ return C(() => {
153
+ let n = Date.now(), a = t - (n - i.current);
154
+ if (a <= 0) i.current = n, r(e);
155
+ else {
156
+ let t = setTimeout(() => {
157
+ i.current = Date.now(), r(e);
158
+ }, a);
159
+ return () => clearTimeout(t);
160
+ }
161
+ }, [e, t]), n;
148
162
  }
149
- function ce({
150
- value: e,
151
- onChange: c,
152
- defaultValue: t
153
- }) {
154
- const r = e !== void 0, [n, o] = S(t), s = g(c);
155
- s.current = c;
156
- const l = a(
157
- (m) => {
158
- var i;
159
- r || o(m), (i = s.current) == null || i.call(s, m);
160
- },
161
- [r]
162
- );
163
- return [r ? e : n, l];
163
+ //#endregion
164
+ //#region src/headless/useControllable.ts
165
+ function N({ value: e, onChange: t, defaultValue: n }) {
166
+ let r = e !== void 0, [i, a] = E(n), o = T(t);
167
+ o.current = t;
168
+ let s = S((e) => {
169
+ r || a(e), o.current?.(e);
170
+ }, [r]);
171
+ return [r ? e : i, s];
164
172
  }
165
- function se(e) {
166
- const [c, t] = S(() => typeof window > "u" ? !1 : window.matchMedia(e).matches);
167
- return z(() => {
168
- if (typeof window > "u") return;
169
- const r = window.matchMedia(e);
170
- t(r.matches);
171
- const n = (o) => t(o.matches);
172
- return r.addEventListener("change", n), () => r.removeEventListener("change", n);
173
- }, [e]), c;
173
+ //#endregion
174
+ //#region src/headless/useMediaQuery.ts
175
+ function P(e) {
176
+ let [t, n] = E(() => typeof window > "u" ? !1 : window.matchMedia(e).matches);
177
+ return C(() => {
178
+ if (typeof window > "u") return;
179
+ let t = window.matchMedia(e);
180
+ n(t.matches);
181
+ let r = (e) => n(e.matches);
182
+ return t.addEventListener("change", r), () => t.removeEventListener("change", r);
183
+ }, [e]), t;
174
184
  }
175
- function oe(e, c) {
176
- const [t, r] = S(() => {
177
- if (typeof window > "u") return c;
178
- try {
179
- const s = window.localStorage.getItem(e);
180
- return s !== null ? JSON.parse(s) : c;
181
- } catch {
182
- return c;
183
- }
184
- }), n = a(
185
- (s) => {
186
- r((l) => {
187
- const m = typeof s == "function" ? s(l) : s;
188
- if (typeof window < "u")
189
- try {
190
- window.localStorage.setItem(e, JSON.stringify(m));
191
- } catch {
192
- }
193
- return m;
194
- });
195
- },
196
- [e]
197
- ), o = a(() => {
198
- if (r(c), typeof window < "u")
199
- try {
200
- window.localStorage.removeItem(e);
201
- } catch {
202
- }
203
- }, [e, c]);
204
- return [t, n, o];
185
+ //#endregion
186
+ //#region src/headless/useLocalStorage.ts
187
+ function F(e, t) {
188
+ let [n, r] = E(() => {
189
+ if (typeof window > "u") return t;
190
+ try {
191
+ let n = window.localStorage.getItem(e);
192
+ return n === null ? t : JSON.parse(n);
193
+ } catch {
194
+ return t;
195
+ }
196
+ });
197
+ return [
198
+ n,
199
+ S((t) => {
200
+ r((n) => {
201
+ let r = typeof t == "function" ? t(n) : t;
202
+ if (typeof window < "u") try {
203
+ window.localStorage.setItem(e, JSON.stringify(r));
204
+ } catch {}
205
+ return r;
206
+ });
207
+ }, [e]),
208
+ S(() => {
209
+ if (r(t), typeof window < "u") try {
210
+ window.localStorage.removeItem(e);
211
+ } catch {}
212
+ }, [e, t])
213
+ ];
205
214
  }
206
- function ue({
207
- threshold: e = 0,
208
- rootMargin: c = "0px",
209
- root: t = null,
210
- once: r = !1
211
- } = {}) {
212
- const n = g(null), [o, s] = S(null), l = g(null);
213
- return z(() => {
214
- const m = n.current;
215
- if (!(!m || typeof IntersectionObserver > "u"))
216
- return l.current = new IntersectionObserver(
217
- ([i]) => {
218
- var d;
219
- s(i), r && i.isIntersecting && ((d = l.current) == null || d.unobserve(m));
220
- },
221
- { threshold: e, rootMargin: c, root: t }
222
- ), l.current.observe(m), () => {
223
- var i;
224
- return (i = l.current) == null ? void 0 : i.disconnect();
225
- };
226
- }, [e, c, t, r]), { ref: n, isIntersecting: (o == null ? void 0 : o.isIntersecting) ?? !1, entry: o };
215
+ //#endregion
216
+ //#region src/headless/useIntersectionObserver.ts
217
+ function I({ threshold: e = 0, rootMargin: t = "0px", root: n = null, once: r = !1 } = {}) {
218
+ let i = T(null), [a, o] = E(null), s = T(null);
219
+ return C(() => {
220
+ let a = i.current;
221
+ if (!(!a || typeof IntersectionObserver > "u")) return s.current = new IntersectionObserver(([e]) => {
222
+ o(e), r && e.isIntersecting && s.current?.unobserve(a);
223
+ }, {
224
+ threshold: e,
225
+ rootMargin: t,
226
+ root: n
227
+ }), s.current.observe(a), () => s.current?.disconnect();
228
+ }, [
229
+ e,
230
+ t,
231
+ n,
232
+ r
233
+ ]), {
234
+ ref: i,
235
+ isIntersecting: a?.isIntersecting ?? !1,
236
+ entry: a
237
+ };
227
238
  }
228
- function ae(e) {
229
- const {
230
- url: c,
231
- protocols: t,
232
- reconnect: r = !0,
233
- reconnectDelay: n = 1e3,
234
- reconnectAttempts: o = 10,
235
- heartbeatInterval: s = 3e4,
236
- heartbeatMessage: l = "ping",
237
- onOpen: m,
238
- onClose: i,
239
- onError: d,
240
- onMessage: p
241
- } = e, [I, w] = S("disconnected"), [h, b] = S(null), [u, f] = S([]), [y, T] = S(0), [A, V] = S(null), v = g(null), k = g(0), j = g(null), F = g(null), P = g(null), O = g([]), E = g(!0), C = g(!1), x = g(m), L = g(i), N = g(d), W = g(p);
242
- x.current = m, L.current = i, N.current = d, W.current = p;
243
- const q = a(() => {
244
- j.current && (clearTimeout(j.current), j.current = null), F.current && (clearInterval(F.current), F.current = null);
245
- }, []), U = a((R) => {
246
- for (; O.current.length > 0; ) {
247
- const M = O.current.shift();
248
- M !== void 0 && R.send(typeof M == "string" ? M : JSON.stringify(M));
249
- }
250
- }, []), Q = a(() => {
251
- if (v.current && v.current.readyState === WebSocket.OPEN) return;
252
- C.current = !1, q(), E.current && w("connecting");
253
- const R = new WebSocket(c, t);
254
- v.current = R, R.onopen = (M) => {
255
- var D;
256
- E.current && (w("connected"), k.current = 0, T(0), (D = x.current) == null || D.call(x, M), U(R), F.current = setInterval(() => {
257
- if (R.readyState === WebSocket.OPEN) {
258
- P.current = Date.now();
259
- try {
260
- R.send(JSON.stringify({ type: "ping", t: P.current }));
261
- } catch {
262
- }
263
- }
264
- }, s));
265
- }, R.onmessage = (M) => {
266
- var H;
267
- if (!E.current) return;
268
- let D;
269
- try {
270
- D = JSON.parse(M.data);
271
- } catch {
272
- D = M.data;
273
- }
274
- const J = D;
275
- if (J && typeof J == "object" && J.type === "pong" && typeof J.t == "number") {
276
- V(Date.now() - J.t);
277
- return;
278
- }
279
- if (D === l && P.current !== null) {
280
- V(Date.now() - P.current), P.current = null;
281
- return;
282
- }
283
- b(D), f((G) => {
284
- const K = [...G, D];
285
- return K.length > 100 ? K.slice(K.length - 100) : K;
286
- }), (H = W.current) == null || H.call(W, D);
287
- }, R.onerror = (M) => {
288
- var D;
289
- E.current && (w("error"), (D = N.current) == null || D.call(N, M));
290
- }, R.onclose = (M) => {
291
- var D;
292
- if (E.current && (q(), w("disconnected"), (D = L.current) == null || D.call(L, M), !C.current && r && k.current < o)) {
293
- const J = k.current, H = n * Math.pow(1.5, J);
294
- k.current += 1, T(k.current), j.current = setTimeout(() => {
295
- E.current && Q();
296
- }, H);
297
- }
298
- };
299
- }, [c, t, r, n, o, s, l, q, U]), B = a(() => {
300
- C.current = !0, q(), v.current && (v.current.close(), v.current = null), E.current && w("disconnected");
301
- }, [q]), $ = a((R) => {
302
- v.current && v.current.readyState === WebSocket.OPEN ? v.current.send(typeof R == "string" ? R : JSON.stringify(R)) : O.current.push(R);
303
- }, []);
304
- return z(() => (E.current = !0, Q(), () => {
305
- E.current = !1, C.current = !0, q(), v.current && (v.current.close(), v.current = null);
306
- }), []), { status: I, lastMessage: h, messages: u, send: $, connect: Q, disconnect: B, reconnectCount: y, latency: A };
239
+ //#endregion
240
+ //#region src/headless/useWebSocket.ts
241
+ function L(e) {
242
+ let { url: t, protocols: n, reconnect: r = !0, reconnectDelay: i = 1e3, reconnectAttempts: a = 10, heartbeatInterval: o = 3e4, heartbeatMessage: s = "ping", onOpen: c, onClose: l, onError: u, onMessage: d } = e, [f, p] = E("disconnected"), [m, h] = E(null), [g, _] = E([]), [v, y] = E(0), [b, x] = E(null), w = T(null), D = T(0), O = T(null), k = T(null), A = T(null), j = T([]), M = T(!0), N = T(!1), P = T(c), F = T(l), I = T(u), L = T(d);
243
+ P.current = c, F.current = l, I.current = u, L.current = d;
244
+ let R = S(() => {
245
+ O.current &&= (clearTimeout(O.current), null), k.current &&= (clearInterval(k.current), null);
246
+ }, []), z = S((e) => {
247
+ for (; j.current.length > 0;) {
248
+ let t = j.current.shift();
249
+ t !== void 0 && e.send(typeof t == "string" ? t : JSON.stringify(t));
250
+ }
251
+ }, []), B = S(() => {
252
+ if (w.current && w.current.readyState === WebSocket.OPEN) return;
253
+ N.current = !1, R(), M.current && p("connecting");
254
+ let e = new WebSocket(t, n);
255
+ w.current = e, e.onopen = (t) => {
256
+ M.current && (p("connected"), D.current = 0, y(0), P.current?.(t), z(e), k.current = setInterval(() => {
257
+ if (e.readyState === WebSocket.OPEN) {
258
+ A.current = Date.now();
259
+ try {
260
+ e.send(JSON.stringify({
261
+ type: "ping",
262
+ t: A.current
263
+ }));
264
+ } catch {}
265
+ }
266
+ }, o));
267
+ }, e.onmessage = (e) => {
268
+ if (!M.current) return;
269
+ let t;
270
+ try {
271
+ t = JSON.parse(e.data);
272
+ } catch {
273
+ t = e.data;
274
+ }
275
+ let n = t;
276
+ if (n && typeof n == "object" && n.type === "pong" && typeof n.t == "number") {
277
+ x(Date.now() - n.t);
278
+ return;
279
+ }
280
+ if (t === s && A.current !== null) {
281
+ x(Date.now() - A.current), A.current = null;
282
+ return;
283
+ }
284
+ h(t), _((e) => {
285
+ let n = [...e, t];
286
+ return n.length > 100 ? n.slice(n.length - 100) : n;
287
+ }), L.current?.(t);
288
+ }, e.onerror = (e) => {
289
+ M.current && (p("error"), I.current?.(e));
290
+ }, e.onclose = (e) => {
291
+ if (M.current && (R(), p("disconnected"), F.current?.(e), !N.current && r && D.current < a)) {
292
+ let e = i * 1.5 ** D.current;
293
+ D.current += 1, y(D.current), O.current = setTimeout(() => {
294
+ M.current && B();
295
+ }, e);
296
+ }
297
+ };
298
+ }, [
299
+ t,
300
+ n,
301
+ r,
302
+ i,
303
+ a,
304
+ o,
305
+ s,
306
+ R,
307
+ z
308
+ ]), V = S(() => {
309
+ N.current = !0, R(), w.current &&= (w.current.close(), null), M.current && p("disconnected");
310
+ }, [R]), H = S((e) => {
311
+ w.current && w.current.readyState === WebSocket.OPEN ? w.current.send(typeof e == "string" ? e : JSON.stringify(e)) : j.current.push(e);
312
+ }, []);
313
+ return C(() => (M.current = !0, B(), () => {
314
+ M.current = !1, N.current = !0, R(), w.current &&= (w.current.close(), null);
315
+ }), []), {
316
+ status: f,
317
+ lastMessage: m,
318
+ messages: g,
319
+ send: H,
320
+ connect: B,
321
+ disconnect: V,
322
+ reconnectCount: v,
323
+ latency: b
324
+ };
307
325
  }
308
- function le(e) {
309
- const {
310
- url: c,
311
- events: t = ["message"],
312
- withCredentials: r = !1,
313
- reconnect: n = !0,
314
- reconnectDelay: o = 3e3,
315
- onOpen: s,
316
- onError: l
317
- } = e, [m, i] = S("connecting"), [d, p] = S(null), [I, w] = S([]), [h, b] = S(0), u = g(null), f = g(null), y = g(!0), T = g(!1), A = g(s), V = g(l);
318
- A.current = s, V.current = l;
319
- const v = a(() => {
320
- f.current && (clearTimeout(f.current), f.current = null);
321
- }, []), k = a(() => {
322
- if (typeof EventSource > "u") {
323
- y.current && i("error");
324
- return;
325
- }
326
- T.current = !1, v(), u.current && (u.current.close(), u.current = null), y.current && i("connecting");
327
- const F = new EventSource(c, { withCredentials: r });
328
- u.current = F, F.onopen = () => {
329
- var O;
330
- y.current && (i("connected"), (O = A.current) == null || O.call(A));
331
- }, F.onerror = (O) => {
332
- var E;
333
- y.current && (i("error"), (E = V.current) == null || E.call(V, O), !T.current && n && (v(), f.current = setTimeout(() => {
334
- y.current && k();
335
- }, o)));
336
- };
337
- const P = (O) => (E) => {
338
- if (!y.current) return;
339
- let C;
340
- try {
341
- C = JSON.parse(E.data);
342
- } catch {
343
- C = E.data;
344
- }
345
- const x = {
346
- type: O,
347
- data: C,
348
- timestamp: Date.now(),
349
- ...E.lastEventId ? { id: E.lastEventId } : {}
350
- };
351
- p({ type: x.type, data: x.data, id: x.id }), w((L) => {
352
- const N = [...L, x];
353
- return N.length > 200 ? N.slice(N.length - 200) : N;
354
- }), b((L) => L + 1);
355
- };
356
- for (const O of t)
357
- F.addEventListener(O, P(O));
358
- }, [c, r, n, o, v]), j = a(() => {
359
- T.current = !0, v(), u.current && (u.current.close(), u.current = null), y.current && i("closed");
360
- }, [v]);
361
- return z(() => (y.current = !0, k(), () => {
362
- y.current = !1, T.current = !0, v(), u.current && (u.current.close(), u.current = null);
363
- }), []), {
364
- status: m,
365
- lastEvent: d,
366
- events: I,
367
- connect: k,
368
- disconnect: j,
369
- eventCount: h
370
- };
326
+ //#endregion
327
+ //#region src/headless/useSSE.ts
328
+ function R(e) {
329
+ let { url: t, events: n = ["message"], withCredentials: r = !1, reconnect: i = !0, reconnectDelay: a = 3e3, onOpen: o, onError: s } = e, [c, l] = E("connecting"), [u, d] = E(null), [f, p] = E([]), [m, h] = E(0), g = T(null), _ = T(null), v = T(!0), y = T(!1), b = T(o), x = T(s);
330
+ b.current = o, x.current = s;
331
+ let w = S(() => {
332
+ _.current &&= (clearTimeout(_.current), null);
333
+ }, []), D = S(() => {
334
+ if (typeof EventSource > "u") {
335
+ v.current && l("error");
336
+ return;
337
+ }
338
+ y.current = !1, w(), g.current &&= (g.current.close(), null), v.current && l("connecting");
339
+ let e = new EventSource(t, { withCredentials: r });
340
+ g.current = e, e.onopen = () => {
341
+ v.current && (l("connected"), b.current?.());
342
+ }, e.onerror = (e) => {
343
+ v.current && (l("error"), x.current?.(e), !y.current && i && (w(), _.current = setTimeout(() => {
344
+ v.current && D();
345
+ }, a)));
346
+ };
347
+ let o = (e) => (t) => {
348
+ if (!v.current) return;
349
+ let n;
350
+ try {
351
+ n = JSON.parse(t.data);
352
+ } catch {
353
+ n = t.data;
354
+ }
355
+ let r = {
356
+ type: e,
357
+ data: n,
358
+ timestamp: Date.now(),
359
+ ...t.lastEventId ? { id: t.lastEventId } : {}
360
+ };
361
+ d({
362
+ type: r.type,
363
+ data: r.data,
364
+ id: r.id
365
+ }), p((e) => {
366
+ let t = [...e, r];
367
+ return t.length > 200 ? t.slice(t.length - 200) : t;
368
+ }), h((e) => e + 1);
369
+ };
370
+ for (let t of n) e.addEventListener(t, o(t));
371
+ }, [
372
+ t,
373
+ r,
374
+ i,
375
+ a,
376
+ w
377
+ ]), O = S(() => {
378
+ y.current = !0, w(), g.current &&= (g.current.close(), null), v.current && l("closed");
379
+ }, [w]);
380
+ return C(() => (v.current = !0, D(), () => {
381
+ v.current = !1, y.current = !0, w(), g.current &&= (g.current.close(), null);
382
+ }), []), {
383
+ status: c,
384
+ lastEvent: u,
385
+ events: f,
386
+ connect: D,
387
+ disconnect: O,
388
+ eventCount: m
389
+ };
371
390
  }
372
- function ie(e) {
373
- const {
374
- queryFn: c,
375
- initialCursor: t = null,
376
- enabled: r = !0,
377
- dedupKey: n
378
- } = e, [o, s] = S([]), [l, m] = S("idle"), [i, d] = S(null), [p, I] = S(!1), [w, h] = S(0), b = g(t ?? null), u = g(!1), f = g(!0), y = g(void 0), T = g(c);
379
- T.current = c;
380
- const A = a(
381
- async (P, O, E) => {
382
- if (u.current || n !== void 0 && n === y.current) return;
383
- u.current = !0;
384
- let C = !1;
385
- f.current && (m(E ? "loading" : "fetching-more"), d(null));
386
- try {
387
- const x = await T.current(P, O);
388
- if (C || !f.current) return;
389
- n !== void 0 && (y.current = n), b.current = x.nextCursor, s((L) => E ? [x.data] : [...L, x.data]), I(x.hasMore), h(O), m("success");
390
- } catch (x) {
391
- if (C || !f.current) return;
392
- d(x instanceof Error ? x : new Error(String(x))), m("error");
393
- } finally {
394
- C || (u.current = !1);
395
- }
396
- return () => {
397
- C = !0;
398
- };
399
- },
400
- // dedupKey intentionally included to allow re-checking on each call
401
- [n]
402
- ), V = a(() => {
403
- !p || u.current || A(b.current, w + 1, !1);
404
- }, [p, w, A]), v = a(() => {
405
- u.current = !1, y.current = void 0, b.current = t ?? null, s([]), m("idle"), d(null), I(!1), h(0);
406
- }, [t]);
407
- z(() => (f.current = !0, r && A(t ?? null, 0, !0), () => {
408
- f.current = !1;
409
- }), [r]);
410
- const k = o.flat(), j = l === "fetching-more", F = k.length;
411
- return {
412
- data: k,
413
- pages: o,
414
- status: l,
415
- error: i,
416
- hasMore: p,
417
- isFetchingMore: j,
418
- fetchMore: V,
419
- reset: v,
420
- pageIndex: w,
421
- totalLoaded: F
422
- };
391
+ //#endregion
392
+ //#region src/headless/useInfiniteQuery.ts
393
+ function z(e) {
394
+ let { queryFn: t, initialCursor: n = null, enabled: r = !0, dedupKey: i } = e, [a, o] = E([]), [s, c] = E("idle"), [l, u] = E(null), [d, f] = E(!1), [p, m] = E(0), h = T(n ?? null), g = T(!1), _ = T(!0), v = T(void 0), y = T(t);
395
+ y.current = t;
396
+ let b = S(async (e, t, n) => {
397
+ if (g.current || i !== void 0 && i === v.current) return;
398
+ g.current = !0;
399
+ let r = !1;
400
+ _.current && (c(n ? "loading" : "fetching-more"), u(null));
401
+ try {
402
+ let a = await y.current(e, t);
403
+ if (r || !_.current) return;
404
+ i !== void 0 && (v.current = i), h.current = a.nextCursor, o((e) => n ? [a.data] : [...e, a.data]), f(a.hasMore), m(t), c("success");
405
+ } catch (e) {
406
+ if (r || !_.current) return;
407
+ u(e instanceof Error ? e : Error(String(e))), c("error");
408
+ } finally {
409
+ r || (g.current = !1);
410
+ }
411
+ return () => {
412
+ r = !0;
413
+ };
414
+ }, [i]), x = S(() => {
415
+ !d || g.current || b(h.current, p + 1, !1);
416
+ }, [
417
+ d,
418
+ p,
419
+ b
420
+ ]), w = S(() => {
421
+ g.current = !1, v.current = void 0, h.current = n ?? null, o([]), c("idle"), u(null), f(!1), m(0);
422
+ }, [n]);
423
+ C(() => (_.current = !0, r && b(n ?? null, 0, !0), () => {
424
+ _.current = !1;
425
+ }), [r]);
426
+ let D = a.flat();
427
+ return {
428
+ data: D,
429
+ pages: a,
430
+ status: s,
431
+ error: l,
432
+ hasMore: d,
433
+ isFetchingMore: s === "fetching-more",
434
+ fetchMore: x,
435
+ reset: w,
436
+ pageIndex: p,
437
+ totalLoaded: D.length
438
+ };
423
439
  }
424
- export {
425
- Ae as contrastRatio,
426
- Ce as cssVar,
427
- Ee as cx,
428
- xe as extractAtomicCSS,
429
- Me as extractCSS,
430
- ke as injectStyles,
431
- Fe as meetsAA,
432
- Le as meetsAAA,
433
- Ie as resetAtomicCSS,
434
- Ve as resetStyles,
435
- Ne as sanitizeProps,
436
- je as sanitizeString,
437
- Oe as tkxListPlugins,
438
- De as tkxPlugin,
439
- Re as tkxRemovePlugin,
440
- ge as useAnnounce,
441
- me as useClickOutside,
442
- ce as useControllable,
443
- ne as useDebounce,
444
- Z as useDisclosure,
445
- he as useEscapeKey,
446
- ye as useFocusTrap,
447
- ee as useFormState,
448
- Se as useHighContrast,
449
- ie as useInfiniteQuery,
450
- ue as useIntersectionObserver,
451
- te as useListSelection,
452
- oe as useLocalStorage,
453
- se as useMediaQuery,
454
- pe as useReducedMotion,
455
- _ as useRovingTabIndex,
456
- le as useSSE,
457
- re as useThrottle,
458
- ve as useTkxForm,
459
- ae as useWebSocket
460
- };
440
+ //#endregion
441
+ export { r as contrastRatio, t as cssVar, m as cx, l as extractAtomicCSS, e as extractCSS, a as injectStyles, n as meetsAA, o as meetsAAA, f as resetAtomicCSS, i as resetStyles, d as sanitizeProps, c as sanitizeString, u as tkxListPlugins, p as tkxPlugin, s as tkxRemovePlugin, b as useAnnounce, _ as useClickOutside, N as useControllable, j as useDebounce, D as useDisclosure, y as useEscapeKey, g as useFocusTrap, k as useFormState, h as useHighContrast, z as useInfiniteQuery, I as useIntersectionObserver, A as useListSelection, F as useLocalStorage, P as useMediaQuery, v as useReducedMotion, O as useRovingTabIndex, R as useSSE, M as useThrottle, x as useTkxForm, L as useWebSocket };