@unicom-cloud/ui 0.8.110 → 0.8.111

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.
package/chunk/zFFM4RBT.js DELETED
@@ -1,2100 +0,0 @@
1
- import { useEffect as D, useState as b, useMemo as x, useRef as E, useLayoutEffect as ge, useCallback as V } from "react";
2
- import "./DsaQZE4X.js";
3
- import { isFunction as k, isString as ee, isNumber as F, isEqual as Ve, isBoolean as qe, isUndefined as je, isObject as Ue } from "@unicom-cloud/utils/is";
4
- import { g as C, u as A, c as j, b as W, i as We, s as $e, d as Ge, e as Ke, f as Je } from "./BDgzrqDN.js";
5
- import { a as y } from "./D1iEYgh3.js";
6
- import { u as te } from "./BJeTDXdz.js";
7
- import oe from "@unicom-cloud/utils/js-cookie";
8
- import Qe from "dayjs";
9
- import De from "lodash/debounce";
10
- import { i as ne } from "./CdXR6dj7.js";
11
- import { u as K, c as Ze } from "./DfChiMIE.js";
12
- import { i as q } from "./Di5KBCVQ.js";
13
- import z from "@unicom-cloud/utils/screenfull";
14
- import { isAppleDevice as et } from "@unicom-cloud/utils/constant/platform";
15
- import { u as re } from "./BO_5qdS_.js";
16
- import Ce from "lodash/throttle";
17
- import fe from "lodash/isPlainObject";
18
- import ce from "@unicom-cloud/utils/query-string";
19
- import * as tt from "react-router";
20
- function nt(e) {
21
- return k(e[Symbol.asyncIterator]);
22
- }
23
- function dn(e, t) {
24
- D(() => {
25
- const n = e();
26
- let r = !1;
27
- async function s() {
28
- if (nt(n))
29
- for (; !((await n.next()).done || r); )
30
- ;
31
- else
32
- await n;
33
- }
34
- return s(), () => {
35
- r = !0;
36
- };
37
- }, t);
38
- }
39
- function rt(e = !1, t) {
40
- const [n, r] = b(e), s = x(() => {
41
- const o = t === void 0 ? !e : t;
42
- return {
43
- toggle: () => r((l) => l === e ? o : e),
44
- set: (l) => r(l),
45
- setLeft: () => r(e),
46
- setRight: () => r(o)
47
- };
48
- }, []);
49
- return [n, s];
50
- }
51
- function st(e = !1) {
52
- const [t, { toggle: n, set: r }] = rt(!!e), s = x(() => ({
53
- toggle: n,
54
- set: (a) => r(!!a),
55
- setTrue: () => r(!0),
56
- setFalse: () => r(!1)
57
- }), []);
58
- return [t, s];
59
- }
60
- const ot = (e) => e.every((t) => {
61
- const n = C(t);
62
- return n ? n.getRootNode() instanceof ShadowRoot : !1;
63
- }), ct = (e) => e ? e.getRootNode() : document, at = (e) => {
64
- if (!e || !document.getRootNode)
65
- return document;
66
- const t = Array.isArray(e) ? e : [e];
67
- return ot(t) ? ct(C(t[0])) : document;
68
- };
69
- function mn(e, t, n = "click") {
70
- const r = A(e);
71
- j(
72
- () => {
73
- const s = (a) => {
74
- (Array.isArray(t) ? t : [t]).some((i) => {
75
- const l = C(i);
76
- return !l || l.contains(a.target);
77
- }) || r.current(a);
78
- }, o = at(t), c = Array.isArray(n) ? n : [n];
79
- return c.forEach(
80
- (a) => o.addEventListener(a, s)
81
- ), () => {
82
- c.forEach(
83
- (a) => o.removeEventListener(a, s)
84
- );
85
- };
86
- },
87
- Array.isArray(n) ? n : [n],
88
- t
89
- );
90
- }
91
- function gn(e, t = {}) {
92
- const n = e ?? {}, {
93
- defaultValue: r,
94
- defaultValuePropName: s = "defaultValue",
95
- valuePropName: o = "value",
96
- trigger: c = "onChange"
97
- } = t, a = n[o], d = Object.prototype.hasOwnProperty.call(
98
- n,
99
- o
100
- ), i = x(() => d ? a : Object.prototype.hasOwnProperty.call(n, s) ? n[s] : r, []), l = E(i);
101
- d && (l.current = a);
102
- const u = te();
103
- function m(h, ...p) {
104
- const f = k(h) ? h(l.current) : h;
105
- d || (l.current = f, u()), n[c] && n[c](f, ...p);
106
- }
107
- return [l.current, y(m)];
108
- }
109
- function hn(e, t = {}) {
110
- const [n, r] = b(() => {
111
- const o = oe.get(e);
112
- return ee(o) ? o : k(t.defaultValue) ? t.defaultValue() : t.defaultValue;
113
- }), s = y(
114
- (o, c = {}) => {
115
- const { defaultValue: a, ...d } = { ...t, ...c }, i = k(o) ? o(n) : o;
116
- r(i), i === void 0 ? oe.remove(e) : oe.set(e, i, d);
117
- }
118
- );
119
- return [n, s];
120
- }
121
- const ae = (e) => {
122
- if (!e)
123
- return 0;
124
- const t = Qe(e).valueOf() - Date.now();
125
- return t < 0 ? 0 : t;
126
- }, ut = (e) => ({
127
- days: Math.floor(e / 864e5),
128
- hours: Math.floor(e / 36e5) % 24,
129
- minutes: Math.floor(e / 6e4) % 60,
130
- seconds: Math.floor(e / 1e3) % 60,
131
- milliseconds: Math.floor(e) % 1e3
132
- }), pn = (e = {}) => {
133
- const { leftTime: t, targetDate: n, interval: r = 1e3, onEnd: s } = e || {}, o = x(() => F(t) && t > 0 ? Date.now() + t : void 0, [t]), c = "leftTime" in e ? o : n, [a, d] = b(() => ae(c)), i = A(s);
134
- D(() => {
135
- if (!c) {
136
- d(0);
137
- return;
138
- }
139
- d(ae(c));
140
- const u = setInterval(() => {
141
- const m = ae(c);
142
- d(m), m === 0 && (clearInterval(u), i.current?.());
143
- }, r);
144
- return () => clearInterval(u);
145
- }, [c, r]);
146
- const l = x(() => ut(a), [a]);
147
- return [a, l];
148
- };
149
- function Ee(e, t = {}) {
150
- const { min: n, max: r } = t;
151
- let s = e;
152
- return F(r) && (s = Math.min(r, s)), F(n) && (s = Math.max(n, s)), s;
153
- }
154
- function vn(e = 0, t = {}) {
155
- const { min: n, max: r } = t, [s, o] = b(() => Ee(e, {
156
- min: n,
157
- max: r
158
- })), c = (u) => {
159
- o((m) => {
160
- const h = F(u) ? u : u(m);
161
- return Ee(h, {
162
- max: r,
163
- min: n
164
- });
165
- });
166
- }, a = (u = 1) => {
167
- c((m) => m + u);
168
- }, d = (u = 1) => {
169
- c((m) => m - u);
170
- }, i = (u) => {
171
- c(u);
172
- }, l = () => {
173
- c(e);
174
- };
175
- return [
176
- s,
177
- {
178
- inc: y(a),
179
- dec: y(d),
180
- set: y(i),
181
- reset: y(l)
182
- }
183
- ];
184
- }
185
- function Me(e, t) {
186
- ne && (k(e) || console.error(
187
- `useDebounceFn expected parameter is a function, got ${typeof e}`
188
- ));
189
- const n = A(e), r = t?.wait ?? 1e3, s = x(
190
- () => De(
191
- (...o) => n.current(...o),
192
- r,
193
- t
194
- ),
195
- []
196
- );
197
- return W(() => {
198
- s.cancel();
199
- }), {
200
- run: s,
201
- cancel: s.cancel,
202
- flush: s.flush
203
- };
204
- }
205
- function yn(e, t) {
206
- const [n, r] = b(e), { run: s } = Me(() => {
207
- r(e);
208
- }, t);
209
- return D(() => {
210
- s();
211
- }, [e]), n;
212
- }
213
- function En(e, t, n) {
214
- const [r, s] = b({}), { run: o } = Me(() => {
215
- s({});
216
- }, n);
217
- D(() => o(), t), K(e, [r]);
218
- }
219
- const Ne = (e = [], t = []) => Ve(e, t), Oe = (e) => (t, n) => {
220
- const r = E(void 0), s = E(0);
221
- (n === void 0 || !Ne(n, r.current)) && (s.current += 1), r.current = n, e(t, [s.current]);
222
- }, wn = Oe(D), Sn = Oe(ge);
223
- function X(e, t, n = {}) {
224
- const { enable: r = !0 } = n, s = A(t);
225
- j(
226
- () => {
227
- if (!r)
228
- return;
229
- const o = C(n.target, window);
230
- if (!o?.addEventListener)
231
- return;
232
- const c = (d) => s.current(d), a = Array.isArray(e) ? e : [e];
233
- return a.forEach((d) => {
234
- o.addEventListener(d, c, {
235
- capture: n.capture,
236
- once: n.once,
237
- passive: n.passive
238
- });
239
- }), () => {
240
- a.forEach((d) => {
241
- o.removeEventListener(d, c, {
242
- capture: n.capture
243
- });
244
- });
245
- };
246
- },
247
- [e, n.capture, n.once, n.passive, r],
248
- n.target
249
- );
250
- }
251
- const we = () => q ? document.visibilityState : "visible";
252
- function bn() {
253
- const [e, t] = b(we);
254
- return X(
255
- "visibilitychange",
256
- () => {
257
- t(we());
258
- },
259
- {
260
- target: () => document
261
- }
262
- ), e;
263
- }
264
- const xe = (e) => {
265
- ne && (k(e) || console.error(
266
- `useMount: parameter \`fn\` expected to be a function, but got "${typeof e}".`
267
- )), D(() => e?.(), []);
268
- }, Rn = (e, t, n = {}) => {
269
- const r = A(n), s = A(e), o = E(void 0), { dragImage: c } = r.current;
270
- xe(() => {
271
- if (c?.image) {
272
- const { image: a } = c;
273
- if (ee(a)) {
274
- const d = new Image();
275
- d.src = a, o.current = d;
276
- } else
277
- o.current = a;
278
- }
279
- }), j(
280
- () => {
281
- const a = C(t);
282
- if (!a?.addEventListener)
283
- return;
284
- const d = (l) => {
285
- if (r.current.onDragStart?.(l), l.dataTransfer.setData("custom", JSON.stringify(s.current)), c?.image && o.current) {
286
- const { offsetX: u = 0, offsetY: m = 0 } = c;
287
- l.dataTransfer.setDragImage(
288
- o.current,
289
- u,
290
- m
291
- );
292
- }
293
- }, i = (l) => {
294
- r.current.onDragEnd?.(l);
295
- };
296
- return a.setAttribute("draggable", "true"), a.addEventListener("dragstart", d), a.addEventListener("dragend", i), () => {
297
- a.removeEventListener("dragstart", d), a.removeEventListener("dragend", i);
298
- };
299
- },
300
- [],
301
- t
302
- );
303
- }, Tn = (e, t = {}) => {
304
- const n = A(t), r = E(void 0);
305
- j(
306
- () => {
307
- const s = C(e);
308
- if (!s?.addEventListener)
309
- return;
310
- const o = (u, m) => {
311
- const h = u.getData("text/uri-list"), p = u.getData("custom");
312
- if (p && n.current.onDom) {
313
- let f = p;
314
- try {
315
- f = JSON.parse(p);
316
- } catch {
317
- f = p;
318
- }
319
- n.current.onDom(f, m);
320
- return;
321
- }
322
- if (h && n.current.onUri) {
323
- n.current.onUri(h, m);
324
- return;
325
- }
326
- if (u.files && u.files.length && n.current.onFiles) {
327
- n.current.onFiles(
328
- Array.from(u.files),
329
- m
330
- );
331
- return;
332
- }
333
- u.items && u.items.length && n.current.onText && u.items[0].getAsString((f) => {
334
- n.current.onText(f, m);
335
- });
336
- }, c = (u) => {
337
- u.preventDefault(), u.stopPropagation(), r.current = u.target, n.current.onDragEnter?.(u);
338
- }, a = (u) => {
339
- u.preventDefault(), n.current.onDragOver?.(u);
340
- }, d = (u) => {
341
- u.target === r.current && n.current.onDragLeave?.(u);
342
- }, i = (u) => {
343
- u.preventDefault(), o(u.dataTransfer, u), n.current.onDrop?.(u);
344
- }, l = (u) => {
345
- o(u.clipboardData, u), n.current.onPaste?.(u);
346
- };
347
- return s.addEventListener("dragenter", c), s.addEventListener("dragover", a), s.addEventListener("dragleave", d), s.addEventListener("drop", i), s.addEventListener("paste", l), () => {
348
- s.removeEventListener("dragenter", c), s.removeEventListener("dragover", a), s.removeEventListener("dragleave", d), s.removeEventListener("drop", i), s.removeEventListener("paste", l);
349
- };
350
- },
351
- [],
352
- e
353
- );
354
- };
355
- function An(e) {
356
- const { initialValue: t, transformer: n } = e || {}, [r, s] = b(t), o = A(n), c = V(() => s(t), []), a = V((d) => {
357
- const i = d.target.value;
358
- return k(o.current) ? s(o.current(i)) : s(i);
359
- }, []);
360
- return [
361
- r,
362
- {
363
- onChange: a,
364
- reset: c
365
- }
366
- ];
367
- }
368
- const it = {
369
- SVG: "image/svg+xml",
370
- ICO: "image/x-icon",
371
- GIF: "image/gif",
372
- PNG: "image/png"
373
- }, Pn = (e) => {
374
- D(() => {
375
- if (!e)
376
- return;
377
- const t = e.split("."), n = t[t.length - 1].toLocaleUpperCase(), r = document.querySelector("link[rel*='icon']") || document.createElement("link");
378
- r.type = it[n], r.href = e, r.rel = "shortcut icon", document.getElementsByTagName("head")[0].appendChild(r);
379
- }, [e]);
380
- };
381
- function Ln(e, t) {
382
- const [n, r] = b(!1), { onFocus: s, onBlur: o, onChange: c } = t || {};
383
- return X(
384
- "focusin",
385
- (a) => {
386
- n || (s?.(a), c?.(!0), r(!0));
387
- },
388
- {
389
- target: e
390
- }
391
- ), X(
392
- "focusout",
393
- (a) => {
394
- n && !a.currentTarget?.contains?.(a.relatedTarget) && (o?.(a), c?.(!1), r(!1));
395
- },
396
- {
397
- target: e
398
- }
399
- ), n;
400
- }
401
- const Dn = (e, t) => {
402
- const { onExit: n, onEnter: r, pageFullscreen: s = !1 } = t || {}, { className: o = "@unicom-cloud-ui-hooks-page-fullscreen", zIndex: c = 999999 } = qe(s) || !s ? {} : s, a = A(n), d = A(r), [i, l] = b(m), u = E(m());
403
- function m() {
404
- return z.isEnabled && !!z.element && z.element === C(e);
405
- }
406
- const h = (v) => {
407
- v ? d.current?.() : a.current?.();
408
- }, p = (v) => {
409
- u.current !== v && (h(v), l(v), u.current = v);
410
- }, f = () => {
411
- const v = m();
412
- p(v);
413
- }, T = (v) => {
414
- const w = C(e);
415
- if (!w)
416
- return;
417
- let R = document.getElementById(o);
418
- v ? (w.classList.add(o), R || (R = document.createElement("style"), R.setAttribute("id", o), R.textContent = `
419
- .${o} {
420
- position: fixed; left: 0; top: 0; right: 0; bottom: 0;
421
- width: 100% !important; height: 100% !important;
422
- z-index: ${c};
423
- }`, w.appendChild(R))) : (w.classList.remove(o), R && R.remove()), p(v);
424
- }, P = () => {
425
- const v = C(e);
426
- if (v) {
427
- if (s) {
428
- T(!0);
429
- return;
430
- }
431
- if (z.isEnabled)
432
- try {
433
- z.request(v);
434
- } catch (w) {
435
- console.error(w);
436
- }
437
- }
438
- }, O = () => {
439
- const v = C(e);
440
- if (v) {
441
- if (s) {
442
- T(!1);
443
- return;
444
- }
445
- z.isEnabled && z.element === v && z.exit();
446
- }
447
- }, g = () => {
448
- i ? O() : P();
449
- };
450
- return D(() => {
451
- if (!(!z.isEnabled || s))
452
- return z.on("change", f), () => {
453
- z.off("change", f);
454
- };
455
- }, []), [
456
- i,
457
- {
458
- enterFullscreen: y(P),
459
- exitFullscreen: y(O),
460
- toggleFullscreen: y(g),
461
- isEnabled: z.isEnabled
462
- }
463
- ];
464
- };
465
- function Cn(e) {
466
- const [t, n] = b(e), r = A(t), s = V(() => r.current, []);
467
- return [t, n, s];
468
- }
469
- const lt = (e, t) => {
470
- let n = e > 0 ? e - 1 : t.length + e;
471
- return n >= t.length - 1 && (n = t.length - 1), n < 0 && (n = 0), n;
472
- }, Se = (e, t) => {
473
- const n = lt(e, t);
474
- return {
475
- _current: t[n],
476
- _before: t.slice(0, n),
477
- _after: t.slice(n + 1)
478
- };
479
- };
480
- function Mn(e, t = 0) {
481
- const [n, r] = b({
482
- present: e,
483
- past: [],
484
- future: []
485
- }), { present: s, past: o, future: c } = n, a = E(e), d = (...h) => {
486
- const p = h.length > 0 ? h[0] : a.current;
487
- a.current = p, r({
488
- present: p,
489
- future: [],
490
- past: []
491
- });
492
- }, i = (h) => {
493
- const p = [...o, s], f = F(t) ? t : Number(t);
494
- f > 0 && p.length > f && p.splice(0, 1), r({
495
- present: h,
496
- future: [],
497
- past: p
498
- });
499
- }, l = (h = 1) => {
500
- if (c.length === 0)
501
- return;
502
- const { _before: p, _current: f, _after: T } = Se(h, c);
503
- r({
504
- past: [...o, s, ...p],
505
- present: f,
506
- future: T
507
- });
508
- }, u = (h = -1) => {
509
- if (o.length === 0)
510
- return;
511
- const { _before: p, _current: f, _after: T } = Se(h, o);
512
- r({
513
- past: p,
514
- present: f,
515
- future: [...T, s, ...c]
516
- });
517
- }, m = (h) => {
518
- const p = F(h) ? h : Number(h);
519
- if (p !== 0) {
520
- if (p > 0)
521
- return l(p);
522
- u(p);
523
- }
524
- };
525
- return {
526
- value: s,
527
- backLength: o.length,
528
- forwardLength: c.length,
529
- setValue: y(i),
530
- go: y(m),
531
- back: y(() => {
532
- m(-1);
533
- }),
534
- forward: y(() => {
535
- m(1);
536
- }),
537
- reset: y(d)
538
- };
539
- }
540
- const Nn = (e, t) => {
541
- const { onEnter: n, onLeave: r, onChange: s } = t || {}, [o, { setTrue: c, setFalse: a }] = st(!1);
542
- return X(
543
- "mouseenter",
544
- () => {
545
- n?.(), c(), s?.(!0);
546
- },
547
- {
548
- target: e
549
- }
550
- ), X(
551
- "mouseleave",
552
- () => {
553
- r?.(), a(), s?.(!1);
554
- },
555
- {
556
- target: e
557
- }
558
- ), o;
559
- };
560
- function On(e, t) {
561
- const { callback: n, ...r } = t || {}, [s, o] = b(), [c, a] = b();
562
- return j(
563
- () => {
564
- const i = (Array.isArray(e) ? e : [e]).map((u) => C(u)).filter(Boolean);
565
- if (!i.length)
566
- return;
567
- const l = new IntersectionObserver(
568
- (u) => {
569
- for (const m of u)
570
- a(m.intersectionRatio), o(m.isIntersecting), n?.(m);
571
- },
572
- {
573
- ...r,
574
- root: C(t?.root)
575
- }
576
- );
577
- return i.forEach((u) => l.observe(u)), () => {
578
- l.disconnect();
579
- };
580
- },
581
- [t?.rootMargin, t?.threshold, n],
582
- e
583
- ), [s, c];
584
- }
585
- const G = /* @__PURE__ */ new Map(), ft = (e, t, n) => {
586
- const r = G.get(e);
587
- r?.timer && clearTimeout(r.timer);
588
- let s;
589
- t > -1 && (s = setTimeout(() => {
590
- G.delete(e);
591
- }, t)), G.set(e, {
592
- ...n,
593
- timer: s
594
- });
595
- }, dt = (e) => G.get(e), xn = (e) => {
596
- e ? (Array.isArray(e) ? e : [e]).forEach((n) => G.delete(n)) : G.clear();
597
- }, Q = /* @__PURE__ */ new Map(), mt = (e) => Q.get(e), gt = (e, t) => {
598
- Q.set(e, t), t.then((n) => (Q.delete(e), n)).catch(() => {
599
- Q.delete(e);
600
- });
601
- }, $ = {}, ht = (e, t) => {
602
- $[e] && $[e].forEach((n) => n(t));
603
- }, ue = (e, t) => ($[e] || ($[e] = []), $[e].push(t), function() {
604
- const r = $[e].indexOf(t);
605
- $[e].splice(r, 1);
606
- }), pt = (e, {
607
- cacheKey: t,
608
- cacheTime: n = 300 * 1e3,
609
- staleTime: r = 0,
610
- setCache: s,
611
- getCache: o
612
- }) => {
613
- const c = E(void 0), a = E(void 0), d = (l, u) => {
614
- s ? s(u) : ft(l, n, u), ht(l, u.data);
615
- }, i = (l, u = []) => o ? o(u) : dt(l);
616
- return re(() => {
617
- if (!t)
618
- return;
619
- const l = i(t);
620
- l && Object.hasOwnProperty.call(l, "data") && (e.state.data = l.data, e.state.params = l.params, (r === -1 || Date.now() - l.time <= r) && (e.state.loading = !1)), c.current = ue(t, (u) => {
621
- e.setState({ data: u });
622
- });
623
- }, []), W(() => {
624
- c.current?.();
625
- }), t ? {
626
- onBefore: (l) => {
627
- const u = i(t, l);
628
- return !u || !Object.hasOwnProperty.call(u, "data") ? {} : r === -1 || Date.now() - u.time <= r ? {
629
- loading: !1,
630
- data: u?.data,
631
- error: void 0,
632
- returnNow: !0
633
- } : {
634
- data: u?.data,
635
- error: void 0
636
- };
637
- },
638
- onRequest: (l, u) => {
639
- let m = mt(t);
640
- return m && m !== a.current ? { servicePromise: m } : (m = l(...u), a.current = m, gt(t, m), { servicePromise: m });
641
- },
642
- onSuccess: (l, u) => {
643
- t && (c.current?.(), d(t, {
644
- data: l,
645
- params: u,
646
- time: Date.now()
647
- }), c.current = ue(t, (m) => {
648
- e.setState({ data: m });
649
- }));
650
- },
651
- onMutate: (l) => {
652
- t && (c.current?.(), d(t, {
653
- data: l,
654
- params: e.state.params,
655
- time: Date.now()
656
- }), c.current = ue(t, (u) => {
657
- e.setState({ data: u });
658
- }));
659
- }
660
- } : {};
661
- }, vt = (e, { debounceWait: t, debounceLeading: n, debounceTrailing: r, debounceMaxWait: s }) => {
662
- const o = E(void 0), c = x(() => {
663
- const a = {};
664
- return n !== void 0 && (a.leading = n), r !== void 0 && (a.trailing = r), s !== void 0 && (a.maxWait = s), a;
665
- }, [n, r, s]);
666
- return D(() => {
667
- if (t) {
668
- const a = e.runAsync.bind(e);
669
- return o.current = De(
670
- (d) => {
671
- d();
672
- },
673
- t,
674
- c
675
- ), e.runAsync = (...d) => new Promise((i, l) => {
676
- o.current?.(() => {
677
- a(...d).then(i).catch(l);
678
- });
679
- }), () => {
680
- o.current?.cancel(), e.runAsync = a;
681
- };
682
- }
683
- }, [t, c]), t ? {
684
- onCancel: () => {
685
- o.current?.cancel();
686
- }
687
- } : {};
688
- }, yt = (e, { loadingDelay: t, ready: n }) => {
689
- const r = E(void 0);
690
- if (!t)
691
- return {};
692
- const s = () => {
693
- r.current && clearTimeout(r.current);
694
- };
695
- return {
696
- onBefore: () => (s(), n !== !1 && (r.current = setTimeout(() => {
697
- e.setState({
698
- loading: !0
699
- });
700
- }, t)), {
701
- loading: !1
702
- }),
703
- onFinally: () => {
704
- s();
705
- },
706
- onCancel: () => {
707
- s();
708
- }
709
- };
710
- }, Et = (e, { pollingInterval: t, pollingWhenHidden: n = !0, pollingErrorRetryCount: r = -1 }) => {
711
- const s = E(void 0), o = E(void 0), c = E(0), a = () => {
712
- s.current && clearTimeout(s.current), o.current?.();
713
- };
714
- return K(() => {
715
- t || a();
716
- }, [t]), t ? {
717
- onBefore: () => {
718
- a();
719
- },
720
- onError: () => {
721
- c.current += 1;
722
- },
723
- onSuccess: () => {
724
- c.current = 0;
725
- },
726
- onFinally: () => {
727
- r === -1 || // When an error occurs, the request is not repeated after pollingErrorRetryCount retries
728
- r !== -1 && c.current <= r ? s.current = setTimeout(() => {
729
- !n && !We() ? o.current = $e(() => {
730
- e.refresh();
731
- }) : e.refresh();
732
- }, t) : c.current = 0;
733
- },
734
- onCancel: () => {
735
- a();
736
- }
737
- } : {};
738
- };
739
- function wt(e, t) {
740
- let n = !1;
741
- return (...r) => {
742
- n || (n = !0, e(...r), setTimeout(() => {
743
- n = !1;
744
- }, t));
745
- };
746
- }
747
- const St = (e, { refreshOnWindowFocus: t, focusTimespan: n = 5e3 }) => {
748
- const r = E(void 0), s = () => {
749
- r.current?.();
750
- };
751
- return D(() => {
752
- if (t) {
753
- const o = wt(
754
- e.refresh.bind(e),
755
- n
756
- );
757
- r.current = Ge(() => {
758
- o();
759
- });
760
- }
761
- return () => {
762
- s();
763
- };
764
- }, [t, n]), W(() => {
765
- s();
766
- }), {};
767
- }, bt = (e, { retryInterval: t, retryCount: n }) => {
768
- const r = E(void 0), s = E(0), o = E(!1);
769
- return n ? {
770
- onBefore: () => {
771
- o.current || (s.current = 0), o.current = !1, r.current && clearTimeout(r.current);
772
- },
773
- onSuccess: () => {
774
- s.current = 0;
775
- },
776
- onError: () => {
777
- if (s.current += 1, n === -1 || s.current <= n) {
778
- const c = t ?? Math.min(1e3 * 2 ** s.current, 3e4);
779
- r.current = setTimeout(() => {
780
- o.current = !0, e.refresh();
781
- }, c);
782
- } else
783
- s.current = 0;
784
- },
785
- onCancel: () => {
786
- s.current = 0, r.current && clearTimeout(r.current);
787
- }
788
- } : {};
789
- }, Rt = (e, { throttleWait: t, throttleLeading: n, throttleTrailing: r }) => {
790
- const s = E(void 0), o = {};
791
- return n !== void 0 && (o.leading = n), r !== void 0 && (o.trailing = r), D(() => {
792
- if (t) {
793
- const c = e.runAsync.bind(e);
794
- return s.current = Ce(
795
- (a) => {
796
- a();
797
- },
798
- t,
799
- o
800
- ), e.runAsync = (...a) => new Promise((d, i) => {
801
- s.current?.(() => {
802
- c(...a).then(d).catch(i);
803
- });
804
- }), () => {
805
- e.runAsync = c, s.current?.cancel();
806
- };
807
- }
808
- }, [t, n, r]), t ? {
809
- onCancel: () => {
810
- s.current?.cancel();
811
- }
812
- } : {};
813
- };
814
- class Tt {
815
- constructor(t, n, r, s = {}) {
816
- this.serviceRef = t, this.options = n, this.subscribe = r, this.initState = s, this.count = 0, this.state = {
817
- loading: !1,
818
- params: void 0,
819
- data: void 0,
820
- error: void 0
821
- }, this.state = {
822
- ...this.state,
823
- loading: !n.manual,
824
- ...s
825
- };
826
- }
827
- setState(t = {}) {
828
- this.state = {
829
- ...this.state,
830
- ...t
831
- }, this.subscribe();
832
- }
833
- runPluginHandler(t, ...n) {
834
- const r = this.pluginImpls.map((s) => s[t]?.(...n)).filter(Boolean);
835
- return Object.assign({}, ...r);
836
- }
837
- async runAsync(...t) {
838
- this.count += 1;
839
- const n = this.count, {
840
- stopNow: r = !1,
841
- returnNow: s = !1,
842
- ...o
843
- } = this.runPluginHandler("onBefore", t);
844
- if (r)
845
- return new Promise(() => {
846
- });
847
- if (this.setState({
848
- loading: !0,
849
- params: t,
850
- ...o
851
- }), s)
852
- return Promise.resolve(o.data);
853
- this.options.onBefore?.(t);
854
- try {
855
- let { servicePromise: c } = this.runPluginHandler(
856
- "onRequest",
857
- this.serviceRef.current,
858
- t
859
- );
860
- c || (c = this.serviceRef.current(...t));
861
- const a = await c;
862
- return n !== this.count ? new Promise(() => {
863
- }) : (this.setState({
864
- data: a,
865
- error: void 0,
866
- loading: !1
867
- }), this.options.onSuccess?.(a, t), this.runPluginHandler("onSuccess", a, t), this.options.onFinally?.(t, a, void 0), n === this.count && this.runPluginHandler("onFinally", t, a, void 0), a);
868
- } catch (c) {
869
- if (n !== this.count)
870
- return new Promise(() => {
871
- });
872
- throw this.setState({
873
- error: c,
874
- loading: !1
875
- }), this.options.onError?.(c, t), this.runPluginHandler("onError", c, t), this.options.onFinally?.(t, void 0, c), n === this.count && this.runPluginHandler("onFinally", t, void 0, c), c;
876
- }
877
- }
878
- run(...t) {
879
- this.runAsync(...t).catch((n) => {
880
- this.options.onError || console.error(n);
881
- });
882
- }
883
- cancel() {
884
- this.count += 1, this.setState({
885
- loading: !1
886
- }), this.runPluginHandler("onCancel");
887
- }
888
- refresh() {
889
- this.run(...this.state.params || []);
890
- }
891
- refreshAsync() {
892
- return this.runAsync(...this.state.params || []);
893
- }
894
- mutate(t) {
895
- const n = k(t) ? t(this.state.data) : t;
896
- this.runPluginHandler("onMutate", n), this.setState({
897
- data: n
898
- });
899
- }
900
- }
901
- function At(e, t = {}, n = []) {
902
- const { manual: r = !1, ready: s = !0, ...o } = t;
903
- ne && t.defaultParams && !Array.isArray(t.defaultParams) && console.warn(
904
- `expected defaultParams is array, got ${typeof t.defaultParams}`
905
- );
906
- const c = {
907
- manual: r,
908
- ready: s,
909
- ...o
910
- }, a = A(e), d = te(), i = re(() => {
911
- const l = n.map((u) => u?.onInit?.(c)).filter(Boolean);
912
- return new Tt(
913
- a,
914
- c,
915
- d,
916
- Object.assign({}, ...l)
917
- );
918
- }, []);
919
- return i.options = c, i.pluginImpls = n.map(
920
- (l) => l(i, c)
921
- ), xe(() => {
922
- if (!r && s) {
923
- const l = i.state.params || t.defaultParams || [];
924
- i.run(...l);
925
- }
926
- }), W(() => {
927
- i.cancel();
928
- }), {
929
- loading: i.state.loading,
930
- data: i.state.data,
931
- error: i.state.error,
932
- params: i.state.params || [],
933
- cancel: y(i.cancel.bind(i)),
934
- refresh: y(i.refresh.bind(i)),
935
- refreshAsync: y(i.refreshAsync.bind(i)),
936
- run: y(i.run.bind(i)),
937
- runAsync: y(i.runAsync.bind(i)),
938
- mutate: y(i.mutate.bind(i))
939
- };
940
- }
941
- function Fe(e, t, n) {
942
- return At(e, t, [
943
- ...n || [],
944
- vt,
945
- yt,
946
- Et,
947
- St,
948
- Rt,
949
- Ke,
950
- pt,
951
- bt
952
- ]);
953
- }
954
- const Pt = (e) => e === document || e === document.documentElement || e === document.body ? Math.max(
955
- window.pageYOffset,
956
- document.documentElement.scrollTop,
957
- document.body.scrollTop
958
- ) : e.scrollTop, be = (e) => e.scrollHeight || Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), Lt = (e) => e.clientHeight || Math.max(document.documentElement.clientHeight, document.body.clientHeight), Fn = (e, t = {}) => {
959
- const {
960
- target: n,
961
- isNoMore: r,
962
- threshold: s = 100,
963
- direction: o = "bottom",
964
- reloadDeps: c = [],
965
- manual: a,
966
- onBefore: d,
967
- onSuccess: i,
968
- onError: l,
969
- onFinally: u
970
- } = t, [m, h] = b(), [p, f] = b(!1), T = o === "top", P = E(void 0), O = E(0), g = x(() => r ? r(m) : !1, [m]), { loading: v, error: w, run: R, runAsync: N, cancel: I } = Fe(
971
- async (M) => ({ currentData: await e(M), lastData: M }),
972
- {
973
- manual: a,
974
- onFinally: (M, _, B) => {
975
- f(!1), u?.(_?.currentData, B);
976
- },
977
- onBefore: () => d?.(),
978
- onSuccess: (M) => {
979
- M.lastData ? h({
980
- ...M.currentData,
981
- list: T ? [...M.currentData.list, ...M.lastData.list ?? []] : [...M.lastData.list ?? [], ...M.currentData.list]
982
- }) : h({
983
- ...M.currentData,
984
- list: [...M.currentData.list ?? []]
985
- }), setTimeout(() => {
986
- if (T) {
987
- let _ = C(n);
988
- if (_ = _ === document ? document.documentElement : _, _) {
989
- const B = be(_);
990
- _.scrollTo(0, B - O.current);
991
- }
992
- } else
993
- ve();
994
- }), i?.(M.currentData);
995
- },
996
- onError: (M) => l?.(M)
997
- }
998
- ), S = y(() => {
999
- g || (f(!0), R(m));
1000
- }), Y = async (M) => (await N(M)).currentData, L = y(() => g ? Promise.reject() : (f(!0), Y(m))), H = () => (f(!1), R()), se = () => (f(!1), Y()), ve = () => {
1001
- const M = C(n);
1002
- if (!M)
1003
- return;
1004
- const _ = M === document ? document.documentElement : M, B = Pt(_), ye = be(_), Be = Lt(_);
1005
- T ? (P.current !== void 0 && P.current > B && B <= s && S(), P.current = B, O.current = ye - B) : ye - B <= Be + s && S();
1006
- };
1007
- return X(
1008
- "scroll",
1009
- () => {
1010
- v || p || ve();
1011
- },
1012
- { target: n }
1013
- ), K(() => {
1014
- R();
1015
- }, [...c]), {
1016
- data: m,
1017
- loading: !p && v,
1018
- error: w,
1019
- loadingMore: p,
1020
- noMore: g,
1021
- loadMore: S,
1022
- loadMoreAsync: L,
1023
- reload: y(H),
1024
- reloadAsync: y(se),
1025
- mutate: h,
1026
- cancel: I
1027
- };
1028
- }, ke = (e, t, n) => {
1029
- const r = E(void 0), s = E(0);
1030
- Ne(t, r.current) || (s.current += 1), r.current = t, j(e, [s.current], n);
1031
- }, He = {
1032
- 0: 48,
1033
- 1: 49,
1034
- 2: 50,
1035
- 3: 51,
1036
- 4: 52,
1037
- 5: 53,
1038
- 6: 54,
1039
- 7: 55,
1040
- 8: 56,
1041
- 9: 57,
1042
- backspace: 8,
1043
- tab: 9,
1044
- enter: 13,
1045
- shift: 16,
1046
- ctrl: 17,
1047
- alt: 18,
1048
- pausebreak: 19,
1049
- capslock: 20,
1050
- esc: 27,
1051
- space: 32,
1052
- pageup: 33,
1053
- pagedown: 34,
1054
- end: 35,
1055
- home: 36,
1056
- leftarrow: 37,
1057
- uparrow: 38,
1058
- rightarrow: 39,
1059
- downarrow: 40,
1060
- insert: 45,
1061
- delete: 46,
1062
- a: 65,
1063
- b: 66,
1064
- c: 67,
1065
- d: 68,
1066
- e: 69,
1067
- f: 70,
1068
- g: 71,
1069
- h: 72,
1070
- i: 73,
1071
- j: 74,
1072
- k: 75,
1073
- l: 76,
1074
- m: 77,
1075
- n: 78,
1076
- o: 79,
1077
- p: 80,
1078
- q: 81,
1079
- r: 82,
1080
- s: 83,
1081
- t: 84,
1082
- u: 85,
1083
- v: 86,
1084
- w: 87,
1085
- x: 88,
1086
- y: 89,
1087
- z: 90,
1088
- leftwindowkey: 91,
1089
- rightwindowkey: 92,
1090
- meta: et ? [91, 93] : [91, 92],
1091
- selectkey: 93,
1092
- numpad0: 96,
1093
- numpad1: 97,
1094
- numpad2: 98,
1095
- numpad3: 99,
1096
- numpad4: 100,
1097
- numpad5: 101,
1098
- numpad6: 102,
1099
- numpad7: 103,
1100
- numpad8: 104,
1101
- numpad9: 105,
1102
- multiply: 106,
1103
- add: 107,
1104
- subtract: 109,
1105
- decimalpoint: 110,
1106
- divide: 111,
1107
- f1: 112,
1108
- f2: 113,
1109
- f3: 114,
1110
- f4: 115,
1111
- f5: 116,
1112
- f6: 117,
1113
- f7: 118,
1114
- f8: 119,
1115
- f9: 120,
1116
- f10: 121,
1117
- f11: 122,
1118
- f12: 123,
1119
- numlock: 144,
1120
- scrolllock: 145,
1121
- semicolon: 186,
1122
- equalsign: 187,
1123
- comma: 188,
1124
- dash: 189,
1125
- period: 190,
1126
- forwardslash: 191,
1127
- graveaccent: 192,
1128
- openbracket: 219,
1129
- backslash: 220,
1130
- closebracket: 221,
1131
- singlequote: 222
1132
- }, de = {
1133
- ctrl: (e) => e.ctrlKey,
1134
- shift: (e) => e.shiftKey,
1135
- alt: (e) => e.altKey,
1136
- meta: (e) => e.type === "keyup" ? He.meta.includes(e.keyCode) : e.metaKey
1137
- };
1138
- function _e(e) {
1139
- return ee(e) || F(e);
1140
- }
1141
- function Dt(e) {
1142
- const t = Object.keys(de).reduce((n, r) => de[r](e) ? n + 1 : n, 0);
1143
- return [16, 17, 18, 91, 92].includes(e.keyCode) ? t : t + 1;
1144
- }
1145
- function Re(e, t, n) {
1146
- if (!e.key)
1147
- return !1;
1148
- if (F(t))
1149
- return e.keyCode === t ? t : !1;
1150
- const r = t.split(".");
1151
- let s = 0;
1152
- for (const o of r) {
1153
- const c = de[o], a = He[o.toLowerCase()];
1154
- (c && c(e) || a && a === e.keyCode) && s++;
1155
- }
1156
- return n ? s === r.length && Dt(e) === r.length ? t : !1 : s === r.length ? t : !1;
1157
- }
1158
- function Ct(e, t) {
1159
- return k(e) ? e : _e(e) ? (n) => Re(n, e, t) : Array.isArray(e) ? (n) => e.find((r) => Re(n, r, t)) : () => !!e;
1160
- }
1161
- const Mt = ["keydown"];
1162
- function kn(e, t, n) {
1163
- const {
1164
- events: r = Mt,
1165
- target: s,
1166
- exactMatch: o = !1,
1167
- useCapture: c = !1
1168
- } = n || {}, a = A(t), d = A(e);
1169
- ke(
1170
- () => {
1171
- const i = C(s, window);
1172
- if (!i)
1173
- return;
1174
- const l = (u) => {
1175
- const h = Ct(d.current, o)(u), p = _e(h) ? h : u.key;
1176
- if (h)
1177
- return a.current?.(u, p);
1178
- };
1179
- for (const u of r)
1180
- i?.addEventListener?.(u, l, c);
1181
- return () => {
1182
- for (const u of r)
1183
- i?.removeEventListener?.(u, l, c);
1184
- };
1185
- },
1186
- [r],
1187
- s
1188
- );
1189
- }
1190
- const Te = "HOOKS_SYNC_STORAGE_EVENT_NAME";
1191
- function Ie(e) {
1192
- function t(n, r = {}) {
1193
- let s;
1194
- const {
1195
- listenStorageChange: o = !1,
1196
- onError: c = (f) => {
1197
- console.error(f);
1198
- }
1199
- } = r;
1200
- try {
1201
- s = e();
1202
- } catch (f) {
1203
- c(f);
1204
- }
1205
- const a = (f) => r.serializer ? r.serializer(f) : JSON.stringify(f), d = (f) => r.deserializer ? r.deserializer(f) : JSON.parse(f);
1206
- function i() {
1207
- try {
1208
- const f = s?.getItem(n);
1209
- if (f)
1210
- return d(f);
1211
- } catch (f) {
1212
- c(f);
1213
- }
1214
- return k(r.defaultValue) ? r.defaultValue() : r.defaultValue;
1215
- }
1216
- const [l, u] = b(i);
1217
- K(() => {
1218
- u(i());
1219
- }, [n]);
1220
- const m = (f) => {
1221
- const T = k(f) ? f(l) : f;
1222
- o || u(T);
1223
- try {
1224
- let P;
1225
- const O = s?.getItem(n);
1226
- je(T) ? (P = null, s?.removeItem(n)) : (P = a(T), s?.setItem(n, P)), dispatchEvent(
1227
- // send custom event to communicate within same page
1228
- // importantly this should not be a StorageEvent since those cannot
1229
- // be constructed with a non-built-in storage area
1230
- new CustomEvent(Te, {
1231
- detail: {
1232
- key: n,
1233
- newValue: P,
1234
- oldValue: O,
1235
- storageArea: s
1236
- }
1237
- })
1238
- );
1239
- } catch (P) {
1240
- c(P);
1241
- }
1242
- }, h = (f) => {
1243
- f.key !== n || f.storageArea !== s || u(i());
1244
- }, p = (f) => {
1245
- h(f.detail);
1246
- };
1247
- return X("storage", h, {
1248
- enable: o
1249
- }), X(Te, p, {
1250
- enable: o
1251
- }), [
1252
- l,
1253
- y(m)
1254
- ];
1255
- }
1256
- return t;
1257
- }
1258
- const Hn = Ie(
1259
- () => q ? localStorage : void 0
1260
- );
1261
- function _n(e) {
1262
- const t = E(!1);
1263
- return V(
1264
- async (...n) => {
1265
- if (!t.current) {
1266
- t.current = !0;
1267
- try {
1268
- return await e(...n);
1269
- } catch (r) {
1270
- throw r;
1271
- } finally {
1272
- t.current = !1;
1273
- }
1274
- }
1275
- },
1276
- [e]
1277
- );
1278
- }
1279
- function In(e, t, { delay: n = 300, moveThreshold: r, onClick: s, onLongPressEnd: o } = {}) {
1280
- const c = A(e), a = A(s), d = A(o), i = E(void 0), l = E(!1), u = E({ x: 0, y: 0 }), m = E(!1), h = E(!1), p = !!(r?.x && r.x > 0 || r?.y && r.y > 0);
1281
- j(
1282
- () => {
1283
- const f = C(t);
1284
- if (!f?.addEventListener)
1285
- return;
1286
- const T = (S) => {
1287
- const { clientX: Y, clientY: L } = P(S), H = Math.abs(Y - u.current.x), se = Math.abs(L - u.current.y);
1288
- return !!(r?.x && H > r.x || r?.y && se > r.y);
1289
- };
1290
- function P(S) {
1291
- return "TouchEvent" in window && S instanceof TouchEvent ? {
1292
- clientX: S.touches[0].clientX,
1293
- clientY: S.touches[0].clientY
1294
- } : S instanceof MouseEvent ? {
1295
- clientX: S.clientX,
1296
- clientY: S.clientY
1297
- } : { clientX: 0, clientY: 0 };
1298
- }
1299
- const O = (S) => {
1300
- i.current = setTimeout(() => {
1301
- c.current(S), l.current = !0;
1302
- }, n);
1303
- }, g = (S) => {
1304
- if (!h.current) {
1305
- if (h.current = !0, p) {
1306
- const { clientX: Y, clientY: L } = P(S);
1307
- u.current.x = Y, u.current.y = L;
1308
- }
1309
- O(S);
1310
- }
1311
- }, v = (S) => {
1312
- S?.sourceCapabilities?.firesTouchEvents || (m.current = !0, p && (u.current.x = S.clientX, u.current.y = S.clientY), O(S));
1313
- }, w = (S) => {
1314
- i.current && T(S) && (clearTimeout(i.current), i.current = void 0);
1315
- }, R = (S) => {
1316
- h.current && (h.current = !1, i.current && (clearTimeout(i.current), i.current = void 0), l.current ? d.current?.(S) : a.current && a.current(S), l.current = !1);
1317
- }, N = (S) => {
1318
- S?.sourceCapabilities?.firesTouchEvents || m.current && (m.current = !1, i.current && (clearTimeout(i.current), i.current = void 0), l.current ? d.current?.(S) : a.current && a.current(S), l.current = !1);
1319
- }, I = (S) => {
1320
- m.current && (m.current = !1, i.current && (clearTimeout(i.current), i.current = void 0), l.current && (d.current?.(S), l.current = !1));
1321
- };
1322
- return f.addEventListener("mousedown", v), f.addEventListener("mouseup", N), f.addEventListener("mouseleave", I), f.addEventListener("touchstart", g), f.addEventListener("touchend", R), p && (f.addEventListener("mousemove", w), f.addEventListener("touchmove", w)), () => {
1323
- i.current && (clearTimeout(i.current), l.current = !1), f.removeEventListener("mousedown", v), f.removeEventListener("mouseup", N), f.removeEventListener("mouseleave", I), f.removeEventListener("touchstart", g), f.removeEventListener("touchend", R), p && (f.removeEventListener("mousemove", w), f.removeEventListener("touchmove", w));
1324
- };
1325
- },
1326
- [],
1327
- t
1328
- );
1329
- }
1330
- function he(e) {
1331
- const t = E(0), [n, r] = b(e), s = V((o) => {
1332
- cancelAnimationFrame(t.current), t.current = requestAnimationFrame(() => {
1333
- r(o);
1334
- });
1335
- }, []);
1336
- return W(() => {
1337
- cancelAnimationFrame(t.current);
1338
- }), [n, s];
1339
- }
1340
- const Nt = {
1341
- screenX: NaN,
1342
- screenY: NaN,
1343
- clientX: NaN,
1344
- clientY: NaN,
1345
- pageX: NaN,
1346
- pageY: NaN,
1347
- elementX: NaN,
1348
- elementY: NaN,
1349
- elementH: NaN,
1350
- elementW: NaN,
1351
- elementPosX: NaN,
1352
- elementPosY: NaN
1353
- }, Yn = (e) => {
1354
- const [t, n] = he(Nt);
1355
- return X(
1356
- "mousemove",
1357
- (r) => {
1358
- const { screenX: s, screenY: o, clientX: c, clientY: a, pageX: d, pageY: i } = r, l = {
1359
- screenX: s,
1360
- screenY: o,
1361
- clientX: c,
1362
- clientY: a,
1363
- pageX: d,
1364
- pageY: i,
1365
- elementX: NaN,
1366
- elementY: NaN,
1367
- elementH: NaN,
1368
- elementW: NaN,
1369
- elementPosX: NaN,
1370
- elementPosY: NaN
1371
- }, u = C(e);
1372
- if (u) {
1373
- const { left: m, top: h, width: p, height: f } = u.getBoundingClientRect();
1374
- l.elementPosX = m + window.pageXOffset, l.elementPosY = h + window.pageYOffset, l.elementX = d - l.elementPosX, l.elementY = i - l.elementPosY, l.elementW = p, l.elementH = f;
1375
- }
1376
- n(l);
1377
- },
1378
- {
1379
- target: () => document
1380
- }
1381
- ), t;
1382
- }, zn = (e, t, n = {}) => {
1383
- const r = A(e);
1384
- ke(
1385
- () => {
1386
- const s = C(t);
1387
- if (!s)
1388
- return;
1389
- const o = new MutationObserver(r.current);
1390
- return o.observe(s, n), () => {
1391
- o?.disconnect();
1392
- };
1393
- },
1394
- [n],
1395
- t
1396
- );
1397
- };
1398
- function Ye() {
1399
- const e = navigator;
1400
- return Ue(e) ? e.connection || e.mozConnection || e.webkitConnection : null;
1401
- }
1402
- function Ae() {
1403
- const e = Ye();
1404
- return e ? {
1405
- rtt: e.rtt,
1406
- type: e.type,
1407
- saveData: e.saveData,
1408
- downlink: e.downlink,
1409
- downlinkMax: e.downlinkMax,
1410
- effectiveType: e.effectiveType
1411
- } : {};
1412
- }
1413
- function Xn() {
1414
- const [e, t] = b(() => ({
1415
- since: void 0,
1416
- online: navigator?.onLine,
1417
- ...Ae()
1418
- }));
1419
- return D(() => {
1420
- const n = () => {
1421
- t((c) => ({
1422
- ...c,
1423
- online: !0,
1424
- since: /* @__PURE__ */ new Date()
1425
- }));
1426
- }, r = () => {
1427
- t((c) => ({
1428
- ...c,
1429
- online: !1,
1430
- since: /* @__PURE__ */ new Date()
1431
- }));
1432
- }, s = () => {
1433
- t((c) => ({
1434
- ...c,
1435
- ...Ae()
1436
- }));
1437
- };
1438
- window.addEventListener("online", n), window.addEventListener("offline", r);
1439
- const o = Ye();
1440
- return o?.addEventListener("change", s), () => {
1441
- window.removeEventListener("online", n), window.removeEventListener("offline", r), o?.removeEventListener(
1442
- "change",
1443
- s
1444
- );
1445
- };
1446
- }, []), e;
1447
- }
1448
- const Bn = (e, t = {}) => {
1449
- const { defaultPageSize: n = 10, defaultCurrent: r = 1, ...s } = t, o = Fe(e, {
1450
- defaultParams: [{ current: r, pageSize: n }],
1451
- refreshDepsAction: () => {
1452
- u(1);
1453
- },
1454
- ...s
1455
- }), { current: c = 1, pageSize: a = n } = o.params[0] || {}, d = o.data?.total || 0, i = x(
1456
- () => Math.ceil(d / a),
1457
- [a, d]
1458
- ), l = (h, p) => {
1459
- let f = h <= 0 ? 1 : h;
1460
- const T = p <= 0 ? 1 : p, P = Math.ceil(d / T);
1461
- f > P && (f = Math.max(1, P));
1462
- const [O = {}, ...g] = o.params || [];
1463
- o.run(
1464
- {
1465
- ...O,
1466
- current: f,
1467
- pageSize: T
1468
- },
1469
- ...g
1470
- );
1471
- }, u = (h) => {
1472
- l(h, a);
1473
- }, m = (h) => {
1474
- l(c, h);
1475
- };
1476
- return {
1477
- ...o,
1478
- pagination: {
1479
- current: c,
1480
- pageSize: a,
1481
- total: d,
1482
- totalPage: i,
1483
- onChange: y(l),
1484
- changeCurrent: y(u),
1485
- changePageSize: y(m)
1486
- }
1487
- };
1488
- }, Ot = (e, t = 0) => {
1489
- if (typeof requestAnimationFrame > "u")
1490
- return {
1491
- id: setInterval(e, t)
1492
- };
1493
- let n = Date.now();
1494
- const r = {
1495
- id: 0
1496
- }, s = () => {
1497
- Date.now() - n >= t && (e(), n = Date.now()), r.id = requestAnimationFrame(s);
1498
- };
1499
- return r.id = requestAnimationFrame(s), r;
1500
- }, xt = (e) => typeof cancelAnimationFrame > "u", Ft = (e) => {
1501
- if (xt(e.id))
1502
- return clearInterval(e.id);
1503
- cancelAnimationFrame(e.id);
1504
- };
1505
- function Vn(e, t, n) {
1506
- const r = n?.immediate, s = A(e), o = E(void 0), c = V(() => {
1507
- o.current && Ft(o.current);
1508
- }, []);
1509
- return D(() => {
1510
- if (!(!F(t) || t < 0))
1511
- return r && s.current(), o.current = Ot(() => {
1512
- s.current();
1513
- }, t), c;
1514
- }, [t]), c;
1515
- }
1516
- const kt = (e, t = 0) => {
1517
- if (typeof requestAnimationFrame > "u")
1518
- return {
1519
- id: setTimeout(e, t)
1520
- };
1521
- const n = {
1522
- id: 0
1523
- }, r = Date.now(), s = () => {
1524
- Date.now() - r >= t ? e() : n.id = requestAnimationFrame(s);
1525
- };
1526
- return n.id = requestAnimationFrame(s), n;
1527
- }, Ht = (e) => typeof cancelAnimationFrame > "u", _t = (e) => {
1528
- if (Ht(e.id))
1529
- return clearTimeout(e.id);
1530
- cancelAnimationFrame(e.id);
1531
- };
1532
- function qn(e, t) {
1533
- const n = A(e), r = E(void 0), s = V(() => {
1534
- r.current && _t(r.current);
1535
- }, []);
1536
- return D(() => {
1537
- if (!(!F(t) || t < 0))
1538
- return r.current = kt(() => {
1539
- n.current();
1540
- }, t), s;
1541
- }, [t]), s;
1542
- }
1543
- const Pe = /* @__PURE__ */ new WeakMap(), Le = /* @__PURE__ */ new WeakMap();
1544
- function ze(e, t) {
1545
- const n = Pe.get(e);
1546
- if (n)
1547
- return n;
1548
- if (Le.has(e))
1549
- return e;
1550
- const r = new Proxy(e, {
1551
- get(s, o, c) {
1552
- const a = Reflect.get(s, o, c), d = Reflect.getOwnPropertyDescriptor(s, o);
1553
- return !d?.configurable && !d?.writable ? a : fe(a) || Array.isArray(a) ? ze(a, t) : a;
1554
- },
1555
- set(s, o, c) {
1556
- const a = Reflect.set(s, o, c);
1557
- return t(), a;
1558
- },
1559
- deleteProperty(s, o) {
1560
- const c = Reflect.deleteProperty(s, o);
1561
- return t(), c;
1562
- }
1563
- });
1564
- return Pe.set(e, r), Le.set(r, e), r;
1565
- }
1566
- function jn(e) {
1567
- const t = te(), n = E(e);
1568
- return re(() => ze(n.current, () => {
1569
- t();
1570
- }), []);
1571
- }
1572
- const Un = (e) => {
1573
- const t = E(e), n = re(
1574
- () => k(t.current) ? t.current() : t.current,
1575
- []
1576
- ), [r, s] = b(n), o = y(() => {
1577
- s(n);
1578
- });
1579
- return [r, s, o];
1580
- }, Z = /* @__PURE__ */ new Set();
1581
- let U, me = {
1582
- xs: 0,
1583
- sm: 576,
1584
- md: 768,
1585
- lg: 992,
1586
- xl: 1200
1587
- };
1588
- function ie() {
1589
- const e = U;
1590
- if (pe(), e !== U)
1591
- for (const t of Z)
1592
- t();
1593
- }
1594
- let J = !1;
1595
- function pe() {
1596
- const e = window.innerWidth, t = {};
1597
- let n = !1;
1598
- for (const r of Object.keys(me))
1599
- t[r] = e >= me[r], t[r] !== U[r] && (n = !0);
1600
- n && (U = t);
1601
- }
1602
- function Wn(e) {
1603
- me = e, U && pe();
1604
- }
1605
- function $n() {
1606
- q && !J && (U = {}, pe(), window.addEventListener("resize", ie), J = !0);
1607
- const [e, t] = b(U);
1608
- return D(() => {
1609
- if (!q)
1610
- return;
1611
- J || window.addEventListener("resize", ie);
1612
- const n = () => {
1613
- t(U);
1614
- };
1615
- return Z.add(n), () => {
1616
- Z.delete(n), Z.size === 0 && (window.removeEventListener("resize", ie), J = !1);
1617
- };
1618
- }, []), e;
1619
- }
1620
- const It = () => {
1621
- const e = E(!1);
1622
- return D(() => (e.current = !1, () => {
1623
- e.current = !0;
1624
- }), []), e;
1625
- };
1626
- function Gn(e) {
1627
- const t = It(), [n, r] = b(e), s = V((o) => {
1628
- t.current || r(o);
1629
- }, []);
1630
- return [n, s];
1631
- }
1632
- function Kn(e, t = () => !0) {
1633
- const [n, r] = he(), s = A(t);
1634
- return j(
1635
- () => {
1636
- const o = C(e, document);
1637
- if (!o)
1638
- return;
1639
- const c = () => {
1640
- let a;
1641
- o === document ? document.scrollingElement ? a = {
1642
- left: document.scrollingElement.scrollLeft,
1643
- top: document.scrollingElement.scrollTop
1644
- } : a = {
1645
- left: Math.max(
1646
- window.pageXOffset,
1647
- document.documentElement.scrollLeft,
1648
- document.body.scrollLeft
1649
- ),
1650
- top: Math.max(
1651
- window.pageYOffset,
1652
- document.documentElement.scrollTop,
1653
- document.body.scrollTop
1654
- )
1655
- } : a = {
1656
- left: o.scrollLeft,
1657
- top: o.scrollTop
1658
- }, s.current(a) && r(a);
1659
- };
1660
- return c(), o.addEventListener("scroll", c), () => {
1661
- o.removeEventListener("scroll", c);
1662
- };
1663
- },
1664
- [],
1665
- e
1666
- ), n;
1667
- }
1668
- function Jn(e, t) {
1669
- let n = [], r;
1670
- Array.isArray(t) ? n = t : fe(t) && (n = t?.defaultSelected ?? n, r = t?.itemKey ?? r);
1671
- const s = (g) => k(r) ? r(g) : ee(r) && fe(g) ? g[r] : g, [o, c] = b(n), a = x(() => {
1672
- const g = /* @__PURE__ */ new Map();
1673
- return Array.isArray(o) && o.forEach((v) => {
1674
- g.set(s(v), v);
1675
- }), g;
1676
- }, [o]), d = (g) => a.has(s(g)), i = (g) => {
1677
- a.set(s(g), g), c(Array.from(a.values()));
1678
- }, l = (g) => {
1679
- a.delete(s(g)), c(Array.from(a.values()));
1680
- }, u = (g) => {
1681
- d(g) ? l(g) : i(g);
1682
- }, m = () => {
1683
- e.forEach((g) => {
1684
- a.set(s(g), g);
1685
- }), c(Array.from(a.values()));
1686
- }, h = () => {
1687
- e.forEach((g) => {
1688
- a.delete(s(g));
1689
- }), c(Array.from(a.values()));
1690
- }, p = x(
1691
- () => e.every((g) => !a.has(s(g))),
1692
- [e, a]
1693
- ), f = x(
1694
- () => e.every((g) => a.has(s(g))) && !p,
1695
- [e, a, p]
1696
- ), T = x(
1697
- () => !p && !f,
1698
- [p, f]
1699
- ), P = () => f ? h() : m(), O = () => {
1700
- a.clear(), c([]);
1701
- };
1702
- return {
1703
- selected: o,
1704
- noneSelected: p,
1705
- allSelected: f,
1706
- partiallySelected: T,
1707
- setSelected: c,
1708
- isSelected: d,
1709
- select: y(i),
1710
- unSelect: y(l),
1711
- toggle: y(u),
1712
- selectAll: y(m),
1713
- unSelectAll: y(h),
1714
- clearAll: y(O),
1715
- toggleAll: y(P)
1716
- };
1717
- }
1718
- const Qn = Ie(
1719
- () => q ? sessionStorage : void 0
1720
- ), Zn = (e) => {
1721
- const [t, n] = b(e), r = y((s) => {
1722
- n((o) => {
1723
- const c = k(s) ? s(o) : s;
1724
- return c ? { ...o, ...c } : o;
1725
- });
1726
- });
1727
- return [t, r];
1728
- }, Yt = Je(ge), zt = q ? Yt : j;
1729
- function Xt(e) {
1730
- const [t, n] = he(() => {
1731
- const r = C(e);
1732
- return r ? { width: r.clientWidth, height: r.clientHeight } : void 0;
1733
- });
1734
- return zt(
1735
- () => {
1736
- const r = C(e);
1737
- if (!r)
1738
- return;
1739
- const s = new ResizeObserver((o) => {
1740
- o.forEach((c) => {
1741
- const { clientWidth: a, clientHeight: d } = c.target;
1742
- n({ width: a, height: d });
1743
- });
1744
- });
1745
- return s.observe(r), () => {
1746
- s.disconnect();
1747
- };
1748
- },
1749
- [],
1750
- e
1751
- ), t;
1752
- }
1753
- const Bt = () => {
1754
- const e = q ? window.matchMedia("(prefers-color-scheme: dark)") : void 0, [t, n] = b(() => q && e?.matches ? "dark" : "light");
1755
- return D(() => {
1756
- const r = (s) => {
1757
- s.matches ? n(
1758
- "dark"
1759
- /* DARK */
1760
- ) : n(
1761
- "light"
1762
- /* LIGHT */
1763
- );
1764
- };
1765
- return e?.addEventListener("change", r), () => {
1766
- e?.removeEventListener("change", r);
1767
- };
1768
- }, []), t;
1769
- };
1770
- function er(e = {}) {
1771
- const { localStorageKey: t } = e, [n, r] = b(() => t?.length && localStorage.getItem(t) || "system"), s = (a) => {
1772
- r(a), t?.length && localStorage.setItem(t, a);
1773
- }, o = Bt();
1774
- return {
1775
- theme: n === "system" ? o : n,
1776
- themeMode: n,
1777
- setThemeMode: y(s)
1778
- };
1779
- }
1780
- function Xe(e, t) {
1781
- ne && (k(e) || console.error(
1782
- `useThrottleFn expected parameter is a function, got ${typeof e}`
1783
- ));
1784
- const n = A(e), r = t?.wait ?? 1e3, s = x(
1785
- () => Ce(
1786
- (...o) => n.current(...o),
1787
- r,
1788
- t
1789
- ),
1790
- []
1791
- );
1792
- return W(() => {
1793
- s.cancel();
1794
- }), {
1795
- run: s,
1796
- cancel: s.cancel,
1797
- flush: s.flush
1798
- };
1799
- }
1800
- function tr(e, t) {
1801
- const [n, r] = b(e), { run: s } = Xe(() => {
1802
- r(e);
1803
- }, t);
1804
- return D(() => {
1805
- s();
1806
- }, [e]), n;
1807
- }
1808
- function nr(e, t, n) {
1809
- const [r, s] = b({}), { run: o } = Xe(() => {
1810
- s({});
1811
- }, n);
1812
- D(() => o(), t), K(e, [r]);
1813
- }
1814
- const rr = (e, t) => {
1815
- const n = y(e), r = E(null), s = V(() => {
1816
- r.current && clearTimeout(r.current);
1817
- }, []);
1818
- return D(() => {
1819
- if (!(!F(t) || t < 0))
1820
- return r.current = setTimeout(n, t), s;
1821
- }, [t]), s;
1822
- }, Vt = {
1823
- restoreOnUnmount: !1
1824
- };
1825
- function sr(e, t = Vt) {
1826
- const n = E(q ? document.title : "");
1827
- D(() => {
1828
- document.title = e;
1829
- }, [e]), W(() => {
1830
- t.restoreOnUnmount && (document.title = n.current);
1831
- });
1832
- }
1833
- const qt = (e, t) => e ? e.map((n, r) => Object.is(e[r], t?.[r]) ? -1 : r).filter((n) => n >= 0) : t ? t.map((n, r) => r) : [], or = (e, t) => {
1834
- const n = E(void 0);
1835
- D(() => {
1836
- const r = qt(n.current, t), s = n.current;
1837
- return n.current = t, e(r, s, t);
1838
- }, t);
1839
- }, cr = Ze(ge), le = tt, jt = {
1840
- parseNumbers: !1,
1841
- parseBooleans: !1
1842
- }, Ut = {
1843
- skipNull: !1,
1844
- skipEmptyString: !1
1845
- }, ar = (e, t) => {
1846
- const {
1847
- navigateMode: n = "push",
1848
- parseOptions: r,
1849
- stringifyOptions: s
1850
- } = t || {}, o = { ...jt, ...r }, c = {
1851
- ...Ut,
1852
- ...s
1853
- }, a = le.useLocation(), d = le.useHistory?.(), i = le.useNavigate?.(), l = te(), u = E(
1854
- typeof e == "function" ? e() : e || {}
1855
- ), m = x(() => ce.parse(a.search, o), [a.search]), h = x(
1856
- () => ({
1857
- ...u.current,
1858
- ...m
1859
- }),
1860
- [m]
1861
- );
1862
- return [h, y((f) => {
1863
- const T = typeof f == "function" ? f(h) : f;
1864
- l(), d && d[n](
1865
- {
1866
- hash: a.hash,
1867
- search: ce.stringify(
1868
- { ...m, ...T },
1869
- c
1870
- ) || "?"
1871
- },
1872
- a.state
1873
- ), i && i(
1874
- {
1875
- hash: a.hash,
1876
- search: ce.stringify(
1877
- { ...m, ...T },
1878
- c
1879
- ) || "?"
1880
- },
1881
- {
1882
- replace: n === "replace",
1883
- state: a.state
1884
- }
1885
- );
1886
- })];
1887
- }, ur = (e, t) => {
1888
- const { containerTarget: n, wrapperTarget: r, itemHeight: s, overscan: o = 5 } = t, c = A(s), a = Xt(n), d = E(!1), [i, l] = b(
1889
- []
1890
- ), [u, m] = b({}), h = (g, v) => {
1891
- if (F(c.current))
1892
- return Math.ceil(g / c.current);
1893
- let w = 0, R = 0;
1894
- for (let N = v; N < e.length; N++) {
1895
- const I = c.current(N, e[N]);
1896
- if (w += I, R = N, w >= g)
1897
- break;
1898
- }
1899
- return R - v;
1900
- }, p = (g) => {
1901
- if (F(c.current))
1902
- return Math.floor(g / c.current);
1903
- let v = 0, w = 0;
1904
- for (let R = 0; R < e.length; R++) {
1905
- const N = c.current(R, e[R]);
1906
- if (v += N, v >= g) {
1907
- w = R;
1908
- break;
1909
- }
1910
- }
1911
- return w + 1;
1912
- }, f = (g) => F(c.current) ? g * c.current : e.slice(0, g).reduce(
1913
- (w, R, N) => w + c.current(N, e[N]),
1914
- 0
1915
- ), T = x(() => F(c.current) ? e.length * c.current : e.reduce(
1916
- (g, v, w) => g + c.current(w, e[w]),
1917
- 0
1918
- ), [e]), P = () => {
1919
- const g = C(n);
1920
- if (g) {
1921
- const { scrollTop: v, clientHeight: w } = g, R = p(v), N = h(w, R), I = Math.max(0, R - o), S = Math.min(e.length, R + N + o), Y = f(I);
1922
- m({
1923
- height: T - Y + "px",
1924
- marginTop: Y + "px"
1925
- }), l(
1926
- e.slice(I, S).map((L, H) => ({
1927
- data: L,
1928
- index: H + I
1929
- }))
1930
- );
1931
- }
1932
- };
1933
- return K(() => {
1934
- const g = C(r);
1935
- g && Object.keys(u).forEach(
1936
- (v) => g.style[v] = u[v]
1937
- );
1938
- }, [u]), D(() => {
1939
- !a?.width || !a?.height || P();
1940
- }, [a?.width, a?.height, e]), X(
1941
- "scroll",
1942
- (g) => {
1943
- if (d.current) {
1944
- d.current = !1;
1945
- return;
1946
- }
1947
- g.preventDefault(), P();
1948
- },
1949
- {
1950
- target: n
1951
- }
1952
- ), [i, y((g) => {
1953
- const v = C(n);
1954
- v && (d.current = !0, v.scrollTop = f(g), P());
1955
- })];
1956
- };
1957
- function ir(e, t = {}) {
1958
- const {
1959
- reconnectLimit: n = 3,
1960
- reconnectInterval: r = 3 * 1e3,
1961
- manual: s = !1,
1962
- onOpen: o,
1963
- onClose: c,
1964
- onMessage: a,
1965
- onError: d,
1966
- protocols: i
1967
- } = t, [l, u] = b(), [m, h] = b(
1968
- 3
1969
- /* Closed */
1970
- ), p = A(o), f = A(c), T = A(a), P = A(d), O = A(m), g = E(0), v = E(void 0), w = E(void 0), R = () => {
1971
- g.current < n && w.current?.readyState !== 1 && (v.current && clearTimeout(v.current), v.current = setTimeout(() => {
1972
- N(), g.current++;
1973
- }, r));
1974
- }, N = () => {
1975
- v.current && clearTimeout(v.current), w.current && w.current.close();
1976
- const L = new WebSocket(e, i);
1977
- h(
1978
- 0
1979
- /* Connecting */
1980
- ), L.onerror = (H) => {
1981
- w.current === L && (R(), P.current?.(H, L), h(
1982
- L.readyState || 3
1983
- /* Closed */
1984
- ));
1985
- }, L.onopen = (H) => {
1986
- w.current === L && (p.current?.(H, L), g.current = 0, h(
1987
- L.readyState || 1
1988
- /* Open */
1989
- ));
1990
- }, L.onmessage = (H) => {
1991
- w.current === L && (T.current?.(H, L), u(H));
1992
- }, L.onclose = (H) => {
1993
- f.current?.(H, L), w.current === L && R(), (!w.current || w.current === L) && h(
1994
- L.readyState || 3
1995
- /* Closed */
1996
- );
1997
- }, w.current = L;
1998
- }, I = (L) => {
1999
- if (O.current === 1)
2000
- w.current?.send(L);
2001
- else
2002
- throw new Error("WebSocket disconnected");
2003
- }, S = () => {
2004
- g.current = 0, N();
2005
- }, Y = () => {
2006
- v.current && clearTimeout(v.current), g.current = n, w.current?.close(), w.current = void 0;
2007
- };
2008
- return D(() => {
2009
- !s && e && S();
2010
- }, [e, s]), W(() => {
2011
- Y();
2012
- }), {
2013
- latestMessage: l,
2014
- sendMessage: y(I),
2015
- connect: y(S),
2016
- disconnect: y(Y),
2017
- readyState: m,
2018
- webSocketIns: w.current
2019
- };
2020
- }
2021
- function lr(e, t) {
2022
- const n = E({});
2023
- D(() => {
2024
- if (n.current) {
2025
- const r = Object.keys({ ...n.current, ...t }), s = {};
2026
- r.forEach((o) => {
2027
- Object.is(n.current[o], t[o]) || (s[o] = {
2028
- from: n.current[o],
2029
- to: t[o]
2030
- });
2031
- }), Object.keys(s).length && console.log("[why-did-you-update]", e, s);
2032
- }
2033
- n.current = t;
2034
- });
2035
- }
2036
- export {
2037
- rr as $,
2038
- On as A,
2039
- kn as B,
2040
- Hn as C,
2041
- _n as D,
2042
- In as E,
2043
- xe as F,
2044
- Yn as G,
2045
- zn as H,
2046
- Xn as I,
2047
- Bn as J,
2048
- Vn as K,
2049
- he as L,
2050
- qn as M,
2051
- jn as N,
2052
- Fe as O,
2053
- Un as P,
2054
- $n as Q,
2055
- Gn as R,
2056
- Kn as S,
2057
- Jn as T,
2058
- Qn as U,
2059
- Zn as V,
2060
- Xt as W,
2061
- er as X,
2062
- tr as Y,
2063
- nr as Z,
2064
- Xe as _,
2065
- Wn as a,
2066
- sr as a0,
2067
- rt as a1,
2068
- or as a2,
2069
- It as a3,
2070
- cr as a4,
2071
- ar as a5,
2072
- ur as a6,
2073
- ir as a7,
2074
- lr as a8,
2075
- st as b,
2076
- xn as c,
2077
- mn as d,
2078
- gn as e,
2079
- hn as f,
2080
- pn as g,
2081
- vn as h,
2082
- yn as i,
2083
- En as j,
2084
- Me as k,
2085
- wn as l,
2086
- Sn as m,
2087
- bn as n,
2088
- Rn as o,
2089
- Tn as p,
2090
- X as q,
2091
- An as r,
2092
- Pn as s,
2093
- Ln as t,
2094
- dn as u,
2095
- Dn as v,
2096
- Cn as w,
2097
- Mn as x,
2098
- Nn as y,
2099
- Fn as z
2100
- };