@byloth/core 2.0.0-rc.4 → 2.0.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,13 +1,13 @@
1
- var Ie = Object.defineProperty;
2
- var Ae = (i, t, e) => t in i ? Ie(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var a = (i, t, e) => Ae(i, typeof t != "symbol" ? t + "" : t, e);
4
- const Me = typeof window < "u" && typeof window.document < "u";
5
- var F;
6
- const Je = typeof process < "u" && ((F = process.versions) == null ? void 0 : F.node);
1
+ var Ae = Object.defineProperty;
2
+ var Oe = (i, t, e) => t in i ? Ae(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
+ var a = (i, t, e) => Oe(i, typeof t != "symbol" ? t + "" : t, e);
4
+ const Re = typeof window < "u" && typeof window.document < "u";
7
5
  var P;
8
- const Ve = typeof self == "object" && ((P = self.constructor) == null ? void 0 : P.name) === "DedicatedWorkerGlobalScope";
9
- var j, I;
10
- class c extends (I = Error, j = Symbol.toStringTag, I) {
6
+ const Ve = typeof process < "u" && ((P = process.versions) == null ? void 0 : P.node);
7
+ var I;
8
+ const We = typeof self == "object" && ((I = self.constructor) == null ? void 0 : I.name) === "DedicatedWorkerGlobalScope";
9
+ var j, A;
10
+ class c extends (A = Error, j = Symbol.toStringTag, A) {
11
11
  constructor(e, n, r = "Exception") {
12
12
  super(e);
13
13
  a(this, j, "Exception");
@@ -27,120 +27,120 @@ Caused by ${n}`);
27
27
  return new c(`${e}`);
28
28
  }
29
29
  }
30
- var A, C;
31
- class x extends (C = c, A = Symbol.toStringTag, C) {
30
+ var O, C;
31
+ class g extends (C = c, O = Symbol.toStringTag, C) {
32
32
  constructor(e, n, r = "FatalErrorException") {
33
33
  e === void 0 && (e = "The program has encountered an unrecoverable error and cannot continue as expected. Please, try again later. If the problem persists, contact the support team.");
34
34
  super(e, n, r);
35
- a(this, A, "FatalErrorException");
35
+ a(this, O, "FatalErrorException");
36
36
  }
37
37
  }
38
- var D, O;
39
- class We extends (O = x, D = Symbol.toStringTag, O) {
38
+ var D, q;
39
+ class Ye extends (q = g, D = Symbol.toStringTag, q) {
40
40
  constructor(e, n, r = "NotImplementedException") {
41
41
  e === void 0 && (e = "This feature is not implemented yet. Please, try again later.");
42
42
  super(e, n, r);
43
43
  a(this, D, "NotImplementedException");
44
44
  }
45
45
  }
46
- var q, N;
47
- class Re extends (N = c, q = Symbol.toStringTag, N) {
46
+ var N, $;
47
+ class Pe extends ($ = c, N = Symbol.toStringTag, $) {
48
48
  constructor(e, n, r = "FileException") {
49
49
  super(e, n, r);
50
- a(this, q, "FileException");
50
+ a(this, N, "FileException");
51
51
  }
52
52
  }
53
- var $, J;
54
- class Ye extends (J = Re, $ = Symbol.toStringTag, J) {
53
+ var J, V;
54
+ class ze extends (V = Pe, J = Symbol.toStringTag, V) {
55
55
  constructor(e, n, r = "FileExistsException") {
56
56
  super(e, n, r);
57
- a(this, $, "FileExistsException");
57
+ a(this, J, "FileExistsException");
58
58
  }
59
59
  }
60
- var V, W;
61
- class ze extends (W = Re, V = Symbol.toStringTag, W) {
60
+ var W, Y;
61
+ class Be extends (Y = Pe, W = Symbol.toStringTag, Y) {
62
62
  constructor(e, n, r = "FileNotFoundException") {
63
63
  super(e, n, r);
64
- a(this, V, "FileNotFoundException");
64
+ a(this, W, "FileNotFoundException");
65
65
  }
66
66
  }
67
- var Y, z;
68
- class Be extends (z = c, Y = Symbol.toStringTag, z) {
67
+ var z, B;
68
+ class Ge extends (B = c, z = Symbol.toStringTag, B) {
69
69
  constructor(e, n, r = "KeyException") {
70
70
  super(e, n, r);
71
- a(this, Y, "KeyException");
71
+ a(this, z, "KeyException");
72
72
  }
73
73
  }
74
- var B, G;
75
- class Ge extends (G = c, B = Symbol.toStringTag, G) {
74
+ var G, K;
75
+ class Ke extends (K = c, G = Symbol.toStringTag, K) {
76
76
  constructor(e, n, r = "NetworkException") {
77
77
  super(e, n, r);
78
- a(this, B, "NetworkException");
78
+ a(this, G, "NetworkException");
79
79
  }
80
80
  }
81
- var K, H;
82
- class Ke extends (H = c, K = Symbol.toStringTag, H) {
81
+ var H, L;
82
+ class He extends (L = c, H = Symbol.toStringTag, L) {
83
83
  constructor(e, n, r = "PermissionException") {
84
84
  super(e, n, r);
85
- a(this, K, "PermissionException");
85
+ a(this, H, "PermissionException");
86
86
  }
87
87
  }
88
- var L, Q;
89
- class Ce extends (Q = c, L = Symbol.toStringTag, Q) {
88
+ var Q, X;
89
+ class Ce extends (X = c, Q = Symbol.toStringTag, X) {
90
90
  constructor(e, n, r = "ReferenceException") {
91
91
  super(e, n, r);
92
- a(this, L, "ReferenceException");
92
+ a(this, Q, "ReferenceException");
93
93
  }
94
94
  }
95
- var X, Z;
96
- class p extends (Z = c, X = Symbol.toStringTag, Z) {
95
+ var Z, U;
96
+ class p extends (U = c, Z = Symbol.toStringTag, U) {
97
97
  constructor(e, n, r = "RuntimeException") {
98
98
  super(e, n, r);
99
- a(this, X, "RuntimeException");
99
+ a(this, Z, "RuntimeException");
100
100
  }
101
101
  }
102
- var U, ee;
103
- class De extends (ee = p, U = Symbol.toStringTag, ee) {
102
+ var ee, te;
103
+ class De extends (te = p, ee = Symbol.toStringTag, te) {
104
104
  constructor(e, n, r = "EnvironmentException") {
105
105
  super(e, n, r);
106
- a(this, U, "EnvironmentException");
106
+ a(this, ee, "EnvironmentException");
107
107
  }
108
108
  }
109
- var te, ne;
110
- class Oe extends (ne = c, te = Symbol.toStringTag, ne) {
109
+ var ne, re;
110
+ class qe extends (re = c, ne = Symbol.toStringTag, re) {
111
111
  constructor(e, n, r = "TimeoutException") {
112
112
  super(e, n, r);
113
- a(this, te, "TimeoutException");
113
+ a(this, ne, "TimeoutException");
114
114
  }
115
115
  }
116
- var re, se;
117
- class He extends (se = c, re = Symbol.toStringTag, se) {
116
+ var se, ie;
117
+ class Le extends (ie = c, se = Symbol.toStringTag, ie) {
118
118
  constructor(e, n, r = "TypeException") {
119
119
  super(e, n, r);
120
- a(this, re, "TypeException");
120
+ a(this, se, "TypeException");
121
121
  }
122
122
  }
123
- var ie, oe;
124
- class d extends (oe = c, ie = Symbol.toStringTag, oe) {
123
+ var oe, ae;
124
+ class d extends (ae = c, oe = Symbol.toStringTag, ae) {
125
125
  constructor(e, n, r = "ValueException") {
126
126
  super(e, n, r);
127
- a(this, ie, "ValueException");
127
+ a(this, oe, "ValueException");
128
128
  }
129
129
  }
130
- var ae, ue;
131
- class Fe extends (ue = d, ae = Symbol.toStringTag, ue) {
130
+ var ue, le;
131
+ class Ie extends (le = d, ue = Symbol.toStringTag, le) {
132
132
  constructor(e, n, r = "RangeException") {
133
133
  super(e, n, r);
134
- a(this, ae, "RangeException");
134
+ a(this, ue, "RangeException");
135
135
  }
136
136
  }
137
- var le;
138
- class l {
137
+ var ce;
138
+ class u {
139
139
  constructor(t) {
140
140
  a(this, "_iterator");
141
141
  a(this, "return");
142
142
  a(this, "throw");
143
- a(this, le, "SmartIterator");
143
+ a(this, ce, "SmartIterator");
144
144
  t instanceof Function ? this._iterator = t() : Symbol.iterator in t ? this._iterator = t[Symbol.iterator]() : this._iterator = t, this._iterator.return && (this.return = (e) => this._iterator.return(e)), this._iterator.throw && (this.throw = (e) => this._iterator.throw(e));
145
145
  }
146
146
  every(t) {
@@ -167,7 +167,7 @@ class l {
167
167
  }
168
168
  filter(t) {
169
169
  const e = this._iterator;
170
- return new l(function* () {
170
+ return new u(function* () {
171
171
  let n = 0;
172
172
  for (; ; ) {
173
173
  const r = e.next();
@@ -179,7 +179,7 @@ class l {
179
179
  }
180
180
  map(t) {
181
181
  const e = this._iterator;
182
- return new l(function* () {
182
+ return new u(function* () {
183
183
  let n = 0;
184
184
  for (; ; ) {
185
185
  const r = e.next();
@@ -206,7 +206,7 @@ class l {
206
206
  }
207
207
  flatMap(t) {
208
208
  const e = this._iterator;
209
- return new l(function* () {
209
+ return new u(function* () {
210
210
  let n = 0;
211
211
  for (; ; ) {
212
212
  const r = e.next();
@@ -221,7 +221,7 @@ class l {
221
221
  }
222
222
  drop(t) {
223
223
  const e = this._iterator;
224
- return new l(function* () {
224
+ return new u(function* () {
225
225
  let n = 0;
226
226
  for (; n < t; ) {
227
227
  if (e.next().done)
@@ -238,7 +238,7 @@ class l {
238
238
  }
239
239
  take(t) {
240
240
  const e = this._iterator;
241
- return new l(function* () {
241
+ return new u(function* () {
242
242
  let n = 0;
243
243
  for (; n < t; ) {
244
244
  const r = e.next();
@@ -264,7 +264,7 @@ class l {
264
264
  }
265
265
  unique() {
266
266
  const t = this._iterator;
267
- return new l(function* () {
267
+ return new u(function* () {
268
268
  const e = /* @__PURE__ */ new Set();
269
269
  for (; ; ) {
270
270
  const n = t.next();
@@ -295,22 +295,22 @@ class l {
295
295
  return this._iterator.next(...t);
296
296
  }
297
297
  groupBy(t) {
298
- return new g(this.map((e, n) => [t(e, n), e]));
298
+ return new v(this.map((e, n) => [t(e, n), e]));
299
299
  }
300
300
  toArray() {
301
301
  return Array.from(this);
302
302
  }
303
- [(le = Symbol.toStringTag, Symbol.iterator)]() {
303
+ [(ce = Symbol.toStringTag, Symbol.iterator)]() {
304
304
  return this;
305
305
  }
306
306
  }
307
- var ce;
308
- ce = Symbol.toStringTag;
309
- const y = class y {
307
+ var fe;
308
+ fe = Symbol.toStringTag;
309
+ const _ = class _ {
310
310
  constructor(t) {
311
311
  a(this, "_elements");
312
- a(this, ce, "ReducedIterator");
313
- this._elements = new l(t);
312
+ a(this, fe, "ReducedIterator");
313
+ this._elements = new u(t);
314
314
  }
315
315
  every(t) {
316
316
  for (const [e, [n, r]] of this._elements.enumerate())
@@ -326,14 +326,14 @@ const y = class y {
326
326
  }
327
327
  filter(t) {
328
328
  const e = this._elements.enumerate();
329
- return new y(function* () {
329
+ return new _(function* () {
330
330
  for (const [n, [r, s]] of e)
331
331
  t(r, s, n) && (yield [r, s]);
332
332
  });
333
333
  }
334
334
  map(t) {
335
335
  const e = this._elements.enumerate();
336
- return new y(function* () {
336
+ return new _(function* () {
337
337
  for (const [n, [r, s]] of e)
338
338
  yield [r, t(r, s, n)];
339
339
  });
@@ -352,7 +352,7 @@ const y = class y {
352
352
  }
353
353
  flatMap(t) {
354
354
  const e = this._elements.enumerate();
355
- return new g(function* () {
355
+ return new v(function* () {
356
356
  for (const [n, [r, s]] of e)
357
357
  for (const o of t(r, s, n))
358
358
  yield [r, o];
@@ -360,14 +360,14 @@ const y = class y {
360
360
  }
361
361
  drop(t) {
362
362
  const e = this._elements.enumerate();
363
- return new y(function* () {
363
+ return new _(function* () {
364
364
  for (const [n, [r, s]] of e)
365
365
  n >= t && (yield [r, s]);
366
366
  });
367
367
  }
368
368
  take(t) {
369
369
  const e = this._elements.enumerate();
370
- return new y(function* () {
370
+ return new _(function* () {
371
371
  for (const [n, [r, s]] of e) {
372
372
  if (n >= t)
373
373
  break;
@@ -380,7 +380,7 @@ const y = class y {
380
380
  }
381
381
  unique() {
382
382
  const t = this._elements;
383
- return new y(function* () {
383
+ return new _(function* () {
384
384
  const e = /* @__PURE__ */ new Set();
385
385
  for (const [n, r] of t)
386
386
  e.has(r) || (e.add(r), yield [n, r]);
@@ -398,7 +398,7 @@ const y = class y {
398
398
  }
399
399
  keys() {
400
400
  const t = this._elements;
401
- return new l(function* () {
401
+ return new u(function* () {
402
402
  for (const [e] of t)
403
403
  yield e;
404
404
  });
@@ -408,7 +408,7 @@ const y = class y {
408
408
  }
409
409
  values() {
410
410
  const t = this._elements;
411
- return new l(function* () {
411
+ return new u(function* () {
412
412
  for (const [e, n] of t)
413
413
  yield n;
414
414
  });
@@ -423,13 +423,13 @@ const y = class y {
423
423
  return Object.fromEntries(this.items());
424
424
  }
425
425
  };
426
- let f = y;
427
- var fe;
428
- fe = Symbol.toStringTag;
426
+ let f = _;
427
+ var he;
428
+ he = Symbol.toStringTag;
429
429
  const m = class m {
430
430
  constructor(t) {
431
431
  a(this, "_elements");
432
- a(this, fe, "AggregatedAsyncIterator");
432
+ a(this, he, "AggregatedAsyncIterator");
433
433
  this._elements = new h(t);
434
434
  }
435
435
  async every(t) {
@@ -477,16 +477,16 @@ const m = class m {
477
477
  async reduce(t, e) {
478
478
  const n = /* @__PURE__ */ new Map();
479
479
  for await (const [r, s] of this._elements) {
480
- let o, u;
480
+ let o, l;
481
481
  if (n.has(r))
482
- [o, u] = n.get(r);
482
+ [o, l] = n.get(r);
483
483
  else if (e !== void 0)
484
- o = 0, u = await e(r);
484
+ o = 0, l = await e(r);
485
485
  else {
486
486
  n.set(r, [0, s]);
487
487
  continue;
488
488
  }
489
- n.set(r, [o + 1, await t(r, u, s, o)]);
489
+ n.set(r, [o + 1, await t(r, l, s, o)]);
490
490
  }
491
491
  return new f(function* () {
492
492
  for (const [r, [s, o]] of n)
@@ -498,9 +498,9 @@ const m = class m {
498
498
  return new m(async function* () {
499
499
  const n = /* @__PURE__ */ new Map();
500
500
  for await (const [r, s] of e) {
501
- const o = n.get(r) ?? 0, u = await t(r, s, o);
502
- for await (const _ of u)
503
- yield [r, _];
501
+ const o = n.get(r) ?? 0, l = await t(r, s, o);
502
+ for await (const x of l)
503
+ yield [r, x];
504
504
  n.set(r, o + 1);
505
505
  }
506
506
  });
@@ -525,12 +525,7 @@ const m = class m {
525
525
  const n = /* @__PURE__ */ new Map();
526
526
  for await (const [r, s] of e) {
527
527
  const o = n.get(r) ?? 0;
528
- if (o >= t) {
529
- if (n.values().every((u) => u >= t))
530
- break;
531
- continue;
532
- }
533
- yield [r, s], n.set(r, o + 1);
528
+ o >= t || (yield [r, s], n.set(r, o + 1));
534
529
  }
535
530
  });
536
531
  }
@@ -613,13 +608,13 @@ const m = class m {
613
608
  }
614
609
  };
615
610
  let S = m;
616
- var he;
611
+ var de;
617
612
  class h {
618
613
  constructor(t) {
619
614
  a(this, "_iterator");
620
615
  a(this, "return");
621
616
  a(this, "throw");
622
- a(this, he, "SmartAsyncIterator");
617
+ a(this, de, "SmartAsyncIterator");
623
618
  if (t instanceof Function) {
624
619
  const e = t();
625
620
  Symbol.asyncIterator in e ? this._iterator = e : this._iterator = async function* () {
@@ -812,17 +807,17 @@ class h {
812
807
  toArray() {
813
808
  return Array.fromAsync(this);
814
809
  }
815
- [(he = Symbol.toStringTag, Symbol.asyncIterator)]() {
810
+ [(de = Symbol.toStringTag, Symbol.asyncIterator)]() {
816
811
  return this;
817
812
  }
818
813
  }
819
- var de;
820
- de = Symbol.toStringTag;
814
+ var me;
815
+ me = Symbol.toStringTag;
821
816
  const w = class w {
822
817
  constructor(t) {
823
818
  a(this, "_elements");
824
- a(this, de, "AggregatedIterator");
825
- this._elements = new l(t);
819
+ a(this, me, "AggregatedIterator");
820
+ this._elements = new u(t);
826
821
  }
827
822
  every(t) {
828
823
  const e = /* @__PURE__ */ new Map();
@@ -869,16 +864,16 @@ const w = class w {
869
864
  reduce(t, e) {
870
865
  const n = /* @__PURE__ */ new Map();
871
866
  for (const [r, s] of this._elements) {
872
- let o, u;
867
+ let o, l;
873
868
  if (n.has(r))
874
- [o, u] = n.get(r);
869
+ [o, l] = n.get(r);
875
870
  else if (e !== void 0)
876
- o = 0, u = e(r);
871
+ o = 0, l = e(r);
877
872
  else {
878
873
  n.set(r, [0, s]);
879
874
  continue;
880
875
  }
881
- n.set(r, [o + 1, t(r, u, s, o)]);
876
+ n.set(r, [o + 1, t(r, l, s, o)]);
882
877
  }
883
878
  return new f(function* () {
884
879
  for (const [r, [s, o]] of n)
@@ -890,9 +885,9 @@ const w = class w {
890
885
  return new w(function* () {
891
886
  const n = /* @__PURE__ */ new Map();
892
887
  for (const [r, s] of e) {
893
- const o = n.get(r) ?? 0, u = t(r, s, o);
894
- for (const _ of u)
895
- yield [r, _];
888
+ const o = n.get(r) ?? 0, l = t(r, s, o);
889
+ for (const x of l)
890
+ yield [r, x];
896
891
  n.set(r, o + 1);
897
892
  }
898
893
  });
@@ -917,12 +912,7 @@ const w = class w {
917
912
  const n = /* @__PURE__ */ new Map();
918
913
  for (const [r, s] of e) {
919
914
  const o = n.get(r) ?? 0;
920
- if (o >= t) {
921
- if (n.values().every((u) => u >= t))
922
- break;
923
- continue;
924
- }
925
- yield [r, s], n.set(r, o + 1);
915
+ o >= t || (yield [r, s], n.set(r, o + 1));
926
916
  }
927
917
  });
928
918
  }
@@ -970,7 +960,7 @@ const w = class w {
970
960
  }
971
961
  keys() {
972
962
  const t = this._elements;
973
- return new l(function* () {
963
+ return new u(function* () {
974
964
  const e = /* @__PURE__ */ new Set();
975
965
  for (const [n] of t)
976
966
  e.has(n) || (e.add(n), yield n);
@@ -981,7 +971,7 @@ const w = class w {
981
971
  }
982
972
  values() {
983
973
  const t = this._elements;
984
- return new l(function* () {
974
+ return new u(function* () {
985
975
  for (const [e, n] of t)
986
976
  yield n;
987
977
  });
@@ -1007,39 +997,23 @@ const w = class w {
1007
997
  return t;
1008
998
  }
1009
999
  };
1010
- let g = w;
1011
- var b = /* @__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))(b || {});
1012
- function Le(i, t, e = 864e5) {
1013
- return i = new Date(i), t = new Date(t), Math.floor((t.getTime() - i.getTime()) / e);
1014
- }
1015
- function Qe(i, t, e = 864e5) {
1016
- return i = new Date(i), t = new Date(t), new l(function* () {
1017
- const n = t.getTime();
1018
- let r = i.getTime();
1019
- for (; r < n; )
1020
- yield new Date(r), r += e;
1021
- });
1022
- }
1023
- function Xe(i, t = 864e5) {
1024
- return i = new Date(i), new Date(Math.floor(i.getTime() / t) * t);
1025
- }
1026
- var me;
1027
- me = Symbol.toStringTag;
1028
- class Pe {
1029
- constructor(t, e = 30) {
1000
+ let v = w;
1001
+ var we;
1002
+ we = Symbol.toStringTag;
1003
+ class je {
1004
+ constructor(t, e = 40) {
1030
1005
  a(this, "_handle");
1031
1006
  a(this, "_startTime");
1032
1007
  a(this, "_isRunning");
1033
1008
  a(this, "_start");
1034
1009
  a(this, "_stop");
1035
- a(this, me, "GameLoop");
1036
- this._startTime = 0, this._isRunning = !1, Me ? (this._start = () => {
1010
+ a(this, we, "GameLoop");
1011
+ this._startTime = 0, this._isRunning = !1, Re ? (this._start = () => {
1037
1012
  t(this.elapsedTime), this._handle = window.requestAnimationFrame(this._start);
1038
1013
  }, this._stop = () => window.cancelAnimationFrame(this._handle)) : (console.warn(
1039
- `Not a browser environment detected. Using setInterval@${e}fps instead of requestAnimationFrame...`
1014
+ `Not a browser environment detected. Using setInterval@${e}ms instead of requestAnimationFrame...`
1040
1015
  ), this._start = () => {
1041
- const n = b.Second / e;
1042
- this._handle = setInterval(() => t(this.elapsedTime), n);
1016
+ this._handle = setInterval(() => t(this.elapsedTime), e);
1043
1017
  }, this._stop = () => clearInterval(this._handle));
1044
1018
  }
1045
1019
  get startTime() {
@@ -1060,19 +1034,19 @@ class Pe {
1060
1034
  if (!this._isRunning)
1061
1035
  throw new p("The game loop hadn't yet started.");
1062
1036
  if (!this._handle)
1063
- throw new x();
1037
+ throw new g();
1064
1038
  this._stop(), this._handle = void 0, this._isRunning = !1;
1065
1039
  }
1066
1040
  }
1067
- var we;
1068
- we = Symbol.toStringTag;
1069
- class Ze {
1041
+ var _e;
1042
+ _e = Symbol.toStringTag;
1043
+ class Qe {
1070
1044
  constructor(t = !0) {
1071
1045
  a(this, "_preferPersistence");
1072
1046
  a(this, "_volatile");
1073
1047
  a(this, "_persistent");
1074
- a(this, we, "JSONStorage");
1075
- if (this._preferPersistence = t, !Me)
1048
+ a(this, _e, "JSONStorage");
1049
+ if (this._preferPersistence = t, !Re)
1076
1050
  throw new De(
1077
1051
  "The `JSONStorage` class can only be instantiated within a browser environment."
1078
1052
  );
@@ -1208,7 +1182,7 @@ class Ze {
1208
1182
  }
1209
1183
  var ye;
1210
1184
  ye = Symbol.toStringTag;
1211
- const E = class E {
1185
+ const T = class T {
1212
1186
  constructor(t) {
1213
1187
  a(this, "_isPending");
1214
1188
  a(this, "_isFulfilled");
@@ -1222,7 +1196,7 @@ const E = class E {
1222
1196
  this._promise = new Promise(t).then(e, n);
1223
1197
  }
1224
1198
  static FromPromise(t) {
1225
- return new E((e, n) => t.then(e, n));
1199
+ return new T((e, n) => t.then(e, n));
1226
1200
  }
1227
1201
  get isPending() {
1228
1202
  return this._isPending;
@@ -1243,13 +1217,13 @@ const E = class E {
1243
1217
  return this._promise.finally(t);
1244
1218
  }
1245
1219
  };
1246
- let v = E;
1247
- var pe, _e;
1248
- class qe extends (_e = v, pe = Symbol.toStringTag, _e) {
1220
+ let b = T;
1221
+ var pe, xe;
1222
+ class Ne extends (xe = b, pe = Symbol.toStringTag, xe) {
1249
1223
  constructor(e, n) {
1250
1224
  let r, s;
1251
- super((o, u) => {
1252
- r = o, s = u;
1225
+ super((o, l) => {
1226
+ r = o, s = l;
1253
1227
  });
1254
1228
  a(this, "_resolve");
1255
1229
  a(this, "_reject");
@@ -1266,26 +1240,80 @@ class qe extends (_e = v, pe = Symbol.toStringTag, _e) {
1266
1240
  return e.then(this.resolve, this.reject), this;
1267
1241
  }
1268
1242
  }
1269
- var xe, ge;
1270
- class Ue extends (ge = v, xe = Symbol.toStringTag, ge) {
1243
+ var ge;
1244
+ ge = Symbol.toStringTag;
1245
+ class Xe {
1246
+ constructor() {
1247
+ a(this, "_onFulfilled");
1248
+ a(this, ge, "Thenable");
1249
+ this._onFulfilled = (t) => t;
1250
+ }
1251
+ _resolve(t) {
1252
+ return this._onFulfilled(t);
1253
+ }
1254
+ then(t, e) {
1255
+ if (e) {
1256
+ const n = this._onFulfilled;
1257
+ this._onFulfilled = (r) => {
1258
+ try {
1259
+ return r = n(r), t(r);
1260
+ } catch (s) {
1261
+ return e(s);
1262
+ }
1263
+ };
1264
+ } else if (t) {
1265
+ const n = this._onFulfilled;
1266
+ this._onFulfilled = (r) => (r = n(r), t(r));
1267
+ }
1268
+ return this;
1269
+ }
1270
+ catch(t) {
1271
+ if (t) {
1272
+ const e = this._onFulfilled;
1273
+ this._onFulfilled = (n) => {
1274
+ try {
1275
+ return e(n);
1276
+ } catch (r) {
1277
+ return t(r);
1278
+ }
1279
+ };
1280
+ }
1281
+ return this;
1282
+ }
1283
+ finally(t) {
1284
+ if (t) {
1285
+ const e = this._onFulfilled;
1286
+ this._onFulfilled = (n) => {
1287
+ try {
1288
+ return e(n);
1289
+ } finally {
1290
+ t();
1291
+ }
1292
+ };
1293
+ }
1294
+ return this;
1295
+ }
1296
+ }
1297
+ var ve, be;
1298
+ class Ze extends (be = b, ve = Symbol.toStringTag, be) {
1271
1299
  constructor(e, n) {
1272
1300
  super((r, s) => {
1273
1301
  const o = (k) => {
1274
- clearTimeout(M), r(k);
1275
- }, u = (k) => {
1276
- clearTimeout(M), s(k);
1277
- }, M = setTimeout(() => u(new Oe("The operation has timed out.")), n);
1278
- e(o, u);
1302
+ clearTimeout(F), r(k);
1303
+ }, l = (k) => {
1304
+ clearTimeout(F), s(k);
1305
+ }, F = setTimeout(() => l(new qe("The operation has timed out.")), n);
1306
+ e(o, l);
1279
1307
  });
1280
- a(this, xe, "TimedPromise");
1308
+ a(this, ve, "TimedPromise");
1281
1309
  }
1282
1310
  }
1283
- var ve;
1284
- ve = Symbol.toStringTag;
1285
- class je {
1311
+ var ke;
1312
+ ke = Symbol.toStringTag;
1313
+ class y {
1286
1314
  constructor() {
1287
1315
  a(this, "_subscribers");
1288
- a(this, ve, "Publisher");
1316
+ a(this, ke, "Publisher");
1289
1317
  this._subscribers = [];
1290
1318
  }
1291
1319
  subscribe(t) {
@@ -1300,47 +1328,73 @@ class je {
1300
1328
  return this._subscribers.slice().map((e) => e(...t));
1301
1329
  }
1302
1330
  }
1303
- var be, ke;
1304
- class et extends (ke = Pe, be = Symbol.toStringTag, ke) {
1305
- constructor(e = b.Second) {
1306
- super((n) => this._publisher.publish(n), e);
1307
- a(this, "_publisher");
1308
- a(this, be, "Clock");
1309
- this._publisher = new je();
1331
+ var E = /* @__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))(E || {});
1332
+ function Ue(i, t, e = 864e5) {
1333
+ return i = new Date(i), t = new Date(t), Math.floor((t.getTime() - i.getTime()) / e);
1334
+ }
1335
+ function et(i, t, e = 864e5) {
1336
+ return i = new Date(i), t = new Date(t), new u(function* () {
1337
+ const n = t.getTime();
1338
+ let r = i.getTime();
1339
+ for (; r < n; )
1340
+ yield new Date(r), r += e;
1341
+ });
1342
+ }
1343
+ function tt(i, t = 864e5) {
1344
+ return i = new Date(i), new Date(Math.floor(i.getTime() / t) * t);
1345
+ }
1346
+ var Se, Ee;
1347
+ class nt extends (Ee = je, Se = Symbol.toStringTag, Ee) {
1348
+ constructor(e = E.Second) {
1349
+ super((n) => this._ticker.publish(n), e);
1350
+ a(this, "_starter");
1351
+ a(this, "_stopper");
1352
+ a(this, "_ticker");
1353
+ a(this, Se, "Clock");
1354
+ this._starter = new y(), this._stopper = new y(), this._ticker = new y();
1310
1355
  }
1311
1356
  start(e = 0) {
1312
1357
  if (this._isRunning)
1313
1358
  throw new p("The clock has already been started.");
1314
- super.start(e);
1359
+ super.start(e), this._starter.publish();
1315
1360
  }
1316
1361
  stop() {
1317
1362
  if (!this._isRunning)
1318
1363
  throw new p("The clock hadn't yet started.");
1319
- super.stop();
1364
+ super.stop(), this._stopper.publish();
1365
+ }
1366
+ onStart(e) {
1367
+ return this._starter.subscribe(e);
1368
+ }
1369
+ onStop(e) {
1370
+ return this._stopper.subscribe(e);
1320
1371
  }
1321
1372
  onTick(e, n = 0) {
1322
1373
  if (n < 0)
1323
- throw new Fe("The tick step must be a non-negative number.");
1374
+ throw new Ie("The tick step must be a non-negative number.");
1324
1375
  if (n === 0)
1325
- return this._publisher.subscribe(e);
1376
+ return this._ticker.subscribe(e);
1326
1377
  let r = 0;
1327
- return this._publisher.subscribe((s) => {
1378
+ return this._ticker.subscribe((s) => {
1328
1379
  s - r < n || (e(s), r = s);
1329
1380
  });
1330
1381
  }
1331
1382
  }
1332
- var Se, Ee;
1333
- class tt extends (Ee = Pe, Se = Symbol.toStringTag, Ee) {
1334
- constructor(e, n = b.Second) {
1383
+ var Te, Me;
1384
+ class rt extends (Me = je, Te = Symbol.toStringTag, Me) {
1385
+ constructor(e, n = E.Second) {
1335
1386
  super(() => {
1336
1387
  const s = this.remainingTime;
1337
- this._publisher.publish(s), s <= 0 && this.stop();
1388
+ this._ticker.publish(s), s <= 0 && (this._deferrerStop(), this._expirer.publish());
1338
1389
  }, n);
1339
1390
  a(this, "_deferrer");
1340
- a(this, "_publisher");
1391
+ a(this, "_expirer");
1392
+ a(this, "_starter");
1393
+ a(this, "_stopper");
1394
+ a(this, "_ticker");
1341
1395
  a(this, "_duration");
1342
- a(this, Se, "Countdown");
1343
- this._publisher = new je(), this._duration = e;
1396
+ a(this, Te, "Countdown");
1397
+ this._expirer = new y(), this._starter = new y(), this._stopper = new y(), this._ticker = new y(), this._duration = e;
1344
1398
  }
1345
1399
  get duration() {
1346
1400
  return this._duration;
@@ -1348,36 +1402,48 @@ class tt extends (Ee = Pe, Se = Symbol.toStringTag, Ee) {
1348
1402
  get remainingTime() {
1349
1403
  return this._duration - this.elapsedTime;
1350
1404
  }
1405
+ _deferrerStop(e) {
1406
+ if (!this._isRunning)
1407
+ throw new p("The countdown hadn't yet started.");
1408
+ if (!this._deferrer)
1409
+ throw new g();
1410
+ super.stop(), e !== void 0 ? this._deferrer.reject(e) : this._deferrer.resolve(), this._deferrer = void 0;
1411
+ }
1351
1412
  start(e = this.duration) {
1352
1413
  if (this._isRunning)
1353
1414
  throw new p("The countdown has already been started.");
1354
1415
  if (this._deferrer)
1355
- throw new x();
1356
- return this._deferrer = new qe(), super.start(this.duration - e), this._deferrer;
1416
+ throw new g();
1417
+ return this._deferrer = new Ne(), super.start(this.duration - e), this._starter.publish(), this._deferrer;
1357
1418
  }
1358
1419
  stop(e) {
1359
- if (!this._isRunning)
1360
- throw new p("The countdown hadn't yet started.");
1361
- if (!this._deferrer)
1362
- throw new x();
1363
- super.stop(), e !== void 0 ? this._deferrer.reject(e) : this._deferrer.resolve(), this._deferrer = void 0;
1420
+ this._deferrerStop(e), this._stopper.publish(e);
1421
+ }
1422
+ onExpire(e) {
1423
+ return this._expirer.subscribe(e);
1424
+ }
1425
+ onStart(e) {
1426
+ return this._starter.subscribe(e);
1427
+ }
1428
+ onStop(e) {
1429
+ return this._stopper.subscribe(e);
1364
1430
  }
1365
1431
  onTick(e, n = 0) {
1366
1432
  if (n < 0)
1367
- throw new Fe("The tick step must be a non-negative number.");
1433
+ throw new Ie("The tick step must be a non-negative number.");
1368
1434
  if (n === 0)
1369
- return this._publisher.subscribe(e);
1435
+ return this._ticker.subscribe(e);
1370
1436
  let r = 0;
1371
- return this._publisher.subscribe((s) => {
1437
+ return this._ticker.subscribe((s) => {
1372
1438
  r - s < n || (e(s), r = s);
1373
1439
  });
1374
1440
  }
1375
1441
  }
1376
- var Te;
1377
- Te = Symbol.toStringTag;
1378
- const T = class T {
1442
+ var Fe;
1443
+ Fe = Symbol.toStringTag;
1444
+ const M = class M {
1379
1445
  constructor() {
1380
- a(this, Te, "Random");
1446
+ a(this, Fe, "Random");
1381
1447
  }
1382
1448
  static Boolean(t = 0.5) {
1383
1449
  return Math.random() < t;
@@ -1394,30 +1460,30 @@ const T = class T {
1394
1460
  return this.Integer(t.length);
1395
1461
  }
1396
1462
  static Choice(t) {
1397
- return t[T.Index(t)];
1463
+ return t[M.Index(t)];
1398
1464
  }
1399
1465
  };
1400
- let R = T;
1401
- function nt(i) {
1466
+ let R = M;
1467
+ function st(i) {
1402
1468
  return new Promise((t) => setTimeout(t, i));
1403
1469
  }
1404
- function rt() {
1470
+ function it() {
1405
1471
  return new Promise((i) => requestAnimationFrame(() => i()));
1406
1472
  }
1407
- function st(i, t = "text/javascript") {
1473
+ function ot(i, t = "text/javascript") {
1408
1474
  return new Promise((e, n) => {
1409
1475
  const r = document.createElement("script");
1410
1476
  r.async = !0, r.defer = !0, r.src = i, r.type = t, r.onload = () => e(), r.onerror = () => n(), document.body.appendChild(r);
1411
1477
  });
1412
1478
  }
1413
- function it(...i) {
1414
- return new l(function* () {
1479
+ function at(...i) {
1480
+ return new u(function* () {
1415
1481
  for (const t of i)
1416
1482
  for (const e of t)
1417
1483
  yield e;
1418
1484
  });
1419
1485
  }
1420
- function ot(i) {
1486
+ function ut(i) {
1421
1487
  if (Array.isArray(i))
1422
1488
  return i.length;
1423
1489
  let t = 0;
@@ -1425,21 +1491,21 @@ function ot(i) {
1425
1491
  t += 1;
1426
1492
  return t;
1427
1493
  }
1428
- function at(i) {
1429
- return new l(function* () {
1494
+ function lt(i) {
1495
+ return new u(function* () {
1430
1496
  let t = 0;
1431
1497
  for (const e of i)
1432
1498
  yield [t, e], t += 1;
1433
1499
  });
1434
1500
  }
1435
- function ut(i, t, e = 1) {
1436
- return new l(function* () {
1501
+ function ct(i, t, e = 1) {
1502
+ return new u(function* () {
1437
1503
  t === void 0 && (t = i, i = 0), i > t && (e = e ?? -1);
1438
1504
  for (let n = i; n < t; n += e)
1439
1505
  yield n;
1440
1506
  });
1441
1507
  }
1442
- function lt(i) {
1508
+ function ft(i) {
1443
1509
  const t = Array.from(i);
1444
1510
  for (let e = t.length - 1; e > 0; e -= 1) {
1445
1511
  const n = Math.floor(Math.random() * (e + 1));
@@ -1447,15 +1513,15 @@ function lt(i) {
1447
1513
  }
1448
1514
  return t;
1449
1515
  }
1450
- function ct(i) {
1451
- return new l(function* () {
1516
+ function ht(i) {
1517
+ return new u(function* () {
1452
1518
  const t = /* @__PURE__ */ new Set();
1453
1519
  for (const e of i)
1454
1520
  t.has(e) || (t.add(e), yield e);
1455
1521
  });
1456
1522
  }
1457
- function Ne(i, t) {
1458
- return new l(function* () {
1523
+ function $e(i, t) {
1524
+ return new u(function* () {
1459
1525
  const e = i[Symbol.iterator](), n = t[Symbol.iterator]();
1460
1526
  for (; ; ) {
1461
1527
  const r = e.next(), s = n.next();
@@ -1465,17 +1531,17 @@ function Ne(i, t) {
1465
1531
  }
1466
1532
  });
1467
1533
  }
1468
- function ft(i, t) {
1534
+ function dt(i, t) {
1469
1535
  if (t === void 0) {
1470
1536
  let s = 0, o = 0;
1471
- for (const u of i)
1472
- s += u, o += 1;
1537
+ for (const l of i)
1538
+ s += l, o += 1;
1473
1539
  if (o === 0)
1474
1540
  throw new d("You must provide at least one value.");
1475
1541
  return s / o;
1476
1542
  }
1477
1543
  let e = 0, n = 0, r = 0;
1478
- for (const [s, o] of Ne(i, t)) {
1544
+ for (const [s, o] of $e(i, t)) {
1479
1545
  if (o <= 0)
1480
1546
  throw new d(`The weight for the value #${r} must be greater than zero.`);
1481
1547
  e += s * o, n += o, r += 1;
@@ -1486,7 +1552,7 @@ function ft(i, t) {
1486
1552
  throw new d("The sum of weights must be greater than zero.");
1487
1553
  return e / n;
1488
1554
  }
1489
- function ht(i) {
1555
+ function mt(i) {
1490
1556
  let t = 0;
1491
1557
  for (let e = 0; e < i.length; e += 1) {
1492
1558
  const n = i.charCodeAt(e);
@@ -1494,67 +1560,68 @@ function ht(i) {
1494
1560
  }
1495
1561
  return t;
1496
1562
  }
1497
- function dt(i) {
1563
+ function wt(i) {
1498
1564
  let t = 0;
1499
1565
  for (const e of i)
1500
1566
  t += e;
1501
1567
  return t;
1502
1568
  }
1503
- function mt(i) {
1569
+ function _t(i) {
1504
1570
  return `${i.charAt(0).toUpperCase()}${i.slice(1)}`;
1505
1571
  }
1506
- const wt = "2.0.0-rc.4";
1572
+ const yt = "2.0.0-rc.6";
1507
1573
  export {
1508
1574
  S as AggregatedAsyncIterator,
1509
- g as AggregatedIterator,
1510
- et as Clock,
1511
- tt as Countdown,
1512
- qe as DeferredPromise,
1575
+ v as AggregatedIterator,
1576
+ nt as Clock,
1577
+ rt as Countdown,
1578
+ Ne as DeferredPromise,
1513
1579
  c as Exception,
1514
- x as FatalErrorException,
1515
- Re as FileException,
1516
- Ye as FileExistsException,
1517
- ze as FileNotFoundException,
1518
- Pe as GameLoop,
1519
- Ze as JSONStorage,
1520
- Be as KeyException,
1521
- Ge as NetworkException,
1522
- We as NotImplementedException,
1523
- Ke as PermissionException,
1524
- je as Publisher,
1580
+ g as FatalErrorException,
1581
+ Pe as FileException,
1582
+ ze as FileExistsException,
1583
+ Be as FileNotFoundException,
1584
+ je as GameLoop,
1585
+ Qe as JSONStorage,
1586
+ Ge as KeyException,
1587
+ Ke as NetworkException,
1588
+ Ye as NotImplementedException,
1589
+ He as PermissionException,
1590
+ y as Publisher,
1525
1591
  R as Random,
1526
- Fe as RangeException,
1592
+ Ie as RangeException,
1527
1593
  f as ReducedIterator,
1528
1594
  Ce as ReferenceException,
1529
1595
  p as RuntimeException,
1530
1596
  h as SmartAsyncIterator,
1531
- l as SmartIterator,
1532
- v as SmartPromise,
1533
- b as TimeUnit,
1534
- Ue as TimedPromise,
1535
- Oe as TimeoutException,
1536
- He as TypeException,
1537
- wt as VERSION,
1597
+ u as SmartIterator,
1598
+ b as SmartPromise,
1599
+ Xe as Thenable,
1600
+ E as TimeUnit,
1601
+ Ze as TimedPromise,
1602
+ qe as TimeoutException,
1603
+ Le as TypeException,
1604
+ yt as VERSION,
1538
1605
  d as ValueException,
1539
- ft as average,
1540
- mt as capitalize,
1541
- it as chain,
1542
- ot as count,
1543
- Le as dateDifference,
1544
- Qe as dateRange,
1545
- Xe as dateRound,
1546
- nt as delay,
1547
- at as enumerate,
1548
- ht as hash,
1549
- Me as isBrowser,
1550
- Je as isNode,
1551
- Ve as isWebWorker,
1552
- st as loadScript,
1553
- rt as nextAnimationFrame,
1554
- ut as range,
1555
- lt as shuffle,
1556
- dt as sum,
1557
- ct as unique,
1558
- Ne as zip
1606
+ dt as average,
1607
+ _t as capitalize,
1608
+ at as chain,
1609
+ ut as count,
1610
+ Ue as dateDifference,
1611
+ et as dateRange,
1612
+ tt as dateRound,
1613
+ st as delay,
1614
+ lt as enumerate,
1615
+ mt as hash,
1616
+ Re as isBrowser,
1617
+ Ve as isNode,
1618
+ We as isWebWorker,
1619
+ ot as loadScript,
1620
+ it as nextAnimationFrame,
1621
+ ct as range,
1622
+ ft as shuffle,
1623
+ wt as sum,
1624
+ ht as unique,
1625
+ $e as zip
1559
1626
  };
1560
1627
  //# sourceMappingURL=core.js.map