@byloth/core 1.5.3 → 2.0.0-rc.2

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/dist/core.js CHANGED
@@ -1,7 +1,153 @@
1
- var S = Object.defineProperty;
2
- var b = (s, e, t) => e in s ? S(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var u = (s, e, t) => b(s, typeof e != "symbol" ? e + "" : e, t);
4
- class c {
1
+ var j = Object.defineProperty;
2
+ var D = (s, e, t) => e in s ? j(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var u = (s, e, t) => D(s, typeof e != "symbol" ? e + "" : e, t);
4
+ const E = typeof window < "u" && typeof window.document < "u";
5
+ var S;
6
+ const J = typeof process < "u" && ((S = process.versions) == null ? void 0 : S.node);
7
+ var k;
8
+ const W = typeof self == "object" && ((k = self.constructor) == null ? void 0 : k.name) === "DedicatedWorkerGlobalScope";
9
+ class h extends Error {
10
+ static FromUnknown(e) {
11
+ if (e instanceof h)
12
+ return e;
13
+ if (e instanceof Error) {
14
+ const t = new h(e.message);
15
+ return t.stack = e.stack, t.name = e.name, t;
16
+ }
17
+ return new h(`${e}`);
18
+ }
19
+ constructor(e, t, n = "Exception") {
20
+ super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
21
+
22
+ Caused by ${t.stack}` : this.stack += `
23
+
24
+ Caused by ${t}`);
25
+ }
26
+ get [Symbol.toStringTag]() {
27
+ return "Exception";
28
+ }
29
+ }
30
+ class g extends h {
31
+ constructor(e, t, n = "FatalErrorException") {
32
+ e === void 0 && (e = "The program has encountered an unrecoverable error and cannot continue as expected. Please, try again later. If the problem persists, contact the support team."), super(e, t, n);
33
+ }
34
+ get [Symbol.toStringTag]() {
35
+ return "FatalErrorException";
36
+ }
37
+ }
38
+ class Y extends g {
39
+ constructor(e, t, n = "NotImplementedException") {
40
+ e === void 0 && (e = "This feature is not implemented yet. Please, try again later."), super(e, t, n);
41
+ }
42
+ get [Symbol.toStringTag]() {
43
+ return "NotImplementedException";
44
+ }
45
+ }
46
+ class T extends h {
47
+ constructor(e, t, n = "FileException") {
48
+ super(e, t, n);
49
+ }
50
+ get [Symbol.toStringTag]() {
51
+ return "FileException";
52
+ }
53
+ }
54
+ class z extends T {
55
+ constructor(e, t, n = "FileExistsException") {
56
+ super(e, t, n);
57
+ }
58
+ get [Symbol.toStringTag]() {
59
+ return "FileExistsException";
60
+ }
61
+ }
62
+ class V extends T {
63
+ constructor(e, t, n = "FileNotFoundException") {
64
+ super(e, t, n);
65
+ }
66
+ get [Symbol.toStringTag]() {
67
+ return "FileNotFoundException";
68
+ }
69
+ }
70
+ class B extends h {
71
+ constructor(e, t, n = "KeyException") {
72
+ super(e, t, n);
73
+ }
74
+ get [Symbol.toStringTag]() {
75
+ return "KeyException";
76
+ }
77
+ }
78
+ class K extends h {
79
+ constructor(e, t, n = "NetworkException") {
80
+ super(e, t, n);
81
+ }
82
+ get [Symbol.toStringTag]() {
83
+ return "NetworkException";
84
+ }
85
+ }
86
+ class G extends h {
87
+ constructor(e, t, n = "PermissionException") {
88
+ super(e, t, n);
89
+ }
90
+ get [Symbol.toStringTag]() {
91
+ return "PermissionException";
92
+ }
93
+ }
94
+ class q extends h {
95
+ constructor(e, t, n = "ReferenceException") {
96
+ super(e, t, n);
97
+ }
98
+ get [Symbol.toStringTag]() {
99
+ return "ReferenceException";
100
+ }
101
+ }
102
+ class m extends h {
103
+ constructor(e, t, n = "RuntimeException") {
104
+ super(e, t, n);
105
+ }
106
+ get [Symbol.toStringTag]() {
107
+ return "RuntimeException";
108
+ }
109
+ }
110
+ class A extends m {
111
+ constructor(e, t, n = "EnvironmentException") {
112
+ super(e, t, n);
113
+ }
114
+ get [Symbol.toStringTag]() {
115
+ return "EnvironmentException";
116
+ }
117
+ }
118
+ class C extends h {
119
+ constructor(e, t, n = "TimeoutException") {
120
+ super(e, t, n);
121
+ }
122
+ get [Symbol.toStringTag]() {
123
+ return "TimeoutException";
124
+ }
125
+ }
126
+ class H extends h {
127
+ constructor(e, t, n = "TypeException") {
128
+ super(e, t, n);
129
+ }
130
+ get [Symbol.toStringTag]() {
131
+ return "TypeException";
132
+ }
133
+ }
134
+ class f extends h {
135
+ constructor(e, t, n = "ValueException") {
136
+ super(e, t, n);
137
+ }
138
+ get [Symbol.toStringTag]() {
139
+ return "ValueException";
140
+ }
141
+ }
142
+ class M extends f {
143
+ constructor(e, t, n = "RangeException") {
144
+ super(e, t, n);
145
+ }
146
+ get [Symbol.toStringTag]() {
147
+ return "RangeException";
148
+ }
149
+ }
150
+ class a {
5
151
  constructor(e) {
6
152
  u(this, "_iterator");
7
153
  u(this, "return");
@@ -32,7 +178,7 @@ class c {
32
178
  }
33
179
  filter(e) {
34
180
  const t = this._iterator;
35
- return new c(function* () {
181
+ return new a(function* () {
36
182
  let n = 0;
37
183
  for (; ; ) {
38
184
  const r = t.next();
@@ -44,7 +190,7 @@ class c {
44
190
  }
45
191
  map(e) {
46
192
  const t = this._iterator;
47
- return new c(function* () {
193
+ return new a(function* () {
48
194
  let n = 0;
49
195
  for (; ; ) {
50
196
  const r = t.next();
@@ -57,16 +203,16 @@ class c {
57
203
  reduce(e, t) {
58
204
  let n = 0, r = t;
59
205
  if (r === void 0) {
60
- const o = this._iterator.next();
61
- if (o.done)
62
- throw new TypeError("Reduce of empty iterator with no initial value");
63
- r = o.value, n += 1;
206
+ const i = this._iterator.next();
207
+ if (i.done)
208
+ throw new f("Cannot reduce an empty iterator without an initial value.");
209
+ r = i.value, n += 1;
64
210
  }
65
211
  for (; ; ) {
66
- const o = this._iterator.next();
67
- if (o.done)
212
+ const i = this._iterator.next();
213
+ if (i.done)
68
214
  return r;
69
- r = e(r, o.value, n), n += 1;
215
+ r = e(r, i.value, n), n += 1;
70
216
  }
71
217
  }
72
218
  enumerate() {
@@ -74,7 +220,7 @@ class c {
74
220
  }
75
221
  unique() {
76
222
  const e = this._iterator;
77
- return new c(function* () {
223
+ return new a(function* () {
78
224
  const t = /* @__PURE__ */ new Set();
79
225
  for (; ; ) {
80
226
  const n = e.next();
@@ -114,7 +260,7 @@ class c {
114
260
  return this;
115
261
  }
116
262
  }
117
- class h {
263
+ class d {
118
264
  constructor(e) {
119
265
  u(this, "_iterator");
120
266
  u(this, "return");
@@ -178,7 +324,7 @@ class h {
178
324
  }
179
325
  filter(e) {
180
326
  const t = this._iterator;
181
- return new h(async function* () {
327
+ return new d(async function* () {
182
328
  let n = 0;
183
329
  for (; ; ) {
184
330
  const r = await t.next();
@@ -190,7 +336,7 @@ class h {
190
336
  }
191
337
  map(e) {
192
338
  const t = this._iterator;
193
- return new h(async function* () {
339
+ return new d(async function* () {
194
340
  let n = 0;
195
341
  for (; ; ) {
196
342
  const r = await t.next();
@@ -203,16 +349,16 @@ class h {
203
349
  async reduce(e, t) {
204
350
  let n = 0, r = t;
205
351
  if (r === void 0) {
206
- const o = await this._iterator.next();
207
- if (o.done)
208
- throw new TypeError("Reduce of empty iterator with no initial value");
209
- r = o.value, n += 1;
352
+ const i = await this._iterator.next();
353
+ if (i.done)
354
+ throw new f("Cannot reduce an empty iterator without an initial value.");
355
+ r = i.value, n += 1;
210
356
  }
211
357
  for (; ; ) {
212
- const o = await this._iterator.next();
213
- if (o.done)
358
+ const i = await this._iterator.next();
359
+ if (i.done)
214
360
  return r;
215
- r = await e(r, o.value, n), n += 1;
361
+ r = await e(r, i.value, n), n += 1;
216
362
  }
217
363
  }
218
364
  enumerate() {
@@ -220,7 +366,7 @@ class h {
220
366
  }
221
367
  unique() {
222
368
  const e = this._iterator;
223
- return new h(async function* () {
369
+ return new d(async function* () {
224
370
  const t = /* @__PURE__ */ new Set();
225
371
  for (; ; ) {
226
372
  const n = await e.next();
@@ -266,132 +412,23 @@ class h {
266
412
  return this;
267
413
  }
268
414
  }
269
- class f extends Error {
270
- static FromUnknown(e) {
271
- if (e instanceof f)
272
- return e;
273
- if (e instanceof Error) {
274
- const t = new f(e.message);
275
- return t.stack = e.stack, t.name = e.name, t;
276
- }
277
- return new f(`${e}`);
278
- }
279
- constructor(e, t, n = "Exception") {
280
- super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
281
-
282
- Caused by ${t.stack}` : this.stack += `
283
-
284
- Caused by ${t}`);
285
- }
286
- get [Symbol.toStringTag]() {
287
- return "Exception";
288
- }
289
- }
290
- class j extends f {
291
- constructor(e, t, n = "FatalErrorException") {
292
- e === void 0 && (e = "The routine has encountered an unrecoverable error and cannot continue as expected. Please, refresh the page and try again. If the problem persists, contact the support team."), super(e, t, n);
293
- }
294
- get [Symbol.toStringTag]() {
295
- return "FatalErrorException";
296
- }
297
- }
298
- class F extends f {
299
- constructor(e, t, n = "NotImplementedException") {
300
- e === void 0 && (e = "This feature is not implemented yet. Please, try again later."), super(e, t, n);
301
- }
302
- get [Symbol.toStringTag]() {
303
- return "NotImplementedException";
304
- }
305
- }
306
- class R extends f {
307
- constructor(e, t, n = "FileNotFoundException") {
308
- super(e, t, n);
309
- }
310
- get [Symbol.toStringTag]() {
311
- return "FileNotFoundException";
312
- }
313
- }
314
- class q extends f {
315
- constructor(e, t, n = "KeyException") {
316
- super(e, t, n);
317
- }
318
- get [Symbol.toStringTag]() {
319
- return "KeyException";
320
- }
321
- }
322
- class A extends f {
323
- constructor(e, t, n = "NetworkException") {
324
- super(e, t, n);
325
- }
326
- get [Symbol.toStringTag]() {
327
- return "NetworkException";
328
- }
329
- }
330
- class O extends f {
331
- constructor(e, t, n = "PermissionException") {
332
- super(e, t, n);
333
- }
334
- get [Symbol.toStringTag]() {
335
- return "PermissionException";
336
- }
337
- }
338
- class k extends f {
339
- constructor(e, t, n = "ReferenceException") {
340
- super(e, t, n);
341
- }
342
- get [Symbol.toStringTag]() {
343
- return "ReferenceException";
344
- }
345
- }
346
- class $ extends f {
347
- constructor(e, t, n = "RuntimeException") {
348
- super(e, t, n);
349
- }
350
- get [Symbol.toStringTag]() {
351
- return "RuntimeException";
352
- }
353
- }
354
- class T extends f {
355
- constructor(e, t, n = "TimeoutException") {
356
- super(e, t, n);
357
- }
358
- get [Symbol.toStringTag]() {
359
- return "TimeoutException";
360
- }
361
- }
362
- class E extends f {
363
- constructor(e, t, n = "TypeException") {
364
- super(e, t, n);
365
- }
366
- get [Symbol.toStringTag]() {
367
- return "TypeException";
368
- }
369
- }
370
- class m extends f {
371
- constructor(e, t, n = "ValueException") {
372
- super(e, t, n);
373
- }
374
- get [Symbol.toStringTag]() {
375
- return "ValueException";
376
- }
377
- }
378
- class a {
415
+ class l {
379
416
  constructor(e) {
380
417
  u(this, "_elements");
381
- this._elements = new c(e);
418
+ this._elements = new a(e);
382
419
  }
383
420
  filter(e) {
384
421
  const t = this._elements;
385
- return new a(function* () {
386
- for (const [n, [r, o]] of t.enumerate())
387
- e(r, o, n) && (yield [r, o]);
422
+ return new l(function* () {
423
+ for (const [n, [r, i]] of t.enumerate())
424
+ e(r, i, n) && (yield [r, i]);
388
425
  });
389
426
  }
390
427
  map(e) {
391
428
  const t = this._elements;
392
- return new a(function* () {
393
- for (const [n, [r, o]] of t.enumerate())
394
- yield [r, e(r, o, n)];
429
+ return new l(function* () {
430
+ for (const [n, [r, i]] of t.enumerate())
431
+ yield [r, e(r, i, n)];
395
432
  });
396
433
  }
397
434
  reduce(e, t) {
@@ -399,18 +436,18 @@ class a {
399
436
  if (t !== void 0)
400
437
  r = t;
401
438
  else {
402
- const o = this._elements.next();
403
- if (o.done)
404
- throw new E("Reduce of empty iterator with no initial value");
405
- n += 1, r = o.value[1];
439
+ const i = this._elements.next();
440
+ if (i.done)
441
+ throw new f("Cannot reduce an empty iterator without an initial value.");
442
+ n += 1, r = i.value[1];
406
443
  }
407
- for (const [o, i] of this._elements)
408
- r = e(o, r, i, n), n += 1;
444
+ for (const [i, o] of this._elements)
445
+ r = e(i, r, o, n), n += 1;
409
446
  return r;
410
447
  }
411
448
  keys() {
412
449
  const e = this._elements;
413
- return new c(function* () {
450
+ return new a(function* () {
414
451
  for (const [t] of e)
415
452
  yield t;
416
453
  });
@@ -420,7 +457,7 @@ class a {
420
457
  }
421
458
  values() {
422
459
  const e = this._elements;
423
- return new c(function* () {
460
+ return new a(function* () {
424
461
  for (const [t, n] of e)
425
462
  yield n;
426
463
  });
@@ -438,79 +475,79 @@ class a {
438
475
  return "ReducedIterator";
439
476
  }
440
477
  }
441
- class d {
478
+ class w {
442
479
  constructor(e) {
443
480
  u(this, "_elements");
444
- this._elements = new c(e);
481
+ this._elements = new a(e);
445
482
  }
446
483
  every(e) {
447
484
  const t = /* @__PURE__ */ new Map();
448
485
  for (const [n, r] of this._elements) {
449
- const [o, i] = t.get(n) ?? [0, !0];
450
- i && t.set(n, [o + 1, e(n, r, o)]);
486
+ const [i, o] = t.get(n) ?? [0, !0];
487
+ o && t.set(n, [i + 1, e(n, r, i)]);
451
488
  }
452
- return new a(function* () {
453
- for (const [n, [r, o]] of t)
454
- yield [n, o];
489
+ return new l(function* () {
490
+ for (const [n, [r, i]] of t)
491
+ yield [n, i];
455
492
  });
456
493
  }
457
494
  some(e) {
458
495
  const t = /* @__PURE__ */ new Map();
459
496
  for (const [n, r] of this._elements) {
460
- const [o, i] = t.get(n) ?? [0, !1];
461
- i || t.set(n, [o + 1, e(n, r, o)]);
497
+ const [i, o] = t.get(n) ?? [0, !1];
498
+ o || t.set(n, [i + 1, e(n, r, i)]);
462
499
  }
463
- return new a(function* () {
464
- for (const [n, [r, o]] of t)
465
- yield [n, o];
500
+ return new l(function* () {
501
+ for (const [n, [r, i]] of t)
502
+ yield [n, i];
466
503
  });
467
504
  }
468
505
  filter(e) {
469
506
  const t = this._elements;
470
- return new d(function* () {
507
+ return new w(function* () {
471
508
  const n = /* @__PURE__ */ new Map();
472
- for (const [r, o] of t) {
473
- const i = n.get(r) ?? 0;
474
- n.set(r, i + 1), e(r, o, i) && (yield [r, o]);
509
+ for (const [r, i] of t) {
510
+ const o = n.get(r) ?? 0;
511
+ n.set(r, o + 1), e(r, i, o) && (yield [r, i]);
475
512
  }
476
513
  });
477
514
  }
478
515
  map(e) {
479
516
  const t = this._elements;
480
- return new d(function* () {
517
+ return new w(function* () {
481
518
  const n = /* @__PURE__ */ new Map();
482
- for (const [r, o] of t) {
483
- const i = n.get(r) ?? 0;
484
- n.set(r, i + 1), yield [r, e(r, o, i)];
519
+ for (const [r, i] of t) {
520
+ const o = n.get(r) ?? 0;
521
+ n.set(r, o + 1), yield [r, e(r, i, o)];
485
522
  }
486
523
  });
487
524
  }
488
525
  reduce(e, t) {
489
526
  const n = /* @__PURE__ */ new Map();
490
- for (const [r, o] of this._elements) {
491
- let i, l;
527
+ for (const [r, i] of this._elements) {
528
+ let o, c;
492
529
  if (n.has(r))
493
- [i, l] = n.get(r), i += 1;
530
+ [o, c] = n.get(r), o += 1;
494
531
  else if (t !== void 0)
495
- i = 0, l = t(r);
532
+ o = 0, c = t(r);
496
533
  else {
497
- n.set(r, [0, o]);
534
+ n.set(r, [0, i]);
498
535
  continue;
499
536
  }
500
- l = e(r, l, o, i), n.set(r, [i, l]);
537
+ c = e(r, c, i, o), n.set(r, [o, c]);
501
538
  }
502
- return new a(function* () {
503
- for (const [r, [o, i]] of n)
504
- yield [r, i];
539
+ return new l(function* () {
540
+ for (const [r, [i, o]] of n)
541
+ yield [r, o];
505
542
  });
506
543
  }
507
544
  unique() {
508
545
  const e = this._elements;
509
- return new d(function* () {
546
+ return new w(function* () {
510
547
  const t = /* @__PURE__ */ new Map();
511
548
  for (const [n, r] of e) {
512
- const o = t.get(n) ?? /* @__PURE__ */ new Set();
513
- o.has(r) || (o.add(r), t.set(n, o), yield [n, r]);
549
+ const i = t.get(n) ?? /* @__PURE__ */ new Set();
550
+ i.has(r) || (i.add(r), t.set(n, i), yield [n, r]);
514
551
  }
515
552
  });
516
553
  }
@@ -520,7 +557,7 @@ class d {
520
557
  const n = e.get(t) ?? 0;
521
558
  e.set(t, n + 1);
522
559
  }
523
- return new a(function* () {
560
+ return new l(function* () {
524
561
  for (const [t, n] of e)
525
562
  yield [t, n];
526
563
  });
@@ -529,7 +566,7 @@ class d {
529
566
  const e = /* @__PURE__ */ new Map();
530
567
  for (const [t, n] of this._elements)
531
568
  e.has(t) || e.set(t, n);
532
- return new a(function* () {
569
+ return new l(function* () {
533
570
  for (const [t, n] of e)
534
571
  yield [t, n];
535
572
  });
@@ -538,14 +575,14 @@ class d {
538
575
  const e = /* @__PURE__ */ new Map();
539
576
  for (const [t, n] of this._elements)
540
577
  e.set(t, n);
541
- return new a(function* () {
578
+ return new l(function* () {
542
579
  for (const [t, n] of e)
543
580
  yield [t, n];
544
581
  });
545
582
  }
546
583
  keys() {
547
584
  const e = this._elements;
548
- return new c(function* () {
585
+ return new a(function* () {
549
586
  const t = /* @__PURE__ */ new Set();
550
587
  for (const [n] of e)
551
588
  t.has(n) || (t.add(n), yield n);
@@ -556,7 +593,7 @@ class d {
556
593
  }
557
594
  values() {
558
595
  const e = this._elements;
559
- return new c(function* () {
596
+ return new a(function* () {
560
597
  for (const [t, n] of e)
561
598
  yield n;
562
599
  });
@@ -584,22 +621,22 @@ class d {
584
621
  return "AggregatedIterator";
585
622
  }
586
623
  }
587
- class w {
624
+ class _ {
588
625
  constructor(e) {
589
626
  u(this, "_elements");
590
- this._elements = new c(e);
627
+ this._elements = new a(e);
591
628
  }
592
629
  filter(e) {
593
- return new w(this._elements.filter(e));
630
+ return new _(this._elements.filter(e));
594
631
  }
595
632
  map(e) {
596
- return new w(this._elements.map(e));
633
+ return new _(this._elements.map(e));
597
634
  }
598
635
  unique() {
599
- return new w(this._elements.unique());
636
+ return new _(this._elements.unique());
600
637
  }
601
638
  groupBy(e) {
602
- return new d(this._elements.map((t, n) => [e(t, n), t]));
639
+ return new w(this._elements.map((t, n) => [e(t, n), t]));
603
640
  }
604
641
  get [Symbol.toStringTag]() {
605
642
  return "Aggregator";
@@ -608,37 +645,37 @@ class w {
608
645
  class y {
609
646
  constructor(e) {
610
647
  u(this, "_elements");
611
- this._elements = new h(e);
648
+ this._elements = new d(e);
612
649
  }
613
650
  async every(e) {
614
651
  const t = /* @__PURE__ */ new Map();
615
652
  for await (const [n, r] of this._elements) {
616
- const [o, i] = t.get(n) ?? [0, !0];
617
- i && t.set(n, [o + 1, await e(n, r, o)]);
653
+ const [i, o] = t.get(n) ?? [0, !0];
654
+ o && t.set(n, [i + 1, await e(n, r, i)]);
618
655
  }
619
- return new a(function* () {
620
- for (const [n, [r, o]] of t)
621
- yield [n, o];
656
+ return new l(function* () {
657
+ for (const [n, [r, i]] of t)
658
+ yield [n, i];
622
659
  });
623
660
  }
624
661
  async some(e) {
625
662
  const t = /* @__PURE__ */ new Map();
626
663
  for await (const [n, r] of this._elements) {
627
- const [o, i] = t.get(n) ?? [0, !1];
628
- i || t.set(n, [o + 1, await e(n, r, o)]);
664
+ const [i, o] = t.get(n) ?? [0, !1];
665
+ o || t.set(n, [i + 1, await e(n, r, i)]);
629
666
  }
630
- return new a(function* () {
631
- for (const [n, [r, o]] of t)
632
- yield [n, o];
667
+ return new l(function* () {
668
+ for (const [n, [r, i]] of t)
669
+ yield [n, i];
633
670
  });
634
671
  }
635
672
  filter(e) {
636
673
  const t = this._elements;
637
674
  return new y(async function* () {
638
675
  const n = /* @__PURE__ */ new Map();
639
- for await (const [r, o] of t) {
640
- const i = n.get(r) ?? 0;
641
- n.set(r, i + 1), await e(r, o, i) && (yield [r, o]);
676
+ for await (const [r, i] of t) {
677
+ const o = n.get(r) ?? 0;
678
+ n.set(r, o + 1), await e(r, i, o) && (yield [r, i]);
642
679
  }
643
680
  });
644
681
  }
@@ -646,29 +683,29 @@ class y {
646
683
  const t = this._elements;
647
684
  return new y(async function* () {
648
685
  const n = /* @__PURE__ */ new Map();
649
- for await (const [r, o] of t) {
650
- const i = n.get(r) ?? 0;
651
- n.set(r, i + 1), yield [r, await e(r, o, i)];
686
+ for await (const [r, i] of t) {
687
+ const o = n.get(r) ?? 0;
688
+ n.set(r, o + 1), yield [r, await e(r, i, o)];
652
689
  }
653
690
  });
654
691
  }
655
692
  async reduce(e, t) {
656
693
  const n = /* @__PURE__ */ new Map();
657
- for await (const [r, o] of this._elements) {
658
- let i, l;
694
+ for await (const [r, i] of this._elements) {
695
+ let o, c;
659
696
  if (n.has(r))
660
- [i, l] = n.get(r), i += 1;
697
+ [o, c] = n.get(r), o += 1;
661
698
  else if (t !== void 0)
662
- i = 0, l = await t(r);
699
+ o = 0, c = await t(r);
663
700
  else {
664
- n.set(r, [0, o]);
701
+ n.set(r, [0, i]);
665
702
  continue;
666
703
  }
667
- l = await e(r, l, o, i), n.set(r, [i, l]);
704
+ c = await e(r, c, i, o), n.set(r, [o, c]);
668
705
  }
669
- return new a(function* () {
670
- for (const [r, [o, i]] of n)
671
- yield [r, i];
706
+ return new l(function* () {
707
+ for (const [r, [i, o]] of n)
708
+ yield [r, o];
672
709
  });
673
710
  }
674
711
  unique() {
@@ -676,8 +713,8 @@ class y {
676
713
  return new y(async function* () {
677
714
  const t = /* @__PURE__ */ new Map();
678
715
  for await (const [n, r] of e) {
679
- const o = t.get(n) ?? /* @__PURE__ */ new Set();
680
- o.has(r) || (o.add(r), t.set(n, o), yield [n, r]);
716
+ const i = t.get(n) ?? /* @__PURE__ */ new Set();
717
+ i.has(r) || (i.add(r), t.set(n, i), yield [n, r]);
681
718
  }
682
719
  });
683
720
  }
@@ -687,7 +724,7 @@ class y {
687
724
  const n = e.get(t) ?? 0;
688
725
  e.set(t, n + 1);
689
726
  }
690
- return new a(function* () {
727
+ return new l(function* () {
691
728
  for (const [t, n] of e)
692
729
  yield [t, n];
693
730
  });
@@ -696,7 +733,7 @@ class y {
696
733
  const e = /* @__PURE__ */ new Map();
697
734
  for await (const [t, n] of this._elements)
698
735
  e.has(t) || e.set(t, n);
699
- return new a(function* () {
736
+ return new l(function* () {
700
737
  for (const [t, n] of e)
701
738
  yield [t, n];
702
739
  });
@@ -705,14 +742,14 @@ class y {
705
742
  const e = /* @__PURE__ */ new Map();
706
743
  for await (const [t, n] of this._elements)
707
744
  e.set(t, n);
708
- return new a(function* () {
745
+ return new l(function* () {
709
746
  for (const [t, n] of e)
710
747
  yield [t, n];
711
748
  });
712
749
  }
713
750
  keys() {
714
751
  const e = this._elements;
715
- return new h(async function* () {
752
+ return new d(async function* () {
716
753
  const t = /* @__PURE__ */ new Set();
717
754
  for await (const [n] of e)
718
755
  t.has(n) || (t.add(n), yield n);
@@ -723,7 +760,7 @@ class y {
723
760
  }
724
761
  values() {
725
762
  const e = this._elements;
726
- return new h(async function* () {
763
+ return new d(async function* () {
727
764
  for await (const [t, n] of e)
728
765
  yield n;
729
766
  });
@@ -752,19 +789,19 @@ class y {
752
789
  return "AggregatedAsyncIterator";
753
790
  }
754
791
  }
755
- class _ {
792
+ class p {
756
793
  constructor(e) {
757
794
  u(this, "_elements");
758
- this._elements = new h(e);
795
+ this._elements = new d(e);
759
796
  }
760
797
  filter(e) {
761
- return new _(this._elements.filter(e));
798
+ return new p(this._elements.filter(e));
762
799
  }
763
800
  map(e) {
764
- return new _(this._elements.map(e));
801
+ return new p(this._elements.map(e));
765
802
  }
766
803
  unique() {
767
- return new _(this._elements.unique());
804
+ return new p(this._elements.unique());
768
805
  }
769
806
  groupBy(e) {
770
807
  return new y(this._elements.map(async (t, n) => [await e(t, n), t]));
@@ -773,12 +810,69 @@ class _ {
773
810
  return "AsyncAggregator";
774
811
  }
775
812
  }
776
- class C {
813
+ var x = /* @__PURE__ */ ((s) => (s[s.Millisecond = 1] = "Millisecond", s[s.Second = 1e3] = "Second", s[s.Minute = 6e4] = "Minute", s[s.Hour = 36e5] = "Hour", s[s.Day = 864e5] = "Day", s[s.Week = 6048e5] = "Week", s[s.Month = 2592e6] = "Month", s[s.Year = 31536e6] = "Year", s))(x || {});
814
+ function L(s, e, t = 864e5) {
815
+ return s = new Date(s), e = new Date(e), Math.floor((e.getTime() - s.getTime()) / t);
816
+ }
817
+ function Q(s, e, t = 864e5) {
818
+ return s = new Date(s), e = new Date(e), new a(function* () {
819
+ const n = e.getTime();
820
+ let r = s.getTime();
821
+ for (; r < n; )
822
+ yield new Date(r), r += t;
823
+ });
824
+ }
825
+ function X(s, e = 864e5) {
826
+ return s = new Date(s), new Date(Math.floor(s.getTime() / e) * e);
827
+ }
828
+ class R {
829
+ constructor(e, t = 30) {
830
+ u(this, "_handle");
831
+ u(this, "_startTime");
832
+ u(this, "_isRunning");
833
+ u(this, "_start");
834
+ u(this, "_stop");
835
+ this._startTime = 0, this._isRunning = !1, E ? (this._start = () => {
836
+ e(this.elapsedTime), this._handle = window.requestAnimationFrame(this._start);
837
+ }, this._stop = () => window.cancelAnimationFrame(this._handle)) : (console.warn(
838
+ `Not a browser environment detected. Using setInterval@${t}fps instead of requestAnimationFrame...`
839
+ ), this._start = () => {
840
+ const n = x.Second / t;
841
+ this._handle = setInterval(() => e(this.elapsedTime), n);
842
+ }, this._stop = () => clearInterval(this._handle));
843
+ }
844
+ get startTime() {
845
+ return this._startTime;
846
+ }
847
+ get isRunning() {
848
+ return this._isRunning;
849
+ }
850
+ get elapsedTime() {
851
+ return performance.now() - this._startTime;
852
+ }
853
+ start(e = 0) {
854
+ if (this._isRunning)
855
+ throw new m("The game loop has already been started.");
856
+ this._startTime = performance.now() - e, this._start(), this._isRunning = !0;
857
+ }
858
+ stop() {
859
+ if (!this._isRunning)
860
+ throw new m("The game loop hadn't yet started.");
861
+ if (!this._handle)
862
+ throw new g();
863
+ this._stop(), this._handle = void 0, this._isRunning = !1;
864
+ }
865
+ }
866
+ class Z {
777
867
  constructor(e = !0) {
778
868
  u(this, "_preferPersistence");
779
869
  u(this, "_volatile");
780
870
  u(this, "_persistent");
781
- this._preferPersistence = e, this._volatile = window.sessionStorage, this._persistent = window.localStorage;
871
+ if (this._preferPersistence = e, !E)
872
+ throw new A(
873
+ "The `JSONStorage` class can only be instantiated within a browser environment."
874
+ );
875
+ this._volatile = window.sessionStorage, this._persistent = window.localStorage;
782
876
  }
783
877
  _get(e, t, n) {
784
878
  const r = e.getItem(t);
@@ -908,31 +1002,10 @@ class C {
908
1002
  this._volatile.removeItem(e), this._persistent.removeItem(e);
909
1003
  }
910
1004
  get [Symbol.toStringTag]() {
911
- return "JsonStorage";
1005
+ return "JSONStorage";
912
1006
  }
913
1007
  }
914
- class N {
915
- constructor() {
916
- u(this, "_subscribers");
917
- this._subscribers = [];
918
- }
919
- add(e) {
920
- this._subscribers.push(e);
921
- }
922
- remove(e) {
923
- const t = this._subscribers.indexOf(e);
924
- if (t < 0)
925
- throw new k("Unable to remove the requested subscriber. It was not found.");
926
- this._subscribers.splice(t, 1);
927
- }
928
- call(...e) {
929
- return this._subscribers.slice().map((t) => t(...e));
930
- }
931
- get [Symbol.toStringTag]() {
932
- return "Subscribers";
933
- }
934
- }
935
- class g {
1008
+ class F {
936
1009
  constructor(e) {
937
1010
  u(this, "_isPending");
938
1011
  u(this, "_isFulfilled");
@@ -966,15 +1039,15 @@ class g {
966
1039
  return "SmartPromise";
967
1040
  }
968
1041
  }
969
- class Y extends g {
1042
+ class O extends F {
970
1043
  constructor(t, n) {
971
- let r, o;
972
- super((i, l) => {
973
- r = i, o = l;
1044
+ let r, i;
1045
+ super((o, c) => {
1046
+ r = o, i = c;
974
1047
  });
975
1048
  u(this, "_resolve");
976
1049
  u(this, "_reject");
977
- this._promise.then(t, n), this._resolve = r, this._reject = o;
1050
+ this._promise.then(t, n), this._resolve = r, this._reject = i;
978
1051
  }
979
1052
  get resolve() {
980
1053
  return this._resolve;
@@ -989,22 +1062,111 @@ class Y extends g {
989
1062
  return "DeferredPromise";
990
1063
  }
991
1064
  }
992
- class z extends g {
1065
+ class U extends F {
993
1066
  constructor(e, t) {
994
1067
  super((n, r) => {
995
- const o = (p) => {
996
- clearTimeout(x), n(p);
997
- }, i = (p) => {
998
- clearTimeout(x), r(p);
999
- }, x = setTimeout(() => i(new T("The operation has timed out.")), t);
1000
- e(o, i);
1068
+ const i = (v) => {
1069
+ clearTimeout(b), n(v);
1070
+ }, o = (v) => {
1071
+ clearTimeout(b), r(v);
1072
+ }, b = setTimeout(() => o(new C("The operation has timed out.")), t);
1073
+ e(i, o);
1001
1074
  });
1002
1075
  }
1003
1076
  get [Symbol.toStringTag]() {
1004
1077
  return "TimedPromise";
1005
1078
  }
1006
1079
  }
1007
- class v {
1080
+ class P {
1081
+ constructor() {
1082
+ u(this, "_subscribers");
1083
+ this._subscribers = [];
1084
+ }
1085
+ subscribe(e) {
1086
+ return this._subscribers.push(e), () => {
1087
+ const t = this._subscribers.indexOf(e);
1088
+ if (t < 0)
1089
+ throw new q("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed.");
1090
+ this._subscribers.splice(t, 1);
1091
+ };
1092
+ }
1093
+ publish(...e) {
1094
+ return this._subscribers.slice().map((t) => t(...e));
1095
+ }
1096
+ get [Symbol.toStringTag]() {
1097
+ return "Publisher";
1098
+ }
1099
+ }
1100
+ class ee extends R {
1101
+ constructor(t = x.Second) {
1102
+ super((n) => this._publisher.publish(n), t);
1103
+ u(this, "_publisher");
1104
+ this._publisher = new P();
1105
+ }
1106
+ start(t = 0) {
1107
+ if (this._isRunning)
1108
+ throw new m("The clock has already been started.");
1109
+ super.start(t);
1110
+ }
1111
+ stop() {
1112
+ if (!this._isRunning)
1113
+ throw new m("The clock hadn't yet started.");
1114
+ super.stop();
1115
+ }
1116
+ onTick(t, n = 0) {
1117
+ if (n < 0)
1118
+ throw new M("The tick step must be a non-negative number.");
1119
+ if (n === 0)
1120
+ return this._publisher.subscribe(t);
1121
+ let r = 0;
1122
+ return this._publisher.subscribe((i) => {
1123
+ i - r < n || (t(i), r = i);
1124
+ });
1125
+ }
1126
+ }
1127
+ class te extends R {
1128
+ constructor(t, n = x.Second) {
1129
+ super(() => {
1130
+ const i = this.remainingTime;
1131
+ this._publisher.publish(i), i <= 0 && this.stop();
1132
+ }, n);
1133
+ u(this, "_deferrer");
1134
+ u(this, "_publisher");
1135
+ u(this, "_duration");
1136
+ this._publisher = new P(), this._duration = t;
1137
+ }
1138
+ get duration() {
1139
+ return this._duration;
1140
+ }
1141
+ get remainingTime() {
1142
+ return this._duration - this.elapsedTime;
1143
+ }
1144
+ start(t = this.duration) {
1145
+ if (this._isRunning)
1146
+ throw new m("The countdown has already been started.");
1147
+ if (this._deferrer)
1148
+ throw new g();
1149
+ return this._deferrer = new O(), super.start(this.duration - t), this._deferrer;
1150
+ }
1151
+ stop(t) {
1152
+ if (!this._isRunning)
1153
+ throw new m("The countdown hadn't yet started.");
1154
+ if (!this._deferrer)
1155
+ throw new g();
1156
+ super.stop(), t !== void 0 ? this._deferrer.reject(t) : this._deferrer.resolve(), this._deferrer = void 0;
1157
+ }
1158
+ onTick(t, n = 0) {
1159
+ if (n < 0)
1160
+ throw new M("The tick step must be a non-negative number.");
1161
+ if (n === 0)
1162
+ return this._publisher.subscribe(t);
1163
+ let r = 0;
1164
+ return this._publisher.subscribe((i) => {
1165
+ r - i < n || (t(i), r = i);
1166
+ });
1167
+ }
1168
+ }
1169
+ class I {
1008
1170
  static Boolean(e = 0.5) {
1009
1171
  return Math.random() < e;
1010
1172
  }
@@ -1016,51 +1178,36 @@ class v {
1016
1178
  }
1017
1179
  static Index(e) {
1018
1180
  if (e.length === 0)
1019
- throw new m("You must provide at least one element.");
1181
+ throw new f("You must provide at least one element.");
1020
1182
  return this.Integer(e.length);
1021
1183
  }
1022
1184
  static Choice(e) {
1023
- return e[v.Index(e)];
1185
+ return e[I.Index(e)];
1024
1186
  }
1025
1187
  // eslint-disable-next-line no-useless-constructor
1026
1188
  constructor() {
1027
1189
  }
1028
1190
  }
1029
- async function J(s) {
1191
+ async function ne(s) {
1030
1192
  return new Promise((e, t) => setTimeout(e, s));
1031
1193
  }
1032
- async function V() {
1194
+ async function re() {
1033
1195
  return new Promise((s, e) => requestAnimationFrame(() => s()));
1034
1196
  }
1035
- var M = /* @__PURE__ */ ((s) => (s[s.Millisecond = 1] = "Millisecond", s[s.Second = 1e3] = "Second", s[s.Minute = 6e4] = "Minute", s[s.Hour = 36e5] = "Hour", s[s.Day = 864e5] = "Day", s[s.Week = 6048e5] = "Week", s[s.Month = 2592e6] = "Month", s[s.Year = 31536e6] = "Year", s))(M || {});
1036
- function B(s, e, t = 864e5) {
1037
- return s = new Date(s), e = new Date(e), Math.floor((e.getTime() - s.getTime()) / t);
1038
- }
1039
- function K(s, e, t = 864e5) {
1040
- return s = new Date(s), e = new Date(e), new c(function* () {
1041
- const n = e.getTime();
1042
- let r = s.getTime();
1043
- for (; r < n; )
1044
- yield new Date(r), r += t;
1045
- });
1046
- }
1047
- function H(s, e = 864e5) {
1048
- return s = new Date(s), new Date(Math.floor(s.getTime() / e) * e);
1049
- }
1050
- function W(s, e = "text/javascript") {
1197
+ function se(s, e = "text/javascript") {
1051
1198
  return new Promise((t, n) => {
1052
1199
  const r = document.createElement("script");
1053
1200
  r.async = !0, r.defer = !0, r.src = s, r.type = e, r.onload = () => t(), r.onerror = () => n(), document.body.appendChild(r);
1054
1201
  });
1055
1202
  }
1056
- function G(...s) {
1057
- return new c(function* () {
1203
+ function ie(...s) {
1204
+ return new a(function* () {
1058
1205
  for (const e of s)
1059
1206
  for (const t of e)
1060
1207
  yield t;
1061
1208
  });
1062
1209
  }
1063
- function L(s) {
1210
+ function oe(s) {
1064
1211
  if (Array.isArray(s))
1065
1212
  return s.length;
1066
1213
  let e = 0;
@@ -1068,21 +1215,21 @@ function L(s) {
1068
1215
  e += 1;
1069
1216
  return e;
1070
1217
  }
1071
- function Q(s) {
1072
- return new c(function* () {
1218
+ function ue(s) {
1219
+ return new a(function* () {
1073
1220
  let e = 0;
1074
1221
  for (const t of s)
1075
1222
  yield [e, t], e += 1;
1076
1223
  });
1077
1224
  }
1078
- function X(s, e, t = 1) {
1079
- return new c(function* () {
1225
+ function ae(s, e, t = 1) {
1226
+ return new a(function* () {
1080
1227
  e === void 0 && (e = s, s = 0), s > e && (t = t ?? -1);
1081
1228
  for (let n = s; n < e; n += t)
1082
1229
  yield n;
1083
1230
  });
1084
1231
  }
1085
- function Z(s) {
1232
+ function ce(s) {
1086
1233
  const e = Array.from(s);
1087
1234
  for (let t = e.length - 1; t > 0; t -= 1) {
1088
1235
  const n = Math.floor(Math.random() * (t + 1));
@@ -1090,46 +1237,46 @@ function Z(s) {
1090
1237
  }
1091
1238
  return e;
1092
1239
  }
1093
- function D(s) {
1094
- return new c(function* () {
1240
+ function le(s) {
1241
+ return new a(function* () {
1095
1242
  const e = /* @__PURE__ */ new Set();
1096
1243
  for (const t of s)
1097
1244
  e.has(t) || (e.add(t), yield t);
1098
1245
  });
1099
1246
  }
1100
- function P(s, e) {
1101
- return new c(function* () {
1247
+ function N(s, e) {
1248
+ return new a(function* () {
1102
1249
  const t = s[Symbol.iterator](), n = e[Symbol.iterator]();
1103
1250
  for (; ; ) {
1104
- const r = t.next(), o = n.next();
1105
- if (r.done || o.done)
1251
+ const r = t.next(), i = n.next();
1252
+ if (r.done || i.done)
1106
1253
  break;
1107
- yield [r.value, o.value];
1254
+ yield [r.value, i.value];
1108
1255
  }
1109
1256
  });
1110
1257
  }
1111
- function U(s, e) {
1258
+ function he(s, e) {
1112
1259
  if (e === void 0) {
1113
- let o = 0, i = 0;
1114
- for (const l of s)
1115
- o += l, i += 1;
1116
- if (i === 0)
1117
- throw new m("You must provide at least one value.");
1118
- return o / i;
1260
+ let i = 0, o = 0;
1261
+ for (const c of s)
1262
+ i += c, o += 1;
1263
+ if (o === 0)
1264
+ throw new f("You must provide at least one value.");
1265
+ return i / o;
1119
1266
  }
1120
1267
  let t = 0, n = 0, r = 0;
1121
- for (const [o, i] of P(s, e)) {
1122
- if (i <= 0)
1123
- throw new m(`The weight for the value #${r} must be greater than zero.`);
1124
- t += o * i, n += i, r += 1;
1268
+ for (const [i, o] of N(s, e)) {
1269
+ if (o <= 0)
1270
+ throw new f(`The weight for the value #${r} must be greater than zero.`);
1271
+ t += i * o, n += o, r += 1;
1125
1272
  }
1126
1273
  if (r === 0)
1127
- throw new m("You must provide at least one value and weight.");
1274
+ throw new f("You must provide at least one value and weight.");
1128
1275
  if (n > 0)
1129
- throw new m("The sum of weights must be greater than zero.");
1276
+ throw new f("The sum of weights must be greater than zero.");
1130
1277
  return t / n;
1131
1278
  }
1132
- function ee(s) {
1279
+ function fe(s) {
1133
1280
  let e = 0;
1134
1281
  for (let t = 0; t < s.length; t += 1) {
1135
1282
  const n = s.charCodeAt(t);
@@ -1137,60 +1284,69 @@ function ee(s) {
1137
1284
  }
1138
1285
  return e;
1139
1286
  }
1140
- function te(s) {
1287
+ function de(s) {
1141
1288
  let e = 0;
1142
1289
  for (const t of s)
1143
1290
  e += t;
1144
1291
  return e;
1145
1292
  }
1146
- function ne(s) {
1293
+ function me(s) {
1147
1294
  return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
1148
1295
  }
1149
- const re = "1.5.3";
1296
+ const we = "2.0.0-rc.2";
1150
1297
  export {
1151
1298
  y as AggregatedAsyncIterator,
1152
- d as AggregatedIterator,
1153
- w as Aggregator,
1154
- _ as AsyncAggregator,
1155
- M as DateUnit,
1156
- Y as DeferredPromise,
1157
- f as Exception,
1158
- j as FatalErrorException,
1159
- R as FileNotFoundException,
1160
- C as JsonStorage,
1161
- q as KeyException,
1162
- A as NetworkException,
1163
- F as NotImplementedException,
1164
- O as PermissionException,
1165
- v as Random,
1166
- a as ReducedIterator,
1167
- k as ReferenceException,
1168
- $ as RuntimeException,
1169
- h as SmartAsyncIterator,
1170
- c as SmartIterator,
1171
- g as SmartPromise,
1172
- N as Subscribers,
1173
- z as TimedPromise,
1174
- T as TimeoutException,
1175
- E as TypeException,
1176
- re as VERSION,
1177
- m as ValueException,
1178
- U as average,
1179
- ne as capitalize,
1180
- G as chain,
1181
- L as count,
1182
- B as dateDifference,
1183
- K as dateRange,
1184
- H as dateRound,
1185
- J as delay,
1186
- Q as enumerate,
1187
- ee as hash,
1188
- W as loadScript,
1189
- V as nextAnimationFrame,
1190
- X as range,
1191
- Z as shuffle,
1192
- te as sum,
1193
- D as unique,
1194
- P as zip
1299
+ w as AggregatedIterator,
1300
+ _ as Aggregator,
1301
+ p as AsyncAggregator,
1302
+ ee as Clock,
1303
+ te as Countdown,
1304
+ O as DeferredPromise,
1305
+ h as Exception,
1306
+ g as FatalErrorException,
1307
+ T as FileException,
1308
+ z as FileExistsException,
1309
+ V as FileNotFoundException,
1310
+ R as GameLoop,
1311
+ Z as JSONStorage,
1312
+ B as KeyException,
1313
+ K as NetworkException,
1314
+ Y as NotImplementedException,
1315
+ G as PermissionException,
1316
+ P as Publisher,
1317
+ I as Random,
1318
+ M as RangeException,
1319
+ l as ReducedIterator,
1320
+ q as ReferenceException,
1321
+ m as RuntimeException,
1322
+ d as SmartAsyncIterator,
1323
+ a as SmartIterator,
1324
+ F as SmartPromise,
1325
+ x as TimeUnit,
1326
+ U as TimedPromise,
1327
+ C as TimeoutException,
1328
+ H as TypeException,
1329
+ we as VERSION,
1330
+ f as ValueException,
1331
+ he as average,
1332
+ me as capitalize,
1333
+ ie as chain,
1334
+ oe as count,
1335
+ L as dateDifference,
1336
+ Q as dateRange,
1337
+ X as dateRound,
1338
+ ne as delay,
1339
+ ue as enumerate,
1340
+ fe as hash,
1341
+ E as isBrowser,
1342
+ J as isNode,
1343
+ W as isWebWorker,
1344
+ se as loadScript,
1345
+ re as nextAnimationFrame,
1346
+ ae as range,
1347
+ ce as shuffle,
1348
+ de as sum,
1349
+ le as unique,
1350
+ N as zip
1195
1351
  };
1196
1352
  //# sourceMappingURL=core.js.map