@byloth/core 2.2.1 → 2.2.3

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.esm.js CHANGED
@@ -1,5 +1,5 @@
1
- const T = typeof window < "u" && typeof window.document < "u", D = typeof process < "u" && !!process.versions?.node, B = typeof self == "object" && self.constructor?.name === "DedicatedWorkerGlobalScope";
2
- class c extends Error {
1
+ const E = typeof window < "u" && typeof window.document < "u", B = typeof process < "u" && !!process.versions?.node, Y = typeof self == "object" && self.constructor?.name === "DedicatedWorkerGlobalScope";
2
+ class h extends Error {
3
3
  /**
4
4
  * A static method to convert a generic caught error, ensuring it's an instance of the {@link Exception} class.
5
5
  *
@@ -23,13 +23,13 @@ class c extends Error {
23
23
  * @returns An instance of the {@link Exception} class.
24
24
  */
25
25
  static FromUnknown(e) {
26
- if (e instanceof c)
26
+ if (e instanceof h)
27
27
  return e;
28
28
  if (e instanceof Error) {
29
- const t = new c(e.message);
30
- return t.stack = e.stack, t.name = e.name, t;
29
+ const t = new h(e.message);
30
+ return t.stack = e.stack, t.cause = e.cause, t.name = e.name, t;
31
31
  }
32
- return new c(`${e}`);
32
+ return new h(`${e}`);
33
33
  }
34
34
  /**
35
35
  * Initializes a new instance of the {@link Exception} class.
@@ -48,15 +48,11 @@ class c extends Error {
48
48
  * @param name The name of the exception. Default is `"Exception"`.
49
49
  */
50
50
  constructor(e, t, n = "Exception") {
51
- super(e), this.cause = t, this.name = n, t && (t instanceof Error ? this.stack += `
52
-
53
- Caused by ${t.stack}` : this.stack += `
54
-
55
- Caused by ${t}`);
51
+ super(e), this.cause = t, this.name = n;
56
52
  }
57
53
  [Symbol.toStringTag] = "Exception";
58
54
  }
59
- class x extends c {
55
+ class g extends h {
60
56
  /**
61
57
  * Initializes a new instance of the {@link FatalErrorException} class.
62
58
  *
@@ -78,7 +74,7 @@ class x extends c {
78
74
  }
79
75
  [Symbol.toStringTag] = "FatalErrorException";
80
76
  }
81
- class P extends x {
77
+ class j extends g {
82
78
  /**
83
79
  * Initializes a new instance of the {@link NotImplementedException} class.
84
80
  *
@@ -100,7 +96,7 @@ class P extends x {
100
96
  }
101
97
  [Symbol.toStringTag] = "NotImplementedException";
102
98
  }
103
- class E extends c {
99
+ class M extends h {
104
100
  /**
105
101
  * Initializes a new instance of the {@link FileException} class.
106
102
  *
@@ -122,7 +118,7 @@ class E extends c {
122
118
  }
123
119
  [Symbol.toStringTag] = "FileException";
124
120
  }
125
- class J extends E {
121
+ class J extends M {
126
122
  /**
127
123
  * Initializes a new instance of the {@link FileExistsException} class.
128
124
  *
@@ -144,7 +140,7 @@ class J extends E {
144
140
  }
145
141
  [Symbol.toStringTag] = "FileExistsException";
146
142
  }
147
- class Y extends E {
143
+ class L extends M {
148
144
  /**
149
145
  * Initializes a new instance of the {@link FileNotFoundException} class.
150
146
  *
@@ -166,7 +162,7 @@ class Y extends E {
166
162
  }
167
163
  [Symbol.toStringTag] = "FileNotFoundException";
168
164
  }
169
- class p extends c {
165
+ class b extends h {
170
166
  /**
171
167
  * Initializes a new instance of the {@link KeyException} class.
172
168
  *
@@ -188,7 +184,7 @@ class p extends c {
188
184
  }
189
185
  [Symbol.toStringTag] = "KeyException";
190
186
  }
191
- class L extends c {
187
+ class V extends h {
192
188
  /**
193
189
  * Initializes a new instance of the {@link NetworkException} class.
194
190
  *
@@ -210,7 +206,7 @@ class L extends c {
210
206
  }
211
207
  [Symbol.toStringTag] = "NetworkException";
212
208
  }
213
- class V extends c {
209
+ class G extends h {
214
210
  /**
215
211
  * Initializes a new instance of the {@link PermissionException} class.
216
212
  *
@@ -232,7 +228,7 @@ class V extends c {
232
228
  }
233
229
  [Symbol.toStringTag] = "PermissionException";
234
230
  }
235
- class k extends c {
231
+ class k extends h {
236
232
  /**
237
233
  * Initializes a new instance of the {@link ReferenceException} class.
238
234
  *
@@ -254,7 +250,7 @@ class k extends c {
254
250
  }
255
251
  [Symbol.toStringTag] = "ReferenceException";
256
252
  }
257
- class _ extends c {
253
+ class y extends h {
258
254
  /**
259
255
  * Initializes a new instance of the {@link RuntimeException} class.
260
256
  *
@@ -276,7 +272,7 @@ class _ extends c {
276
272
  }
277
273
  [Symbol.toStringTag] = "RuntimeException";
278
274
  }
279
- class j extends _ {
275
+ class O extends y {
280
276
  /**
281
277
  * Initializes a new instance of the {@link EnvironmentException} class.
282
278
  *
@@ -298,7 +294,7 @@ class j extends _ {
298
294
  }
299
295
  [Symbol.toStringTag] = "EnvironmentException";
300
296
  }
301
- class O extends c {
297
+ class N extends h {
302
298
  /**
303
299
  * Initializes a new instance of the {@link TimeoutException} class.
304
300
  *
@@ -320,7 +316,7 @@ class O extends c {
320
316
  }
321
317
  [Symbol.toStringTag] = "TimeoutException";
322
318
  }
323
- class G extends c {
319
+ class K extends h {
324
320
  /**
325
321
  * Initializes a new instance of the {@link TypeException} class.
326
322
  *
@@ -342,7 +338,7 @@ class G extends c {
342
338
  }
343
339
  [Symbol.toStringTag] = "TypeException";
344
340
  }
345
- class f extends c {
341
+ class u extends h {
346
342
  /**
347
343
  * Initializes a new instance of the {@link ValueException} class.
348
344
  *
@@ -364,7 +360,7 @@ class f extends c {
364
360
  }
365
361
  [Symbol.toStringTag] = "ValueException";
366
362
  }
367
- class b extends f {
363
+ class x extends u {
368
364
  /**
369
365
  * Initializes a new instance of the {@link RangeException} class.
370
366
  *
@@ -534,7 +530,7 @@ class l {
534
530
  if (s === void 0) {
535
531
  const r = this._iterator.next();
536
532
  if (r.done)
537
- throw new f("Cannot reduce an empty iterator without an initial value.");
533
+ throw new u("Cannot reduce an empty iterator without an initial value.");
538
534
  s = r.value, n += 1;
539
535
  }
540
536
  for (; ; ) {
@@ -914,7 +910,7 @@ class l {
914
910
  * {
915
911
  * try
916
912
  * {
917
- * if (value > 5) { throw new Error("The index is too high."); }
913
+ * if (value > 5) { throw new Exception("The index is too high."); }
918
914
  *
919
915
  * console.log(value); // 1, 2, 3, 4, 5
920
916
  * }
@@ -964,7 +960,7 @@ class l {
964
960
  * @returns A new instance of the {@link AggregatedIterator} class containing the grouped elements.
965
961
  */
966
962
  groupBy(e) {
967
- return new h(this.map((t, n) => [e(t, n), t]));
963
+ return new d(this.map((t, n) => [e(t, n), t]));
968
964
  }
969
965
  /**
970
966
  * Materializes the iterator into an array.
@@ -997,7 +993,7 @@ class l {
997
993
  return this;
998
994
  }
999
995
  }
1000
- class u {
996
+ class c {
1001
997
  /**
1002
998
  * The internal {@link SmartIterator} object that holds the reduced elements.
1003
999
  */
@@ -1081,7 +1077,7 @@ class u {
1081
1077
  }
1082
1078
  filter(e) {
1083
1079
  const t = this._elements.enumerate();
1084
- return new u(function* () {
1080
+ return new c(function* () {
1085
1081
  for (const [n, [s, r]] of t)
1086
1082
  e(s, r, n) && (yield [s, r]);
1087
1083
  });
@@ -1121,7 +1117,7 @@ class u {
1121
1117
  */
1122
1118
  map(e) {
1123
1119
  const t = this._elements.enumerate();
1124
- return new u(function* () {
1120
+ return new c(function* () {
1125
1121
  for (const [n, [s, r]] of t)
1126
1122
  yield [s, e(s, r, n)];
1127
1123
  });
@@ -1131,7 +1127,7 @@ class u {
1131
1127
  if (s === void 0) {
1132
1128
  const r = this._elements.next();
1133
1129
  if (r.done)
1134
- throw new f("Cannot reduce an empty iterator without an initial value.");
1130
+ throw new u("Cannot reduce an empty iterator without an initial value.");
1135
1131
  s = r.value[1], n += 1;
1136
1132
  }
1137
1133
  for (const [r, o] of this._elements)
@@ -1173,7 +1169,7 @@ class u {
1173
1169
  */
1174
1170
  flatMap(e) {
1175
1171
  const t = this._elements.enumerate();
1176
- return new h(function* () {
1172
+ return new d(function* () {
1177
1173
  for (const [n, [s, r]] of t) {
1178
1174
  const o = e(s, r, n);
1179
1175
  if (o instanceof Array)
@@ -1219,7 +1215,7 @@ class u {
1219
1215
  */
1220
1216
  drop(e) {
1221
1217
  const t = this._elements.enumerate();
1222
- return new u(function* () {
1218
+ return new c(function* () {
1223
1219
  for (const [n, [s, r]] of t)
1224
1220
  n >= e && (yield [s, r]);
1225
1221
  });
@@ -1261,7 +1257,7 @@ class u {
1261
1257
  */
1262
1258
  take(e) {
1263
1259
  const t = this._elements.enumerate();
1264
- return new u(function* () {
1260
+ return new c(function* () {
1265
1261
  for (const [n, [s, r]] of t) {
1266
1262
  if (n >= e)
1267
1263
  break;
@@ -1331,7 +1327,7 @@ class u {
1331
1327
  */
1332
1328
  unique() {
1333
1329
  const e = this._elements;
1334
- return new u(function* () {
1330
+ return new c(function* () {
1335
1331
  const t = /* @__PURE__ */ new Set();
1336
1332
  for (const [n, s] of e)
1337
1333
  t.has(s) || (t.add(s), yield [n, s]);
@@ -1427,7 +1423,7 @@ class u {
1427
1423
  */
1428
1424
  reorganizeBy(e) {
1429
1425
  const t = this._elements.enumerate();
1430
- return new h(function* () {
1426
+ return new d(function* () {
1431
1427
  for (const [n, [s, r]] of t)
1432
1428
  yield [e(s, r, n), r];
1433
1429
  });
@@ -1605,13 +1601,13 @@ class u {
1605
1601
  }
1606
1602
  [Symbol.toStringTag] = "ReducedIterator";
1607
1603
  }
1608
- class w {
1604
+ class p {
1609
1605
  /**
1610
1606
  * The internal {@link SmartAsyncIterator} object that holds the elements to aggregate.
1611
1607
  */
1612
1608
  _elements;
1613
1609
  constructor(e) {
1614
- this._elements = new d(e);
1610
+ this._elements = new w(e);
1615
1611
  }
1616
1612
  /**
1617
1613
  * Determines whether all elements of each group of the iterator satisfy a given condition.
@@ -1650,7 +1646,7 @@ class w {
1650
1646
  const [r, o] = t.get(n) ?? [0, !0];
1651
1647
  o && t.set(n, [r + 1, await e(n, s, r)]);
1652
1648
  }
1653
- return new u(function* () {
1649
+ return new c(function* () {
1654
1650
  for (const [n, [s, r]] of t)
1655
1651
  yield [n, r];
1656
1652
  });
@@ -1692,14 +1688,14 @@ class w {
1692
1688
  const [r, o] = t.get(n) ?? [0, !1];
1693
1689
  o || t.set(n, [r + 1, await e(n, s, r)]);
1694
1690
  }
1695
- return new u(function* () {
1691
+ return new c(function* () {
1696
1692
  for (const [n, [s, r]] of t)
1697
1693
  yield [n, r];
1698
1694
  });
1699
1695
  }
1700
1696
  filter(e) {
1701
1697
  const t = this._elements;
1702
- return new w(async function* () {
1698
+ return new p(async function* () {
1703
1699
  const n = /* @__PURE__ */ new Map();
1704
1700
  for await (const [s, r] of t) {
1705
1701
  const o = n.get(s) ?? 0;
@@ -1741,7 +1737,7 @@ class w {
1741
1737
  */
1742
1738
  map(e) {
1743
1739
  const t = this._elements;
1744
- return new w(async function* () {
1740
+ return new p(async function* () {
1745
1741
  const n = /* @__PURE__ */ new Map();
1746
1742
  for await (const [s, r] of t) {
1747
1743
  const o = n.get(s) ?? 0;
@@ -1763,7 +1759,7 @@ class w {
1763
1759
  }
1764
1760
  n.set(s, [o + 1, await e(s, a, r, o)]);
1765
1761
  }
1766
- return new u(function* () {
1762
+ return new c(function* () {
1767
1763
  for (const [s, [r, o]] of n)
1768
1764
  yield [s, o];
1769
1765
  });
@@ -1806,13 +1802,13 @@ class w {
1806
1802
  */
1807
1803
  flatMap(e) {
1808
1804
  const t = this._elements;
1809
- return new w(async function* () {
1805
+ return new p(async function* () {
1810
1806
  const n = /* @__PURE__ */ new Map();
1811
1807
  for await (const [s, r] of t) {
1812
1808
  const o = n.get(s) ?? 0, a = await e(s, r, o);
1813
1809
  if (a instanceof Array)
1814
- for (const y of a)
1815
- yield [s, y];
1810
+ for (const f of a)
1811
+ yield [s, f];
1816
1812
  else
1817
1813
  yield [s, a];
1818
1814
  n.set(s, o + 1);
@@ -1850,7 +1846,7 @@ class w {
1850
1846
  */
1851
1847
  drop(e) {
1852
1848
  const t = this._elements;
1853
- return new w(async function* () {
1849
+ return new p(async function* () {
1854
1850
  const n = /* @__PURE__ */ new Map();
1855
1851
  for await (const [s, r] of t) {
1856
1852
  const o = n.get(s) ?? 0;
@@ -1893,7 +1889,7 @@ class w {
1893
1889
  */
1894
1890
  take(e) {
1895
1891
  const t = this._elements;
1896
- return new w(async function* () {
1892
+ return new p(async function* () {
1897
1893
  const n = /* @__PURE__ */ new Map();
1898
1894
  for await (const [s, r] of t) {
1899
1895
  const o = n.get(s) ?? 0;
@@ -1907,7 +1903,7 @@ class w {
1907
1903
  let [r, o] = t.get(n) ?? [0, void 0];
1908
1904
  o === void 0 && (await e(n, s, r) && (o = s), t.set(n, [r + 1, o]));
1909
1905
  }
1910
- return new u(function* () {
1906
+ return new c(function* () {
1911
1907
  for (const [n, [s, r]] of t)
1912
1908
  yield [n, r];
1913
1909
  });
@@ -1969,7 +1965,7 @@ class w {
1969
1965
  */
1970
1966
  unique() {
1971
1967
  const e = this._elements;
1972
- return new w(async function* () {
1968
+ return new p(async function* () {
1973
1969
  const t = /* @__PURE__ */ new Map();
1974
1970
  for await (const [n, s] of e) {
1975
1971
  const r = t.get(n) ?? /* @__PURE__ */ new Set();
@@ -2005,7 +2001,7 @@ class w {
2005
2001
  const n = e.get(t) ?? 0;
2006
2002
  e.set(t, n + 1);
2007
2003
  }
2008
- return new u(function* () {
2004
+ return new c(function* () {
2009
2005
  for (const [t, n] of e)
2010
2006
  yield [t, n];
2011
2007
  });
@@ -2076,7 +2072,7 @@ class w {
2076
2072
  */
2077
2073
  reorganizeBy(e) {
2078
2074
  const t = this._elements;
2079
- return new w(async function* () {
2075
+ return new p(async function* () {
2080
2076
  const n = /* @__PURE__ */ new Map();
2081
2077
  for await (const [s, r] of t) {
2082
2078
  const o = n.get(s) ?? 0;
@@ -2112,7 +2108,7 @@ class w {
2112
2108
  */
2113
2109
  keys() {
2114
2110
  const e = this._elements;
2115
- return new d(async function* () {
2111
+ return new w(async function* () {
2116
2112
  const t = /* @__PURE__ */ new Set();
2117
2113
  for await (const [n] of e)
2118
2114
  t.has(n) || (t.add(n), yield n);
@@ -2176,7 +2172,7 @@ class w {
2176
2172
  */
2177
2173
  values() {
2178
2174
  const e = this._elements;
2179
- return new d(async function* () {
2175
+ return new w(async function* () {
2180
2176
  for await (const [t, n] of e)
2181
2177
  yield n;
2182
2178
  });
@@ -2263,7 +2259,7 @@ class w {
2263
2259
  }
2264
2260
  [Symbol.toStringTag] = "AggregatedAsyncIterator";
2265
2261
  }
2266
- class d {
2262
+ class w {
2267
2263
  /**
2268
2264
  * The native {@link AsyncIterator} object that is being wrapped by this instance.
2269
2265
  */
@@ -2387,7 +2383,7 @@ class d {
2387
2383
  }
2388
2384
  filter(e) {
2389
2385
  const t = this._iterator;
2390
- return new d(async function* () {
2386
+ return new w(async function* () {
2391
2387
  let n = 0;
2392
2388
  for (; ; ) {
2393
2389
  const s = await t.next();
@@ -2430,7 +2426,7 @@ class d {
2430
2426
  */
2431
2427
  map(e) {
2432
2428
  const t = this._iterator;
2433
- return new d(async function* () {
2429
+ return new w(async function* () {
2434
2430
  let n = 0;
2435
2431
  for (; ; ) {
2436
2432
  const s = await t.next();
@@ -2445,7 +2441,7 @@ class d {
2445
2441
  if (s === void 0) {
2446
2442
  const r = await this._iterator.next();
2447
2443
  if (r.done)
2448
- throw new f("Cannot reduce an empty iterator without an initial value.");
2444
+ throw new u("Cannot reduce an empty iterator without an initial value.");
2449
2445
  s = r.value, n += 1;
2450
2446
  }
2451
2447
  for (; ; ) {
@@ -2488,7 +2484,7 @@ class d {
2488
2484
  */
2489
2485
  flatMap(e) {
2490
2486
  const t = this._iterator;
2491
- return new d(async function* () {
2487
+ return new w(async function* () {
2492
2488
  let n = 0;
2493
2489
  for (; ; ) {
2494
2490
  const s = await t.next();
@@ -2537,7 +2533,7 @@ class d {
2537
2533
  */
2538
2534
  drop(e) {
2539
2535
  const t = this._iterator;
2540
- return new d(async function* () {
2536
+ return new w(async function* () {
2541
2537
  let n = 0;
2542
2538
  for (; n < e; ) {
2543
2539
  if ((await t.next()).done)
@@ -2586,7 +2582,7 @@ class d {
2586
2582
  */
2587
2583
  take(e) {
2588
2584
  const t = this._iterator;
2589
- return new d(async function* () {
2585
+ return new w(async function* () {
2590
2586
  let n = 0;
2591
2587
  for (; n < e; ) {
2592
2588
  const s = await t.next();
@@ -2665,7 +2661,7 @@ class d {
2665
2661
  */
2666
2662
  unique() {
2667
2663
  const e = this._iterator;
2668
- return new d(async function* () {
2664
+ return new w(async function* () {
2669
2665
  const t = /* @__PURE__ */ new Set();
2670
2666
  for (; ; ) {
2671
2667
  const n = await e.next();
@@ -2832,7 +2828,7 @@ class d {
2832
2828
  * {
2833
2829
  * try
2834
2830
  * {
2835
- * if (value > 5) { throw new Error("The index is too high."); }
2831
+ * if (value > 5) { throw new Exception("The index is too high."); }
2836
2832
  *
2837
2833
  * console.log(value); // 1, 2, 3, 4, 5
2838
2834
  * }
@@ -2882,7 +2878,7 @@ class d {
2882
2878
  * @returns A new instance of the {@link AggregatedAsyncIterator} class containing the grouped elements.
2883
2879
  */
2884
2880
  groupBy(e) {
2885
- return new w(this.map(async (t, n) => [await e(t, n), t]));
2881
+ return new p(this.map(async (t, n) => [await e(t, n), t]));
2886
2882
  }
2887
2883
  /**
2888
2884
  * Materializes the iterator into an array.
@@ -2915,7 +2911,7 @@ class d {
2915
2911
  return this;
2916
2912
  }
2917
2913
  }
2918
- class h {
2914
+ class d {
2919
2915
  /**
2920
2916
  * The internal {@link SmartIterator} object that holds the elements to aggregate.
2921
2917
  */
@@ -2959,7 +2955,7 @@ class h {
2959
2955
  const [r, o] = t.get(n) ?? [0, !0];
2960
2956
  o && t.set(n, [r + 1, e(n, s, r)]);
2961
2957
  }
2962
- return new u(function* () {
2958
+ return new c(function* () {
2963
2959
  for (const [n, [s, r]] of t)
2964
2960
  yield [n, r];
2965
2961
  });
@@ -3000,14 +2996,14 @@ class h {
3000
2996
  const [r, o] = t.get(n) ?? [0, !1];
3001
2997
  o || t.set(n, [r + 1, e(n, s, r)]);
3002
2998
  }
3003
- return new u(function* () {
2999
+ return new c(function* () {
3004
3000
  for (const [n, [s, r]] of t)
3005
3001
  yield [n, r];
3006
3002
  });
3007
3003
  }
3008
3004
  filter(e) {
3009
3005
  const t = this._elements;
3010
- return new h(function* () {
3006
+ return new d(function* () {
3011
3007
  const n = /* @__PURE__ */ new Map();
3012
3008
  for (const [s, r] of t) {
3013
3009
  const o = n.get(s) ?? 0;
@@ -3049,7 +3045,7 @@ class h {
3049
3045
  */
3050
3046
  map(e) {
3051
3047
  const t = this._elements;
3052
- return new h(function* () {
3048
+ return new d(function* () {
3053
3049
  const n = /* @__PURE__ */ new Map();
3054
3050
  for (const [s, r] of t) {
3055
3051
  const o = n.get(s) ?? 0;
@@ -3071,7 +3067,7 @@ class h {
3071
3067
  }
3072
3068
  n.set(s, [o + 1, e(s, a, r, o)]);
3073
3069
  }
3074
- return new u(function* () {
3070
+ return new c(function* () {
3075
3071
  for (const [s, [r, o]] of n)
3076
3072
  yield [s, o];
3077
3073
  });
@@ -3114,13 +3110,13 @@ class h {
3114
3110
  */
3115
3111
  flatMap(e) {
3116
3112
  const t = this._elements;
3117
- return new h(function* () {
3113
+ return new d(function* () {
3118
3114
  const n = /* @__PURE__ */ new Map();
3119
3115
  for (const [s, r] of t) {
3120
3116
  const o = n.get(s) ?? 0, a = e(s, r, o);
3121
3117
  if (a instanceof Array)
3122
- for (const y of a)
3123
- yield [s, y];
3118
+ for (const f of a)
3119
+ yield [s, f];
3124
3120
  else
3125
3121
  yield [s, a];
3126
3122
  n.set(s, o + 1);
@@ -3158,7 +3154,7 @@ class h {
3158
3154
  */
3159
3155
  drop(e) {
3160
3156
  const t = this._elements;
3161
- return new h(function* () {
3157
+ return new d(function* () {
3162
3158
  const n = /* @__PURE__ */ new Map();
3163
3159
  for (const [s, r] of t) {
3164
3160
  const o = n.get(s) ?? 0;
@@ -3201,7 +3197,7 @@ class h {
3201
3197
  */
3202
3198
  take(e) {
3203
3199
  const t = this._elements;
3204
- return new h(function* () {
3200
+ return new d(function* () {
3205
3201
  const n = /* @__PURE__ */ new Map();
3206
3202
  for (const [s, r] of t) {
3207
3203
  const o = n.get(s) ?? 0;
@@ -3215,7 +3211,7 @@ class h {
3215
3211
  let [r, o] = t.get(n) ?? [0, void 0];
3216
3212
  o === void 0 && (e(n, s, r) && (o = s), t.set(n, [r + 1, o]));
3217
3213
  }
3218
- return new u(function* () {
3214
+ return new c(function* () {
3219
3215
  for (const [n, [s, r]] of t)
3220
3216
  yield [n, r];
3221
3217
  });
@@ -3277,7 +3273,7 @@ class h {
3277
3273
  */
3278
3274
  unique() {
3279
3275
  const e = this._elements;
3280
- return new h(function* () {
3276
+ return new d(function* () {
3281
3277
  const t = /* @__PURE__ */ new Map();
3282
3278
  for (const [n, s] of e) {
3283
3279
  const r = t.get(n) ?? /* @__PURE__ */ new Set();
@@ -3312,7 +3308,7 @@ class h {
3312
3308
  const n = e.get(t) ?? 0;
3313
3309
  e.set(t, n + 1);
3314
3310
  }
3315
- return new u(function* () {
3311
+ return new c(function* () {
3316
3312
  for (const [t, n] of e)
3317
3313
  yield [t, n];
3318
3314
  });
@@ -3381,7 +3377,7 @@ class h {
3381
3377
  */
3382
3378
  reorganizeBy(e) {
3383
3379
  const t = this._elements;
3384
- return new h(function* () {
3380
+ return new d(function* () {
3385
3381
  const n = /* @__PURE__ */ new Map();
3386
3382
  for (const [s, r] of t) {
3387
3383
  const o = n.get(s) ?? 0;
@@ -3568,8 +3564,8 @@ class h {
3568
3564
  }
3569
3565
  [Symbol.toStringTag] = "AggregatedIterator";
3570
3566
  }
3571
- const N = Function;
3572
- class M extends N {
3567
+ const z = Function;
3568
+ class R extends z {
3573
3569
  /**
3574
3570
  * Initializes a new instance of the {@link CallableObject} class.
3575
3571
  */
@@ -3580,7 +3576,7 @@ class M extends N {
3580
3576
  }
3581
3577
  [Symbol.toStringTag] = "CallableObject";
3582
3578
  }
3583
- class K extends M {
3579
+ class Q extends R {
3584
3580
  /**
3585
3581
  * The array containing all the functions in the chain.
3586
3582
  */
@@ -3618,7 +3614,10 @@ class K extends M {
3618
3614
  * @returns An array containing the return values of all functions.
3619
3615
  */
3620
3616
  _invoke(...e) {
3621
- return this._callbacks.map((t) => t(...e));
3617
+ const t = this._callbacks.length, n = new Array(t);
3618
+ for (let s = 0; s < t; s += 1)
3619
+ n[s] = this._callbacks[s](...e);
3620
+ return n;
3622
3621
  }
3623
3622
  /**
3624
3623
  * Adds a function to the chain.
@@ -3687,7 +3686,7 @@ class K extends M {
3687
3686
  }
3688
3687
  [Symbol.toStringTag] = "CallbackChain";
3689
3688
  }
3690
- class g {
3689
+ class v {
3691
3690
  /**
3692
3691
  * A map containing all the subscribers for each event.
3693
3692
  *
@@ -3743,14 +3742,21 @@ class g {
3743
3742
  */
3744
3743
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
3745
3744
  createScope() {
3746
- const e = new g();
3745
+ const e = new v();
3747
3746
  return this.subscribe("__internals__:clear", () => e.clear()), this.subscribe("*", (t, ...n) => {
3748
3747
  e.publish(t, ...n);
3749
3748
  }), e;
3750
3749
  }
3751
3750
  publish(e, ...t) {
3752
3751
  let n, s = this._subscribers.get(e);
3753
- return s ? n = s.slice().map((r) => r(...t)) : n = [], e.startsWith("__") || (s = this._subscribers.get("*"), s && s.slice().forEach((r) => r(e, ...t))), n;
3752
+ if (s) {
3753
+ const r = s.slice(), o = r.length;
3754
+ n = new Array(o);
3755
+ for (let a = 0; a < o; a += 1)
3756
+ n[a] = r[a](...t);
3757
+ } else
3758
+ n = [];
3759
+ return e.startsWith("__") || (s = this._subscribers.get("*"), s && s.slice().forEach((r) => r(e, ...t))), n;
3754
3760
  }
3755
3761
  subscribe(e, t) {
3756
3762
  const n = this._subscribers.get(e) ?? [];
@@ -3798,9 +3804,9 @@ class g {
3798
3804
  }
3799
3805
  [Symbol.toStringTag] = "Publisher";
3800
3806
  }
3801
- const q = () => {
3807
+ const A = () => {
3802
3808
  };
3803
- class Q extends M {
3809
+ class H extends R {
3804
3810
  /**
3805
3811
  * The currently selected implementation of the callback.
3806
3812
  */
@@ -3848,7 +3854,7 @@ class Q extends M {
3848
3854
  _invoke;
3849
3855
  constructor(e, t = "default") {
3850
3856
  super(), this._callbacks = /* @__PURE__ */ new Map(), this._isEnabled = !0, e ? this._callbacks.set(t, e) : (t = "", e = (() => {
3851
- throw new P(
3857
+ throw new j(
3852
3858
  "The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
3853
3859
  );
3854
3860
  })), this._key = t, this._callback = e, this._invoke = (...n) => this._callback(...n);
@@ -3878,16 +3884,16 @@ class Q extends M {
3878
3884
  enable(e) {
3879
3885
  if (e === void 0) {
3880
3886
  if (!this._key)
3881
- throw new p(
3887
+ throw new b(
3882
3888
  "The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
3883
3889
  );
3884
3890
  e = this._key;
3885
3891
  } else if (e) {
3886
3892
  if (!this._callbacks.has(e))
3887
- throw new p(`The key '${e}' doesn't yet have any associated callback.`);
3888
- } else throw new p("The key must be a non-empty string.");
3893
+ throw new b(`The key '${e}' doesn't yet have any associated callback.`);
3894
+ } else throw new b("The key must be a non-empty string.");
3889
3895
  if (this._isEnabled)
3890
- throw new _("The `SwitchableCallback` is already enabled.");
3896
+ throw new y("The `SwitchableCallback` is already enabled.");
3891
3897
  this._callback = this._callbacks.get(e), this._isEnabled = !0;
3892
3898
  }
3893
3899
  /**
@@ -3905,8 +3911,8 @@ class Q extends M {
3905
3911
  */
3906
3912
  disable() {
3907
3913
  if (!this._isEnabled)
3908
- throw new _("The `SwitchableCallback` is already disabled.");
3909
- this._callback = q, this._isEnabled = !1;
3914
+ throw new y("The `SwitchableCallback` is already disabled.");
3915
+ this._callback = A, this._isEnabled = !1;
3910
3916
  }
3911
3917
  /**
3912
3918
  * Registers a new implementation for the callback.
@@ -3932,7 +3938,7 @@ class Q extends M {
3932
3938
  if (this._callbacks.size === 0)
3933
3939
  this._key = e, this._callback = t;
3934
3940
  else if (this._callbacks.has(e))
3935
- throw new p(`The key '${e}' has already been used for another callback.`);
3941
+ throw new b(`The key '${e}' has already been used for another callback.`);
3936
3942
  this._callbacks.set(e, t);
3937
3943
  }
3938
3944
  /**
@@ -3955,9 +3961,9 @@ class Q extends M {
3955
3961
  */
3956
3962
  unregister(e) {
3957
3963
  if (this._key === e)
3958
- throw new p("Unable to unregister the currently selected callback.");
3964
+ throw new b("Unable to unregister the currently selected callback.");
3959
3965
  if (!this._callbacks.has(e))
3960
- throw new p(`The key '${e}' doesn't yet have any associated callback.`);
3966
+ throw new b(`The key '${e}' doesn't yet have any associated callback.`);
3961
3967
  this._callbacks.delete(e);
3962
3968
  }
3963
3969
  /**
@@ -3980,12 +3986,12 @@ class Q extends M {
3980
3986
  */
3981
3987
  switch(e) {
3982
3988
  if (!this._callbacks.has(e))
3983
- throw new p(`The key '${e}' doesn't yet have any associated callback.`);
3989
+ throw new b(`The key '${e}' doesn't yet have any associated callback.`);
3984
3990
  this._key !== e && (this._key = e, this._isEnabled && (this._callback = this._callbacks.get(e)));
3985
3991
  }
3986
3992
  [Symbol.toStringTag] = "SwitchableCallback";
3987
3993
  }
3988
- class H extends Map {
3994
+ class X extends Map {
3989
3995
  /**
3990
3996
  * The internal {@link Publisher} instance used to publish events.
3991
3997
  */
@@ -4005,7 +4011,7 @@ class H extends Map {
4005
4011
  * @param iterable An optional iterable of key-value pairs to initialize the {@link Map} with.
4006
4012
  */
4007
4013
  constructor(e) {
4008
- if (super(), this._publisher = new g(), e)
4014
+ if (super(), this._publisher = new v(), e)
4009
4015
  for (const [t, n] of e)
4010
4016
  this.set(t, n);
4011
4017
  }
@@ -4142,7 +4148,7 @@ class H extends Map {
4142
4148
  }
4143
4149
  [Symbol.toStringTag] = "MapView";
4144
4150
  }
4145
- class X extends Set {
4151
+ class Z extends Set {
4146
4152
  /**
4147
4153
  * The internal {@link Publisher} instance used to publish events.
4148
4154
  */
@@ -4162,7 +4168,7 @@ class X extends Set {
4162
4168
  * @param iterable An optional iterable of values to initialize the {@link Set} with.
4163
4169
  */
4164
4170
  constructor(e) {
4165
- if (super(), this._publisher = new g(), e)
4171
+ if (super(), this._publisher = new v(), e)
4166
4172
  for (const t of e)
4167
4173
  this.add(t);
4168
4174
  }
@@ -4298,7 +4304,7 @@ class X extends Set {
4298
4304
  }
4299
4305
  [Symbol.toStringTag] = "SetView";
4300
4306
  }
4301
- class Z {
4307
+ class W {
4302
4308
  /**
4303
4309
  * Whether to prefer the {@link localStorage} over the {@link sessionStorage} when calling an ambivalent method.
4304
4310
  *
@@ -4332,8 +4338,8 @@ class Z {
4332
4338
  * If omitted, it defaults to `true` to prefer the persistent storage.
4333
4339
  */
4334
4340
  constructor(e = !0) {
4335
- if (!T)
4336
- throw new j(
4341
+ if (!E)
4342
+ throw new O(
4337
4343
  "The `JSONStorage` class can only be instantiated within a browser environment."
4338
4344
  );
4339
4345
  this._preferPersistence = e, this._volatile = window.sessionStorage, this._persistent = window.localStorage;
@@ -4739,7 +4745,7 @@ class m {
4739
4745
  }
4740
4746
  [Symbol.toStringTag] = "SmartPromise";
4741
4747
  }
4742
- class R extends m {
4748
+ class F extends m {
4743
4749
  /**
4744
4750
  * The exposed function that allows to resolve the promise.
4745
4751
  *
@@ -4812,7 +4818,7 @@ class R extends m {
4812
4818
  }
4813
4819
  [Symbol.toStringTag] = "DeferredPromise";
4814
4820
  }
4815
- class z extends m {
4821
+ class q extends m {
4816
4822
  /**
4817
4823
  * Initializes a new instance of the {@link TimedPromise} class.
4818
4824
  *
@@ -4837,17 +4843,17 @@ class z extends m {
4837
4843
  */
4838
4844
  constructor(e, t) {
4839
4845
  super((n, s) => {
4840
- const r = (v) => {
4841
- clearTimeout(y), n(v);
4842
- }, o = (v) => {
4843
- clearTimeout(y), s(v);
4844
- }, y = setTimeout(() => o(new O("The operation has timed out.")), t);
4846
+ const r = (_) => {
4847
+ clearTimeout(f), n(_);
4848
+ }, o = (_) => {
4849
+ clearTimeout(f), s(_);
4850
+ }, f = setTimeout(() => o(new N("The operation has timed out.")), t);
4845
4851
  e(r, o);
4846
4852
  });
4847
4853
  }
4848
4854
  [Symbol.toStringTag] = "TimedPromise";
4849
4855
  }
4850
- class W extends m {
4856
+ class U extends m {
4851
4857
  /**
4852
4858
  * The number of promises currently in the queue.
4853
4859
  */
@@ -4871,7 +4877,7 @@ class W extends m {
4871
4877
  * Accessing this property will always result in a {@link ValueException}.
4872
4878
  */
4873
4879
  get isRejected() {
4874
- throw new f("`PromiseQueue` doesn't support rejection states.");
4880
+ throw new u("`PromiseQueue` doesn't support rejection states.");
4875
4881
  }
4876
4882
  /**
4877
4883
  * Initializes a new instance of the {@link PromiseQueue} class.
@@ -4880,7 +4886,7 @@ class W extends m {
4880
4886
  super((e) => e()), this._count = 0, this._isPending = !1, this._isFulfilled = !1, this._isRejected = !1;
4881
4887
  }
4882
4888
  enqueue(e, t) {
4883
- if (this._count += 1, e instanceof R) {
4889
+ if (this._count += 1, e instanceof F) {
4884
4890
  const s = e;
4885
4891
  e = () => (s.resolve(), s);
4886
4892
  }
@@ -4891,18 +4897,18 @@ class W extends m {
4891
4897
  this._count -= 1, r(o);
4892
4898
  });
4893
4899
  };
4894
- return t ? new z(n, t) : new m(n);
4900
+ return t ? new q(n, t) : new m(n);
4895
4901
  }
4896
4902
  [Symbol.toStringTag] = "PromiseQueue";
4897
4903
  }
4898
- var S = /* @__PURE__ */ ((i) => (i[i.Millisecond = 1] = "Millisecond", i[i.Second = 1e3] = "Second", i[i.Minute = 6e4] = "Minute", i[i.Hour = 36e5] = "Hour", i[i.Day = 864e5] = "Day", i[i.Week = 6048e5] = "Week", i[i.Month = 2592e6] = "Month", i[i.Year = 31536e6] = "Year", i))(S || {}), $ = /* @__PURE__ */ ((i) => (i[i.Sunday = 0] = "Sunday", i[i.Monday = 1] = "Monday", i[i.Tuesday = 2] = "Tuesday", i[i.Wednesday = 3] = "Wednesday", i[i.Thursday = 4] = "Thursday", i[i.Friday = 5] = "Friday", i[i.Saturday = 6] = "Saturday", i))($ || {});
4899
- function U(i, e, t = 864e5) {
4904
+ var S = /* @__PURE__ */ ((i) => (i[i.Millisecond = 1] = "Millisecond", i[i.Second = 1e3] = "Second", i[i.Minute = 6e4] = "Minute", i[i.Hour = 36e5] = "Hour", i[i.Day = 864e5] = "Day", i[i.Week = 6048e5] = "Week", i[i.Month = 2592e6] = "Month", i[i.Year = 31536e6] = "Year", i))(S || {}), I = /* @__PURE__ */ ((i) => (i[i.Sunday = 0] = "Sunday", i[i.Monday = 1] = "Monday", i[i.Tuesday = 2] = "Tuesday", i[i.Wednesday = 3] = "Wednesday", i[i.Thursday = 4] = "Thursday", i[i.Friday = 5] = "Friday", i[i.Saturday = 6] = "Saturday", i))(I || {});
4905
+ function ee(i, e, t = 864e5) {
4900
4906
  let n;
4901
4907
  return i = new Date(i), e = new Date(e), i < e ? n = Math.floor : n = Math.ceil, n((e.getTime() - i.getTime()) / t);
4902
4908
  }
4903
- function ee(i, e, t = 864e5) {
4909
+ function te(i, e, t = 864e5) {
4904
4910
  if (i = new Date(i), e = new Date(e), i >= e)
4905
- throw new b("The end date must be greater than the start date.");
4911
+ throw new x("The end date must be greater than the start date.");
4906
4912
  return new l(function* () {
4907
4913
  const n = e.getTime();
4908
4914
  let s = i.getTime();
@@ -4910,23 +4916,23 @@ function ee(i, e, t = 864e5) {
4910
4916
  yield new Date(s), s += t;
4911
4917
  });
4912
4918
  }
4913
- function I(i, e = 864e5) {
4919
+ function $(i, e = 864e5) {
4914
4920
  if (e <= 1)
4915
- throw new b(
4921
+ throw new x(
4916
4922
  "Rounding a timestamp by milliseconds or less makes no sense.Use the timestamp value directly instead."
4917
4923
  );
4918
4924
  if (e > 864e5)
4919
- throw new b(
4925
+ throw new x(
4920
4926
  "Rounding by more than a day leads to unexpected results. Consider using other methods to round dates by weeks, months or years."
4921
4927
  );
4922
4928
  return i = new Date(i), new Date(Math.floor(i.getTime() / e) * e);
4923
4929
  }
4924
- function te(i, e = 0) {
4930
+ function ne(i, e = 0) {
4925
4931
  i = new Date(i);
4926
4932
  const t = 7 - e, n = (i.getUTCDay() + t) % 7, s = i.getTime() - 864e5 * n;
4927
- return I(new Date(s));
4933
+ return $(new Date(s));
4928
4934
  }
4929
- class F {
4935
+ class C {
4930
4936
  /**
4931
4937
  * The handle of the interval or the animation frame, depending on the environment.
4932
4938
  * It's used to stop the game loop when the {@link GameLoop._stop} method is called.
@@ -5004,13 +5010,13 @@ class F {
5004
5010
  * The interval in milliseconds that will be used if the current environment isn't a browser. Default is `40`.
5005
5011
  */
5006
5012
  constructor(e, t = 40) {
5007
- this._startTime = 0, this._isRunning = !1, T ? (this._start = () => {
5013
+ this._startTime = 0, this._isRunning = !1, E ? (this._start = () => {
5008
5014
  e(this.elapsedTime), this._handle = window.requestAnimationFrame(this._start);
5009
5015
  }, this._stop = () => window.cancelAnimationFrame(this._handle)) : (console.warn(
5010
5016
  `Not a browser environment detected. Using setInterval@${t}ms instead of requestAnimationFrame...`
5011
5017
  ), this._start = () => {
5012
5018
  this._handle = setInterval(() => e(this.elapsedTime), t);
5013
- }, this._stop = () => clearInterval(this._handle)), this._publisher = new g();
5019
+ }, this._stop = () => clearInterval(this._handle)), this._publisher = new v();
5014
5020
  }
5015
5021
  /**
5016
5022
  * Starts the execution of the game loop.
@@ -5031,7 +5037,7 @@ class F {
5031
5037
  */
5032
5038
  start(e = 0) {
5033
5039
  if (this._isRunning)
5034
- throw new _("The game loop has already been started.");
5040
+ throw new y("The game loop has already been started.");
5035
5041
  this._startTime = performance.now() - e, this._start(), this._isRunning = !0, this._publisher.publish("start");
5036
5042
  }
5037
5043
  /**
@@ -5049,9 +5055,9 @@ class F {
5049
5055
  */
5050
5056
  stop() {
5051
5057
  if (!this._isRunning)
5052
- throw new _("The game loop had already stopped or hadn't yet started.");
5058
+ throw new y("The game loop had already stopped or hadn't yet started.");
5053
5059
  if (!this._handle)
5054
- throw new x();
5060
+ throw new g();
5055
5061
  this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
5056
5062
  }
5057
5063
  /**
@@ -5094,7 +5100,7 @@ class F {
5094
5100
  }
5095
5101
  [Symbol.toStringTag] = "GameLoop";
5096
5102
  }
5097
- class ne extends F {
5103
+ class se extends C {
5098
5104
  /**
5099
5105
  * Initializes a new instance of the {@link Clock} class.
5100
5106
  *
@@ -5133,7 +5139,7 @@ class ne extends F {
5133
5139
  */
5134
5140
  start(e = 0) {
5135
5141
  if (this._isRunning)
5136
- throw new _("The clock has already been started.");
5142
+ throw new y("The clock has already been started.");
5137
5143
  this._startTime = performance.now() - e, this._start(), this._isRunning = !0, this._publisher.publish("start");
5138
5144
  }
5139
5145
  /**
@@ -5151,9 +5157,9 @@ class ne extends F {
5151
5157
  */
5152
5158
  stop() {
5153
5159
  if (!this._isRunning)
5154
- throw new _("The clock had already stopped or hadn't yet started.");
5160
+ throw new y("The clock had already stopped or hadn't yet started.");
5155
5161
  if (!this._handle)
5156
- throw new x();
5162
+ throw new g();
5157
5163
  this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
5158
5164
  }
5159
5165
  /**
@@ -5182,7 +5188,7 @@ class ne extends F {
5182
5188
  */
5183
5189
  onTick(e, t = 0) {
5184
5190
  if (t < 0)
5185
- throw new b("The tick step must be a non-negative number.");
5191
+ throw new x("The tick step must be a non-negative number.");
5186
5192
  if (t === 0)
5187
5193
  return this._publisher.subscribe("tick", e);
5188
5194
  let n = 0;
@@ -5192,7 +5198,7 @@ class ne extends F {
5192
5198
  }
5193
5199
  [Symbol.toStringTag] = "Clock";
5194
5200
  }
5195
- class se extends F {
5201
+ class re extends C {
5196
5202
  /**
5197
5203
  * The total duration of the countdown in milliseconds.
5198
5204
  *
@@ -5257,9 +5263,9 @@ class se extends F {
5257
5263
  */
5258
5264
  _deferrerStop(e) {
5259
5265
  if (!this._isRunning)
5260
- throw new _("The countdown hadn't yet started.");
5266
+ throw new y("The countdown hadn't yet started.");
5261
5267
  if (!this._deferrer)
5262
- throw new x();
5268
+ throw new g();
5263
5269
  this._stop(), this._handle = void 0, this._isRunning = !1, e !== void 0 ? this._deferrer.reject(e) : this._deferrer.resolve(), this._deferrer = void 0;
5264
5270
  }
5265
5271
  /**
@@ -5285,10 +5291,10 @@ class se extends F {
5285
5291
  */
5286
5292
  start(e = this.duration) {
5287
5293
  if (this._isRunning)
5288
- throw new _("The countdown had already stopped or hadn't yet started.");
5294
+ throw new y("The countdown had already stopped or hadn't yet started.");
5289
5295
  if (this._deferrer)
5290
- throw new x();
5291
- return this._deferrer = new R(), super.start(this.duration - e), this._publisher.publish("start"), this._deferrer;
5296
+ throw new g();
5297
+ return this._deferrer = new F(), super.start(this.duration - e), this._publisher.publish("start"), this._deferrer;
5292
5298
  }
5293
5299
  /**
5294
5300
  * Stops the execution of the countdown.
@@ -5340,7 +5346,7 @@ class se extends F {
5340
5346
  */
5341
5347
  onTick(e, t = 0) {
5342
5348
  if (t < 0)
5343
- throw new b("The tick step must be a non-negative number.");
5349
+ throw new x("The tick step must be a non-negative number.");
5344
5350
  if (t === 0)
5345
5351
  return this._publisher.subscribe("tick", e);
5346
5352
  let n = this.remainingTime;
@@ -5370,7 +5376,7 @@ class se extends F {
5370
5376
  }
5371
5377
  [Symbol.toStringTag] = "Countdown";
5372
5378
  }
5373
- class re {
5379
+ class ie {
5374
5380
  /**
5375
5381
  * Generates a given number of values following a linear curve.
5376
5382
  * The values are equally spaced and normalized between 0 and 1.
@@ -5428,7 +5434,7 @@ class re {
5428
5434
  */
5429
5435
  static Exponential(e, t = 2) {
5430
5436
  if (t < 0)
5431
- throw new f("The base of the exponential curve cannot be negative.");
5437
+ throw new u("The base of the exponential curve cannot be negative.");
5432
5438
  const n = e - 1;
5433
5439
  return new l(function* () {
5434
5440
  for (let s = 0; s < e; s += 1)
@@ -5439,7 +5445,7 @@ class re {
5439
5445
  }
5440
5446
  [Symbol.toStringTag] = "Curve";
5441
5447
  }
5442
- class C {
5448
+ class P {
5443
5449
  /**
5444
5450
  * Generates a random boolean value.
5445
5451
  *
@@ -5487,7 +5493,7 @@ class C {
5487
5493
  */
5488
5494
  static Index(e) {
5489
5495
  if (e.length === 0)
5490
- throw new f("You must provide at least one element.");
5496
+ throw new u("You must provide at least one element.");
5491
5497
  return this.Integer(e.length);
5492
5498
  }
5493
5499
  /**
@@ -5505,35 +5511,67 @@ class C {
5505
5511
  * @returns A random element from the given array.
5506
5512
  */
5507
5513
  static Choice(e) {
5508
- return e[C.Index(e)];
5514
+ return e[P.Index(e)];
5515
+ }
5516
+ static Sample(e, t, n) {
5517
+ const s = e.length;
5518
+ if (s === 0)
5519
+ throw new u("You must provide at least one element.");
5520
+ if (t < 0)
5521
+ throw new u("Count must be non-negative.");
5522
+ if (t > s)
5523
+ throw new u("Count cannot exceed the number of elements.");
5524
+ if (t === 0)
5525
+ return [];
5526
+ if (n === void 0) {
5527
+ const a = [...e], f = new Array(t);
5528
+ for (let _ = 0; _ < t; _ += 1) {
5529
+ const T = this.Integer(_, s);
5530
+ f[_] = a[T], a[T] = a[_];
5531
+ }
5532
+ return f;
5533
+ }
5534
+ if (n.length !== s)
5535
+ throw new u("Weights array must have the same length as elements array.");
5536
+ const r = new Array(s);
5537
+ for (let a = 0; a < s; a += 1) {
5538
+ if (n[a] <= 0)
5539
+ throw new u(`Weight for element #${a} must be greater than zero.`);
5540
+ r[a] = { index: a, key: Math.pow(Math.random(), 1 / n[a]) };
5541
+ }
5542
+ r.sort((a, f) => f.key - a.key);
5543
+ const o = new Array(t);
5544
+ for (let a = 0; a < t; a += 1)
5545
+ o[a] = e[r[a].index];
5546
+ return o;
5509
5547
  }
5510
5548
  constructor() {
5511
5549
  }
5512
5550
  [Symbol.toStringTag] = "Random";
5513
5551
  }
5514
- function ie(i) {
5552
+ function oe(i) {
5515
5553
  return new m((e) => setTimeout(e, i));
5516
5554
  }
5517
- function oe() {
5555
+ function ae() {
5518
5556
  return new m((i) => requestAnimationFrame(() => i()));
5519
5557
  }
5520
- function ae() {
5558
+ function le() {
5521
5559
  return new m((i) => setTimeout(i));
5522
5560
  }
5523
- function le(i, e = "text/javascript") {
5561
+ function ue(i, e = "text/javascript") {
5524
5562
  return new m((t, n) => {
5525
5563
  const s = document.createElement("script");
5526
5564
  s.async = !0, s.defer = !0, s.src = i, s.type = e, s.onload = (r) => t(), s.onerror = (r) => n(r), document.body.appendChild(s);
5527
5565
  });
5528
5566
  }
5529
- function ue(...i) {
5567
+ function ce(...i) {
5530
5568
  return new l(function* () {
5531
5569
  for (const e of i)
5532
5570
  for (const t of e)
5533
5571
  yield t;
5534
5572
  });
5535
5573
  }
5536
- function ce(i) {
5574
+ function he(i) {
5537
5575
  if (i instanceof Array)
5538
5576
  return i.length;
5539
5577
  let e = 0;
@@ -5541,16 +5579,16 @@ function ce(i) {
5541
5579
  e += 1;
5542
5580
  return e;
5543
5581
  }
5544
- function he(i) {
5582
+ function fe(i) {
5545
5583
  return new l(function* () {
5546
5584
  let e = 0;
5547
5585
  for (const t of i)
5548
5586
  yield [e, t], e += 1;
5549
5587
  });
5550
5588
  }
5551
- function fe(i, e, t = 1) {
5589
+ function de(i, e, t = 1) {
5552
5590
  if (t <= 0)
5553
- throw new b(
5591
+ throw new x(
5554
5592
  "Step must be always a positive number, even when generating numbers in reverse order."
5555
5593
  );
5556
5594
  return e === void 0 && (e = i, i = 0), i > e ? new l(function* () {
@@ -5561,7 +5599,7 @@ function fe(i, e, t = 1) {
5561
5599
  yield n;
5562
5600
  });
5563
5601
  }
5564
- function de(i) {
5602
+ function we(i) {
5565
5603
  const e = Array.from(i);
5566
5604
  for (let t = e.length - 1; t > 0; t -= 1) {
5567
5605
  const n = Math.floor(Math.random() * (t + 1));
@@ -5576,7 +5614,7 @@ function me(i) {
5576
5614
  e.has(t) || (e.add(t), yield t);
5577
5615
  });
5578
5616
  }
5579
- function A(i, e) {
5617
+ function D(i, e) {
5580
5618
  const t = i[Symbol.iterator](), n = e[Symbol.iterator]();
5581
5619
  return new l(function* () {
5582
5620
  for (; ; ) {
@@ -5587,28 +5625,28 @@ function A(i, e) {
5587
5625
  }
5588
5626
  });
5589
5627
  }
5590
- function we(i, e) {
5628
+ function _e(i, e) {
5591
5629
  if (e === void 0) {
5592
5630
  let r = 0, o = 0;
5593
5631
  for (const a of i)
5594
5632
  r += a, o += 1;
5595
5633
  if (o === 0)
5596
- throw new f("You must provide at least one value.");
5634
+ throw new u("You must provide at least one value.");
5597
5635
  return r / o;
5598
5636
  }
5599
5637
  let t = 0, n = 0, s = 0;
5600
- for (const [r, o] of A(i, e)) {
5638
+ for (const [r, o] of D(i, e)) {
5601
5639
  if (o <= 0)
5602
- throw new f(`The weight for the value #${s} must be greater than zero.`);
5640
+ throw new u(`The weight for the value #${s} must be greater than zero.`);
5603
5641
  t += r * o, n += o, s += 1;
5604
5642
  }
5605
5643
  if (s === 0)
5606
- throw new f("You must provide at least one value and weight.");
5644
+ throw new u("You must provide at least one value and weight.");
5607
5645
  if (n <= 0)
5608
- throw new f("The sum of weights must be greater than zero.");
5646
+ throw new u("The sum of weights must be greater than zero.");
5609
5647
  return t / n;
5610
5648
  }
5611
- function _e(i) {
5649
+ function pe(i) {
5612
5650
  let e = 0;
5613
5651
  for (let t = 0; t < i.length; t += 1) {
5614
5652
  const n = i.charCodeAt(t);
@@ -5616,78 +5654,78 @@ function _e(i) {
5616
5654
  }
5617
5655
  return e;
5618
5656
  }
5619
- function pe(i) {
5657
+ function ye(i) {
5620
5658
  let e = 0;
5621
5659
  for (const t of i)
5622
5660
  e += t;
5623
5661
  return e;
5624
5662
  }
5625
- function ye(i) {
5663
+ function be(i) {
5626
5664
  return `${i.charAt(0).toUpperCase()}${i.slice(1)}`;
5627
5665
  }
5628
- const be = "2.2.1";
5666
+ const xe = "2.2.3";
5629
5667
  export {
5630
- w as AggregatedAsyncIterator,
5631
- h as AggregatedIterator,
5632
- M as CallableObject,
5633
- K as CallbackChain,
5634
- ne as Clock,
5635
- se as Countdown,
5636
- re as Curve,
5637
- R as DeferredPromise,
5638
- j as EnvironmentException,
5639
- c as Exception,
5640
- x as FatalErrorException,
5641
- E as FileException,
5668
+ p as AggregatedAsyncIterator,
5669
+ d as AggregatedIterator,
5670
+ R as CallableObject,
5671
+ Q as CallbackChain,
5672
+ se as Clock,
5673
+ re as Countdown,
5674
+ ie as Curve,
5675
+ F as DeferredPromise,
5676
+ O as EnvironmentException,
5677
+ h as Exception,
5678
+ g as FatalErrorException,
5679
+ M as FileException,
5642
5680
  J as FileExistsException,
5643
- Y as FileNotFoundException,
5644
- F as GameLoop,
5645
- Z as JSONStorage,
5646
- p as KeyException,
5647
- H as MapView,
5648
- L as NetworkException,
5649
- P as NotImplementedException,
5650
- V as PermissionException,
5651
- W as PromiseQueue,
5652
- g as Publisher,
5653
- C as Random,
5654
- b as RangeException,
5655
- u as ReducedIterator,
5681
+ L as FileNotFoundException,
5682
+ C as GameLoop,
5683
+ W as JSONStorage,
5684
+ b as KeyException,
5685
+ X as MapView,
5686
+ V as NetworkException,
5687
+ j as NotImplementedException,
5688
+ G as PermissionException,
5689
+ U as PromiseQueue,
5690
+ v as Publisher,
5691
+ P as Random,
5692
+ x as RangeException,
5693
+ c as ReducedIterator,
5656
5694
  k as ReferenceException,
5657
- _ as RuntimeException,
5658
- X as SetView,
5659
- d as SmartAsyncIterator,
5695
+ y as RuntimeException,
5696
+ Z as SetView,
5697
+ w as SmartAsyncIterator,
5660
5698
  l as SmartIterator,
5661
5699
  m as SmartPromise,
5662
- Q as SwitchableCallback,
5700
+ H as SwitchableCallback,
5663
5701
  S as TimeUnit,
5664
- z as TimedPromise,
5665
- O as TimeoutException,
5666
- G as TypeException,
5667
- be as VERSION,
5668
- f as ValueException,
5669
- $ as WeekDay,
5670
- we as average,
5671
- ye as capitalize,
5672
- ue as chain,
5673
- ce as count,
5674
- U as dateDifference,
5675
- ee as dateRange,
5676
- I as dateRound,
5677
- ie as delay,
5678
- he as enumerate,
5679
- te as getWeek,
5680
- _e as hash,
5681
- T as isBrowser,
5682
- D as isNode,
5683
- B as isWorker,
5684
- le as loadScript,
5685
- oe as nextAnimationFrame,
5686
- fe as range,
5687
- de as shuffle,
5688
- pe as sum,
5702
+ q as TimedPromise,
5703
+ N as TimeoutException,
5704
+ K as TypeException,
5705
+ xe as VERSION,
5706
+ u as ValueException,
5707
+ I as WeekDay,
5708
+ _e as average,
5709
+ be as capitalize,
5710
+ ce as chain,
5711
+ he as count,
5712
+ ee as dateDifference,
5713
+ te as dateRange,
5714
+ $ as dateRound,
5715
+ oe as delay,
5716
+ fe as enumerate,
5717
+ ne as getWeek,
5718
+ pe as hash,
5719
+ E as isBrowser,
5720
+ B as isNode,
5721
+ Y as isWorker,
5722
+ ue as loadScript,
5723
+ ae as nextAnimationFrame,
5724
+ de as range,
5725
+ we as shuffle,
5726
+ ye as sum,
5689
5727
  me as unique,
5690
- ae as yieldToEventLoop,
5691
- A as zip
5728
+ le as yieldToEventLoop,
5729
+ D as zip
5692
5730
  };
5693
5731
  //# sourceMappingURL=core.esm.js.map