@flemist/simple-utils 2.1.4 → 2.1.6

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 (51) hide show
  1. package/build/browser/index.cjs +1 -1
  2. package/build/browser/index.mjs +175 -146
  3. package/build/common/async/Locker.d.ts +28 -0
  4. package/build/common/async/index.d.ts +2 -0
  5. package/build/common/async/promise.d.ts +7 -0
  6. package/build/common/cache/Cache.d.ts +46 -0
  7. package/build/common/cache/CacheStats.d.ts +20 -0
  8. package/build/common/cache/MemoryStorage.d.ts +11 -0
  9. package/build/common/cache/getHashKey.d.ts +1 -0
  10. package/build/common/cache/getJsonKey.d.ts +1 -0
  11. package/build/common/cache/index.d.ts +6 -0
  12. package/build/common/cache/types.d.ts +28 -0
  13. package/build/common/converter/converterErrorToBuffer.d.ts +2 -0
  14. package/build/common/converter/converterJson.d.ts +2 -0
  15. package/build/common/converter/converterJsonBuffer.d.ts +2 -0
  16. package/build/common/converter/converterStringToBuffer.d.ts +2 -0
  17. package/build/common/converter/helpers.d.ts +13 -0
  18. package/build/common/converter/index.d.ts +8 -0
  19. package/build/common/converter/mapObjectConverter.d.ts +2 -0
  20. package/build/common/converter/setArrayConverter.d.ts +2 -0
  21. package/build/common/converter/types.d.ts +41 -0
  22. package/build/common/gzip/compressGzip.d.ts +35 -0
  23. package/build/common/gzip/decompressGzip.d.ts +2 -0
  24. package/build/common/gzip/index.d.ts +2 -0
  25. package/build/common/index.cjs +1 -1
  26. package/build/common/index.d.ts +3 -0
  27. package/build/common/index.mjs +175 -146
  28. package/build/common/string/index.d.ts +1 -1
  29. package/build/node/cache/FileStatStorage.d.ts +23 -0
  30. package/build/node/cache/FileStorage.d.ts +29 -0
  31. package/build/node/cache/createConverterSubPath.d.ts +12 -0
  32. package/build/node/cache/createFileCacheOptions.d.ts +15 -0
  33. package/build/node/cache/generateTempFileName.d.ts +1 -0
  34. package/build/node/cache/index.d.ts +6 -0
  35. package/build/node/cache/writeFileThroughTmp.d.ts +2 -0
  36. package/build/node/fs/index.d.ts +1 -0
  37. package/build/node/fs/readDirRecursive.d.ts +6 -0
  38. package/build/node/index.cjs +8 -8
  39. package/build/node/index.d.ts +1 -0
  40. package/build/node/index.mjs +1063 -606
  41. package/build/node/test/helpers/common.d.ts +2 -0
  42. package/build/node/test/helpers/createTestE2e.d.ts +30 -0
  43. package/build/node/test/helpers/index.d.ts +3 -0
  44. package/build/node/test/helpers/waitPageStable.d.ts +35 -0
  45. package/build/node/test/index.d.ts +1 -0
  46. package/build/urlGet-BoqnOos7.js +17 -0
  47. package/build/urlGet-OHY_Qdk-.mjs +2416 -0
  48. package/package.json +37 -38
  49. package/build/common/time/dateToString.d.ts +0 -2
  50. package/build/urlGet-CerQ1cKh.js +0 -17
  51. package/build/urlGet-DZEwtNXt.mjs +0 -2000
