@byloth/core 2.2.3 → 2.2.4

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 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 {
1
+ const E = typeof window < "u" && typeof window.document < "u", B = typeof process < "u" && !!process.versions?.node, V = typeof self == "object" && self.constructor?.name === "DedicatedWorkerGlobalScope";
2
+ class f 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 h extends Error {
23
23
  * @returns An instance of the {@link Exception} class.
24
24
  */
25
25
  static FromUnknown(e) {
26
- if (e instanceof h)
26
+ if (e instanceof f)
27
27
  return e;
28
28
  if (e instanceof Error) {
29
- const t = new h(e.message);
29
+ const t = new f(e.message);
30
30
  return t.stack = e.stack, t.cause = e.cause, t.name = e.name, t;
31
31
  }
32
- return new h(`${e}`);
32
+ return new f(`${e}`);
33
33
  }
34
34
  /**
35
35
  * Initializes a new instance of the {@link Exception} class.
@@ -52,7 +52,7 @@ class h extends Error {
52
52
  }
53
53
  [Symbol.toStringTag] = "Exception";
54
54
  }
55
- class g extends h {
55
+ class v extends f {
56
56
  /**
57
57
  * Initializes a new instance of the {@link FatalErrorException} class.
58
58
  *
@@ -74,7 +74,7 @@ class g extends h {
74
74
  }
75
75
  [Symbol.toStringTag] = "FatalErrorException";
76
76
  }
77
- class j extends g {
77
+ class j extends v {
78
78
  /**
79
79
  * Initializes a new instance of the {@link NotImplementedException} class.
80
80
  *
@@ -96,7 +96,7 @@ class j extends g {
96
96
  }
97
97
  [Symbol.toStringTag] = "NotImplementedException";
98
98
  }
99
- class M extends h {
99
+ class M extends f {
100
100
  /**
101
101
  * Initializes a new instance of the {@link FileException} class.
102
102
  *
@@ -162,7 +162,7 @@ class L extends M {
162
162
  }
163
163
  [Symbol.toStringTag] = "FileNotFoundException";
164
164
  }
165
- class b extends h {
165
+ class y extends f {
166
166
  /**
167
167
  * Initializes a new instance of the {@link KeyException} class.
168
168
  *
@@ -184,7 +184,7 @@ class b extends h {
184
184
  }
185
185
  [Symbol.toStringTag] = "KeyException";
186
186
  }
187
- class V extends h {
187
+ class A extends f {
188
188
  /**
189
189
  * Initializes a new instance of the {@link NetworkException} class.
190
190
  *
@@ -206,7 +206,30 @@ class V extends h {
206
206
  }
207
207
  [Symbol.toStringTag] = "NetworkException";
208
208
  }
209
- class G extends h {
209
+ class G extends A {
210
+ response;
211
+ /**
212
+ * Initializes a new instance of the {@link ResponseException} class.
213
+ *
214
+ * ---
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * throw new ResponseException(response);
219
+ * ```
220
+ *
221
+ * ---
222
+ *
223
+ * @param response The response that caused the error.
224
+ * @param cause The previous caught error that caused this one, if any.
225
+ * @param name The name of the exception. Default is `"ResponseException"`.
226
+ */
227
+ constructor(e, t, n = "ResponseException") {
228
+ super(`The request failed with the status code ${e.status} (${e.statusText}).`, t, n), this.response = e;
229
+ }
230
+ [Symbol.toStringTag] = "ResponseException";
231
+ }
232
+ class K extends f {
210
233
  /**
211
234
  * Initializes a new instance of the {@link PermissionException} class.
212
235
  *
@@ -228,7 +251,7 @@ class G extends h {
228
251
  }
229
252
  [Symbol.toStringTag] = "PermissionException";
230
253
  }
231
- class k extends h {
254
+ class S extends f {
232
255
  /**
233
256
  * Initializes a new instance of the {@link ReferenceException} class.
234
257
  *
@@ -250,7 +273,7 @@ class k extends h {
250
273
  }
251
274
  [Symbol.toStringTag] = "ReferenceException";
252
275
  }
253
- class y extends h {
276
+ class b extends f {
254
277
  /**
255
278
  * Initializes a new instance of the {@link RuntimeException} class.
256
279
  *
@@ -272,7 +295,7 @@ class y extends h {
272
295
  }
273
296
  [Symbol.toStringTag] = "RuntimeException";
274
297
  }
275
- class O extends y {
298
+ class z extends b {
276
299
  /**
277
300
  * Initializes a new instance of the {@link EnvironmentException} class.
278
301
  *
@@ -294,7 +317,7 @@ class O extends y {
294
317
  }
295
318
  [Symbol.toStringTag] = "EnvironmentException";
296
319
  }
297
- class N extends h {
320
+ class N extends f {
298
321
  /**
299
322
  * Initializes a new instance of the {@link TimeoutException} class.
300
323
  *
@@ -316,7 +339,7 @@ class N extends h {
316
339
  }
317
340
  [Symbol.toStringTag] = "TimeoutException";
318
341
  }
319
- class K extends h {
342
+ class Q extends f {
320
343
  /**
321
344
  * Initializes a new instance of the {@link TypeException} class.
322
345
  *
@@ -338,7 +361,7 @@ class K extends h {
338
361
  }
339
362
  [Symbol.toStringTag] = "TypeException";
340
363
  }
341
- class u extends h {
364
+ class c extends f {
342
365
  /**
343
366
  * Initializes a new instance of the {@link ValueException} class.
344
367
  *
@@ -360,7 +383,7 @@ class u extends h {
360
383
  }
361
384
  [Symbol.toStringTag] = "ValueException";
362
385
  }
363
- class x extends u {
386
+ class x extends c {
364
387
  /**
365
388
  * Initializes a new instance of the {@link RangeException} class.
366
389
  *
@@ -530,7 +553,7 @@ class l {
530
553
  if (s === void 0) {
531
554
  const r = this._iterator.next();
532
555
  if (r.done)
533
- throw new u("Cannot reduce an empty iterator without an initial value.");
556
+ throw new c("Cannot reduce an empty iterator without an initial value.");
534
557
  s = r.value, n += 1;
535
558
  }
536
559
  for (; ; ) {
@@ -993,7 +1016,7 @@ class l {
993
1016
  return this;
994
1017
  }
995
1018
  }
996
- class c {
1019
+ class h {
997
1020
  /**
998
1021
  * The internal {@link SmartIterator} object that holds the reduced elements.
999
1022
  */
@@ -1077,7 +1100,7 @@ class c {
1077
1100
  }
1078
1101
  filter(e) {
1079
1102
  const t = this._elements.enumerate();
1080
- return new c(function* () {
1103
+ return new h(function* () {
1081
1104
  for (const [n, [s, r]] of t)
1082
1105
  e(s, r, n) && (yield [s, r]);
1083
1106
  });
@@ -1117,7 +1140,7 @@ class c {
1117
1140
  */
1118
1141
  map(e) {
1119
1142
  const t = this._elements.enumerate();
1120
- return new c(function* () {
1143
+ return new h(function* () {
1121
1144
  for (const [n, [s, r]] of t)
1122
1145
  yield [s, e(s, r, n)];
1123
1146
  });
@@ -1127,7 +1150,7 @@ class c {
1127
1150
  if (s === void 0) {
1128
1151
  const r = this._elements.next();
1129
1152
  if (r.done)
1130
- throw new u("Cannot reduce an empty iterator without an initial value.");
1153
+ throw new c("Cannot reduce an empty iterator without an initial value.");
1131
1154
  s = r.value[1], n += 1;
1132
1155
  }
1133
1156
  for (const [r, o] of this._elements)
@@ -1215,7 +1238,7 @@ class c {
1215
1238
  */
1216
1239
  drop(e) {
1217
1240
  const t = this._elements.enumerate();
1218
- return new c(function* () {
1241
+ return new h(function* () {
1219
1242
  for (const [n, [s, r]] of t)
1220
1243
  n >= e && (yield [s, r]);
1221
1244
  });
@@ -1257,7 +1280,7 @@ class c {
1257
1280
  */
1258
1281
  take(e) {
1259
1282
  const t = this._elements.enumerate();
1260
- return new c(function* () {
1283
+ return new h(function* () {
1261
1284
  for (const [n, [s, r]] of t) {
1262
1285
  if (n >= e)
1263
1286
  break;
@@ -1327,7 +1350,7 @@ class c {
1327
1350
  */
1328
1351
  unique() {
1329
1352
  const e = this._elements;
1330
- return new c(function* () {
1353
+ return new h(function* () {
1331
1354
  const t = /* @__PURE__ */ new Set();
1332
1355
  for (const [n, s] of e)
1333
1356
  t.has(s) || (t.add(s), yield [n, s]);
@@ -1601,13 +1624,13 @@ class c {
1601
1624
  }
1602
1625
  [Symbol.toStringTag] = "ReducedIterator";
1603
1626
  }
1604
- class p {
1627
+ class _ {
1605
1628
  /**
1606
1629
  * The internal {@link SmartAsyncIterator} object that holds the elements to aggregate.
1607
1630
  */
1608
1631
  _elements;
1609
1632
  constructor(e) {
1610
- this._elements = new w(e);
1633
+ this._elements = new m(e);
1611
1634
  }
1612
1635
  /**
1613
1636
  * Determines whether all elements of each group of the iterator satisfy a given condition.
@@ -1646,7 +1669,7 @@ class p {
1646
1669
  const [r, o] = t.get(n) ?? [0, !0];
1647
1670
  o && t.set(n, [r + 1, await e(n, s, r)]);
1648
1671
  }
1649
- return new c(function* () {
1672
+ return new h(function* () {
1650
1673
  for (const [n, [s, r]] of t)
1651
1674
  yield [n, r];
1652
1675
  });
@@ -1688,14 +1711,14 @@ class p {
1688
1711
  const [r, o] = t.get(n) ?? [0, !1];
1689
1712
  o || t.set(n, [r + 1, await e(n, s, r)]);
1690
1713
  }
1691
- return new c(function* () {
1714
+ return new h(function* () {
1692
1715
  for (const [n, [s, r]] of t)
1693
1716
  yield [n, r];
1694
1717
  });
1695
1718
  }
1696
1719
  filter(e) {
1697
1720
  const t = this._elements;
1698
- return new p(async function* () {
1721
+ return new _(async function* () {
1699
1722
  const n = /* @__PURE__ */ new Map();
1700
1723
  for await (const [s, r] of t) {
1701
1724
  const o = n.get(s) ?? 0;
@@ -1737,7 +1760,7 @@ class p {
1737
1760
  */
1738
1761
  map(e) {
1739
1762
  const t = this._elements;
1740
- return new p(async function* () {
1763
+ return new _(async function* () {
1741
1764
  const n = /* @__PURE__ */ new Map();
1742
1765
  for await (const [s, r] of t) {
1743
1766
  const o = n.get(s) ?? 0;
@@ -1759,7 +1782,7 @@ class p {
1759
1782
  }
1760
1783
  n.set(s, [o + 1, await e(s, a, r, o)]);
1761
1784
  }
1762
- return new c(function* () {
1785
+ return new h(function* () {
1763
1786
  for (const [s, [r, o]] of n)
1764
1787
  yield [s, o];
1765
1788
  });
@@ -1802,13 +1825,13 @@ class p {
1802
1825
  */
1803
1826
  flatMap(e) {
1804
1827
  const t = this._elements;
1805
- return new p(async function* () {
1828
+ return new _(async function* () {
1806
1829
  const n = /* @__PURE__ */ new Map();
1807
1830
  for await (const [s, r] of t) {
1808
1831
  const o = n.get(s) ?? 0, a = await e(s, r, o);
1809
1832
  if (a instanceof Array)
1810
- for (const f of a)
1811
- yield [s, f];
1833
+ for (const u of a)
1834
+ yield [s, u];
1812
1835
  else
1813
1836
  yield [s, a];
1814
1837
  n.set(s, o + 1);
@@ -1846,7 +1869,7 @@ class p {
1846
1869
  */
1847
1870
  drop(e) {
1848
1871
  const t = this._elements;
1849
- return new p(async function* () {
1872
+ return new _(async function* () {
1850
1873
  const n = /* @__PURE__ */ new Map();
1851
1874
  for await (const [s, r] of t) {
1852
1875
  const o = n.get(s) ?? 0;
@@ -1889,7 +1912,7 @@ class p {
1889
1912
  */
1890
1913
  take(e) {
1891
1914
  const t = this._elements;
1892
- return new p(async function* () {
1915
+ return new _(async function* () {
1893
1916
  const n = /* @__PURE__ */ new Map();
1894
1917
  for await (const [s, r] of t) {
1895
1918
  const o = n.get(s) ?? 0;
@@ -1903,7 +1926,7 @@ class p {
1903
1926
  let [r, o] = t.get(n) ?? [0, void 0];
1904
1927
  o === void 0 && (await e(n, s, r) && (o = s), t.set(n, [r + 1, o]));
1905
1928
  }
1906
- return new c(function* () {
1929
+ return new h(function* () {
1907
1930
  for (const [n, [s, r]] of t)
1908
1931
  yield [n, r];
1909
1932
  });
@@ -1965,7 +1988,7 @@ class p {
1965
1988
  */
1966
1989
  unique() {
1967
1990
  const e = this._elements;
1968
- return new p(async function* () {
1991
+ return new _(async function* () {
1969
1992
  const t = /* @__PURE__ */ new Map();
1970
1993
  for await (const [n, s] of e) {
1971
1994
  const r = t.get(n) ?? /* @__PURE__ */ new Set();
@@ -2001,7 +2024,7 @@ class p {
2001
2024
  const n = e.get(t) ?? 0;
2002
2025
  e.set(t, n + 1);
2003
2026
  }
2004
- return new c(function* () {
2027
+ return new h(function* () {
2005
2028
  for (const [t, n] of e)
2006
2029
  yield [t, n];
2007
2030
  });
@@ -2072,7 +2095,7 @@ class p {
2072
2095
  */
2073
2096
  reorganizeBy(e) {
2074
2097
  const t = this._elements;
2075
- return new p(async function* () {
2098
+ return new _(async function* () {
2076
2099
  const n = /* @__PURE__ */ new Map();
2077
2100
  for await (const [s, r] of t) {
2078
2101
  const o = n.get(s) ?? 0;
@@ -2108,7 +2131,7 @@ class p {
2108
2131
  */
2109
2132
  keys() {
2110
2133
  const e = this._elements;
2111
- return new w(async function* () {
2134
+ return new m(async function* () {
2112
2135
  const t = /* @__PURE__ */ new Set();
2113
2136
  for await (const [n] of e)
2114
2137
  t.has(n) || (t.add(n), yield n);
@@ -2172,7 +2195,7 @@ class p {
2172
2195
  */
2173
2196
  values() {
2174
2197
  const e = this._elements;
2175
- return new w(async function* () {
2198
+ return new m(async function* () {
2176
2199
  for await (const [t, n] of e)
2177
2200
  yield n;
2178
2201
  });
@@ -2259,7 +2282,7 @@ class p {
2259
2282
  }
2260
2283
  [Symbol.toStringTag] = "AggregatedAsyncIterator";
2261
2284
  }
2262
- class w {
2285
+ class m {
2263
2286
  /**
2264
2287
  * The native {@link AsyncIterator} object that is being wrapped by this instance.
2265
2288
  */
@@ -2383,7 +2406,7 @@ class w {
2383
2406
  }
2384
2407
  filter(e) {
2385
2408
  const t = this._iterator;
2386
- return new w(async function* () {
2409
+ return new m(async function* () {
2387
2410
  let n = 0;
2388
2411
  for (; ; ) {
2389
2412
  const s = await t.next();
@@ -2426,7 +2449,7 @@ class w {
2426
2449
  */
2427
2450
  map(e) {
2428
2451
  const t = this._iterator;
2429
- return new w(async function* () {
2452
+ return new m(async function* () {
2430
2453
  let n = 0;
2431
2454
  for (; ; ) {
2432
2455
  const s = await t.next();
@@ -2441,7 +2464,7 @@ class w {
2441
2464
  if (s === void 0) {
2442
2465
  const r = await this._iterator.next();
2443
2466
  if (r.done)
2444
- throw new u("Cannot reduce an empty iterator without an initial value.");
2467
+ throw new c("Cannot reduce an empty iterator without an initial value.");
2445
2468
  s = r.value, n += 1;
2446
2469
  }
2447
2470
  for (; ; ) {
@@ -2484,7 +2507,7 @@ class w {
2484
2507
  */
2485
2508
  flatMap(e) {
2486
2509
  const t = this._iterator;
2487
- return new w(async function* () {
2510
+ return new m(async function* () {
2488
2511
  let n = 0;
2489
2512
  for (; ; ) {
2490
2513
  const s = await t.next();
@@ -2533,7 +2556,7 @@ class w {
2533
2556
  */
2534
2557
  drop(e) {
2535
2558
  const t = this._iterator;
2536
- return new w(async function* () {
2559
+ return new m(async function* () {
2537
2560
  let n = 0;
2538
2561
  for (; n < e; ) {
2539
2562
  if ((await t.next()).done)
@@ -2582,7 +2605,7 @@ class w {
2582
2605
  */
2583
2606
  take(e) {
2584
2607
  const t = this._iterator;
2585
- return new w(async function* () {
2608
+ return new m(async function* () {
2586
2609
  let n = 0;
2587
2610
  for (; n < e; ) {
2588
2611
  const s = await t.next();
@@ -2661,7 +2684,7 @@ class w {
2661
2684
  */
2662
2685
  unique() {
2663
2686
  const e = this._iterator;
2664
- return new w(async function* () {
2687
+ return new m(async function* () {
2665
2688
  const t = /* @__PURE__ */ new Set();
2666
2689
  for (; ; ) {
2667
2690
  const n = await e.next();
@@ -2878,7 +2901,7 @@ class w {
2878
2901
  * @returns A new instance of the {@link AggregatedAsyncIterator} class containing the grouped elements.
2879
2902
  */
2880
2903
  groupBy(e) {
2881
- return new p(this.map(async (t, n) => [await e(t, n), t]));
2904
+ return new _(this.map(async (t, n) => [await e(t, n), t]));
2882
2905
  }
2883
2906
  /**
2884
2907
  * Materializes the iterator into an array.
@@ -2955,7 +2978,7 @@ class d {
2955
2978
  const [r, o] = t.get(n) ?? [0, !0];
2956
2979
  o && t.set(n, [r + 1, e(n, s, r)]);
2957
2980
  }
2958
- return new c(function* () {
2981
+ return new h(function* () {
2959
2982
  for (const [n, [s, r]] of t)
2960
2983
  yield [n, r];
2961
2984
  });
@@ -2996,7 +3019,7 @@ class d {
2996
3019
  const [r, o] = t.get(n) ?? [0, !1];
2997
3020
  o || t.set(n, [r + 1, e(n, s, r)]);
2998
3021
  }
2999
- return new c(function* () {
3022
+ return new h(function* () {
3000
3023
  for (const [n, [s, r]] of t)
3001
3024
  yield [n, r];
3002
3025
  });
@@ -3067,7 +3090,7 @@ class d {
3067
3090
  }
3068
3091
  n.set(s, [o + 1, e(s, a, r, o)]);
3069
3092
  }
3070
- return new c(function* () {
3093
+ return new h(function* () {
3071
3094
  for (const [s, [r, o]] of n)
3072
3095
  yield [s, o];
3073
3096
  });
@@ -3115,8 +3138,8 @@ class d {
3115
3138
  for (const [s, r] of t) {
3116
3139
  const o = n.get(s) ?? 0, a = e(s, r, o);
3117
3140
  if (a instanceof Array)
3118
- for (const f of a)
3119
- yield [s, f];
3141
+ for (const u of a)
3142
+ yield [s, u];
3120
3143
  else
3121
3144
  yield [s, a];
3122
3145
  n.set(s, o + 1);
@@ -3211,7 +3234,7 @@ class d {
3211
3234
  let [r, o] = t.get(n) ?? [0, void 0];
3212
3235
  o === void 0 && (e(n, s, r) && (o = s), t.set(n, [r + 1, o]));
3213
3236
  }
3214
- return new c(function* () {
3237
+ return new h(function* () {
3215
3238
  for (const [n, [s, r]] of t)
3216
3239
  yield [n, r];
3217
3240
  });
@@ -3308,7 +3331,7 @@ class d {
3308
3331
  const n = e.get(t) ?? 0;
3309
3332
  e.set(t, n + 1);
3310
3333
  }
3311
- return new c(function* () {
3334
+ return new h(function* () {
3312
3335
  for (const [t, n] of e)
3313
3336
  yield [t, n];
3314
3337
  });
@@ -3564,8 +3587,8 @@ class d {
3564
3587
  }
3565
3588
  [Symbol.toStringTag] = "AggregatedIterator";
3566
3589
  }
3567
- const z = Function;
3568
- class R extends z {
3590
+ const q = Function;
3591
+ class R extends q {
3569
3592
  /**
3570
3593
  * Initializes a new instance of the {@link CallableObject} class.
3571
3594
  */
@@ -3576,7 +3599,7 @@ class R extends z {
3576
3599
  }
3577
3600
  [Symbol.toStringTag] = "CallableObject";
3578
3601
  }
3579
- class Q extends R {
3602
+ class H extends R {
3580
3603
  /**
3581
3604
  * The array containing all the functions in the chain.
3582
3605
  */
@@ -3686,7 +3709,7 @@ class Q extends R {
3686
3709
  }
3687
3710
  [Symbol.toStringTag] = "CallbackChain";
3688
3711
  }
3689
- class v {
3712
+ class g {
3690
3713
  /**
3691
3714
  * A map containing all the subscribers for each event.
3692
3715
  *
@@ -3742,7 +3765,7 @@ class v {
3742
3765
  */
3743
3766
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
3744
3767
  createScope() {
3745
- const e = new v();
3768
+ const e = new g();
3746
3769
  return this.subscribe("__internals__:clear", () => e.clear()), this.subscribe("*", (t, ...n) => {
3747
3770
  e.publish(t, ...n);
3748
3771
  }), e;
@@ -3763,17 +3786,17 @@ class v {
3763
3786
  return n.push(t), this._subscribers.set(e, n), () => {
3764
3787
  const s = n.indexOf(t);
3765
3788
  if (s < 0)
3766
- throw new k("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed.");
3789
+ throw new S("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed.");
3767
3790
  n.splice(s, 1);
3768
3791
  };
3769
3792
  }
3770
3793
  unsubscribe(e, t) {
3771
3794
  const n = this._subscribers.get(e);
3772
3795
  if (!n)
3773
- throw new k("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
3796
+ throw new S("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
3774
3797
  const s = n.indexOf(t);
3775
3798
  if (s < 0)
3776
- throw new k("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
3799
+ throw new S("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
3777
3800
  n.splice(s, 1), n.length === 0 && this._subscribers.delete(e);
3778
3801
  }
3779
3802
  unsubscribeAll(e) {
@@ -3804,9 +3827,9 @@ class v {
3804
3827
  }
3805
3828
  [Symbol.toStringTag] = "Publisher";
3806
3829
  }
3807
- const A = () => {
3830
+ const I = () => {
3808
3831
  };
3809
- class H extends R {
3832
+ class X extends R {
3810
3833
  /**
3811
3834
  * The currently selected implementation of the callback.
3812
3835
  */
@@ -3884,16 +3907,16 @@ class H extends R {
3884
3907
  enable(e) {
3885
3908
  if (e === void 0) {
3886
3909
  if (!this._key)
3887
- throw new b(
3910
+ throw new y(
3888
3911
  "The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
3889
3912
  );
3890
3913
  e = this._key;
3891
3914
  } else if (e) {
3892
3915
  if (!this._callbacks.has(e))
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.");
3916
+ throw new y(`The key '${e}' doesn't yet have any associated callback.`);
3917
+ } else throw new y("The key must be a non-empty string.");
3895
3918
  if (this._isEnabled)
3896
- throw new y("The `SwitchableCallback` is already enabled.");
3919
+ throw new b("The `SwitchableCallback` is already enabled.");
3897
3920
  this._callback = this._callbacks.get(e), this._isEnabled = !0;
3898
3921
  }
3899
3922
  /**
@@ -3911,8 +3934,8 @@ class H extends R {
3911
3934
  */
3912
3935
  disable() {
3913
3936
  if (!this._isEnabled)
3914
- throw new y("The `SwitchableCallback` is already disabled.");
3915
- this._callback = A, this._isEnabled = !1;
3937
+ throw new b("The `SwitchableCallback` is already disabled.");
3938
+ this._callback = I, this._isEnabled = !1;
3916
3939
  }
3917
3940
  /**
3918
3941
  * Registers a new implementation for the callback.
@@ -3938,7 +3961,7 @@ class H extends R {
3938
3961
  if (this._callbacks.size === 0)
3939
3962
  this._key = e, this._callback = t;
3940
3963
  else if (this._callbacks.has(e))
3941
- throw new b(`The key '${e}' has already been used for another callback.`);
3964
+ throw new y(`The key '${e}' has already been used for another callback.`);
3942
3965
  this._callbacks.set(e, t);
3943
3966
  }
3944
3967
  /**
@@ -3961,9 +3984,9 @@ class H extends R {
3961
3984
  */
3962
3985
  unregister(e) {
3963
3986
  if (this._key === e)
3964
- throw new b("Unable to unregister the currently selected callback.");
3987
+ throw new y("Unable to unregister the currently selected callback.");
3965
3988
  if (!this._callbacks.has(e))
3966
- throw new b(`The key '${e}' doesn't yet have any associated callback.`);
3989
+ throw new y(`The key '${e}' doesn't yet have any associated callback.`);
3967
3990
  this._callbacks.delete(e);
3968
3991
  }
3969
3992
  /**
@@ -3986,12 +4009,231 @@ class H extends R {
3986
4009
  */
3987
4010
  switch(e) {
3988
4011
  if (!this._callbacks.has(e))
3989
- throw new b(`The key '${e}' doesn't yet have any associated callback.`);
4012
+ throw new y(`The key '${e}' doesn't yet have any associated callback.`);
3990
4013
  this._key !== e && (this._key = e, this._isEnabled && (this._callback = this._callbacks.get(e)));
3991
4014
  }
3992
4015
  [Symbol.toStringTag] = "SwitchableCallback";
3993
4016
  }
3994
- class X extends Map {
4017
+ class Z extends Array {
4018
+ /**
4019
+ * The internal {@link Publisher} instance used to publish events.
4020
+ */
4021
+ _publisher;
4022
+ constructor(...e) {
4023
+ super(...e), this._publisher = new g();
4024
+ }
4025
+ /**
4026
+ * Appends new elements to the end of the {@link Array} and returns the new length of the array.
4027
+ *
4028
+ * ---
4029
+ *
4030
+ * @example
4031
+ * ```ts
4032
+ * const array = new ArrayView<number>();
4033
+ * array.push(2, 4, 8);
4034
+ *
4035
+ * console.log(array); // ArrayView(3) [2, 4, 8]
4036
+ * ```
4037
+ *
4038
+ * ---
4039
+ *
4040
+ * @param items New elements to add to the array.
4041
+ *
4042
+ * @returns The new length of the array.
4043
+ */
4044
+ push(...e) {
4045
+ const t = this.length, n = super.push(...e);
4046
+ for (let s = 0; s < e.length; s += 1)
4047
+ this._publisher.publish("add", e[s], t + s);
4048
+ return n;
4049
+ }
4050
+ /**
4051
+ * Removes the last element from the {@link Array} and returns it.
4052
+ *
4053
+ * ---
4054
+ *
4055
+ * @example
4056
+ * ```ts
4057
+ * const array = new ArrayView<number>(2, 4, 8);
4058
+ * array.pop(); // 8
4059
+ *
4060
+ * console.log(array); // ArrayView(2) [2, 4]
4061
+ * ```
4062
+ *
4063
+ * ---
4064
+ *
4065
+ * @returns The removed element, or `undefined` if the array is empty.
4066
+ */
4067
+ pop() {
4068
+ const e = this.length - 1;
4069
+ if (e < 0)
4070
+ return;
4071
+ const t = super.pop();
4072
+ return this._publisher.publish("remove", t, e), t;
4073
+ }
4074
+ /**
4075
+ * Removes the first element from the {@link Array} and returns it.
4076
+ *
4077
+ * ---
4078
+ *
4079
+ * @example
4080
+ * ```ts
4081
+ * const array = new ArrayView<number>(2, 4, 8);
4082
+ * array.shift(); // 2
4083
+ *
4084
+ * console.log(array); // ArrayView(2) [4, 8]
4085
+ * ```
4086
+ *
4087
+ * ---
4088
+ *
4089
+ * @returns The removed element, or `undefined` if the array is empty.
4090
+ */
4091
+ shift() {
4092
+ if (this.length === 0)
4093
+ return;
4094
+ const e = super.shift();
4095
+ return this._publisher.publish("remove", e, 0), e;
4096
+ }
4097
+ /**
4098
+ * Inserts new elements at the start of the {@link Array} and returns the new length of the array.
4099
+ *
4100
+ * ---
4101
+ *
4102
+ * @example
4103
+ * ```ts
4104
+ * const array = new ArrayView<number>(4, 8);
4105
+ * array.unshift(2);
4106
+ *
4107
+ * console.log(array); // ArrayView(3) [2, 4, 8]
4108
+ * ```
4109
+ *
4110
+ * ---
4111
+ *
4112
+ * @param items Elements to insert at the start of the array.
4113
+ *
4114
+ * @returns The new length of the array.
4115
+ */
4116
+ unshift(...e) {
4117
+ const t = super.unshift(...e);
4118
+ for (let n = 0; n < e.length; n += 1)
4119
+ this._publisher.publish("add", e[n], n);
4120
+ return t;
4121
+ }
4122
+ /**
4123
+ * Removes elements from the {@link Array} and, if necessary, inserts new elements in their place,
4124
+ * returning the deleted elements.
4125
+ *
4126
+ * ---
4127
+ *
4128
+ * @example
4129
+ * ```ts
4130
+ * const array = new ArrayView<number>(2, 4, 8, 16);
4131
+ * array.splice(1, 2, 32, 64); // [4, 8]
4132
+ *
4133
+ * console.log(array); // ArrayView(4) [2, 32, 64, 16]
4134
+ * ```
4135
+ *
4136
+ * ---
4137
+ *
4138
+ * @param start The zero-based location in the array from which to start removing elements.
4139
+ * @param deleteCount The number of elements to remove.
4140
+ * @param items Elements to insert into the array in place of the deleted elements.
4141
+ *
4142
+ * @returns An array containing the elements that were deleted.
4143
+ */
4144
+ splice(e, t, ...n) {
4145
+ const s = e < 0 ? Math.max(this.length + e, 0) : Math.min(e, this.length), r = t === void 0 ? this.length - s : Math.min(Math.max(t, 0), this.length - s), o = super.splice(e, r, ...n);
4146
+ for (let a = 0; a < o.length; a += 1)
4147
+ this._publisher.publish("remove", o[a], s + a);
4148
+ for (let a = 0; a < n.length; a += 1)
4149
+ this._publisher.publish("add", n[a], s + a);
4150
+ return o;
4151
+ }
4152
+ /**
4153
+ * Removes all elements from the {@link Array}.
4154
+ *
4155
+ * ---
4156
+ *
4157
+ * @example
4158
+ * ```ts
4159
+ * const array = new ArrayView<number>(2, 4, 8);
4160
+ * array.clear();
4161
+ *
4162
+ * console.log(array); // ArrayView(0) []
4163
+ * ```
4164
+ */
4165
+ clear() {
4166
+ const e = this.length;
4167
+ this.length = 0, e > 0 && this._publisher.publish("clear");
4168
+ }
4169
+ /**
4170
+ * Subscribes to the `add` event of the array with a callback that will be executed when an element is added.
4171
+ *
4172
+ * ---
4173
+ *
4174
+ * @example
4175
+ * ```ts
4176
+ * array.onAdd((value, index) => console.log(`Added ${value} at index ${index}`));
4177
+ *
4178
+ * array.push(2); // "Added 2 at index 0"
4179
+ * array.push(42); // "Added 42 at index 1"
4180
+ * ```
4181
+ *
4182
+ * ---
4183
+ *
4184
+ * @param callback The callback that will be executed when an element is added to the array.
4185
+ *
4186
+ * @returns A function that can be used to unsubscribe from the event.
4187
+ */
4188
+ onAdd(e) {
4189
+ return this._publisher.subscribe("add", e);
4190
+ }
4191
+ /**
4192
+ * Subscribes to the `remove` event of the array with a callback that will be executed when an element is removed.
4193
+ *
4194
+ * ---
4195
+ *
4196
+ * @example
4197
+ * ```ts
4198
+ * array.onRemove((value, index) => console.log(`Removed ${value} at index ${index}`));
4199
+ *
4200
+ * array.pop(); // "Removed 8 at index 2"
4201
+ * array.shift(); // "Removed 2 at index 0"
4202
+ * ```
4203
+ *
4204
+ * ---
4205
+ *
4206
+ * @param callback The callback that will be executed when an element is removed from the array.
4207
+ *
4208
+ * @returns A function that can be used to unsubscribe from the event.
4209
+ */
4210
+ onRemove(e) {
4211
+ return this._publisher.subscribe("remove", e);
4212
+ }
4213
+ /**
4214
+ * Subscribes to the `clear` event of the array with a callback that will be executed when the array is cleared.
4215
+ *
4216
+ * ---
4217
+ *
4218
+ * @example
4219
+ * ```ts
4220
+ * array.onClear(() => console.log("The array has been cleared."));
4221
+ * array.clear(); // "The array has been cleared."
4222
+ * ```
4223
+ *
4224
+ * ---
4225
+ *
4226
+ * @param callback The callback that will be executed when the array is cleared.
4227
+ *
4228
+ * @returns A function that can be used to unsubscribe from the event.
4229
+ */
4230
+ onClear(e) {
4231
+ return this._publisher.subscribe("clear", e);
4232
+ }
4233
+ [Symbol.toStringTag] = "ArrayView";
4234
+ static [Symbol.species] = Array;
4235
+ }
4236
+ class W extends Map {
3995
4237
  /**
3996
4238
  * The internal {@link Publisher} instance used to publish events.
3997
4239
  */
@@ -4011,9 +4253,9 @@ class X extends Map {
4011
4253
  * @param iterable An optional iterable of key-value pairs to initialize the {@link Map} with.
4012
4254
  */
4013
4255
  constructor(e) {
4014
- if (super(), this._publisher = new v(), e)
4256
+ if (super(), this._publisher = new g(), e)
4015
4257
  for (const [t, n] of e)
4016
- this.set(t, n);
4258
+ super.set(t, n);
4017
4259
  }
4018
4260
  /**
4019
4261
  * Adds a new entry with a specified key and value to the {@link Map}.
@@ -4148,7 +4390,7 @@ class X extends Map {
4148
4390
  }
4149
4391
  [Symbol.toStringTag] = "MapView";
4150
4392
  }
4151
- class Z extends Set {
4393
+ class U extends Set {
4152
4394
  /**
4153
4395
  * The internal {@link Publisher} instance used to publish events.
4154
4396
  */
@@ -4168,9 +4410,9 @@ class Z extends Set {
4168
4410
  * @param iterable An optional iterable of values to initialize the {@link Set} with.
4169
4411
  */
4170
4412
  constructor(e) {
4171
- if (super(), this._publisher = new v(), e)
4413
+ if (super(), this._publisher = new g(), e)
4172
4414
  for (const t of e)
4173
- this.add(t);
4415
+ super.add(t);
4174
4416
  }
4175
4417
  /**
4176
4418
  * Appends a new element with a specified value to the end of the {@link Set}.
@@ -4185,7 +4427,7 @@ class Z extends Set {
4185
4427
  * .add(4)
4186
4428
  * .add(8);
4187
4429
  *
4188
- * console.log(set); // SetView(4) { 2, 4, 8 }
4430
+ * console.log(set); // SetView(3) { 2, 4, 8 }
4189
4431
  * ```
4190
4432
  *
4191
4433
  * ---
@@ -4304,7 +4546,7 @@ class Z extends Set {
4304
4546
  }
4305
4547
  [Symbol.toStringTag] = "SetView";
4306
4548
  }
4307
- class W {
4549
+ class ee {
4308
4550
  /**
4309
4551
  * Whether to prefer the {@link localStorage} over the {@link sessionStorage} when calling an ambivalent method.
4310
4552
  *
@@ -4339,7 +4581,7 @@ class W {
4339
4581
  */
4340
4582
  constructor(e = !0) {
4341
4583
  if (!E)
4342
- throw new O(
4584
+ throw new z(
4343
4585
  "The `JSONStorage` class can only be instantiated within a browser environment."
4344
4586
  );
4345
4587
  this._preferPersistence = e, this._volatile = window.sessionStorage, this._persistent = window.localStorage;
@@ -4612,7 +4854,7 @@ class W {
4612
4854
  }
4613
4855
  [Symbol.toStringTag] = "JSONStorage";
4614
4856
  }
4615
- class m {
4857
+ class w {
4616
4858
  /**
4617
4859
  * Wraps a new {@link SmartPromise} object around an existing native {@link Promise} object.
4618
4860
  *
@@ -4637,7 +4879,7 @@ class m {
4637
4879
  * @returns A new {@link SmartPromise} object that wraps the provided promise.
4638
4880
  */
4639
4881
  static FromPromise(e) {
4640
- return new m((t, n) => e.then(t, n));
4882
+ return new w((t, n) => e.then(t, n));
4641
4883
  }
4642
4884
  /**
4643
4885
  * A flag indicating whether the promise is still pending or not.
@@ -4745,7 +4987,7 @@ class m {
4745
4987
  }
4746
4988
  [Symbol.toStringTag] = "SmartPromise";
4747
4989
  }
4748
- class F extends m {
4990
+ class F extends w {
4749
4991
  /**
4750
4992
  * The exposed function that allows to resolve the promise.
4751
4993
  *
@@ -4818,7 +5060,7 @@ class F extends m {
4818
5060
  }
4819
5061
  [Symbol.toStringTag] = "DeferredPromise";
4820
5062
  }
4821
- class q extends m {
5063
+ class O extends w {
4822
5064
  /**
4823
5065
  * Initializes a new instance of the {@link TimedPromise} class.
4824
5066
  *
@@ -4843,17 +5085,17 @@ class q extends m {
4843
5085
  */
4844
5086
  constructor(e, t) {
4845
5087
  super((n, s) => {
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);
5088
+ const r = (p) => {
5089
+ clearTimeout(u), n(p);
5090
+ }, o = (p) => {
5091
+ clearTimeout(u), s(p);
5092
+ }, u = setTimeout(() => o(new N("The operation has timed out.")), t);
4851
5093
  e(r, o);
4852
5094
  });
4853
5095
  }
4854
5096
  [Symbol.toStringTag] = "TimedPromise";
4855
5097
  }
4856
- class U extends m {
5098
+ class te extends w {
4857
5099
  /**
4858
5100
  * The number of promises currently in the queue.
4859
5101
  */
@@ -4877,7 +5119,7 @@ class U extends m {
4877
5119
  * Accessing this property will always result in a {@link ValueException}.
4878
5120
  */
4879
5121
  get isRejected() {
4880
- throw new u("`PromiseQueue` doesn't support rejection states.");
5122
+ throw new c("`PromiseQueue` doesn't support rejection states.");
4881
5123
  }
4882
5124
  /**
4883
5125
  * Initializes a new instance of the {@link PromiseQueue} class.
@@ -4897,16 +5139,16 @@ class U extends m {
4897
5139
  this._count -= 1, r(o);
4898
5140
  });
4899
5141
  };
4900
- return t ? new q(n, t) : new m(n);
5142
+ return t ? new O(n, t) : new w(n);
4901
5143
  }
4902
5144
  [Symbol.toStringTag] = "PromiseQueue";
4903
5145
  }
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) {
5146
+ var k = /* @__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))(k || {}), $ = /* @__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))($ || {});
5147
+ function ne(i, e, t = 864e5) {
4906
5148
  let n;
4907
5149
  return i = new Date(i), e = new Date(e), i < e ? n = Math.floor : n = Math.ceil, n((e.getTime() - i.getTime()) / t);
4908
5150
  }
4909
- function te(i, e, t = 864e5) {
5151
+ function se(i, e, t = 864e5) {
4910
5152
  if (i = new Date(i), e = new Date(e), i >= e)
4911
5153
  throw new x("The end date must be greater than the start date.");
4912
5154
  return new l(function* () {
@@ -4916,7 +5158,7 @@ function te(i, e, t = 864e5) {
4916
5158
  yield new Date(s), s += t;
4917
5159
  });
4918
5160
  }
4919
- function $(i, e = 864e5) {
5161
+ function D(i, e = 864e5) {
4920
5162
  if (e <= 1)
4921
5163
  throw new x(
4922
5164
  "Rounding a timestamp by milliseconds or less makes no sense.Use the timestamp value directly instead."
@@ -4927,10 +5169,10 @@ function $(i, e = 864e5) {
4927
5169
  );
4928
5170
  return i = new Date(i), new Date(Math.floor(i.getTime() / e) * e);
4929
5171
  }
4930
- function ne(i, e = 0) {
5172
+ function re(i, e = 0) {
4931
5173
  i = new Date(i);
4932
5174
  const t = 7 - e, n = (i.getUTCDay() + t) % 7, s = i.getTime() - 864e5 * n;
4933
- return $(new Date(s));
5175
+ return D(new Date(s));
4934
5176
  }
4935
5177
  class C {
4936
5178
  /**
@@ -5016,7 +5258,7 @@ class C {
5016
5258
  `Not a browser environment detected. Using setInterval@${t}ms instead of requestAnimationFrame...`
5017
5259
  ), this._start = () => {
5018
5260
  this._handle = setInterval(() => e(this.elapsedTime), t);
5019
- }, this._stop = () => clearInterval(this._handle)), this._publisher = new v();
5261
+ }, this._stop = () => clearInterval(this._handle)), this._publisher = new g();
5020
5262
  }
5021
5263
  /**
5022
5264
  * Starts the execution of the game loop.
@@ -5037,7 +5279,7 @@ class C {
5037
5279
  */
5038
5280
  start(e = 0) {
5039
5281
  if (this._isRunning)
5040
- throw new y("The game loop has already been started.");
5282
+ throw new b("The game loop has already been started.");
5041
5283
  this._startTime = performance.now() - e, this._start(), this._isRunning = !0, this._publisher.publish("start");
5042
5284
  }
5043
5285
  /**
@@ -5055,9 +5297,9 @@ class C {
5055
5297
  */
5056
5298
  stop() {
5057
5299
  if (!this._isRunning)
5058
- throw new y("The game loop had already stopped or hadn't yet started.");
5300
+ throw new b("The game loop had already stopped or hadn't yet started.");
5059
5301
  if (!this._handle)
5060
- throw new g();
5302
+ throw new v();
5061
5303
  this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
5062
5304
  }
5063
5305
  /**
@@ -5100,7 +5342,7 @@ class C {
5100
5342
  }
5101
5343
  [Symbol.toStringTag] = "GameLoop";
5102
5344
  }
5103
- class se extends C {
5345
+ class ie extends C {
5104
5346
  /**
5105
5347
  * Initializes a new instance of the {@link Clock} class.
5106
5348
  *
@@ -5117,7 +5359,7 @@ class se extends C {
5117
5359
  * The interval in milliseconds at which the clock will tick if the environment is not a browser.
5118
5360
  * `TimeUnit.Second` by default.
5119
5361
  */
5120
- constructor(e = S.Second) {
5362
+ constructor(e = k.Second) {
5121
5363
  super((t) => this._publisher.publish("tick", t), e);
5122
5364
  }
5123
5365
  /**
@@ -5139,7 +5381,7 @@ class se extends C {
5139
5381
  */
5140
5382
  start(e = 0) {
5141
5383
  if (this._isRunning)
5142
- throw new y("The clock has already been started.");
5384
+ throw new b("The clock has already been started.");
5143
5385
  this._startTime = performance.now() - e, this._start(), this._isRunning = !0, this._publisher.publish("start");
5144
5386
  }
5145
5387
  /**
@@ -5157,9 +5399,9 @@ class se extends C {
5157
5399
  */
5158
5400
  stop() {
5159
5401
  if (!this._isRunning)
5160
- throw new y("The clock had already stopped or hadn't yet started.");
5402
+ throw new b("The clock had already stopped or hadn't yet started.");
5161
5403
  if (!this._handle)
5162
- throw new g();
5404
+ throw new v();
5163
5405
  this._stop(), this._handle = void 0, this._isRunning = !1, this._publisher.publish("stop");
5164
5406
  }
5165
5407
  /**
@@ -5198,7 +5440,7 @@ class se extends C {
5198
5440
  }
5199
5441
  [Symbol.toStringTag] = "Clock";
5200
5442
  }
5201
- class re extends C {
5443
+ class oe extends C {
5202
5444
  /**
5203
5445
  * The total duration of the countdown in milliseconds.
5204
5446
  *
@@ -5242,7 +5484,7 @@ class re extends C {
5242
5484
  * The interval in milliseconds at which the countdown will tick if the environment is not a browser.
5243
5485
  * `TimeUnit.Second` by default.
5244
5486
  */
5245
- constructor(e, t = S.Second) {
5487
+ constructor(e, t = k.Second) {
5246
5488
  const n = () => {
5247
5489
  const s = this.remainingTime;
5248
5490
  s <= 0 ? (this._deferrerStop(), this._publisher.publish("tick", 0), this._publisher.publish("expire")) : this._publisher.publish("tick", s);
@@ -5263,9 +5505,9 @@ class re extends C {
5263
5505
  */
5264
5506
  _deferrerStop(e) {
5265
5507
  if (!this._isRunning)
5266
- throw new y("The countdown hadn't yet started.");
5508
+ throw new b("The countdown hadn't yet started.");
5267
5509
  if (!this._deferrer)
5268
- throw new g();
5510
+ throw new v();
5269
5511
  this._stop(), this._handle = void 0, this._isRunning = !1, e !== void 0 ? this._deferrer.reject(e) : this._deferrer.resolve(), this._deferrer = void 0;
5270
5512
  }
5271
5513
  /**
@@ -5291,9 +5533,9 @@ class re extends C {
5291
5533
  */
5292
5534
  start(e = this.duration) {
5293
5535
  if (this._isRunning)
5294
- throw new y("The countdown had already stopped or hadn't yet started.");
5536
+ throw new b("The countdown had already stopped or hadn't yet started.");
5295
5537
  if (this._deferrer)
5296
- throw new g();
5538
+ throw new v();
5297
5539
  return this._deferrer = new F(), super.start(this.duration - e), this._publisher.publish("start"), this._deferrer;
5298
5540
  }
5299
5541
  /**
@@ -5376,7 +5618,7 @@ class re extends C {
5376
5618
  }
5377
5619
  [Symbol.toStringTag] = "Countdown";
5378
5620
  }
5379
- class ie {
5621
+ class ae {
5380
5622
  /**
5381
5623
  * Generates a given number of values following a linear curve.
5382
5624
  * The values are equally spaced and normalized between 0 and 1.
@@ -5434,7 +5676,7 @@ class ie {
5434
5676
  */
5435
5677
  static Exponential(e, t = 2) {
5436
5678
  if (t < 0)
5437
- throw new u("The base of the exponential curve cannot be negative.");
5679
+ throw new c("The base of the exponential curve cannot be negative.");
5438
5680
  const n = e - 1;
5439
5681
  return new l(function* () {
5440
5682
  for (let s = 0; s < e; s += 1)
@@ -5493,7 +5735,7 @@ class P {
5493
5735
  */
5494
5736
  static Index(e) {
5495
5737
  if (e.length === 0)
5496
- throw new u("You must provide at least one element.");
5738
+ throw new c("You must provide at least one element.");
5497
5739
  return this.Integer(e.length);
5498
5740
  }
5499
5741
  /**
@@ -5516,62 +5758,94 @@ class P {
5516
5758
  static Sample(e, t, n) {
5517
5759
  const s = e.length;
5518
5760
  if (s === 0)
5519
- throw new u("You must provide at least one element.");
5761
+ throw new c("You must provide at least one element.");
5520
5762
  if (t < 0)
5521
- throw new u("Count must be non-negative.");
5763
+ throw new c("Count must be non-negative.");
5522
5764
  if (t > s)
5523
- throw new u("Count cannot exceed the number of elements.");
5765
+ throw new c("Count cannot exceed the number of elements.");
5524
5766
  if (t === 0)
5525
5767
  return [];
5526
5768
  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[_];
5769
+ const a = Array.from(e), u = new Array(t);
5770
+ for (let p = 0; p < t; p += 1) {
5771
+ const T = this.Integer(p, s);
5772
+ u[p] = a[T], a[T] = a[p];
5531
5773
  }
5532
- return f;
5774
+ return u;
5533
5775
  }
5534
5776
  if (n.length !== s)
5535
- throw new u("Weights array must have the same length as elements array.");
5777
+ throw new c("Weights array must have the same length as elements array.");
5536
5778
  const r = new Array(s);
5537
5779
  for (let a = 0; a < s; a += 1) {
5538
5780
  if (n[a] <= 0)
5539
- throw new u(`Weight for element #${a} must be greater than zero.`);
5781
+ throw new c(`Weight for element #${a} must be greater than zero.`);
5540
5782
  r[a] = { index: a, key: Math.pow(Math.random(), 1 / n[a]) };
5541
5783
  }
5542
- r.sort((a, f) => f.key - a.key);
5784
+ r.sort((a, u) => u.key - a.key);
5543
5785
  const o = new Array(t);
5544
5786
  for (let a = 0; a < t; a += 1)
5545
5787
  o[a] = e[r[a].index];
5546
5788
  return o;
5547
5789
  }
5790
+ static #e(e, t) {
5791
+ const n = new Array(t - 1);
5792
+ for (let a = 0; a < n.length; a += 1)
5793
+ n[a] = Math.random() * e;
5794
+ n.sort((a, u) => a - u);
5795
+ const s = [0, ...n, e], r = new Array(t);
5796
+ for (let a = 0; a < t; a += 1)
5797
+ r[a] = Math.floor(s[a + 1] - s[a]);
5798
+ let o = e - r.reduce((a, u) => a + u, 0);
5799
+ for (; o > 0; )
5800
+ r[this.Integer(t)] += 1, o -= 1;
5801
+ return r;
5802
+ }
5803
+ static Split(e, t) {
5804
+ if (t < 1)
5805
+ throw new c("The number of splits must be greater than zero.");
5806
+ if (typeof e == "number") {
5807
+ if (e < 0)
5808
+ throw new c("The total must be a non-negative number.");
5809
+ return this.#e(e, t);
5810
+ }
5811
+ const n = Array.from(e), s = n.length;
5812
+ if (s === 0)
5813
+ throw new c("You must provide at least one element.");
5814
+ if (t > s)
5815
+ throw new c("The number of splits cannot exceed the number of elements.");
5816
+ const r = this.#e(s, t), o = new Array(t);
5817
+ let a = 0;
5818
+ for (let u = 0; u < t; u += 1)
5819
+ o[u] = n.slice(a, a + r[u]), a += r[u];
5820
+ return o;
5821
+ }
5548
5822
  constructor() {
5549
5823
  }
5550
5824
  [Symbol.toStringTag] = "Random";
5551
5825
  }
5552
- function oe(i) {
5553
- return new m((e) => setTimeout(e, i));
5826
+ function le(i) {
5827
+ return new w((e) => setTimeout(e, i));
5554
5828
  }
5555
- function ae() {
5556
- return new m((i) => requestAnimationFrame(() => i()));
5829
+ function ue() {
5830
+ return new w((i) => requestAnimationFrame(() => i()));
5557
5831
  }
5558
- function le() {
5559
- return new m((i) => setTimeout(i));
5832
+ function ce() {
5833
+ return new w((i) => setTimeout(i));
5560
5834
  }
5561
- function ue(i, e = "text/javascript") {
5562
- return new m((t, n) => {
5835
+ function he(i, e = "text/javascript") {
5836
+ return new w((t, n) => {
5563
5837
  const s = document.createElement("script");
5564
5838
  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);
5565
5839
  });
5566
5840
  }
5567
- function ce(...i) {
5841
+ function fe(...i) {
5568
5842
  return new l(function* () {
5569
5843
  for (const e of i)
5570
5844
  for (const t of e)
5571
5845
  yield t;
5572
5846
  });
5573
5847
  }
5574
- function he(i) {
5848
+ function de(i) {
5575
5849
  if (i instanceof Array)
5576
5850
  return i.length;
5577
5851
  let e = 0;
@@ -5579,14 +5853,14 @@ function he(i) {
5579
5853
  e += 1;
5580
5854
  return e;
5581
5855
  }
5582
- function fe(i) {
5856
+ function me(i) {
5583
5857
  return new l(function* () {
5584
5858
  let e = 0;
5585
5859
  for (const t of i)
5586
5860
  yield [e, t], e += 1;
5587
5861
  });
5588
5862
  }
5589
- function de(i, e, t = 1) {
5863
+ function we(i, e, t = 1) {
5590
5864
  if (t <= 0)
5591
5865
  throw new x(
5592
5866
  "Step must be always a positive number, even when generating numbers in reverse order."
@@ -5599,7 +5873,7 @@ function de(i, e, t = 1) {
5599
5873
  yield n;
5600
5874
  });
5601
5875
  }
5602
- function we(i) {
5876
+ function pe(i) {
5603
5877
  const e = Array.from(i);
5604
5878
  for (let t = e.length - 1; t > 0; t -= 1) {
5605
5879
  const n = Math.floor(Math.random() * (t + 1));
@@ -5607,14 +5881,14 @@ function we(i) {
5607
5881
  }
5608
5882
  return e;
5609
5883
  }
5610
- function me(i) {
5884
+ function _e(i) {
5611
5885
  return new l(function* () {
5612
5886
  const e = /* @__PURE__ */ new Set();
5613
5887
  for (const t of i)
5614
5888
  e.has(t) || (e.add(t), yield t);
5615
5889
  });
5616
5890
  }
5617
- function D(i, e) {
5891
+ function Y(i, e) {
5618
5892
  const t = i[Symbol.iterator](), n = e[Symbol.iterator]();
5619
5893
  return new l(function* () {
5620
5894
  for (; ; ) {
@@ -5625,28 +5899,28 @@ function D(i, e) {
5625
5899
  }
5626
5900
  });
5627
5901
  }
5628
- function _e(i, e) {
5902
+ function be(i, e) {
5629
5903
  if (e === void 0) {
5630
5904
  let r = 0, o = 0;
5631
5905
  for (const a of i)
5632
5906
  r += a, o += 1;
5633
5907
  if (o === 0)
5634
- throw new u("You must provide at least one value.");
5908
+ throw new c("You must provide at least one value.");
5635
5909
  return r / o;
5636
5910
  }
5637
5911
  let t = 0, n = 0, s = 0;
5638
- for (const [r, o] of D(i, e)) {
5912
+ for (const [r, o] of Y(i, e)) {
5639
5913
  if (o <= 0)
5640
- throw new u(`The weight for the value #${s} must be greater than zero.`);
5914
+ throw new c(`The weight for the value #${s} must be greater than zero.`);
5641
5915
  t += r * o, n += o, s += 1;
5642
5916
  }
5643
5917
  if (s === 0)
5644
- throw new u("You must provide at least one value and weight.");
5918
+ throw new c("You must provide at least one value and weight.");
5645
5919
  if (n <= 0)
5646
- throw new u("The sum of weights must be greater than zero.");
5920
+ throw new c("The sum of weights must be greater than zero.");
5647
5921
  return t / n;
5648
5922
  }
5649
- function pe(i) {
5923
+ function ye(i) {
5650
5924
  let e = 0;
5651
5925
  for (let t = 0; t < i.length; t += 1) {
5652
5926
  const n = i.charCodeAt(t);
@@ -5654,78 +5928,80 @@ function pe(i) {
5654
5928
  }
5655
5929
  return e;
5656
5930
  }
5657
- function ye(i) {
5931
+ function xe(i) {
5658
5932
  let e = 0;
5659
5933
  for (const t of i)
5660
5934
  e += t;
5661
5935
  return e;
5662
5936
  }
5663
- function be(i) {
5937
+ function ge(i) {
5664
5938
  return `${i.charAt(0).toUpperCase()}${i.slice(1)}`;
5665
5939
  }
5666
- const xe = "2.2.3";
5940
+ const ve = "2.2.4";
5667
5941
  export {
5668
- p as AggregatedAsyncIterator,
5942
+ _ as AggregatedAsyncIterator,
5669
5943
  d as AggregatedIterator,
5944
+ Z as ArrayView,
5670
5945
  R as CallableObject,
5671
- Q as CallbackChain,
5672
- se as Clock,
5673
- re as Countdown,
5674
- ie as Curve,
5946
+ H as CallbackChain,
5947
+ ie as Clock,
5948
+ oe as Countdown,
5949
+ ae as Curve,
5675
5950
  F as DeferredPromise,
5676
- O as EnvironmentException,
5677
- h as Exception,
5678
- g as FatalErrorException,
5951
+ z as EnvironmentException,
5952
+ f as Exception,
5953
+ v as FatalErrorException,
5679
5954
  M as FileException,
5680
5955
  J as FileExistsException,
5681
5956
  L as FileNotFoundException,
5682
5957
  C as GameLoop,
5683
- W as JSONStorage,
5684
- b as KeyException,
5685
- X as MapView,
5686
- V as NetworkException,
5958
+ ee as JSONStorage,
5959
+ y as KeyException,
5960
+ W as MapView,
5961
+ A as NetworkException,
5687
5962
  j as NotImplementedException,
5688
- G as PermissionException,
5689
- U as PromiseQueue,
5690
- v as Publisher,
5963
+ K as PermissionException,
5964
+ te as PromiseQueue,
5965
+ g as Publisher,
5691
5966
  P as Random,
5692
5967
  x as RangeException,
5693
- c as ReducedIterator,
5694
- k as ReferenceException,
5695
- y as RuntimeException,
5696
- Z as SetView,
5697
- w as SmartAsyncIterator,
5968
+ h as ReducedIterator,
5969
+ S as ReferenceException,
5970
+ G as ResponseException,
5971
+ b as RuntimeException,
5972
+ U as SetView,
5973
+ m as SmartAsyncIterator,
5698
5974
  l as SmartIterator,
5699
- m as SmartPromise,
5700
- H as SwitchableCallback,
5701
- S as TimeUnit,
5702
- q as TimedPromise,
5975
+ w as SmartPromise,
5976
+ X as SwitchableCallback,
5977
+ k as TimeUnit,
5978
+ O as TimedPromise,
5703
5979
  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,
5980
+ Q as TypeException,
5981
+ ve as VERSION,
5982
+ c as ValueException,
5983
+ $ as WeekDay,
5984
+ be as average,
5985
+ ge as capitalize,
5986
+ fe as chain,
5987
+ de as count,
5988
+ ne as dateDifference,
5989
+ se as dateRange,
5990
+ D as dateRound,
5991
+ le as delay,
5992
+ me as enumerate,
5993
+ re as getWeek,
5994
+ ye as hash,
5719
5995
  E as isBrowser,
5720
5996
  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,
5727
- me as unique,
5728
- le as yieldToEventLoop,
5729
- D as zip
5997
+ V as isWorker,
5998
+ he as loadScript,
5999
+ ue as nextAnimationFrame,
6000
+ we as range,
6001
+ pe as shuffle,
6002
+ xe as sum,
6003
+ _e as unique,
6004
+ ce as yieldToEventLoop,
6005
+ Y as zip
5730
6006
  };
5731
6007
  //# sourceMappingURL=core.esm.js.map