@@ -0,0 +1,2416 @@
1
+ import { AbortControllerFast as It, AbortError as te, toAbortSignal as ee } from "@flemist/abort-controller-fast";
2
+ import { timeControllerDefault as bt } from "@flemist/time-controller";
3
+ import { isPromiseLike as E, promiseLikeToPromise as Ot, delay as re, EMPTY_FUNC as ne, ValueState as se } from "@flemist/async-utils";
4
+ import { gzip as ie, gunzip as oe } from "fflate";
5
+ function ae(t) {
6
+ if (!t || t.timeout == null)
7
+ return null;
8
+ const e = new It(), r = t.timeController ?? bt;
9
+ if (t.timeout) {
10
+ const n = r.setTimeout(() => {
11
+ e.abort(
12
+ new te(
13
+ `[timeoutAbortController] Timeout error: ${t.timeout}ms`
14
+ )
15
+ );
16
+ }, t.timeout);
17
+ e.signal.subscribe(() => {
18
+ clearTimeout(n);
19
+ });
20
+ }
21
+ return t.abortSignal?.subscribe((n) => {
22
+ e.abort(n);
23
+ }), e;
24
+ }
25
+ async function br(t, e) {
26
+ const r = ae(e);
27
+ try {
28
+ return await t(r?.signal ?? e?.abortSignal ?? null);
29
+ } finally {
30
+ r?.abort();
31
+ }
32
+ }
33
+ class Sr {
34
+ _options;
35
+ _hasValue = !1;
36
+ _promiseOrValue = null;
37
+ constructor(e) {
38
+ this._options = e;
39
+ }
40
+ run() {
41
+ if (!this._hasValue) {
42
+ let e = this._options.func();
43
+ const r = (s) => (this._options.persist ? this._promiseOrValue = s : (this._promiseOrValue = null, this._hasValue = !1), s), n = (s) => {
44
+ throw this._options.persist || (this._promiseOrValue = null, this._hasValue = !1), s;
45
+ };
46
+ if (E(e))
47
+ e = e.then(r, n);
48
+ else if (!this._options.persist)
49
+ return e;
50
+ this._promiseOrValue = e, this._hasValue = !0;
51
+ }
52
+ return this._promiseOrValue;
53
+ }
54
+ set(e) {
55
+ if (!this._options.persist)
56
+ throw new Error("[Lazy][set] Cannot set value when persist is false");
57
+ this._hasValue = !0, this._promiseOrValue = e;
58
+ }
59
+ }
60
+ class xr {
61
+ _options;
62
+ _promiseOrValues = /* @__PURE__ */ new Map();
63
+ constructor(e) {
64
+ this._options = e;
65
+ }
66
+ run(e) {
67
+ if (this._promiseOrValues.has(e))
68
+ return this._promiseOrValues.get(e);
69
+ let r = this._options.func(e);
70
+ const n = (i) => (this._options.persist ? this._promiseOrValues.set(e, i) : this._promiseOrValues.delete(e), i), s = (i) => {
71
+ throw this._options.persist || this._promiseOrValues.delete(e), i;
72
+ };
73
+ if (E(r))
74
+ r = r.then(n, s);
75
+ else if (!this._options.persist)
76
+ return r;
77
+ return this._promiseOrValues.set(e, r), r;
78
+ }
79
+ set(e, r) {
80
+ if (!this._options.persist)
81
+ throw new Error(
82
+ "[LazyWithId][set] Cannot set value when persist is false"
83
+ );
84
+ this._promiseOrValues.set(e, r);
85
+ }
86
+ }
87
+ class ue {
88
+ _lockPromise = null;
89
+ get hasQueued() {
90
+ return this._lockPromise != null;
91
+ }
92
+ lock(e) {
93
+ if (this._lockPromise)
94
+ return Ot(
95
+ this._lockPromise.then(() => this.lock(e))
96
+ );
97
+ const r = e();
98
+ if (E(r)) {
99
+ const n = r.then(
100
+ () => {
101
+ this._lockPromise === n && (this._lockPromise = null);
102
+ },
103
+ () => {
104
+ this._lockPromise === n && (this._lockPromise = null);
105
+ }
106
+ );
107
+ this._lockPromise = n;
108
+ }
109
+ return Ot(r);
110
+ }
111
+ }
112
+ class le {
113
+ _lockers = /* @__PURE__ */ new Map();
114
+ lock(e, r) {
115
+ let n = this._lockers.get(e);
116
+ n == null && (n = new ue(), this._lockers.set(e, n));
117
+ const s = () => {
118
+ n.hasQueued || this._lockers.delete(e);
119
+ };
120
+ let i;
121
+ try {
122
+ i = n.lock(r);
123
+ } catch (o) {
124
+ throw s(), o;
125
+ }
126
+ return E(i) ? i.then(
127
+ (o) => (s(), o),
128
+ (o) => {
129
+ throw s(), o;
130
+ }
131
+ ) : (s(), i);
132
+ }
133
+ hasQueued(e) {
134
+ const r = this._lockers.get(e);
135
+ return r != null && r.hasQueued;
136
+ }
137
+ }
138
+ var Ut = /* @__PURE__ */ ((t) => (t[t.none = 0] = "none", t[t.error = 1] = "error", t[t.warn = 2] = "warn", t[t.debug = 3] = "debug", t))(Ut || {});
139
+ async function Er(t) {
140
+ const e = t.abortSignal ?? null, r = t.timeController ?? bt;
141
+ let n = 0;
142
+ for (; ; )
143
+ try {
144
+ return await t.func({ abortSignal: e });
145
+ } catch (s) {
146
+ if ((t.logLevel == null || t.logLevel >= Ut.error) && console.error("[withRetry] error", s), e?.aborted)
147
+ throw s;
148
+ const i = t.delay({
149
+ error: s,
150
+ retryCount: n++,
151
+ abortSignal: e
152
+ });
153
+ if (i == null || (typeof i == "number" ? await re(i, e ?? void 0, r) : await i(), e?.aborted))
154
+ throw s;
155
+ }
156
+ }
157
+ function Or({
158
+ maxRetries: t,
159
+ delays: e,
160
+ isRetriableError: r
161
+ }) {
162
+ return function({ retryCount: s, error: i }) {
163
+ if (s == null || t != null && s >= t)
164
+ return null;
165
+ if (r == null || r(i)) {
166
+ if (Array.isArray(e))
167
+ return e[Math.min(s, e.length - 1)];
168
+ {
169
+ const o = e.mult ?? 2;
170
+ return Math.min(e.min * o ** s, e.max);
171
+ }
172
+ }
173
+ return null;
174
+ };
175
+ }
176
+ async function I(t) {
177
+ const e = await Promise.allSettled(t), r = [];
178
+ return e.forEach((n) => {
179
+ if (n.status === "fulfilled")
180
+ r.push(n.value);
181
+ else
182
+ throw n.reason;
183
+ }), r;
184
+ }
185
+ class ce {
186
+ _options;
187
+ _statsMap = null;
188
+ _totalSize = null;
189
+ _initPromise = null;
190
+ constructor(e) {
191
+ this._options = e;
192
+ }
193
+ async loadStatsMap(e) {
194
+ const r = await this._options.storage.getEntries(), n = [];
195
+ r.forEach((s, i) => {
196
+ const o = this._options.converter ? this._options.converter.from(s) : s;
197
+ E(o) ? n.push(
198
+ o.then((a) => {
199
+ e(i, a);
200
+ })
201
+ ) : e(i, o);
202
+ }), await Promise.all(n);
203
+ }
204
+ init() {
205
+ return this._initPromise == null && (this._initPromise = this._init()), this._initPromise;
206
+ }
207
+ async _init() {
208
+ const e = /* @__PURE__ */ new Map();
209
+ let r = 0;
210
+ await this.loadStatsMap((n, s) => {
211
+ e.set(n, s), r += s.size;
212
+ }), this._statsMap = e, this._totalSize = r;
213
+ }
214
+ async getTotalSize() {
215
+ return await this.init(), this._totalSize;
216
+ }
217
+ async get(e) {
218
+ return await this.init(), this._statsMap.get(e) ?? null;
219
+ }
220
+ async set(e, r) {
221
+ if (await this.init(), r != null) {
222
+ const n = this._options.converter ? await this._options.converter.to(r) : r;
223
+ await this._options.storage.set(e, n);
224
+ const s = this._statsMap.get(e);
225
+ this._statsMap.set(e, r), this._totalSize += r.size - (s?.size ?? 0);
226
+ } else {
227
+ await this._options.storage.delete(e);
228
+ const n = this._statsMap.get(e);
229
+ n != null && (this._statsMap.delete(e), this._totalSize -= n.size);
230
+ }
231
+ }
232
+ async getEntries() {
233
+ return await this.init(), this._statsMap;
234
+ }
235
+ }
236
+ function fe(t, e) {
237
+ return t[1].dateUsed !== e[1].dateUsed ? t[1].dateUsed < e[1].dateUsed ? -1 : 1 : t[1].size !== e[1].size ? t[1].size < e[1].size ? -1 : 1 : t[1].dateModified !== e[1].dateModified ? t[1].dateModified < e[1].dateModified ? -1 : 1 : t[0] !== e[0] ? t[0] < e[0] ? -1 : 1 : 0;
238
+ }
239
+ class $r {
240
+ _options;
241
+ _timeController;
242
+ _locker;
243
+ _stats;
244
+ constructor(e) {
245
+ this._options = e, this._timeController = e.timeController ?? bt, this._locker = new le(), this._stats = new ce({
246
+ storage: e.storages.stat,
247
+ converter: e.converterStat
248
+ });
249
+ }
250
+ async freeUpSpace(e, r, n) {
251
+ if (this._options.totalSize == null)
252
+ return;
253
+ const s = this._options.totalSize[0], i = this._options.totalSize[1];
254
+ if (n > i)
255
+ throw new Error(
256
+ `[Cache][freeUpSpace] value size (${n}) exceeds maximum total size (${i})`
257
+ );
258
+ let o = await this._stats.getTotalSize();
259
+ if (o += n - (r ?? 0), o <= i)
260
+ return;
261
+ const a = [], u = await this._stats.getEntries(), l = Array.from(u.entries());
262
+ l.sort(fe), l.forEach(([c, d]) => {
263
+ if (c === e || this._locker.hasQueued(c))
264
+ return;
265
+ const f = -d.size;
266
+ (o > i || o + f > s) && (a.push(
267
+ this._locker.lock(c, async () => (await I([
268
+ this._options.storages.value.delete(c),
269
+ this._options.storages.error.delete(c)
270
+ ]), this._stats.set(c, null)))
271
+ ), o += f);
272
+ }), await I(a);
273
+ }
274
+ async getOrCreate(e, r) {
275
+ const n = this._options.converterInput ? await this._options.converterInput(e) : e;
276
+ return this._locker.lock(n, async () => {
277
+ let s = await this._stats.get(n);
278
+ if (s == null || this._options.isExpired != null && this._options.isExpired(s))
279
+ await I([
280
+ this._options.storages.value.delete(n),
281
+ this._options.storages.error.delete(n),
282
+ this._stats.set(n, null)
283
+ ]), s = null;
284
+ else {
285
+ const [p, f] = await Promise.all([
286
+ this._options.storages.value.get(n),
287
+ this._options.storages.error.get(n)
288
+ ]), h = this._timeController.now();
289
+ if (!s.hasError && p != null) {
290
+ const m = {
291
+ ...s,
292
+ dateUsed: h
293
+ }, y = this._options.converterValue ? await this._options.converterValue.from(p) : p;
294
+ return await this._stats.set(n, m), y;
295
+ }
296
+ if (s.hasError && f != null) {
297
+ const m = {
298
+ ...s,
299
+ dateUsed: h
300
+ }, y = this._options.converterError ? await this._options.converterError.from(f) : f;
301
+ throw await this._stats.set(n, m), y;
302
+ }
303
+ }
304
+ let i = null, o = null, a = !1;
305
+ try {
306
+ i = await r(e);
307
+ } catch (p) {
308
+ o = p, a = !0;
309
+ }
310
+ if (a) {
311
+ const p = this._options.converterError ? await this._options.converterError.to(o) : o, f = this._options.getSize.error(p) + this._options.getSize.stat();
312
+ await this.freeUpSpace(n, s?.size, f), await I([
313
+ this._options.storages.error.set(n, p),
314
+ this._options.storages.value.delete(n)
315
+ ]);
316
+ const h = this._timeController.now(), m = {
317
+ dateModified: h,
318
+ dateUsed: h,
319
+ size: f,
320
+ hasError: !0
321
+ };
322
+ throw await this._stats.set(n, m), o;
323
+ }
324
+ const u = this._options.converterValue ? await this._options.converterValue.to(i) : i, l = this._options.getSize.value(u) + this._options.getSize.stat();
325
+ await this.freeUpSpace(n, s?.size, l), await I([
326
+ this._options.storages.value.set(n, u),
327
+ this._options.storages.error.delete(n)
328
+ ]);
329
+ const c = this._timeController.now(), d = {
330
+ dateModified: c,
331
+ dateUsed: c,
332
+ size: l
333
+ };
334
+ return await this._stats.set(n, d), i;
335
+ });
336
+ }
337
+ async delete(e) {
338
+ const r = this._options.converterInput ? await this._options.converterInput(e) : e;
339
+ return this._locker.lock(r, async () => {
340
+ await I([
341
+ this._options.storages.value.delete(r),
342
+ this._options.storages.error.delete(r),
343
+ this._stats.set(r, null)
344
+ ]);
345
+ });
346
+ }
347
+ /**
348
+ * Deletes all cache entries at this moment.
349
+ * But does not prevent new entries from being added during the clearing process
350
+ */
351
+ async clear() {
352
+ const [e, r, n] = await Promise.all([
353
+ this._options.storages.value.getKeys(),
354
+ this._options.storages.error.getKeys(),
355
+ this._options.storages.stat.getKeys()
356
+ ]), s = /* @__PURE__ */ new Set([...e, ...r, ...n]), i = [];
357
+ s.forEach((o) => {
358
+ const a = this._locker.lock(o, async () => {
359
+ const u = [], l = this._options.storages.value.delete(o);
360
+ E(l) && u.push(l);
361
+ const c = this._options.storages.error.delete(o);
362
+ E(c) && u.push(c);
363
+ const d = this._stats.set(o, null);
364
+ E(d) && u.push(d), await I(u);
365
+ });
366
+ E(a) && i.push(a);
367
+ }), await I(i);
368
+ }
369
+ }
370
+ class Mr {
371
+ _cache = /* @__PURE__ */ new Map();
372
+ set(e, r) {
373
+ this._cache.set(e, r);
374
+ }
375
+ get(e) {
376
+ return this._cache.get(e);
377
+ }
378
+ delete(e) {
379
+ this._cache.delete(e);
380
+ }
381
+ clear() {
382
+ this._cache.clear();
383
+ }
384
+ getKeys() {
385
+ return Array.from(this._cache.keys());
386
+ }
387
+ getEntries() {
388
+ return new Map(this._cache);
389
+ }
390
+ }
391
+ function $t(t) {
392
+ if (t == null)
393
+ return null;
394
+ if (Array.isArray(t)) {
395
+ const e = t.length, r = [];
396
+ for (let n = 0; n < e; n++)
397
+ r.push($t(t[n]));
398
+ return r;
399
+ }
400
+ if (typeof t == "object") {
401
+ if (t.constructor && t.constructor !== Object)
402
+ return t;
403
+ const e = {};
404
+ for (const r in t)
405
+ Object.prototype.hasOwnProperty.call(t, r) && (e[r] = $t(t[r]));
406
+ return e;
407
+ }
408
+ return t;
409
+ }
410
+ function Z(t, e) {
411
+ if (t === e)
412
+ return !0;
413
+ if (t == null)
414
+ return e == null;
415
+ if (e == null)
416
+ return !1;
417
+ if (Array.isArray(t)) {
418
+ if (!Array.isArray(e))
419
+ return !1;
420
+ const r = t.length;
421
+ if (r !== e.length)
422
+ return !1;
423
+ for (let n = 0; n < r; n++)
424
+ if (!Z(t[n], e[n]))
425
+ return !1;
426
+ return !0;
427
+ }
428
+ if (typeof t == "object") {
429
+ if (typeof e != "object" || t.constructor && t.constructor !== Object || e.constructor && e.constructor !== Object)
430
+ return !1;
431
+ for (const r in t)
432
+ if (Object.prototype.hasOwnProperty.call(t, r) && !Z(
433
+ t[r],
434
+ Object.prototype.hasOwnProperty.call(e, r) ? e[r] : null
435
+ ))
436
+ return !1;
437
+ for (const r in e)
438
+ if (Object.prototype.hasOwnProperty.call(e, r) && !Object.prototype.hasOwnProperty.call(t, r) && !Z(e[r], null))
439
+ return !1;
440
+ return !0;
441
+ }
442
+ return !1;
443
+ }
444
+ function Ar(t, e) {
445
+ if (t == null || e == null)
446
+ return t == null == (e == null);
447
+ if (t.size !== e.size)
448
+ return !1;
449
+ for (const [r, n] of t)
450
+ if (!Z(n, e.get(r)))
451
+ return !1;
452
+ return !0;
453
+ }
454
+ function Cr(t, e) {
455
+ const r = t.length;
456
+ if (r !== e.length)
457
+ return !1;
458
+ for (let n = 0; n < r; n++)
459
+ if (t[n] !== e[n])
460
+ return !1;
461
+ return !0;
462
+ }
463
+ function gt(t) {
464
+ return !t || typeof t != "object" ? t : Array.isArray(t) ? t.map(gt) : t && Object.keys(t).sort().reduce((e, r) => {
465
+ const n = gt(t[r]);
466
+ return n != null && (e[r] = n), e;
467
+ }, {});
468
+ }
469
+ function kr(t, e) {
470
+ return Object.defineProperty(t, "name", { value: e, configurable: !0 }), t;
471
+ }
472
+ function he(t) {
473
+ return t = gt(t), JSON.stringify(t ?? null);
474
+ }
475
+ let H = null;
476
+ function me() {
477
+ if (!H) {
478
+ H = new Array(256);
479
+ for (let t = 0; t < 256; t++)
480
+ H[t] = t.toString(16).padStart(2, "0");
481
+ }
482
+ return H;
483
+ }
484
+ function pe(t) {
485
+ const e = me(), r = new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
486
+ let n = "";
487
+ for (let s = 0, i = r.length; s < i; s++)
488
+ n += e[r[s]];
489
+ return n;
490
+ }
491
+ let yt = null, Pt = null, tt = null, zt = null;
492
+ function de() {
493
+ yt || (yt = new Uint32Array([
494
+ 1116352408,
495
+ 1899447441,
496
+ 3049323471,
497
+ 3921009573,
498
+ 961987163,
499
+ 1508970993,
500
+ 2453635748,
501
+ 2870763221,
502
+ 3624381080,
503
+ 310598401,
504
+ 607225278,
505
+ 1426881987,
506
+ 1925078388,
507
+ 2162078206,
508
+ 2614888103,
509
+ 3248222580,
510
+ 3835390401,
511
+ 4022224774,
512
+ 264347078,
513
+ 604807628,
514
+ 770255983,
515
+ 1249150122,
516
+ 1555081692,
517
+ 1996064986,
518
+ 2554220882,
519
+ 2821834349,
520
+ 2952996808,
521
+ 3210313671,
522
+ 3336571891,
523
+ 3584528711,
524
+ 113926993,
525
+ 338241895,
526
+ 666307205,
527
+ 773529912,
528
+ 1294757372,
529
+ 1396182291,
530
+ 1695183700,
531
+ 1986661051,
532
+ 2177026350,
533
+ 2456956037,
534
+ 2730485921,
535
+ 2820302411,
536
+ 3259730800,
537
+ 3345764771,
538
+ 3516065817,
539
+ 3600352804,
540
+ 4094571909,
541
+ 275423344,
542
+ 430227734,
543
+ 506948616,
544
+ 659060556,
545
+ 883997877,
546
+ 958139571,
547
+ 1322822218,
548
+ 1537002063,
549
+ 1747873779,
550
+ 1955562222,
551
+ 2024104815,
552
+ 2227730452,
553
+ 2361852424,
554
+ 2428436474,
555
+ 2756734187,
556
+ 3204031479,
557
+ 3329325298
558
+ ]), Pt = new Uint32Array(64), zt = new TextEncoder(), tt = new Uint8Array(65536));
559
+ }
560
+ function _e(t) {
561
+ if (t == null)
562
+ return null;
563
+ de();
564
+ const e = yt, r = Pt, n = zt;
565
+ let s = tt, i;
566
+ if (typeof t == "string") {
567
+ const w = t.length * 3;
568
+ s.length < w + 128 && (s = tt = new Uint8Array(w + 128));
569
+ const g = n.encodeInto(t, s);
570
+ i = s.subarray(0, g.written);
571
+ } else if (t instanceof Uint8Array)
572
+ i = t;
573
+ else if (ArrayBuffer.isView(t))
574
+ i = new Uint8Array(
575
+ t.buffer,
576
+ t.byteOffset,
577
+ t.byteLength
578
+ );
579
+ else
580
+ throw new Error(
581
+ `[sha256Buffer] Unsupported content type: ${typeof t}`
582
+ );
583
+ const o = i.length, a = o + 72 >>> 6 << 6;
584
+ s.length < a && (s = tt = new Uint8Array(a)), i !== s && s.set(i), s[o] = 128;
585
+ for (let w = o + 1; w < a; w++)
586
+ s[w] = 0;
587
+ const u = o * 8, l = u / 4294967296 | 0, c = u | 0;
588
+ s[a - 8] = l >>> 24, s[a - 7] = l >>> 16, s[a - 6] = l >>> 8, s[a - 5] = l, s[a - 4] = c >>> 24, s[a - 3] = c >>> 16, s[a - 2] = c >>> 8, s[a - 1] = c;
589
+ let d = 1779033703, p = -1150833019, f = 1013904242, h = -1521486534, m = 1359893119, y = -1694144372, S = 528734635, O = 1541459225;
590
+ for (let w = 0; w < a; w += 64) {
591
+ for (let b = 0; b < 16; b++) {
592
+ const x = w + (b << 2);
593
+ r[b] = s[x] << 24 | s[x + 1] << 16 | s[x + 2] << 8 | s[x + 3];
594
+ }
595
+ for (let b = 16; b < 64; b++) {
596
+ const x = r[b - 15], T = r[b - 2], ft = (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ x >>> 3, G = (T >>> 17 | T << 15) ^ (T >>> 19 | T << 13) ^ T >>> 10;
597
+ r[b] = r[b - 16] + ft + r[b - 7] + G | 0;
598
+ }
599
+ let g = d, M = p, q = f, lt = h, A = m, J = y, L = S, ct = O;
600
+ for (let b = 0; b < 64; b += 4)
601
+ for (let x = 0; x < 4; x++) {
602
+ const T = b + x, ft = (A >>> 6 | A << 26) ^ (A >>> 11 | A << 21) ^ (A >>> 25 | A << 7), G = ct + ft + (L ^ A & (J ^ L)) + e[T] + r[T] | 0, Zt = ((g >>> 2 | g << 30) ^ (g >>> 13 | g << 19) ^ (g >>> 22 | g << 10)) + (g & M ^ q & (g ^ M)) | 0;
603
+ ct = L, L = J, J = A, A = lt + G | 0, lt = q, q = M, M = g, g = G + Zt | 0;
604
+ }
605
+ d = d + g | 0, p = p + M | 0, f = f + q | 0, h = h + lt | 0, m = m + A | 0, y = y + J | 0, S = S + L | 0, O = O + ct | 0;
606
+ }
607
+ const $ = new Uint8Array(32), K = [d, p, f, h, m, y, S, O];
608
+ for (let w = 0; w < 8; w++) {
609
+ const g = K[w], M = w << 2;
610
+ $[M] = g >>> 24, $[M + 1] = g >>> 16 & 255, $[M + 2] = g >>> 8 & 255, $[M + 3] = g & 255;
611
+ }
612
+ return $;
613
+ }
614
+ function ge(t) {
615
+ const e = _e(t);
616
+ return e ? pe(e) : null;
617
+ }
618
+ function Tr(t) {
619
+ const e = he(t);
620
+ return ge(e);
621
+ }
622
+ function Ir(t, e) {
623
+ return t == null ? e : (r, n) => t(r, (s) => e(s, n));
624
+ }
625
+ function Ur(t, e) {
626
+ return t == null ? e : (r) => t(r, (n) => e(n));
627
+ }
628
+ function ye(t, e) {
629
+ return t == null ? e : (r, n) => t(r, (s) => e(s, n));
630
+ }
631
+ function we(t, e) {
632
+ return t == null ? e : (r, n) => t(r, (s) => e(s, n));
633
+ }
634
+ function be(t, e) {
635
+ return t == null ? e : {
636
+ to: ye(
637
+ (r, n) => t.to(r, n),
638
+ (r, n) => e.to(r, n)
639
+ )
640
+ };
641
+ }
642
+ function Se(t, e) {
643
+ return t == null ? e : {
644
+ from: we(
645
+ (r, n) => t.from(r, n),
646
+ (r, n) => e.from(r, n)
647
+ )
648
+ };
649
+ }
650
+ function Pr(t, e) {
651
+ return t == null ? e : {
652
+ to: be(t, e).to,
653
+ from: Se(t, e).from
654
+ };
655
+ }
656
+ function xe(t, e) {
657
+ return t == null ? e : (r) => t(r, (n) => e(n));
658
+ }
659
+ function Ee(t, e) {
660
+ return t == null ? e : (r) => t(r, (n) => e(n));
661
+ }
662
+ function Oe(t, e) {
663
+ return t == null ? e : {
664
+ to: xe(
665
+ (r, n) => t.to(r, n),
666
+ (r) => e.to(r)
667
+ )
668
+ };
669
+ }
670
+ function $e(t, e) {
671
+ return t == null ? e : {
672
+ from: Ee(
673
+ (r, n) => t.from(r, n),
674
+ (r) => e.from(r)
675
+ )
676
+ };
677
+ }
678
+ function zr(t, e) {
679
+ return t == null ? e : {
680
+ to: Oe(t, e).to,
681
+ from: $e(t, e).from
682
+ };
683
+ }
684
+ const Mt = {
685
+ to: (t) => JSON.stringify(t ?? null, null, 2),
686
+ from: (t) => JSON.parse(t)
687
+ }, et = {
688
+ to: (t) => new TextEncoder().encode(t),
689
+ from: (t) => new TextDecoder().decode(t)
690
+ }, Nr = {
691
+ to: (t) => {
692
+ const e = Mt.to(t);
693
+ return et.to(e);
694
+ },
695
+ from: (t) => {
696
+ const e = et.from(t);
697
+ return Mt.from(e);
698
+ }
699
+ };
700
+ function vr(t) {
701
+ return t == null ? null : t.replace(/[&<>"']/g, (e) => {
702
+ switch (e) {
703
+ case "&":
704
+ return "&amp;";
705
+ case "<":
706
+ return "&lt;";
707
+ case ">":
708
+ return "&rt;";
709
+ case '"':
710
+ return "&quot;";
711
+ default:
712
+ return "&#039;";
713
+ }
714
+ });
715
+ }
716
+ function Dr(t) {
717
+ return t == null ? null : t?.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&");
718
+ }
719
+ function Nt(t, e, r) {
720
+ const n = e == null ? t : new Date(
721
+ t.toLocaleString("en-US", {
722
+ timeZone: e
723
+ })
724
+ ), s = r == null ? t : new Date(
725
+ t.toLocaleString("en-US", {
726
+ timeZone: r
727
+ })
728
+ );
729
+ return new Date(
730
+ t.getTime() + s.getTime() - n.getTime()
731
+ );
732
+ }
733
+ function Me(t, e) {
734
+ t = Nt(t, "UTC", e);
735
+ const r = t.getUTCFullYear().toString().padStart(4, "0"), n = (t.getUTCMonth() + 1).toString().padStart(2, "0"), s = t.getUTCDate().toString().padStart(2, "0"), i = t.getUTCHours().toString().padStart(2, "0"), o = t.getUTCMinutes().toString().padStart(2, "0"), a = t.getUTCSeconds().toString().padStart(2, "0");
736
+ return `${r}-${n}-${s} ${i}:${o}:${a}`;
737
+ }
738
+ let Ae = 0;
739
+ const ht = /* @__PURE__ */ new WeakMap();
740
+ function j(t) {
741
+ if (ht.has(t))
742
+ return ht.get(t);
743
+ const e = Ae++;
744
+ return ht.set(t, e), e;
745
+ }
746
+ function Q(t, e, r) {
747
+ if (t == null)
748
+ return null;
749
+ if (e == null || t.length <= e)
750
+ return t;
751
+ const n = r?.appendEllipsis ? "…" : "", s = n.length + (r?.appendTruncatedLength ? String(t.length).length + 2 : 0), i = Math.max(0, e - s), o = r?.appendTruncatedLength ? `(${t.length - i})` : "";
752
+ return i <= 0 ? o + n : r?.fromStart ? o + n + t.slice(t.length - i) : t.slice(0, i) + n + o;
753
+ }
754
+ function At(t, e) {
755
+ try {
756
+ return t[e];
757
+ } catch (r) {
758
+ return "Error: " + (r instanceof Error ? r.message : String(r));
759
+ }
760
+ }
761
+ function U(t, e, r, n) {
762
+ const {
763
+ pretty: s,
764
+ filter: i,
765
+ maxDepth: o,
766
+ maxItems: a,
767
+ maxStringLength: u,
768
+ showObjectId: l,
769
+ showArrayIndex: c,
770
+ customToString: d
771
+ } = e ?? {};
772
+ if (r == null && (r = []), n == null && (n = /* @__PURE__ */ new Set()), d) {
773
+ const f = d(
774
+ t,
775
+ r,
776
+ (h) => U(h, e, r, n)
777
+ );
778
+ if (f != null)
779
+ return Q(f, u, e?.truncateOptions);
780
+ }
781
+ const p = r.length;
782
+ if (typeof t == "string")
783
+ return t = Q(t, u, e?.truncateOptions), n.size > 0 && (t = JSON.stringify(t)), t;
784
+ if (t == null || typeof t != "object")
785
+ return String(t);
786
+ if (t instanceof ArrayBuffer || ArrayBuffer.isView(t))
787
+ return `${t.constructor?.name ?? ""}#${j(t)}[${t.byteLength}]`;
788
+ if (t instanceof RegExp)
789
+ return Q(
790
+ String(t),
791
+ u,
792
+ e?.truncateOptions
793
+ );
794
+ if (t instanceof Date)
795
+ return Me(t);
796
+ if (t instanceof Object) {
797
+ if (n.has(t) || o != null && p >= o)
798
+ return `${t.constructor === Object ? "" : t.constructor?.name ?? ""}#${j(t)}`;
799
+ n.add(t);
800
+ }
801
+ if (t instanceof Error)
802
+ return Q(
803
+ t.stack || t.message || String(t),
804
+ u,
805
+ e?.truncateOptions
806
+ );
807
+ if (Array.isArray(t)) {
808
+ const f = s ? " ".repeat(p) : "";
809
+ let h = "";
810
+ l && (h += `#${j(t)} `), h += "[";
811
+ let m = 0, y = !1;
812
+ for (let S = 0; S < t.length; S++) {
813
+ if (a != null && m >= a) {
814
+ y = !0;
815
+ break;
816
+ }
817
+ const O = [...r, String(S)], $ = At(t, S);
818
+ if (i != null && !i(O, $))
819
+ continue;
820
+ const K = U($, e, O, n);
821
+ m > 0 && (h += ","), s && (h += `
822
+ `), s && (h += `${f} `), c && (h += `${S}: `), h += `${K}`, m++;
823
+ }
824
+ return y ? (m > 0 && (h += ","), s ? (h += `
825
+ `, h += `${f} ...
826
+ `) : h += "...", h += f, h += "]") : (m > 0 && s && (h += `
827
+ ${f}`), h += "]"), h;
828
+ }
829
+ if (t instanceof Map) {
830
+ let f = "";
831
+ return l && (f += `#${j(t)} `), f += "Map", f += U(Array.from(t.entries()), e, r, n), f;
832
+ }
833
+ if (t instanceof Set) {
834
+ let f = "";
835
+ return l && (f += `#${j(t)} `), f += "Set", f += U(Array.from(t.values()), e, r, n), f;
836
+ }
837
+ {
838
+ const f = t.constructor === Object ? "" : t.constructor?.name ?? "", h = s ? " ".repeat(p) : "";
839
+ let m = f ? `${f} ` : "";
840
+ l && (m += `#${j(t)} `), m += "{";
841
+ let y = 0, S = !1;
842
+ for (const O in t) {
843
+ if (a != null && y >= a) {
844
+ S = !0;
845
+ break;
846
+ }
847
+ const $ = [...r, O], K = At(t, O);
848
+ if (i != null && !i($, K))
849
+ continue;
850
+ const w = U(K, e, $, n);
851
+ y > 0 && (m += ","), s && (m += `
852
+ `), s && (m += `${h} `), m += `${O}: ${w}`, y++;
853
+ }
854
+ return S && (y > 0 && (m += ","), s ? (m += `
855
+ `, m += `${h} ...
856
+ `) : m += "...", m += h), y > 0 && s && !S && (m += `
857
+ ${h}`), m += "}", m;
858
+ }
859
+ }
860
+ function Ce(t, e) {
861
+ t = Nt(t, "UTC", e);
862
+ const r = t.getUTCFullYear().toString().padStart(4, "0"), n = (t.getUTCMonth() + 1).toString().padStart(2, "0"), s = t.getUTCDate().toString().padStart(2, "0"), i = t.getUTCHours().toString().padStart(2, "0"), o = t.getUTCMinutes().toString().padStart(2, "0"), a = t.getUTCSeconds().toString().padStart(2, "0");
863
+ return `${r}-${n}-${s}_${i}-${o}-${a}`;
864
+ }
865
+ const Rr = {
866
+ to: (t) => {
867
+ const e = U(t, {
868
+ pretty: !0,
869
+ maxDepth: 10,
870
+ maxItems: 50,
871
+ maxStringLength: 1e3
872
+ });
873
+ return et.to(e);
874
+ },
875
+ from: (t) => et.from(t)
876
+ }, Kr = {
877
+ to: (t) => Array.from(t.entries()).reduce((e, [r, n]) => (e[r] = n, e), {}),
878
+ from: (t) => new Map(Object.entries(t))
879
+ }, jr = {
880
+ to: (t) => Array.from(t),
881
+ from: (t) => new Set(t)
882
+ };
883
+ async function Vr(t, e) {
884
+ return new Promise((r, n) => {
885
+ ie(t, { level: e.level }, (s, i) => {
886
+ s ? n(s) : r(i);
887
+ });
888
+ });
889
+ }
890
+ function Lr(t) {
891
+ return t[0] === 31 && t[1] === 139;
892
+ }
893
+ async function Fr(t) {
894
+ return new Promise((e, r) => {
895
+ oe(t, (n, s) => {
896
+ n ? r(n) : e(s);
897
+ });
898
+ });
899
+ }
900
+ function ke(t, e) {
901
+ return t == null ? e : e == null ? t : Math.min(t, e);
902
+ }
903
+ function Te(t, e) {
904
+ return t == null ? e : e == null ? t : Math.max(t, e);
905
+ }
906
+ function Br(t, e, r) {
907
+ return Te(ke(t, e), r);
908
+ }
909
+ function Wr(t, e) {
910
+ return (t % e + e) % e;
911
+ }
912
+ function Ie(t) {
913
+ return function() {
914
+ let r = t += 1831565813;
915
+ return r = Math.imul(r ^ r >>> 15, r | 1), r ^= r + Math.imul(r ^ r >>> 7, r | 61), (r ^ r >>> 14) / 4294967296 + 0.5;
916
+ };
917
+ }
918
+ function Ue() {
919
+ return Math.random();
920
+ }
921
+ function qr() {
922
+ return Math.random() * 2 ** 32 >>> 0;
923
+ }
924
+ function Pe(t) {
925
+ return t != null ? Ie(t) : Ue;
926
+ }
927
+ class wt {
928
+ _seed;
929
+ _rnd;
930
+ constructor(e) {
931
+ this._seed = e, this._rnd = Pe(e);
932
+ }
933
+ get seed() {
934
+ return this._seed;
935
+ }
936
+ nextSeed() {
937
+ return this.next() * 2 ** 32 >>> 0;
938
+ }
939
+ nextRandom() {
940
+ return new wt(this.nextSeed());
941
+ }
942
+ next() {
943
+ return this._rnd();
944
+ }
945
+ clone() {
946
+ return new wt(this._seed);
947
+ }
948
+ }
949
+ function vt(t, e, r) {
950
+ if (r == null && (r = e, e = 0), r <= e)
951
+ throw new Error(
952
+ `[random][randomFloat] toExclusive (${r}) must be greater than from (${e})`
953
+ );
954
+ return t.next() * (r - e) + e;
955
+ }
956
+ function ze(t, e, r) {
957
+ return Math.floor(vt(t, e, r));
958
+ }
959
+ function Jr(t, e) {
960
+ return t.next() < (e ?? 0.5);
961
+ }
962
+ function Gr(t, e, r) {
963
+ if (Array.isArray(e)) {
964
+ const i = e;
965
+ e = i.length, r = (o) => i[o];
966
+ }
967
+ if (!r)
968
+ throw new Error("[random][randomIndexWeighted] getWeight is required");
969
+ let n = 0;
970
+ for (let i = 0; i < e; i++)
971
+ n += r(i);
972
+ if (n === 0)
973
+ return -1;
974
+ let s = vt(t, n);
975
+ for (let i = 0; i < e; i++)
976
+ if (s -= r(i), s < 0)
977
+ return i;
978
+ return e - 1;
979
+ }
980
+ function Dt(t, e) {
981
+ if (e.length === 0)
982
+ throw new Error("[random][randomItem] items is empty");
983
+ const r = ze(t, e.length);
984
+ return e[r];
985
+ }
986
+ function Hr(t, e, r) {
987
+ if (e.length === 0)
988
+ throw new Error("[random][randomItems] items is empty");
989
+ const n = [];
990
+ for (let s = 0; s < r; s++)
991
+ n.push(Dt(t, e));
992
+ return n;
993
+ }
994
+ function Qr(t, e, r) {
995
+ let n = Object.values(e);
996
+ return r && (n = n.filter(r)), Dt(t, n);
997
+ }
998
+ const Rt = 1073741789, mt = (Rt >> 2) - 1;
999
+ function Xr(t = mt, e) {
1000
+ if (t <= 0)
1001
+ throw new Error(`[random][PseudoRandom] count(${t}) must be > 0`);
1002
+ if (t > mt)
1003
+ throw new Error(
1004
+ `[random][PseudoRandom] count(${t}) must be <= ${mt}`
1005
+ );
1006
+ if (e == null && (e = Math.floor(Math.random() * t)), e >= t)
1007
+ throw new Error(
1008
+ `[random][PseudoRandom] startFrom(${e}) must be < count(${t})`
1009
+ );
1010
+ let r = e;
1011
+ return function() {
1012
+ return r = (r + Rt) % t, r;
1013
+ };
1014
+ }
1015
+ let F = null;
1016
+ function Yr() {
1017
+ const t = Date.now();
1018
+ return F == null || t > F ? (F = t, t) : (F++, F);
1019
+ }
1020
+ async function Zr({
1021
+ url: t,
1022
+ timeout: e
1023
+ } = {}) {
1024
+ t || (t = typeof window < "u" ? "/" : "https://google.com");
1025
+ let r;
1026
+ try {
1027
+ const n = new It();
1028
+ r = e ? setTimeout(() => {
1029
+ n.abort();
1030
+ }, e) : null;
1031
+ const s = await fetch(t, {
1032
+ method: "HEAD",
1033
+ signal: ee(n.signal)
1034
+ }), i = s.headers.get("date");
1035
+ if (!i)
1036
+ throw new Error(
1037
+ `[Now][getDateInet] No date header in response: ${s.status} ${t}`
1038
+ );
1039
+ return new Date(i).getTime();
1040
+ } finally {
1041
+ r && clearTimeout(r);
1042
+ }
1043
+ }
1044
+ function tn(t) {
1045
+ const e = alert;
1046
+ return window.alert = (r) => t(e, r), () => {
1047
+ window.alert = e;
1048
+ };
1049
+ }
1050
+ var B = /* @__PURE__ */ ((t) => (t.log = "log", t.warn = "warn", t.error = "error", t.info = "info", t.debug = "debug", t.trace = "trace", t.assert = "assert", t))(B || {});
1051
+ const Ct = Object.values(B);
1052
+ function N(t) {
1053
+ return function() {
1054
+ t.apply(console, arguments);
1055
+ };
1056
+ }
1057
+ const kt = {
1058
+ log: N(console.log),
1059
+ warn: N(console.warn),
1060
+ error: N(console.error),
1061
+ info: N(console.info),
1062
+ debug: N(console.debug),
1063
+ trace: N(console.trace),
1064
+ assert: N(console.assert)
1065
+ };
1066
+ function Kt(t) {
1067
+ return Ct.forEach((e) => {
1068
+ console[e] = (...r) => {
1069
+ t(kt, e, r);
1070
+ };
1071
+ }), () => {
1072
+ Ct.forEach((e) => {
1073
+ console[e] = kt[e];
1074
+ });
1075
+ };
1076
+ }
1077
+ function en(t) {
1078
+ return function(r) {
1079
+ let n = null;
1080
+ const i = Kt((a, u, l) => {
1081
+ try {
1082
+ t(a, u, l);
1083
+ } catch (c) {
1084
+ throw n || (n = c), c;
1085
+ }
1086
+ }), o = () => {
1087
+ if (i(), n)
1088
+ throw n;
1089
+ };
1090
+ try {
1091
+ const a = r();
1092
+ return E(a) ? a.then(
1093
+ (u) => (o(), u),
1094
+ (u) => {
1095
+ throw o(), u;
1096
+ }
1097
+ ) : (o(), a);
1098
+ } catch (a) {
1099
+ throw o(), a;
1100
+ }
1101
+ };
1102
+ }
1103
+ class jt {
1104
+ _listeners = /* @__PURE__ */ new Map();
1105
+ _listenersAdd = /* @__PURE__ */ new Map();
1106
+ _startStopNotifier;
1107
+ _emit;
1108
+ _update;
1109
+ _unsubscribeNotifier = null;
1110
+ _emitLast;
1111
+ _hasLast;
1112
+ _last = void 0;
1113
+ _emitting = !1;
1114
+ _subscribing = !1;
1115
+ _actionOnCycle;
1116
+ constructor({
1117
+ emitLastEvent: e,
1118
+ startStopNotifier: r,
1119
+ hasLast: n,
1120
+ last: s,
1121
+ actionOnCycle: i
1122
+ } = {}) {
1123
+ this._startStopNotifier = r ?? null, this._emit = r ? (o) => this.emit(o) : null, this._update = r ? (o) => this.update(o) : null, this._emitLast = e ?? !1, this._hasLast = n ?? !1, this._last = s, this._actionOnCycle = i ?? !1;
1124
+ }
1125
+ get hasLast() {
1126
+ return this._hasLast;
1127
+ }
1128
+ get last() {
1129
+ return this._last;
1130
+ }
1131
+ get hasListeners() {
1132
+ return this._listeners.size > 0;
1133
+ }
1134
+ subscribe(e) {
1135
+ const r = {};
1136
+ if (this._emitting ? this._listenersAdd.set(r, e) : this._listeners.set(r, e), this._subscribing && this._actionOnCycle === "throw")
1137
+ throw new Error("[Rx][Subject] Circular subscription detected");
1138
+ if ((this._hasLast || this._subscribing && this._actionOnCycle === "emitLast") && e(this._last), this._startStopNotifier && this._listeners.size + this._listenersAdd.size === 1)
1139
+ try {
1140
+ this._subscribing = !0, this._unsubscribeNotifier = this._startStopNotifier(this._emit, this._update) ?? null;
1141
+ } finally {
1142
+ this._subscribing = !1;
1143
+ }
1144
+ return () => {
1145
+ if (this._listeners.delete(r), this._listenersAdd.delete(r), this._startStopNotifier && this._listeners.size === 0 && this._listenersAdd.size === 0) {
1146
+ const n = this._unsubscribeNotifier;
1147
+ this._unsubscribeNotifier = null, n?.();
1148
+ }
1149
+ };
1150
+ }
1151
+ emit(e) {
1152
+ if (this._emitting) {
1153
+ if (this._actionOnCycle === "throw")
1154
+ throw new Error("[Rx][Subject] Circular emit detected");
1155
+ this._actionOnCycle === "emitLast" && (this._last = e, this._hasLast = !0);
1156
+ return;
1157
+ }
1158
+ const r = () => {
1159
+ this._listenersAdd.size > 0 && (this._listenersAdd.forEach((n, s) => {
1160
+ this._listeners.set(s, n);
1161
+ }), this._listenersAdd.clear()), this._emitting = !1;
1162
+ };
1163
+ try {
1164
+ this._emitting = !0, this._emitLast && (this._last = e, this._hasLast = !0);
1165
+ let n;
1166
+ if (this._listeners.forEach((s) => {
1167
+ const i = s(e);
1168
+ E(i) && (n || (n = []), n.push(i));
1169
+ }), n)
1170
+ return Promise.all(n).then(r, (s) => {
1171
+ throw r(), s;
1172
+ });
1173
+ r();
1174
+ } catch (n) {
1175
+ throw r(), n;
1176
+ }
1177
+ }
1178
+ update(e) {
1179
+ if (!this._emitLast)
1180
+ throw new Error(
1181
+ "[Rx][Subject] update available only for subjects with emitLastEvent"
1182
+ );
1183
+ const r = e(this._last);
1184
+ return this.emit(r);
1185
+ }
1186
+ }
1187
+ function Ne(t, e) {
1188
+ return U(t, {
1189
+ maxDepth: 5,
1190
+ maxItems: 10,
1191
+ ...e
1192
+ });
1193
+ }
1194
+ function ve(t) {
1195
+ return t.map(
1196
+ (e) => e && typeof e == "object" ? Ne(e) : e
1197
+ );
1198
+ }
1199
+ function rn(t) {
1200
+ return `${Ce(/* @__PURE__ */ new Date())} [${t.level.toUpperCase()}] ${ve(
1201
+ t.args
1202
+ ).join(" ")}`;
1203
+ }
1204
+ let rt = null, pt = null;
1205
+ function De() {
1206
+ return pt || (pt = new jt({
1207
+ startStopNotifier: (t) => (rt = t, () => {
1208
+ rt = null;
1209
+ })
1210
+ })), pt;
1211
+ }
1212
+ function nn() {
1213
+ return Kt((t, e, r) => {
1214
+ e === "assert" && r[0] === !0 || (e === B.error || e === B.warn || e === B.assert) && (rt && rt({
1215
+ date: Date.now(),
1216
+ level: e,
1217
+ args: r
1218
+ }), t[e](...r));
1219
+ });
1220
+ }
1221
+ function sn(t) {
1222
+ if (typeof window > "u")
1223
+ return ne;
1224
+ const { levels: e, predicate: r } = t;
1225
+ return De().subscribe((n) => {
1226
+ if (e && !e.includes(n.level))
1227
+ return;
1228
+ const s = n.args.join(`
1229
+ `);
1230
+ r && !r({ text: s, message: n }) || alert(s);
1231
+ });
1232
+ }
1233
+ function Re() {
1234
+ let t = new Error().stack;
1235
+ if (t != null) {
1236
+ const e = t.indexOf(`
1237
+ `);
1238
+ e != null && e >= 0 && (t = t.substring(e + 1));
1239
+ }
1240
+ return t ?? "";
1241
+ }
1242
+ function on(t) {
1243
+ return function(...e) {
1244
+ const r = Re();
1245
+ try {
1246
+ return t.apply(this, e);
1247
+ } catch (n) {
1248
+ throw n instanceof Error || (n = new Error(String(n))), n.stack = n.stack ? n.stack + `
1249
+ ` + r : r, n;
1250
+ }
1251
+ };
1252
+ }
1253
+ function an(t) {
1254
+ return t != null && typeof t == "object" && typeof t.subscribe == "function";
1255
+ }
1256
+ class un {
1257
+ _subjects = /* @__PURE__ */ new Map();
1258
+ _getLastEvent;
1259
+ constructor({
1260
+ getLastEvent: e
1261
+ } = {}) {
1262
+ this._getLastEvent = e;
1263
+ }
1264
+ subscribe(e, r) {
1265
+ let n = this._subjects.get(e);
1266
+ n || (n = new jt(), this._subjects.set(e, n));
1267
+ const s = n.subscribe(r);
1268
+ if (this._getLastEvent) {
1269
+ const i = this._getLastEvent(e);
1270
+ r(i);
1271
+ }
1272
+ return () => {
1273
+ s(), n?.hasListeners || this._subjects.delete(e);
1274
+ };
1275
+ }
1276
+ emit(e, r) {
1277
+ const n = this._subjects.get(e);
1278
+ if (n)
1279
+ return n.emit(r);
1280
+ }
1281
+ forEach(e) {
1282
+ this._subjects.forEach(e);
1283
+ }
1284
+ observable(e) {
1285
+ return {
1286
+ subscribe: (r) => this.subscribe(e, r)
1287
+ };
1288
+ }
1289
+ emitter(e) {
1290
+ return {
1291
+ emit: (r) => this.emit(e, r)
1292
+ };
1293
+ }
1294
+ subject(e) {
1295
+ return {
1296
+ subscribe: (r) => this.subscribe(e, r),
1297
+ emit: (r) => this.emit(e, r)
1298
+ };
1299
+ }
1300
+ }
1301
+ function ln(t, e, r) {
1302
+ return new Promise((n) => {
1303
+ let s = !1, i;
1304
+ function o(c) {
1305
+ u?.(), i?.(), s = !0, n(c);
1306
+ }
1307
+ function a(c) {
1308
+ u?.(), i?.(), s = !0, n(Promise.reject(c));
1309
+ }
1310
+ const u = r?.subscribe(a);
1311
+ let l = !0;
1312
+ i = t.subscribe((c) => {
1313
+ (!e || e(c, l)) && o(c), l = !1;
1314
+ }), s && i?.();
1315
+ });
1316
+ }
1317
+ class v extends Error {
1318
+ constructor(e) {
1319
+ super(e);
1320
+ }
1321
+ }
1322
+ class _ {
1323
+ _args;
1324
+ constructor(e) {
1325
+ this._args = e && { ...e };
1326
+ }
1327
+ set(e) {
1328
+ return this._args = {
1329
+ ...this._args ?? {},
1330
+ ...e
1331
+ }, this;
1332
+ }
1333
+ name(e) {
1334
+ return this.set({ name: e });
1335
+ }
1336
+ toString(e) {
1337
+ const r = this._args?.name;
1338
+ return r ? typeof r == "string" ? r : r(e) : this.nameDefault(e);
1339
+ }
1340
+ }
1341
+ function Vt(t, e) {
1342
+ return U(t, {
1343
+ maxDepth: 1,
1344
+ maxItems: 5,
1345
+ ...e
1346
+ });
1347
+ }
1348
+ function D(t) {
1349
+ return t instanceof _;
1350
+ }
1351
+ function it(t) {
1352
+ return Vt(t);
1353
+ }
1354
+ function St(t, ...e) {
1355
+ if (t == null)
1356
+ return "";
1357
+ const r = Vt(t, {
1358
+ filter: (n, s) => {
1359
+ if (n.length === 0)
1360
+ return !0;
1361
+ if (n.length !== 1)
1362
+ return !1;
1363
+ const i = n[0];
1364
+ return !(i === "name" || i === "expected" || s == null || s === !1 || e.includes(i));
1365
+ }
1366
+ });
1367
+ return /^(#\d+\s*)\{}$/.test(r) ? "" : `(${r})`;
1368
+ }
1369
+ function nt(t) {
1370
+ const { result: e, cause: r, nested: n, error: s } = t;
1371
+ if (s) {
1372
+ if (!(s instanceof Error))
1373
+ throw new v(
1374
+ `[test][validateMatchResult] error must be an instance of Error, but it is: ${s}`
1375
+ );
1376
+ if (e != null)
1377
+ throw new v(
1378
+ `[test][validateMatchResult] result must be null if error is set, but it is: ${e}`
1379
+ );
1380
+ if (r != null)
1381
+ throw new v(
1382
+ `[test][validateMatchResult] cause must be null if error is set, but it is: ${r}`
1383
+ );
1384
+ if (n != null)
1385
+ throw new v(
1386
+ `[test][validateMatchResult] nested must be null if error is set, but it is: ${n}`
1387
+ );
1388
+ return t;
1389
+ }
1390
+ if (typeof e != "boolean")
1391
+ throw new v(
1392
+ `[test][validateMatchResult] result must be a boolean, but it is: ${e}`
1393
+ );
1394
+ if (typeof r != "string" && r != null)
1395
+ throw new v(
1396
+ `[test][validateMatchResult] cause must be a string or null, but it is: ${r}`
1397
+ );
1398
+ if (n != null && !(n instanceof Array))
1399
+ throw new v(
1400
+ `[test][validateMatchResult] nested must be an array or null, but it is: ${n}`
1401
+ );
1402
+ return t;
1403
+ }
1404
+ function Ke(t, e, r) {
1405
+ return nt({
1406
+ actual: t,
1407
+ expected: e,
1408
+ result: null,
1409
+ cause: null,
1410
+ nested: null,
1411
+ error: r
1412
+ });
1413
+ }
1414
+ function Lt(t, e, r) {
1415
+ return nt({
1416
+ actual: t,
1417
+ expected: e,
1418
+ result: r,
1419
+ cause: null,
1420
+ nested: null,
1421
+ error: null
1422
+ });
1423
+ }
1424
+ function Ft(t, e, r) {
1425
+ return typeof r == "boolean" ? Lt(t, e, r) : nt(typeof r == "string" ? {
1426
+ actual: t,
1427
+ expected: e,
1428
+ result: !1,
1429
+ cause: r,
1430
+ nested: null,
1431
+ error: null
1432
+ } : {
1433
+ actual: t,
1434
+ expected: e,
1435
+ result: r.result,
1436
+ cause: r.cause ?? null,
1437
+ nested: r.nested ?? null,
1438
+ error: null
1439
+ });
1440
+ }
1441
+ function C(t, e) {
1442
+ try {
1443
+ if (D(e)) {
1444
+ const r = e.match(t);
1445
+ return Ft(t, e, r);
1446
+ }
1447
+ return Lt(t, e, t === e);
1448
+ } catch (r) {
1449
+ return Ke(t, e, r);
1450
+ }
1451
+ }
1452
+ class Bt extends _ {
1453
+ match(e) {
1454
+ const r = this._args.expected, n = C(e, r);
1455
+ return {
1456
+ result: !n.result,
1457
+ nested: [
1458
+ {
1459
+ actualKey: null,
1460
+ result: n
1461
+ }
1462
+ ]
1463
+ };
1464
+ }
1465
+ nameDefault() {
1466
+ return "not";
1467
+ }
1468
+ }
1469
+ function je(t, e) {
1470
+ const r = Wt(t.result, e);
1471
+ return r ? {
1472
+ actualKey: t.actualKey,
1473
+ expectedKey: t.expectedKey,
1474
+ result: r
1475
+ } : null;
1476
+ }
1477
+ function Wt(t, e) {
1478
+ if (e ? !t.result : t.result)
1479
+ return null;
1480
+ t.expected instanceof Bt && (e = !e);
1481
+ let r = null;
1482
+ return t.nested && t.nested.forEach((n) => {
1483
+ const s = je(n, e);
1484
+ s && (r || (r = []), r.push(s));
1485
+ }), {
1486
+ actual: t.actual,
1487
+ expected: t.expected,
1488
+ result: t.result,
1489
+ cause: t.cause,
1490
+ nested: r,
1491
+ error: t.error
1492
+ };
1493
+ }
1494
+ function Ve(t, e) {
1495
+ const r = qt(t.result, e + " ");
1496
+ return `${e}${t.actualKey == null ? "| " : t.actualKey + ": "}${r}`;
1497
+ }
1498
+ function qt(t, e) {
1499
+ if (t.result)
1500
+ return t.expected.toString();
1501
+ let r = "";
1502
+ t.nested && (r = t.nested.map((s) => Ve(s, e)).join(`
1503
+ `));
1504
+ let n = t.cause || "";
1505
+ return r ? (n || (n = D(t.expected) ? t.expected.toString(t.actual) : ""), `${n}
1506
+ ${r}`) : `${n}
1507
+ ${e}expected: ${D(t.expected) ? t.expected.toString(t.actual) : t.expected}
1508
+ ${e}actual: ${it(t.actual)}`;
1509
+ }
1510
+ class Jt extends Error {
1511
+ constructor(e) {
1512
+ super(e);
1513
+ }
1514
+ }
1515
+ function X(t) {
1516
+ return function(r, n) {
1517
+ const s = C(t, r);
1518
+ if (s.error)
1519
+ throw s.error;
1520
+ const i = Wt(s, !1);
1521
+ if (!i)
1522
+ return;
1523
+ const o = qt(i, "");
1524
+ console.log(`[test][check] CheckError:
1525
+ ` + o);
1526
+ const a = new Jt(o);
1527
+ throw n?.(a), a;
1528
+ };
1529
+ }
1530
+ function cn(t) {
1531
+ return function(r, n) {
1532
+ let s;
1533
+ try {
1534
+ s = t();
1535
+ } catch (i) {
1536
+ X(i)(n);
1537
+ return;
1538
+ }
1539
+ return E(s) ? s.then((i) => (X(i)(r), i)).catch((i) => {
1540
+ if (i instanceof Jt)
1541
+ throw i;
1542
+ try {
1543
+ X(i)(n);
1544
+ } catch (o) {
1545
+ throw console.error("[test][check] error", o), i;
1546
+ }
1547
+ }) : (X(s)(r), s);
1548
+ };
1549
+ }
1550
+ const ot = 10;
1551
+ class Gt extends _ {
1552
+ match(e) {
1553
+ if (e == null)
1554
+ return `Expected array, got "${e}"`;
1555
+ if (typeof e != "object")
1556
+ return `Expected array, got "${typeof e}"`;
1557
+ if (!(e instanceof Array))
1558
+ return "Expected array";
1559
+ const r = this._args?.expected;
1560
+ if (r == null)
1561
+ return !0;
1562
+ const n = this._args?.maxReportItems ?? ot, s = this._args?.matchType || "equals";
1563
+ if (s === "equals") {
1564
+ if (e.length !== r.length)
1565
+ return `Expected array length to be ${r.length}, got ${e.length}`;
1566
+ let i = !0, o = 0, a = 0;
1567
+ const u = [];
1568
+ for (let l = 0; l < r.length; l++) {
1569
+ const c = e[l], d = r[l], p = C(c, d);
1570
+ if (p.result ? (o < n && u.push({
1571
+ actualKey: l,
1572
+ expectedKey: l,
1573
+ result: p
1574
+ }), o++) : (a < n && u.push({
1575
+ actualKey: l,
1576
+ expectedKey: l,
1577
+ result: p
1578
+ }), a++, i = !1), !i && o >= n && a >= n)
1579
+ break;
1580
+ }
1581
+ return {
1582
+ result: i,
1583
+ nested: u
1584
+ };
1585
+ }
1586
+ if (s === "includes") {
1587
+ let i = !0;
1588
+ const o = [];
1589
+ let a = 0, u = 0;
1590
+ for (let l = 0; l < r.length; l++) {
1591
+ const c = r[l];
1592
+ let d = !1;
1593
+ for (let p = 0; p < e.length; p++) {
1594
+ const f = e[p], h = C(f, c);
1595
+ if (h.result) {
1596
+ d = !0, a < n && o.push({
1597
+ actualKey: p,
1598
+ expectedKey: l,
1599
+ result: h
1600
+ }), a++;
1601
+ break;
1602
+ }
1603
+ }
1604
+ if (d || (i = !1, u < n && o.push({
1605
+ expectedKey: l,
1606
+ result: {
1607
+ result: !1,
1608
+ actual: void 0,
1609
+ expected: c
1610
+ }
1611
+ }), u++), !i && a >= n && u >= n)
1612
+ break;
1613
+ }
1614
+ return {
1615
+ result: i,
1616
+ nested: o
1617
+ };
1618
+ }
1619
+ return `Unknown matchType "${s}"`;
1620
+ }
1621
+ nameDefault() {
1622
+ return `array ${this._args?.matchType || "equals"} ${it(this._args?.expected)}`;
1623
+ }
1624
+ }
1625
+ class Le extends _ {
1626
+ match() {
1627
+ return !0;
1628
+ }
1629
+ nameDefault() {
1630
+ return "any";
1631
+ }
1632
+ }
1633
+ class Fe extends _ {
1634
+ match(e) {
1635
+ if (typeof e != "object")
1636
+ return `Expected array, got "${typeof e}"`;
1637
+ if (!(e instanceof Array))
1638
+ return "Expected array";
1639
+ const r = this._args.expected;
1640
+ let n = !0;
1641
+ const s = [], i = this._args?.maxReportItems ?? ot;
1642
+ let o = 0, a = 0;
1643
+ for (let u = 0; u < e.length; u++) {
1644
+ const l = e[u], c = C(l, r);
1645
+ if (c.result ? (o < i && s.push({
1646
+ actualKey: u,
1647
+ expectedKey: u,
1648
+ result: c
1649
+ }), o++) : (a < i && s.push({
1650
+ actualKey: u,
1651
+ expectedKey: u,
1652
+ result: c
1653
+ }), a++, n = !1), !n && o >= i && a >= i)
1654
+ break;
1655
+ }
1656
+ return {
1657
+ result: n,
1658
+ nested: s
1659
+ };
1660
+ }
1661
+ nameDefault() {
1662
+ return "array item";
1663
+ }
1664
+ }
1665
+ class Be extends _ {
1666
+ match(e) {
1667
+ const { expected: r, convert: n } = this._args, s = C(n(e), r), i = [
1668
+ {
1669
+ result: s
1670
+ }
1671
+ ];
1672
+ return {
1673
+ result: s.result,
1674
+ nested: i
1675
+ };
1676
+ }
1677
+ nameDefault() {
1678
+ return "convert";
1679
+ }
1680
+ }
1681
+ class Ht extends _ {
1682
+ match(e) {
1683
+ const { expected: r, nonStrict: n } = this._args;
1684
+ return n ? e == r : e === r;
1685
+ }
1686
+ nameDefault() {
1687
+ return `is(${it(this._args.expected)})`;
1688
+ }
1689
+ }
1690
+ class We extends _ {
1691
+ match(e) {
1692
+ if (e == null)
1693
+ return `Expected number, got "${e}"`;
1694
+ if (typeof e != "number")
1695
+ return `Expected number, got "${typeof e}"`;
1696
+ if (this._args == null)
1697
+ return Number.isFinite(e) ? !0 : "Expected finite number";
1698
+ if (!this._args.allowNaN && Number.isNaN(e))
1699
+ return "Expected not NaN";
1700
+ if (!this._args.allowInfinity && !Number.isFinite(e))
1701
+ return "Expected not Infinity";
1702
+ const { min: r, max: n, float: s } = this._args;
1703
+ return !s && !Number.isInteger(e) ? `Expected integer, got "${e}"` : r != null && e < r ? `Expected number to be >= ${r}, got ${e}` : n != null && e > n ? `Expected number to be <= ${n}, got ${e}` : !0;
1704
+ }
1705
+ nameDefault() {
1706
+ return `number(${St(this._args)})`;
1707
+ }
1708
+ }
1709
+ class qe extends _ {
1710
+ match(e) {
1711
+ if (e == null)
1712
+ return `Expected object, got "${e}"`;
1713
+ if (Array.isArray(e))
1714
+ return "Expected object, got array";
1715
+ if (typeof e != "object")
1716
+ return `Expected object, got "${typeof e}"`;
1717
+ const r = this._args?.expected;
1718
+ if (r == null)
1719
+ return !0;
1720
+ let n = !0;
1721
+ const s = [], i = this._args?.maxReportItems ?? ot;
1722
+ let o = 0, a = 0;
1723
+ for (const u in r) {
1724
+ if (!Object.prototype.hasOwnProperty.call(r, u))
1725
+ continue;
1726
+ const l = e[u], c = r[u], d = C(l, c);
1727
+ if (d.result ? (o < i && s.push({
1728
+ actualKey: u,
1729
+ expectedKey: u,
1730
+ result: d
1731
+ }), o++) : (a < i && s.push({
1732
+ actualKey: u,
1733
+ expectedKey: u,
1734
+ result: d
1735
+ }), a++, n = !1), !n && o >= i && a >= i)
1736
+ break;
1737
+ }
1738
+ if (!this._args?.ignoreExtraKeys)
1739
+ for (const u in e) {
1740
+ if (!Object.prototype.hasOwnProperty.call(e, u) || Object.prototype.hasOwnProperty.call(r, u))
1741
+ continue;
1742
+ const l = e[u];
1743
+ if (a < i && s.push({
1744
+ actualKey: u,
1745
+ expectedKey: u,
1746
+ result: Ft(l, void 0, "Unexpected key")
1747
+ }), a++, n = !1, a >= i)
1748
+ break;
1749
+ }
1750
+ return {
1751
+ result: n,
1752
+ nested: s
1753
+ };
1754
+ }
1755
+ nameDefault() {
1756
+ return "object" + St(this._args);
1757
+ }
1758
+ }
1759
+ class Je extends _ {
1760
+ match(e) {
1761
+ if (e == null)
1762
+ return `Expected string, got ${e}`;
1763
+ if (typeof e != "string")
1764
+ return `Expected string, got "${typeof e}"`;
1765
+ if (this._args == null)
1766
+ return !0;
1767
+ const { pattern: r } = this._args;
1768
+ if (r != null) {
1769
+ if (typeof r == "function")
1770
+ return r(e);
1771
+ if (!r.test(e))
1772
+ return !1;
1773
+ }
1774
+ return !0;
1775
+ }
1776
+ nameDefault() {
1777
+ return this._args?.pattern ? `string(${this._args.pattern})` : "string";
1778
+ }
1779
+ }
1780
+ class Ge extends _ {
1781
+ match(e) {
1782
+ const r = this._args.expected;
1783
+ return e instanceof r ? !0 : `Expected instance of "${r}", got "${e}"`;
1784
+ }
1785
+ nameDefault() {
1786
+ return `instanceOf(${this._args.expected.name})`;
1787
+ }
1788
+ }
1789
+ class He extends _ {
1790
+ constructor(e) {
1791
+ super({
1792
+ ...e,
1793
+ expected: e.expected instanceof Set ? e.expected : new Set(e.expected)
1794
+ });
1795
+ }
1796
+ match(e) {
1797
+ return !!this._args.expected.has(e);
1798
+ }
1799
+ nameDefault() {
1800
+ return `in(${it(this._args.expected)})`;
1801
+ }
1802
+ }
1803
+ class at extends _ {
1804
+ match(e) {
1805
+ const { type: r, expecteds: n, pipe: s } = this._args;
1806
+ let i = r === "and";
1807
+ const o = [];
1808
+ for (let a = 0; a < n.length; a++) {
1809
+ const u = n[a], l = C(e, u);
1810
+ if (o.push({
1811
+ actualKey: `<${r} ${a}>`,
1812
+ expectedKey: `<${r} ${a}>`,
1813
+ result: l
1814
+ }), r === "or") {
1815
+ if (l.result && (i = !0, s))
1816
+ break;
1817
+ } else if (r === "and") {
1818
+ if (!l.result && (i = !1, s))
1819
+ break;
1820
+ } else
1821
+ throw new Error(`[test][MatcherFew] Unknown type "${r}"`);
1822
+ }
1823
+ return {
1824
+ result: n.length === 0 || i,
1825
+ nested: o
1826
+ };
1827
+ }
1828
+ nameDefault() {
1829
+ return this._args.type;
1830
+ }
1831
+ }
1832
+ class Qe extends _ {
1833
+ match(e) {
1834
+ const r = this._args.matcher;
1835
+ return D(r) ? r.match(e) : r(e);
1836
+ }
1837
+ nameDefault(e) {
1838
+ const r = this._args.name;
1839
+ return typeof r == "string" ? r : r ? r(e) : "custom";
1840
+ }
1841
+ }
1842
+ class Xe extends _ {
1843
+ match() {
1844
+ return !1;
1845
+ }
1846
+ nameDefault() {
1847
+ return "never";
1848
+ }
1849
+ }
1850
+ class Ye extends _ {
1851
+ match(e) {
1852
+ if (e == null)
1853
+ return `Expected object, got "${e}"`;
1854
+ if (Array.isArray(e))
1855
+ return "Expected object, got array";
1856
+ if (typeof e != "object")
1857
+ return `Expected object, got "${typeof e}"`;
1858
+ const r = this._args?.expected;
1859
+ if (r == null)
1860
+ return !0;
1861
+ let n = !0;
1862
+ const s = [], i = this._args?.maxReportItems ?? ot;
1863
+ let o = 0, a = 0;
1864
+ for (const u in e) {
1865
+ if (!Object.prototype.hasOwnProperty.call(e, u))
1866
+ continue;
1867
+ const l = [u, e[u]], c = C(l, r);
1868
+ if (c.result ? (o < i && s.push({
1869
+ actualKey: u,
1870
+ expectedKey: u,
1871
+ result: c
1872
+ }), o++) : (a < i && s.push({
1873
+ actualKey: u,
1874
+ expectedKey: u,
1875
+ result: c
1876
+ }), a++, n = !1), !n && o >= i && a >= i)
1877
+ break;
1878
+ }
1879
+ return {
1880
+ result: n,
1881
+ nested: s
1882
+ };
1883
+ }
1884
+ nameDefault() {
1885
+ return "object entries" + St(this._args);
1886
+ }
1887
+ }
1888
+ class Ze extends _ {
1889
+ _hasExpected = !1;
1890
+ _expected = void 0;
1891
+ get expected() {
1892
+ return this._expected;
1893
+ }
1894
+ set expected(e) {
1895
+ this._expected = e, this._hasExpected = !0;
1896
+ }
1897
+ match(e) {
1898
+ const r = C(e, this._expected), n = [
1899
+ {
1900
+ result: r
1901
+ }
1902
+ ];
1903
+ return {
1904
+ result: r.result,
1905
+ nested: n
1906
+ };
1907
+ }
1908
+ nameDefault() {
1909
+ return "ref";
1910
+ }
1911
+ }
1912
+ function R(t) {
1913
+ return new Gt({ expected: t });
1914
+ }
1915
+ function fn(t) {
1916
+ return new Gt({ expected: t, matchType: "includes" });
1917
+ }
1918
+ function W() {
1919
+ return new Le();
1920
+ }
1921
+ function hn() {
1922
+ return new Ze();
1923
+ }
1924
+ function mn(t) {
1925
+ return new Xe({ name: t });
1926
+ }
1927
+ function pn(t, e) {
1928
+ const r = new Fe({ expected: e });
1929
+ return t == null ? r : k(
1930
+ sr(
1931
+ D(t) || typeof t == "number" ? t : ut(t)
1932
+ ),
1933
+ r
1934
+ ).name("array item");
1935
+ }
1936
+ function P(t, e, r) {
1937
+ return new Be({ name: t, convert: e, expected: r });
1938
+ }
1939
+ function tr(t) {
1940
+ return new Ht({ expected: t, nonStrict: !0 });
1941
+ }
1942
+ function er(t) {
1943
+ return new Ht({ expected: t, nonStrict: !1 });
1944
+ }
1945
+ function Qt(t) {
1946
+ return new We(t);
1947
+ }
1948
+ function ut(t) {
1949
+ return Qt({
1950
+ ...t,
1951
+ float: !1
1952
+ });
1953
+ }
1954
+ function dn(t) {
1955
+ return Qt({
1956
+ ...t,
1957
+ float: !0
1958
+ });
1959
+ }
1960
+ function z(t) {
1961
+ return new qe({ expected: t });
1962
+ }
1963
+ function dt(t, e, r = null) {
1964
+ if (t instanceof _ || e && (t = e(t, r), t instanceof _))
1965
+ return t;
1966
+ if (t == null)
1967
+ return st();
1968
+ if (Array.isArray(t)) {
1969
+ const n = t.map((s, i) => dt(s, e, i));
1970
+ return R(n);
1971
+ }
1972
+ if (t.constructor === Object) {
1973
+ const n = {};
1974
+ for (const s in t)
1975
+ Object.prototype.hasOwnProperty.call(t, s) && (n[s] = dt(t[s], e, s));
1976
+ return z(n);
1977
+ }
1978
+ return t instanceof se ? cr({
1979
+ ...t,
1980
+ value: dt(t.value, e, "value")
1981
+ }) : er(t);
1982
+ }
1983
+ function _n(t) {
1984
+ return z(t).set({
1985
+ ignoreExtraKeys: !0
1986
+ });
1987
+ }
1988
+ function Xt(t) {
1989
+ return new Je({
1990
+ pattern: t
1991
+ });
1992
+ }
1993
+ function gn(t) {
1994
+ return new Ge({ expected: t });
1995
+ }
1996
+ function rr(t) {
1997
+ return P(
1998
+ "typeof",
1999
+ (e) => e === null ? "null" : typeof e,
2000
+ t
2001
+ );
2002
+ }
2003
+ function yn(t) {
2004
+ return P(
2005
+ "constructor",
2006
+ (e) => e.constructor,
2007
+ t
2008
+ );
2009
+ }
2010
+ function _t() {
2011
+ return rr("boolean");
2012
+ }
2013
+ function st() {
2014
+ return tr(null);
2015
+ }
2016
+ function wn() {
2017
+ return lr(st());
2018
+ }
2019
+ function bn(...t) {
2020
+ return new at({
2021
+ expecteds: t,
2022
+ type: "or",
2023
+ pipe: !1
2024
+ });
2025
+ }
2026
+ function Sn(...t) {
2027
+ return new at({
2028
+ expecteds: t,
2029
+ type: "and",
2030
+ pipe: !1
2031
+ });
2032
+ }
2033
+ function nr(...t) {
2034
+ return new at({
2035
+ expecteds: t,
2036
+ type: "or",
2037
+ pipe: !0
2038
+ });
2039
+ }
2040
+ function k(...t) {
2041
+ return new at({
2042
+ expecteds: t,
2043
+ type: "and",
2044
+ pipe: !0
2045
+ });
2046
+ }
2047
+ function V(t, e) {
2048
+ return e == null ? nr(st(), t) : e ? t : st();
2049
+ }
2050
+ function sr(t) {
2051
+ const e = typeof t == "number" || D(t) ? t : ut(t ?? { min: 1 });
2052
+ return k(
2053
+ R(),
2054
+ P("length", (r) => r.length, e)
2055
+ ).name("array length");
2056
+ }
2057
+ function xn(t) {
2058
+ const e = typeof t == "number" || D(t) ? t : ut(t ?? { min: 1 });
2059
+ return k(
2060
+ Xt(),
2061
+ P("length", (r) => r.length, e)
2062
+ ).name("string length");
2063
+ }
2064
+ function En(t) {
2065
+ return k(z(), t);
2066
+ }
2067
+ function On(t) {
2068
+ return k(R(), t);
2069
+ }
2070
+ function $n(t) {
2071
+ return k(
2072
+ z(),
2073
+ P(
2074
+ "keys",
2075
+ (e) => Object.keys(e),
2076
+ t
2077
+ )
2078
+ );
2079
+ }
2080
+ function Mn(t) {
2081
+ return k(
2082
+ z(),
2083
+ P(
2084
+ "values",
2085
+ (e) => Object.values(e),
2086
+ t
2087
+ )
2088
+ );
2089
+ }
2090
+ function An(t) {
2091
+ return k(
2092
+ z(),
2093
+ P(
2094
+ "entries",
2095
+ (e) => Object.entries(e),
2096
+ t
2097
+ )
2098
+ );
2099
+ }
2100
+ function xt(t) {
2101
+ return new Ye({ expected: t });
2102
+ }
2103
+ function Cn(t) {
2104
+ return xt(R([t, W()]));
2105
+ }
2106
+ function kn(t) {
2107
+ return xt(R([W(), t]));
2108
+ }
2109
+ function Tn(t, e) {
2110
+ return xt(R([t, e]));
2111
+ }
2112
+ function In(t) {
2113
+ return k(
2114
+ z(),
2115
+ P(
2116
+ "keys not null",
2117
+ (e) => Object.keys(e).filter((r) => e[r] != null),
2118
+ t
2119
+ )
2120
+ );
2121
+ }
2122
+ function ir(t) {
2123
+ return new He({ expected: t });
2124
+ }
2125
+ function Un(t) {
2126
+ return ir(Object.values(t));
2127
+ }
2128
+ function Yt(t, e) {
2129
+ return new Qe({ matcher: e, name: t });
2130
+ }
2131
+ const or = Math.ceil(Date.now() - 10 * 365.25 * 24 * 60 * 60 * 1e3), ar = Math.ceil(Date.now() + 10 * 365.25 * 24 * 60 * 60 * 1e3);
2132
+ function Y(t) {
2133
+ return ut({
2134
+ ...t,
2135
+ min: t?.min ?? or,
2136
+ max: t?.max ?? ar
2137
+ }).name("int date");
2138
+ }
2139
+ function ur(t) {
2140
+ const e = {
2141
+ min: t?.from?.min ?? t?.common?.min,
2142
+ max: t?.from?.max ?? t?.common?.max,
2143
+ float: t?.from?.float ?? t?.common?.float,
2144
+ optional: t?.from?.optional ?? t?.common?.optional
2145
+ }, r = {
2146
+ min: t?.to?.min ?? t?.common?.min,
2147
+ max: t?.to?.max ?? t?.common?.max,
2148
+ float: t?.to?.float ?? t?.common?.float,
2149
+ optional: t?.to?.optional ?? t?.common?.optional
2150
+ };
2151
+ return k(
2152
+ R([
2153
+ e.optional ? V(Y()) : Y(),
2154
+ r.optional ? V(Y()) : Y()
2155
+ ]),
2156
+ Yt("min <= max", (n) => n[0] != null && n[1] != null && n[0] > n[1] ? `Expected range to be [min, max], got [${n.join(", ")}]` : !0)
2157
+ ).name("range");
2158
+ }
2159
+ function Pn(t) {
2160
+ return ur({
2161
+ ...t,
2162
+ common: {
2163
+ min: new Date(2020, 0, 1).getTime(),
2164
+ max: Date.now() + 900 * 1e3,
2165
+ ...t?.common
2166
+ }
2167
+ }).name("range date");
2168
+ }
2169
+ function lr(t) {
2170
+ return new Bt({ expected: t });
2171
+ }
2172
+ function zn() {
2173
+ return Xt(/^[\da-f-]{36}|[\da-f]{32}$/i).name("uuid");
2174
+ }
2175
+ function cr(t) {
2176
+ return z({
2177
+ [Symbol.toStringTag]: V(W()),
2178
+ loading: V(_t()),
2179
+ hasValue: V(_t()),
2180
+ value: W(),
2181
+ hasError: V(_t()),
2182
+ error: W(),
2183
+ ...t
2184
+ });
2185
+ }
2186
+ function Nn(t) {
2187
+ return t != null && typeof t == "string" && (t = new TextEncoder().encode(t).buffer), Yt("array buffer", (e) => {
2188
+ if (e == null || typeof e != "object" || typeof e.byteLength != "number")
2189
+ return `Expected array buffer, got "${e}"`;
2190
+ if (t == null)
2191
+ return !0;
2192
+ if (e.byteLength !== t.byteLength)
2193
+ return `Expected array buffer length to be ${t.byteLength}, got ${e.byteLength}`;
2194
+ for (let r = 0, n = t.byteLength; r < n; r++)
2195
+ if (e[r] !== t[r])
2196
+ return `Expected array buffer[${r}] to be ${t[r]}, got ${e[r]}`;
2197
+ return !0;
2198
+ });
2199
+ }
2200
+ function Tt(t) {
2201
+ return t.replace(/\W/g, "").toLowerCase();
2202
+ }
2203
+ function fr(t) {
2204
+ return t instanceof URL ? t.searchParams : t instanceof URLSearchParams ? t : typeof t == "string" ? new URL(t).searchParams : typeof window < "u" ? new URL(window.location.href).searchParams : new URLSearchParams();
2205
+ }
2206
+ function hr(t) {
2207
+ return t == null ? null : (t = t.toLowerCase().trim(), t === "true" || t === "1" || t === "yes" ? !0 : t === "false" || t === "0" || t === "no" ? !1 : null);
2208
+ }
2209
+ function mr(t) {
2210
+ if (t == null)
2211
+ return null;
2212
+ t = t.trim();
2213
+ const e = parseInt(t, 10);
2214
+ return isNaN(e) ? null : e;
2215
+ }
2216
+ function pr(t) {
2217
+ if (t == null)
2218
+ return null;
2219
+ t = t.trim();
2220
+ const e = parseFloat(t);
2221
+ return isNaN(e) ? null : e;
2222
+ }
2223
+ function Et(t, e) {
2224
+ const r = fr(e), n = Tt(t);
2225
+ for (const [s, i] of r.entries())
2226
+ if (Tt(s) === n)
2227
+ return i;
2228
+ return null;
2229
+ }
2230
+ function vn(t, e) {
2231
+ return hr(Et(t, e));
2232
+ }
2233
+ function Dn(t, e) {
2234
+ return mr(Et(t, e));
2235
+ }
2236
+ function Rn(t, e) {
2237
+ return pr(Et(t, e));
2238
+ }
2239
+ export {
2240
+ j as $,
2241
+ Fr as A,
2242
+ ke as B,
2243
+ $r as C,
2244
+ Te as D,
2245
+ Br as E,
2246
+ Wr as F,
2247
+ qr as G,
2248
+ Pe as H,
2249
+ vt as I,
2250
+ ze as J,
2251
+ Jr as K,
2252
+ Gr as L,
2253
+ Mr as M,
2254
+ Dt as N,
2255
+ Hr as O,
2256
+ Qr as P,
2257
+ Xr as Q,
2258
+ wt as R,
2259
+ Yr as S,
2260
+ Zr as T,
2261
+ mt as U,
2262
+ Nt as V,
2263
+ vr as W,
2264
+ Dr as X,
2265
+ U as Y,
2266
+ Me as Z,
2267
+ Ce as _,
2268
+ Tr as a,
2269
+ _n as a$,
2270
+ Q as a0,
2271
+ $t as a1,
2272
+ Z as a2,
2273
+ Ar as a3,
2274
+ Cr as a4,
2275
+ gt as a5,
2276
+ kr as a6,
2277
+ tn as a7,
2278
+ rn as a8,
2279
+ De as a9,
2280
+ nt as aA,
2281
+ Ke as aB,
2282
+ Lt as aC,
2283
+ Ft as aD,
2284
+ C as aE,
2285
+ Jt as aF,
2286
+ X as aG,
2287
+ cn as aH,
2288
+ je as aI,
2289
+ Wt as aJ,
2290
+ Ve as aK,
2291
+ qt as aL,
2292
+ ot as aM,
2293
+ R as aN,
2294
+ fn as aO,
2295
+ W as aP,
2296
+ hn as aQ,
2297
+ mn as aR,
2298
+ pn as aS,
2299
+ P as aT,
2300
+ tr as aU,
2301
+ er as aV,
2302
+ Qt as aW,
2303
+ ut as aX,
2304
+ dn as aY,
2305
+ z as aZ,
2306
+ dt as a_,
2307
+ nn as aa,
2308
+ sn as ab,
2309
+ B as ac,
2310
+ Kt as ad,
2311
+ en as ae,
2312
+ Ut as af,
2313
+ on as ag,
2314
+ Re as ah,
2315
+ ae as ai,
2316
+ br as aj,
2317
+ Sr as ak,
2318
+ xr as al,
2319
+ ue as am,
2320
+ le as an,
2321
+ Er as ao,
2322
+ Or as ap,
2323
+ I as aq,
2324
+ an as ar,
2325
+ jt as as,
2326
+ un as at,
2327
+ ln as au,
2328
+ v as av,
2329
+ _ as aw,
2330
+ D as ax,
2331
+ it as ay,
2332
+ St as az,
2333
+ ce as b,
2334
+ Xt as b0,
2335
+ gn as b1,
2336
+ rr as b2,
2337
+ yn as b3,
2338
+ _t as b4,
2339
+ st as b5,
2340
+ wn as b6,
2341
+ bn as b7,
2342
+ Sn as b8,
2343
+ nr as b9,
2344
+ Fe as bA,
2345
+ Be as bB,
2346
+ Qe as bC,
2347
+ at as bD,
2348
+ He as bE,
2349
+ Ht as bF,
2350
+ Xe as bG,
2351
+ Bt as bH,
2352
+ We as bI,
2353
+ qe as bJ,
2354
+ Ye as bK,
2355
+ Ze as bL,
2356
+ Je as bM,
2357
+ Ge as bN,
2358
+ fr as bO,
2359
+ hr as bP,
2360
+ mr as bQ,
2361
+ pr as bR,
2362
+ Et as bS,
2363
+ vn as bT,
2364
+ Dn as bU,
2365
+ Rn as bV,
2366
+ k as ba,
2367
+ V as bb,
2368
+ sr as bc,
2369
+ xn as bd,
2370
+ En as be,
2371
+ On as bf,
2372
+ $n as bg,
2373
+ Mn as bh,
2374
+ An as bi,
2375
+ xt as bj,
2376
+ Cn as bk,
2377
+ kn as bl,
2378
+ Tn as bm,
2379
+ In as bn,
2380
+ ir as bo,
2381
+ Un as bp,
2382
+ Yt as bq,
2383
+ Y as br,
2384
+ ur as bs,
2385
+ Pn as bt,
2386
+ lr as bu,
2387
+ zn as bv,
2388
+ cr as bw,
2389
+ Nn as bx,
2390
+ Le as by,
2391
+ Gt as bz,
2392
+ Ur as c,
2393
+ ye as d,
2394
+ we as e,
2395
+ be as f,
2396
+ he as g,
2397
+ Se as h,
2398
+ Pr as i,
2399
+ xe as j,
2400
+ Ee as k,
2401
+ Oe as l,
2402
+ $e as m,
2403
+ zr as n,
2404
+ Mt as o,
2405
+ et as p,
2406
+ Nr as q,
2407
+ Rr as r,
2408
+ Kr as s,
2409
+ Ir as t,
2410
+ jr as u,
2411
+ _e as v,
2412
+ ge as w,
2413
+ pe as x,
2414
+ Vr as y,
2415
+ Lr as z
2416
+ };