@tktb-tess/util-fns 0.10.0 → 0.11.0

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/bundle.js CHANGED
@@ -1,216 +1,248 @@
1
- const L = new TextEncoder(), X = (n, t) => [n].includes(t), g = (n, t) => {
2
- if (typeof n != typeof t) return !1;
3
- const e = Object.prototype.toString.call(n), r = Object.prototype.toString.call(t);
4
- if (e !== r) return !1;
5
- if (typeof n == "string" || typeof n == "bigint" || typeof n == "boolean" || typeof n == "symbol" || n == null)
6
- return n === t;
7
- if (typeof n == "number")
8
- return n !== n && t !== t || n === t;
9
- if (typeof n == "function")
1
+ const M = new TextEncoder(), X = (e, t) => [e].includes(t), d = (e, t) => {
2
+ if (typeof e != typeof t) return !1;
3
+ const n = Object.prototype.toString.call(e), r = Object.prototype.toString.call(t);
4
+ if (n !== r) return !1;
5
+ if (typeof e == "string" || typeof e == "bigint" || typeof e == "boolean" || typeof e == "symbol" || e == null)
6
+ return e === t;
7
+ if (typeof e == "number")
8
+ return e !== e && t !== t || e === t;
9
+ if (typeof e == "function")
10
10
  return !1;
11
- if (Array.isArray(n) && Array.isArray(t)) {
12
- if (n.length !== t.length) return !1;
13
- for (let o = 0; o < n.length; o++)
14
- if (!g(n[o], t[o])) return !1;
11
+ if (Array.isArray(e) && Array.isArray(t)) {
12
+ if (e.length !== t.length) return !1;
13
+ for (let s = 0; s < e.length; s++)
14
+ if (!d(e[s], t[s])) return !1;
15
15
  return !0;
16
16
  }
17
- if (n instanceof Set && t instanceof Set) {
18
- const o = [...n.values()], s = [...t.values()];
19
- return !!g(o, s);
17
+ if (e instanceof Set && t instanceof Set) {
18
+ const s = [...e.values()], o = [...t.values()];
19
+ return !!d(s, o);
20
20
  }
21
- if (n instanceof Map && t instanceof Map) {
22
- const o = [...n.keys()], s = [...t.keys()];
23
- if (!g(o, s)) return !1;
24
- const i = [...n.values()], c = [...t.values()];
25
- return !!g(i, c);
21
+ if (e instanceof Map && t instanceof Map) {
22
+ const s = [...e.keys()], o = [...t.keys()];
23
+ if (!d(s, o)) return !1;
24
+ const i = [...e.values()], c = [...t.values()];
25
+ return !!d(i, c);
26
26
  }
27
- if (e === "[object Object]") {
28
- const o = n, s = t, i = Object.keys(o), c = Object.keys(s);
29
- for (const f of i) {
30
- const l = c.find((d) => d === f);
27
+ if (n === "[object Object]") {
28
+ const s = e, o = t, i = Object.keys(s), c = Object.keys(o);
29
+ for (const a of i) {
30
+ const l = c.find((y) => y === a);
31
31
  if (l === void 0) return !1;
32
- const [u, h] = [o[f], s[l]];
33
- if (!g(u, h)) return !1;
32
+ const [f, h] = [s[a], o[l]];
33
+ if (!d(f, h)) return !1;
34
34
  }
35
35
  return !0;
36
36
  }
37
- throw Error(`comparing these objects is unavailable: ${n}, ${t}`, {
38
- cause: [n, t]
37
+ throw Error(`comparing these objects is unavailable: ${e}, ${t}`, {
38
+ cause: [e, t]
39
39
  });
40
40
  }, H = () => {
41
- let n, t;
41
+ let e, t;
42
42
  return {
43
- promise: new Promise((r, o) => {
44
- n = r, t = o;
43
+ promise: new Promise((r, s) => {
44
+ e = r, t = s;
45
45
  }),
46
- resolve: n,
46
+ resolve: e,
47
47
  reject: t
48
48
  };
49
- }, J = (n) => new Promise((t) => {
50
- setTimeout(() => t(), n);
51
- }), W = (n) => Object.prototype.toString.call(n).match(/^\[Object\s(.+)\]$/)?.at(1), Y = (n) => (...t) => () => n(...t), Z = (n) => {
49
+ }, J = (e) => new Promise((t) => {
50
+ setTimeout(() => t(), e);
51
+ }), Y = (e) => Object.prototype.toString.call(e).match(/^\[Object\s(.+)\]$/)?.at(1), Z = (e) => (...t) => () => e(...t), Q = (e) => {
52
52
  const t = [];
53
- let e = [], r = "", o = !1;
54
- for (let s = 0; s < n.length; s++) {
55
- const i = n[s];
56
- i === '"' && (s === 0 || n[s - 1] !== "\\") ? o = !o : i === "," && !o ? (e.push(r.trim()), r = "") : i === `
57
- ` && !o ? (e.push(r.trim()), t.push(e), e = [], r = "") : r += i;
58
- }
59
- return e.push(r.trim()), t.push(e), t;
60
- }, Q = async (n, t) => {
61
- const e = L.encode(n), r = await crypto.subtle.digest(t, e);
53
+ let n = [], r = "", s = !1;
54
+ for (let o = 0; o < e.length; o++) {
55
+ const i = e[o];
56
+ i === '"' && (o === 0 || e[o - 1] !== "\\") ? s = !s : i === "," && !s ? (n.push(r.trim()), r = "") : i === `
57
+ ` && !s ? (n.push(r.trim()), t.push(n), n = [], r = "") : r += i;
58
+ }
59
+ return n.push(r.trim()), t.push(n), t;
60
+ }, tt = async (e, t) => {
61
+ const n = M.encode(e), r = await crypto.subtle.digest(t, n);
62
62
  return new Uint8Array(r);
63
- }, tt = () => !!globalThis.process && typeof process.version < "u" && typeof process.versions.node < "u", nt = (n) => encodeURIComponent(n).replace(
63
+ }, et = () => !!globalThis.process && typeof process.version < "u" && typeof process.versions.node < "u", nt = (e) => encodeURIComponent(e).replace(
64
64
  /[!'()*]/g,
65
- (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`
66
- ), et = (n) => {
67
- if (n.includes("+"))
65
+ (n) => `%${n.charCodeAt(0).toString(16).toUpperCase()}`
66
+ ), rt = (e) => {
67
+ if (e.includes("+"))
68
68
  throw Error("An input string has '+'");
69
- return decodeURIComponent(n);
70
- }, rt = async (n, t) => {
71
- const r = new Blob([n]).stream().pipeThrough(new CompressionStream(t));
69
+ return decodeURIComponent(e);
70
+ }, st = async (e, t) => {
71
+ const r = new Blob([e]).stream().pipeThrough(new CompressionStream(t));
72
72
  return new Response(r).bytes();
73
- }, st = async (n, t) => {
74
- const r = new Blob([n]).stream().pipeThrough(new DecompressionStream(t));
73
+ }, ot = async (e, t) => {
74
+ const r = new Blob([e]).stream().pipeThrough(new DecompressionStream(t));
75
75
  return new Response(r).bytes();
76
- }, ot = (n, t) => Math.floor(Math.random() * (t - n) + n), m = (n, t) => {
76
+ }, it = (e, t) => new Promise((n, r) => {
77
+ setTimeout(async () => {
78
+ try {
79
+ const s = await e();
80
+ n(s);
81
+ } catch (s) {
82
+ r(s);
83
+ }
84
+ }, t);
85
+ });
86
+ class m extends Error {
87
+ constructor(t, n, r) {
88
+ super(n, r), this.errName = t;
89
+ }
90
+ static name = "NamedError";
91
+ toJSON() {
92
+ const t = (() => {
93
+ const o = this.cause;
94
+ return typeof o == "string" || typeof o == "number" || typeof o == "boolean" ? o : typeof o == "bigint" ? o.toString() : typeof o == "object" && o !== null ? o instanceof Set || o instanceof Map ? Object.fromEntries(o) : o : void 0;
95
+ })(), { errName: n, message: r, stack: s } = this;
96
+ return {
97
+ errName: n,
98
+ message: r,
99
+ stack: s,
100
+ cause: t
101
+ };
102
+ }
103
+ }
104
+ Object.defineProperty(m.prototype, Symbol.toStringTag, {
105
+ value: m.name
106
+ });
107
+ const ct = (e, t) => Math.floor(Math.random() * (t - e) + e), g = (e, t) => {
77
108
  t < 0n && (t *= -1n);
78
- const e = n % t;
79
- return e < 0n ? e + t : e;
80
- }, A = (n, t = !1) => {
81
- if (!Number.isFinite(n)) throw Error("`length` is not a valid number");
82
- if (n <= 0) throw Error("`length` must be positive");
83
- const e = Math.ceil(n / 8), r = crypto.getRandomValues(new Uint8Array(e));
84
- let o = Array.from(r, (s) => s.toString(2).padStart(8, "0")).join("").slice(0, n);
85
- return t && (o = o.replace(/^\d/, "1")), BigInt("0b" + o);
86
- }, v = (n, t) => {
87
- if (n >= t) throw Error("rangeError");
88
- const e = t - n, r = e.toString(2).length, o = (() => {
109
+ const n = e % t;
110
+ return n < 0n ? n + t : n;
111
+ }, N = (e, t = !1) => {
112
+ if (!Number.isFinite(e)) throw Error("`length` is not a valid number");
113
+ if (e <= 0) throw Error("`length` must be positive");
114
+ const n = Math.ceil(e / 8), r = crypto.getRandomValues(new Uint8Array(n));
115
+ let s = Array.from(r, (o) => o.toString(2).padStart(8, "0")).join("").slice(0, e);
116
+ return t && (s = s.replace(/^\d/, "1")), BigInt("0b" + s);
117
+ }, A = (e, t) => {
118
+ if (e >= t)
119
+ throw new m("RangeError", "min is larger than max");
120
+ const n = t - e, r = n.toString(2).length, s = (() => {
89
121
  for (let i = 0; i < 1e5; i++) {
90
- const c = A(r);
91
- if (c >= p(2n, BigInt(r), e))
92
- return c % e;
122
+ const c = N(r);
123
+ if (c >= p(2n, BigInt(r), n))
124
+ return c % n;
93
125
  }
94
126
  throw Error("Failed to generate a random bigint");
95
127
  })();
96
- return n + o;
97
- }, p = (n, t, e) => {
98
- if (e < 1n) throw Error("`mod` must be positive");
128
+ return e + s;
129
+ }, p = (e, t, n) => {
130
+ if (n < 1n) throw Error("`mod` must be positive");
99
131
  if (t < 0n) throw Error("`power` must not be negative");
100
- if (n = m(n, e), e === 1n) return 0n;
101
- if (n % e === 1n || n % e === 0n) return n;
102
- if (n === e - 1n) return t & 1n ? e - 1n : 1n;
132
+ if (e = g(e, n), n === 1n) return 0n;
133
+ if (e % n === 1n || e % n === 0n) return e;
134
+ if (e === n - 1n) return t & 1n ? n - 1n : 1n;
103
135
  let r = 1n;
104
136
  for (; t > 0n; )
105
- t & 1n && (r = r * n % e), n = n * n % e, t >>= 1n;
137
+ t & 1n && (r = r * e % n), e = e * e % n, t >>= 1n;
106
138
  return r;
107
- }, _ = (n, t) => {
108
- if (n === 0n && t === 0n) return { x: 0n, y: 0n, gcd: 0n };
109
- if (n === 0n)
139
+ }, T = (e, t) => {
140
+ if (e === 0n && t === 0n) return { x: 0n, y: 0n, gcd: 0n };
141
+ if (e === 0n)
110
142
  return t > 0n ? { x: 0n, y: -1n, gcd: t } : { x: 0n, y: 1n, gcd: -t };
111
143
  if (t === 0n)
112
- return n > 0n ? { x: 1n, y: 0n, gcd: n } : { x: -1n, y: 0n, gcd: -n };
113
- let [e, r, o] = [1n, 0n, n], [s, i, c] = [0n, -1n, t];
144
+ return e > 0n ? { x: 1n, y: 0n, gcd: e } : { x: -1n, y: 0n, gcd: -e };
145
+ let [n, r, s] = [1n, 0n, e], [o, i, c] = [0n, -1n, t];
114
146
  for (; ; ) {
115
- const f = o / c, l = o - f * c;
147
+ const a = s / c, l = s - a * c;
116
148
  if (l === 0n) break;
117
- [e, s] = [s, e - f * s], [r, i] = [i, r - f * i], [o, c] = [c, l];
118
- }
119
- return c < 0n && (s *= -1n, i *= -1n, c *= -1n), { x: s, y: i, gcd: c };
120
- }, w = (n, t) => {
121
- if (n >= t) return 1n;
122
- const e = BigInt((t - 2n).toString(2).length), r = (t - n) / 2n;
123
- if (e * r < 63n) {
124
- let c = n;
125
- for (let f = n + 2n; f < t; f += 2n)
126
- c *= f;
149
+ [n, o] = [o, n - a * o], [r, i] = [i, r - a * i], [s, c] = [c, l];
150
+ }
151
+ return c < 0n && (o *= -1n, i *= -1n, c *= -1n), { x: o, y: i, gcd: c };
152
+ }, w = (e, t) => {
153
+ if (e >= t) return 1n;
154
+ const n = BigInt((t - 2n).toString(2).length), r = (t - e) / 2n;
155
+ if (n * r < 63n) {
156
+ let c = e;
157
+ for (let a = e + 2n; a < t; a += 2n)
158
+ c *= a;
127
159
  return c;
128
160
  }
129
- const o = n + r | 1n, s = w(n, o), i = w(o, t);
130
- return s * i;
131
- }, j = (n) => {
132
- let t = 3n, e = 1n, r = 1n;
133
- const o = BigInt(n.toString(2).length) - 1n;
134
- for (let s = o - 1n; s > -1n; --s) {
135
- const i = (n >> s) + 1n | 1n;
136
- r *= w(t, i), t = i, e *= r;
137
- }
138
- return e;
139
- }, it = (n) => {
140
- if (n < 0n) throw Error("'n' must be non-negative");
141
- if (n === 0n) return 1n;
142
- const t = n - BigInt(n.toString(2).match(/1/g)?.length ?? 0);
143
- return j(n) << t;
144
- }, P = (n, t) => (n >>> (t & 31) | n << (-t & 31)) >>> 0, b = (n, t) => BigInt.asUintN(64, n >> (t & 63n) | n << (-t & 63n)), B = (n, t) => {
161
+ const s = e + r | 1n, o = w(e, s), i = w(s, t);
162
+ return o * i;
163
+ }, P = (e) => {
164
+ let t = 3n, n = 1n, r = 1n;
165
+ const s = BigInt(e.toString(2).length) - 1n;
166
+ for (let o = s - 1n; o > -1n; --o) {
167
+ const i = (e >> o) + 1n | 1n;
168
+ r *= w(t, i), t = i, n *= r;
169
+ }
170
+ return n;
171
+ }, at = (e) => {
172
+ if (e < 0n) throw Error("'n' must be non-negative");
173
+ if (e === 0n) return 1n;
174
+ const t = e - BigInt(e.toString(2).match(/1/g)?.length ?? 0);
175
+ return P(e) << t;
176
+ }, j = (e, t) => (e >>> (t & 31) | e << (-t & 31)) >>> 0, b = (e, t) => BigInt.asUintN(64, e >> (t & 63n) | e << (-t & 63n)), E = (e, t) => {
145
177
  if (t < 1n || t % 2n === 0n)
146
178
  throw Error("`n` is invalid");
147
- for (; n < 0n; )
148
- n += t;
149
- n %= t;
150
- let e = 1n;
151
- for (; n !== 0n; ) {
152
- for (; n % 2n === 0n; ) {
153
- n /= 2n;
179
+ for (; e < 0n; )
180
+ e += t;
181
+ e %= t;
182
+ let n = 1n;
183
+ for (; e !== 0n; ) {
184
+ for (; e % 2n === 0n; ) {
185
+ e /= 2n;
154
186
  const r = t % 8n;
155
- (r === 3n || r === 5n) && (e *= -1n);
187
+ (r === 3n || r === 5n) && (n *= -1n);
156
188
  }
157
- [n, t] = [t, n], n % 4n === 3n && t % 4n === 3n && (e *= -1n), n %= t;
158
- }
159
- return t === 1n ? e : 0n;
160
- }, O = (n) => {
161
- if (n < 0n) return !1;
162
- if (n === 0n) return !0;
163
- let t = 1n, e = n;
164
- for (; t + 1n < e; ) {
165
- const r = (t + e) / 2n;
166
- r ** 2n < n ? t = r : e = r;
167
- }
168
- return n === t ** 2n || n === (t + 1n) ** 2n;
169
- }, C = (n) => {
170
- if (n <= 1n) return !1;
171
- if (n % 2n === 0n) return n === 2n;
172
- let t = n - 1n, e = 0n;
189
+ [e, t] = [t, e], e % 4n === 3n && t % 4n === 3n && (n *= -1n), e %= t;
190
+ }
191
+ return t === 1n ? n : 0n;
192
+ }, _ = (e) => {
193
+ if (e < 0n) return !1;
194
+ if (e === 0n) return !0;
195
+ let t = 1n, n = e;
196
+ for (; t + 1n < n; ) {
197
+ const r = (t + n) / 2n;
198
+ r * r < e ? t = r : n = r;
199
+ }
200
+ return e === t ** 2n || e === (t + 1n) ** 2n;
201
+ }, C = (e) => {
202
+ if (e <= 1n) return !1;
203
+ if (e % 2n === 0n) return e === 2n;
204
+ let t = e - 1n, n = 0n;
173
205
  for (; t % 2n === 0n; )
174
- t >>= 1n, e += 1n;
175
- const [r, o] = [t, e];
176
- let i = p(2n, r, n);
206
+ t >>= 1n, n += 1n;
207
+ const [r, s] = [t, n];
208
+ let i = p(2n, r, e);
177
209
  if (i === 1n) return !0;
178
- for (let c = 0n; c < o; c++) {
179
- if (i === n - 1n) return !0;
180
- i = i * i % n;
210
+ for (let c = 0n; c < s; c++) {
211
+ if (i === e - 1n) return !0;
212
+ i = i * i % e;
181
213
  }
182
214
  return !1;
183
- }, F = (n) => {
184
- let t = 5n, e = B(t, n);
185
- for (; e > 0n; ) {
186
- if (t = t > 0n ? t + 2n : t - 2n, t *= -1n, t === -15n && O(n))
215
+ }, O = (e) => {
216
+ let t = 5n, n = E(t, e);
217
+ for (; n > 0n; ) {
218
+ if (t = t > 0n ? t + 2n : t - 2n, t *= -1n, t === -15n && _(e))
187
219
  return [0n, 0n];
188
- e = B(t, n);
220
+ n = E(t, e);
189
221
  }
190
- return [t, e];
191
- }, I = (n, t) => (n & 1n) === 1n ? m(n + t >> 1n, t) : m(n >> 1n, t), V = (n, t, e, r) => {
192
- let o = 1n, s = e;
193
- const i = n.toString(2).slice(1);
222
+ return [t, n];
223
+ }, I = (e, t) => (e & 1n) === 1n ? g(e + t >> 1n, t) : g(e >> 1n, t), F = (e, t, n, r) => {
224
+ let s = 1n, o = n;
225
+ const i = e.toString(2).slice(1);
194
226
  for (const c of i)
195
- [o, s] = [m(o * s, t), I(s * s + r * o * o, t)], c === "1" && ([o, s] = [I(e * o + s, t), I(r * o + e * s, t)]);
196
- return [o, s];
197
- }, k = (n, t, e, r) => {
198
- if (n % 2n !== 1n) throw Error("`n` must be odd");
199
- let o = n + 1n, s = 0n;
200
- for (; o % 2n === 0n; )
201
- o >>= 1n, s += 1n;
202
- const [i, c] = V(o, n, e, t);
203
- let f = c;
227
+ [s, o] = [g(s * o, t), I(o * o + r * s * s, t)], c === "1" && ([s, o] = [I(n * s + o, t), I(r * s + n * o, t)]);
228
+ return [s, o];
229
+ }, V = (e, t, n, r) => {
230
+ if (e % 2n !== 1n) throw Error("`n` must be odd");
231
+ let s = e + 1n, o = 0n;
232
+ for (; s % 2n === 0n; )
233
+ s >>= 1n, o += 1n;
234
+ const [i, c] = F(s, e, n, t);
235
+ let a = c;
204
236
  if (i === 0n) return !0;
205
- r = p(r, o, n);
206
- for (let l = 0n; l < s; l++) {
207
- if (f === 0n) return !0;
208
- f = m(f * f - 2n * r, n), r = p(r, 2n, n);
237
+ r = p(r, s, e);
238
+ for (let l = 0n; l < o; l++) {
239
+ if (a === 0n) return !0;
240
+ a = g(a * a - 2n * r, e), r = p(r, 2n, e);
209
241
  }
210
242
  return !1;
211
- }, T = (n) => {
212
- if (n <= 1n) return !1;
213
- if (n % 2n === 0n) return n === 2n;
243
+ }, R = (e) => {
244
+ if (e <= 1n) return !1;
245
+ if (e % 2n === 0n) return e === 2n;
214
246
  const t = [
215
247
  2n,
216
248
  3n,
@@ -239,89 +271,89 @@ const L = new TextEncoder(), X = (n, t) => [n].includes(t), g = (n, t) => {
239
271
  97n,
240
272
  101n
241
273
  ];
242
- for (const s of t)
243
- if (n % s === 0n)
244
- return n === s;
245
- if (!C(n))
274
+ for (const o of t)
275
+ if (e % o === 0n)
276
+ return e === o;
277
+ if (!C(e))
246
278
  return !1;
247
- const [e, r] = F(n);
279
+ const [n, r] = O(e);
248
280
  if (r === 0n) return !1;
249
- const o = (1n - e) / 4n;
250
- return k(n, e, 1n, o);
251
- }, ct = (n, t) => {
281
+ const s = (1n - n) / 4n;
282
+ return V(e, n, 1n, s);
283
+ }, lt = (e, t) => {
252
284
  if (t < 2n)
253
285
  throw Error("noPrimesFound");
254
286
  for (let r = 0; r < 1e5; r++) {
255
- const o = v(n, t);
256
- if (T(o)) return o;
287
+ const s = A(e, t);
288
+ if (R(s)) return s;
257
289
  }
258
290
  throw Error("noPrimesFound");
259
- }, ft = (n, t = !1) => {
260
- if (n < 2)
291
+ }, ut = (e, t = !1) => {
292
+ if (e < 2)
261
293
  throw Error("noPrimesFound");
262
294
  for (let r = 0; r < 1e5; r++) {
263
- const o = A(n, t);
264
- if (T(o)) return o;
295
+ const s = N(e, t);
296
+ if (R(s)) return s;
265
297
  }
266
298
  throw Error("noPrimesFound");
267
299
  };
268
- class a {
300
+ class u {
269
301
  #t;
270
- #n;
302
+ #e;
271
303
  static name = "Rational";
272
304
  /**
273
305
  * fraction (rational) class
274
306
  * @param numerator
275
307
  * @param denominator
276
308
  */
277
- constructor(t, e) {
278
- e === 0n ? (this.#n = 0n, this.#t = t === 0n ? 0n : t > 0n ? 1n : -1n) : e > 0n ? (this.#t = t, this.#n = e) : (this.#t = -t, this.#n = -e), this.#e();
309
+ constructor(t, n) {
310
+ n === 0n ? (this.#e = 0n, this.#t = t === 0n ? 0n : t > 0n ? 1n : -1n) : n > 0n ? (this.#t = t, this.#e = n) : (this.#t = -t, this.#e = -n), this.#n();
279
311
  }
280
312
  /**
281
313
  * generates fraction from `number` decimal using continued fraction
282
314
  * @param value decimal
283
315
  * @param denominatorDigits limit of digits of denominator
284
316
  */
285
- static fromDecimal(t, e = 5) {
317
+ static fromDecimal(t, n = 5) {
286
318
  if (Number.isNaN(t))
287
- return new a(0n, 0n);
319
+ return new u(0n, 0n);
288
320
  if (Math.abs(t) === 1 / 0)
289
- return new a(t > 0 ? 1n : -1n, 0n);
321
+ return new u(t > 0 ? 1n : -1n, 0n);
290
322
  const r = t < 0;
291
323
  r && (t *= -1);
292
- const o = BigInt(Math.floor(t)), s = t - Number(o);
293
- if (s === 0)
294
- return new a(r ? -o : o, 1n);
295
- t = 1 / s;
296
- let [i, c] = [1n, o], [f, l] = [0n, 1n];
297
- for (; `${l}`.length < e + 1; ) {
298
- const u = BigInt(Math.floor(t)), h = t - Number(u);
299
- if ([i, c] = [c, u * c + i], [f, l] = [l, u * l + f], h === 0)
300
- return new a(r ? -c : c, l);
324
+ const s = BigInt(Math.floor(t)), o = t - Number(s);
325
+ if (o === 0)
326
+ return new u(r ? -s : s, 1n);
327
+ t = 1 / o;
328
+ let [i, c] = [1n, s], [a, l] = [0n, 1n];
329
+ for (; `${l}`.length < n + 1; ) {
330
+ const f = BigInt(Math.floor(t)), h = t - Number(f);
331
+ if ([i, c] = [c, f * c + i], [a, l] = [l, f * l + a], h === 0)
332
+ return new u(r ? -c : c, l);
301
333
  t = 1 / h;
302
334
  }
303
- return new a(r ? -i : i, f);
335
+ return new u(r ? -i : i, a);
304
336
  }
305
337
  /**
306
338
  * reduction
307
339
  */
308
- #e() {
309
- const { gcd: t } = _(this.#t, this.#n);
310
- t !== 0n && (this.#t /= t, this.#n /= t);
340
+ #n() {
341
+ const { gcd: t } = T(this.#t, this.#e);
342
+ t !== 0n && (this.#t /= t, this.#e /= t);
311
343
  }
312
344
  /**
313
345
  * returns a fraction multiplied by -1
314
346
  * @returns
315
347
  */
316
348
  minus() {
317
- return new a(-this.#t, this.#n);
349
+ return new u(-this.#t, this.#e);
318
350
  }
319
351
  /**
320
352
  * returns inverse of this fraction
321
353
  * @returns
322
354
  */
323
355
  inverse() {
324
- return new a(this.#n, this.#t);
356
+ return new u(this.#e, this.#t);
325
357
  }
326
358
  /**
327
359
  * returns `this + right`
@@ -329,8 +361,8 @@ class a {
329
361
  * @returns
330
362
  */
331
363
  add(t) {
332
- const e = this.#n * t.#n, r = this.#t * t.#n + t.#t * this.#n;
333
- return new a(r, e);
364
+ const n = this.#e * t.#e, r = this.#t * t.#e + t.#t * this.#e;
365
+ return new u(r, n);
334
366
  }
335
367
  /**
336
368
  * returns `this - right`
@@ -346,8 +378,8 @@ class a {
346
378
  * @returns
347
379
  */
348
380
  multiply(t) {
349
- const e = this.#n * t.#n, r = this.#t * t.#t;
350
- return new a(r, e);
381
+ const n = this.#e * t.#e, r = this.#t * t.#t;
382
+ return new u(r, n);
351
383
  }
352
384
  /**
353
385
  * returns `this / right`
@@ -364,22 +396,22 @@ class a {
364
396
  * @returns `(a+c)/(b+d)`
365
397
  */
366
398
  mediant(t) {
367
- const e = this.#n + t.#n, r = this.#t + t.#t;
368
- return new a(r, e);
399
+ const n = this.#e + t.#e, r = this.#t + t.#t;
400
+ return new u(r, n);
369
401
  }
370
402
  /**
371
403
  * returns `number` type decimal
372
404
  * @returns decimal
373
405
  */
374
406
  toDecimal() {
375
- return Number(this.#t) / Number(this.#n);
407
+ return Number(this.#t) / Number(this.#e);
376
408
  }
377
409
  /**
378
410
  * returns `'numerator/denominator'`
379
411
  * @returns string form
380
412
  */
381
413
  toString() {
382
- return this.#t === 0n && this.#n === 0n ? "NaN" : this.#t === 0n ? "0" : this.#n === 0n ? this.#t < 0n ? "-Infinity" : "Infinity" : this.#n === 1n ? `${this.#t}` : `${this.#t}/${this.#n}`;
414
+ return this.#t === 0n && this.#e === 0n ? "NaN" : this.#t === 0n ? "0" : this.#e === 0n ? this.#t < 0n ? "-Infinity" : "Infinity" : this.#e === 1n ? `${this.#t}` : `${this.#t}/${this.#e}`;
383
415
  }
384
416
  valueOf() {
385
417
  return this.toDecimal();
@@ -387,7 +419,7 @@ class a {
387
419
  toJSON() {
388
420
  return {
389
421
  type: "Rational",
390
- value: ["0x" + this.#t.toString(16), "0x" + this.#n.toString(16)]
422
+ value: ["0x" + this.#t.toString(16), "0x" + this.#e.toString(16)]
391
423
  };
392
424
  }
393
425
  /**
@@ -396,8 +428,8 @@ class a {
396
428
  * @returns
397
429
  */
398
430
  static fromData(t) {
399
- const e = BigInt(t.value[0]), r = BigInt(t.value[1]);
400
- return new a(e, r);
431
+ const n = BigInt(t.value[0]), r = BigInt(t.value[1]);
432
+ return new u(n, r);
401
433
  }
402
434
  /**
403
435
  * pases string whose form is `'numerator/denominator'`
@@ -408,236 +440,209 @@ class a {
408
440
  const r = /^\s*(\d+)\s*\/\s*(\d+)\s*$/.exec(t);
409
441
  if (!r)
410
442
  throw Error("cannot parse");
411
- const o = r.at(1), s = r.at(2);
412
- if (!o || !s)
443
+ const s = r.at(1), o = r.at(2);
444
+ if (!s || !o)
413
445
  throw Error("cannot parse");
414
- return new a(BigInt(o), BigInt(s));
446
+ return new u(BigInt(s), BigInt(o));
415
447
  }
416
448
  }
417
- Object.defineProperty(a.prototype, Symbol.toStringTag, {
418
- value: a.name
449
+ Object.defineProperty(u.prototype, Symbol.toStringTag, {
450
+ value: u.name
419
451
  });
420
- const $ = (n) => {
421
- const t = Array.from(n, (e) => String.fromCharCode(e));
452
+ const $ = (e) => {
453
+ const t = Array.from(e, (n) => String.fromCharCode(n));
422
454
  return btoa(t.join(""));
423
- }, D = (n) => {
424
- const t = atob(n);
425
- return Uint8Array.from(t, (e) => e.charCodeAt(0));
426
- }, lt = (n) => $(n).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, ""), at = (n) => {
427
- const t = n.length & 3;
428
- t > 0 && (n = n + "=".repeat(4 - t));
429
- const e = n.replaceAll("-", "+").replaceAll("_", "/");
430
- return D(e);
431
- }, ut = (n) => {
432
- let t = Array.from(n, (s) => s.toString(16).padStart(2, "0")).join("");
433
- const e = t.length % 6;
434
- e && (t = "0".repeat(6 - e) + t);
455
+ }, D = (e) => {
456
+ const t = atob(e);
457
+ return Uint8Array.from(t, (n) => n.charCodeAt(0));
458
+ }, ft = (e) => $(e).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, ""), ht = (e) => {
459
+ const t = e.length & 3;
460
+ t > 0 && (e = e + "=".repeat(4 - t));
461
+ const n = e.replaceAll("-", "+").replaceAll("_", "/");
462
+ return D(n);
463
+ }, dt = (e) => {
464
+ let t = Array.from(e, (o) => o.toString(16).padStart(2, "0")).join("");
465
+ const n = t.length % 6;
466
+ n && (t = "0".repeat(6 - n) + t);
435
467
  const r = t.matchAll(/.{6}/g);
436
468
  return Array.from(
437
469
  r,
438
- (s) => Number.parseInt(s[0], 16).toString(8).padStart(8, "0")
470
+ (o) => Number.parseInt(o[0], 16).toString(8).padStart(8, "0")
439
471
  ).join("").replace(/^0+/, "");
440
- }, ht = (n) => {
441
- const t = n.length & 7;
442
- t && (n = "0".repeat(8 - t) + n);
443
- const e = n.matchAll(/.{8}/g), o = Array.from(e, (s) => {
444
- const i = s[0];
472
+ }, gt = (e) => {
473
+ const t = e.length & 7;
474
+ t && (e = "0".repeat(8 - t) + e);
475
+ const n = e.matchAll(/.{8}/g), s = Array.from(n, (o) => {
476
+ const i = o[0];
445
477
  return Number.parseInt(i, 8).toString(16).padStart(6, "0");
446
478
  }).join("").matchAll(/.{2}/g);
447
- return Uint8Array.from(o, (s) => Number.parseInt(s[0], 16));
448
- }, K = (n) => {
449
- const t = n < 0n;
450
- t && (n *= -1n);
451
- const e = n.toString(2).length, r = n === 1n << BigInt(e - 1) && !(e % 7) && t, o = Math.floor(e / 7) + 1;
452
- return r ? o - 1 : o;
453
- }, dt = (n) => {
454
- const t = K(n);
455
- n = BigInt.asUintN(t * 7, n);
456
- const e = new Uint8Array(t);
457
- for (let o = 0; o < t - 1; ++o) {
458
- const s = Number(n & 127n) | 128;
459
- e[o] = s, n >>= 7n;
460
- }
461
- const r = Number(n & 127n);
462
- return e[t - 1] = r, n >>= 7n, e;
463
- }, gt = (n) => {
464
- const t = n.length;
465
- let e = 0n;
479
+ return Uint8Array.from(s, (o) => Number.parseInt(o[0], 16));
480
+ }, k = (e) => {
481
+ const t = e < 0n;
482
+ t && (e *= -1n);
483
+ const n = e.toString(2).length, r = e === 1n << BigInt(n - 1) && !(n % 7) && t, s = Math.floor(n / 7) + 1;
484
+ return r ? s - 1 : s;
485
+ }, mt = (e) => {
486
+ const t = k(e);
487
+ e = BigInt.asUintN(t * 7, e);
488
+ const n = new Uint8Array(t);
489
+ for (let s = 0; s < t - 1; ++s) {
490
+ const o = Number(e & 127n) | 128;
491
+ n[s] = o, e >>= 7n;
492
+ }
493
+ const r = Number(e & 127n);
494
+ return n[t - 1] = r, e >>= 7n, n;
495
+ }, pt = (e) => {
496
+ const t = e.length;
497
+ let n = 0n;
466
498
  for (let r = 0; r < t; ++r) {
467
- const o = BigInt(n[r] & 127);
468
- e += o << BigInt(7 * r);
469
- }
470
- return BigInt.asIntN(7 * t, e);
471
- };
472
- class U extends Error {
473
- name;
474
- static name = "NamedError";
475
- constructor(t, e, r) {
476
- super(e, { cause: r }), this.name = t;
477
- }
478
- toJSON() {
479
- const t = (() => {
480
- const s = this.cause;
481
- return typeof s == "string" || typeof s == "number" || typeof s == "boolean" ? s : typeof s == "bigint" ? s.toString() : typeof s == "object" && s !== null ? s instanceof Set || s instanceof Map ? Object.fromEntries(s) : s : void 0;
482
- })(), { name: e, message: r, stack: o } = this;
483
- return {
484
- name: e,
485
- message: r,
486
- stack: o,
487
- cause: t
488
- };
499
+ const s = BigInt(e[r] & 127);
500
+ n += s << BigInt(7 * r);
489
501
  }
490
- }
491
- Object.defineProperty(U.prototype, Symbol.toStringTag, {
492
- value: U.name
493
- });
494
- const E = (n) => {
495
- if (n === 0) return 32;
502
+ return BigInt.asIntN(7 * t, n);
503
+ }, B = (e) => {
504
+ if (e === 0) return 32;
496
505
  let t = 0;
497
- for (; n > 0 && !(n & 1); )
498
- ++t, n >>>= 1;
506
+ for (; e > 0 && !(e & 1); )
507
+ ++t, e >>>= 1;
499
508
  return t;
500
- }, S = (n) => {
501
- if (n === 0n) return 64n;
509
+ }, x = "FloatRng", S = (e) => {
510
+ if (e === 0n) return 64n;
502
511
  let t = 0n;
503
- for (; n > 0n && !(n & 1n); )
504
- ++t, n >>= 1n;
512
+ for (; e > 0n && !(e & 1n); )
513
+ ++t, e >>= 1n;
505
514
  return BigInt.asUintN(64, t);
506
515
  };
507
- class R {
516
+ class q {
508
517
  #t;
509
- static name = "FloatRng";
518
+ static name = x;
510
519
  constructor(t) {
511
520
  this.#t = t;
512
521
  }
513
- #n() {
522
+ #e() {
514
523
  const r = (() => {
515
524
  switch (this.#t.bits) {
516
525
  case 32:
517
526
  return this.#t.getU32Rand() >>> 0;
518
527
  case 64: {
519
- const u = this.#t.getU64Rand() & 0xffffffffn;
520
- return Number(u);
528
+ const a = this.#t.getU64Rand() & 0xffffffffn;
529
+ return Number(a);
521
530
  }
522
531
  }
523
- })(), o = r & 255;
524
- let s = 126;
525
- if (o === 0) {
526
- s -= 8;
527
- const u = 1e5;
528
- let h = 0;
532
+ })(), s = r & 255;
533
+ let o = 126;
534
+ if (s === 0) {
535
+ o -= 8;
536
+ const a = 1e5;
537
+ let l = 0;
529
538
  t: for (; ; ) {
530
- if (h > u)
539
+ if (l > a)
531
540
  throw Error("loop exceeded limit");
532
- const d = (() => {
541
+ const f = (() => {
533
542
  switch (this.#t.bits) {
534
543
  case 32:
535
544
  return this.#t.getU32Rand() >>> 0;
536
545
  case 64: {
537
- const y = BigInt.asUintN(32, this.#t.getU64Rand());
538
- return Number(y);
546
+ const h = BigInt.asUintN(32, this.#t.getU64Rand());
547
+ return Number(h);
539
548
  }
540
549
  }
541
550
  })();
542
- if (d === 0) {
543
- if (s -= 32, s < 0) {
544
- s = 0;
551
+ if (f === 0) {
552
+ if (o -= 32, o < 0) {
553
+ o = 0;
545
554
  break t;
546
555
  }
547
556
  } else {
548
- s -= E(d);
557
+ o -= B(f);
549
558
  break t;
550
559
  }
551
- ++h;
560
+ ++l;
552
561
  }
553
562
  } else
554
- s -= E(o);
563
+ o -= B(s);
555
564
  const i = r >>> 8 & 8388607;
556
- i === 0 && r >>> 31 && ++s;
557
- const { buffer: c, byteOffset: f, length: l } = Uint32Array.from([
558
- s << 23 | i
559
- ]);
560
- return new Float32Array(c, f, l)[0];
565
+ i === 0 && r >>> 31 && ++o;
566
+ const c = Uint32Array.from([o << 23 | i]);
567
+ return new Float32Array(c.buffer)[0];
561
568
  }
562
569
  /**
563
570
  * returns a random single-precision floating-point number (float32) in the range of [0.0, 1.0)
564
571
  * @returns
565
572
  */
566
573
  getF32Rand() {
567
- for (let e = 0; e < 1e5; ++e) {
568
- const r = this.#n();
574
+ for (let n = 0; n < 1e5; ++n) {
575
+ const r = this.#e();
569
576
  if (r < 1)
570
577
  return r;
571
578
  }
572
579
  throw Error("exceeded loop limit");
573
580
  }
574
- #e() {
575
- const t = 0n, e = 1023n, r = (() => {
581
+ #n() {
582
+ const t = 0n, n = 1023n, r = (() => {
576
583
  switch (this.#t.bits) {
577
584
  case 32: {
578
- const u = BigInt(this.#t.getU32Rand() >>> 0), h = BigInt(this.#t.getU32Rand() >>> 0);
579
- return u << 32n | h;
585
+ const a = BigInt(this.#t.getU32Rand() >>> 0), l = BigInt(this.#t.getU32Rand() >>> 0);
586
+ return a << 32n | l;
580
587
  }
581
588
  case 64:
582
589
  return BigInt.asUintN(64, this.#t.getU64Rand());
583
590
  }
584
- })(), o = r & 0x7ffn;
585
- let s = e - 1n;
586
- if (o === 0n) {
587
- s -= 11n;
588
- const u = 1e5;
589
- let h = 0;
591
+ })(), s = r & 0x7ffn;
592
+ let o = n - 1n;
593
+ if (s === 0n) {
594
+ o -= 11n;
595
+ const a = 1e5;
596
+ let l = 0;
590
597
  t: for (; ; ) {
591
- if (h > u)
598
+ if (l > a)
592
599
  throw Error("loop exceeded limit");
593
- const d = (() => {
600
+ const f = (() => {
594
601
  switch (this.#t.bits) {
595
602
  case 32: {
596
- const y = BigInt(this.#t.getU32Rand() >>> 0), M = BigInt(this.#t.getU32Rand() >>> 0);
597
- return y << 32n | M;
603
+ const h = BigInt(this.#t.getU32Rand() >>> 0), y = BigInt(this.#t.getU32Rand() >>> 0);
604
+ return h << 32n | y;
598
605
  }
599
606
  case 64:
600
607
  return BigInt.asUintN(64, this.#t.getU64Rand());
601
608
  }
602
609
  })();
603
- if (d === 0n) {
604
- if (s -= 64n, s < t) {
605
- s = t;
610
+ if (f === 0n) {
611
+ if (o -= 64n, o < t) {
612
+ o = t;
606
613
  break t;
607
614
  }
608
615
  } else {
609
- s -= S(d);
616
+ o -= S(f);
610
617
  break t;
611
618
  }
612
- ++h;
619
+ ++l;
613
620
  }
614
621
  } else
615
- s -= S(o);
622
+ o -= S(s);
616
623
  const i = BigInt.asUintN(52, r >> 11n);
617
- i === 0n && r >> 63n && ++s;
618
- const { buffer: c, byteOffset: f, length: l } = BigUint64Array.from([
619
- s << 52n | i
620
- ]);
621
- return new Float64Array(c, f, l)[0];
624
+ i === 0n && r >> 63n && ++o;
625
+ const c = BigUint64Array.from([o << 52n | i]);
626
+ return new Float64Array(c.buffer)[0];
622
627
  }
623
628
  /**
624
629
  * returns a random double-precision floating-point number (float64) in the range of [0.0, 1.0)
625
630
  * @returns
626
631
  */
627
632
  getF64Rand() {
628
- for (let e = 0; e < 1e5; ++e) {
629
- const r = this.#e();
633
+ for (let n = 0; n < 1e5; ++n) {
634
+ const r = this.#n();
630
635
  if (r < 1)
631
636
  return r;
632
637
  }
633
638
  throw Error("exceeded loop limit");
634
639
  }
635
640
  }
636
- Object.defineProperty(R.prototype, Symbol.toStringTag, {
637
- value: R.name
641
+ Object.defineProperty(q.prototype, Symbol.toStringTag, {
642
+ value: x
638
643
  });
639
- const q = [0x853c49e6748fea9bn, 0xda3e39cb94b95bdbn], G = 0x5851f42d4c957f2dn;
640
- class N {
644
+ const K = [0x853c49e6748fea9bn, 0xda3e39cb94b95bdbn], G = 0x5851f42d4c957f2dn;
645
+ class U {
641
646
  /**
642
647
  * length = 2, `[state, increment]`
643
648
  */
@@ -658,23 +663,23 @@ class N {
658
663
  * const betterRng = new PCGMinimal(seed);
659
664
  */
660
665
  constructor(t) {
661
- t && t.length >= 2 ? (this.#t = new BigUint64Array(2), this.#t[1] = t[1] << 1n | 1n, this.#n(), this.#t[0] += t[0], this.#n()) : this.#t = BigUint64Array.from(q);
666
+ t && t.length >= 2 ? (this.#t = new BigUint64Array(2), this.#t[1] = t[1] << 1n | 1n, this.#e(), this.#t[0] += t[0], this.#e()) : this.#t = BigUint64Array.from(K);
662
667
  }
663
668
  /** step inner state */
664
- #n() {
669
+ #e() {
665
670
  this.#t[0] = this.#t[0] * G + this.#t[1];
666
671
  }
667
672
  /** 32bit 乱数を返す (内部状態は変わらない) */
668
- get #e() {
669
- const t = this.#t[0], e = Number(t >> 59n), r = Number(BigInt.asUintN(32, (t ^ t >> 18n) >> 27n));
670
- return P(r, e);
673
+ get #n() {
674
+ const t = this.#t[0], n = Number(t >> 59n), r = Number(BigInt.asUintN(32, (t ^ t >> 18n) >> 27n));
675
+ return j(r, n);
671
676
  }
672
677
  /**
673
678
  *
674
679
  * @returns a random 32-bit unsigned integer
675
680
  */
676
681
  getU32Rand() {
677
- return this.#n(), this.#e;
682
+ return this.#e(), this.#n;
678
683
  }
679
684
  /**
680
685
  * @returns a random 32-bit unsigned integer less than `bound`
@@ -683,8 +688,8 @@ class N {
683
688
  if (t > 4294967296) throw Error("`bound` exceeded limit (2^32)");
684
689
  if (t <= 0)
685
690
  throw Error("'bound' must be positive");
686
- const r = 4294967296 % t, o = 1e5;
687
- for (let s = 0; s < o; ++s) {
691
+ const r = 4294967296 % t, s = 1e5;
692
+ for (let o = 0; o < s; ++o) {
688
693
  const i = this.getU32Rand();
689
694
  if (i >= r)
690
695
  return i % t;
@@ -699,23 +704,23 @@ class N {
699
704
  * the iterator that generates random 32-bit unsigned integers `step` times \
700
705
  * if `bound` is given, random integers are less than `bound`
701
706
  */
702
- *genU32Rands(t, e) {
707
+ *genU32Rands(t, n) {
703
708
  if (t <= 0)
704
709
  throw Error("'step' must be positive");
705
710
  for (let r = 0; r < t; r++)
706
- yield typeof e == "number" ? this.getBoundedU32Rand(e) : this.getU32Rand();
711
+ yield typeof n == "number" ? this.getBoundedU32Rand(n) : this.getU32Rand();
707
712
  }
708
713
  }
709
- Object.defineProperty(N.prototype, Symbol.toStringTag, {
710
- value: N.name
714
+ Object.defineProperty(U.prototype, Symbol.toStringTag, {
715
+ value: U.name
711
716
  });
712
- const z = [
717
+ const W = [
713
718
  0xbe562cb412e2260en,
714
719
  0x2e4284137d641affn,
715
720
  0x4e19b36ee933e27en,
716
721
  0x7581cf8c4f4d4f7dn
717
722
  ];
718
- class x {
723
+ class v {
719
724
  bits = 64;
720
725
  #t;
721
726
  static name = "XoshiroMinimal";
@@ -733,9 +738,9 @@ class x {
733
738
  * const betterRng = new XoshiroMinimal(seed);
734
739
  */
735
740
  constructor(t) {
736
- t && t.length >= 4 ? (this.#t = new BigUint64Array(4), this.#t[0] = t[0], this.#t[1] = t[1], this.#n(), this.#t[2] += t[2], this.#t[3] += t[3]) : this.#t = BigUint64Array.from(z);
741
+ t && t.length >= 4 ? (this.#t = new BigUint64Array(4), this.#t[0] = t[0], this.#t[1] = t[1], this.#e(), this.#t[2] += t[2], this.#t[3] += t[3]) : this.#t = BigUint64Array.from(W);
737
742
  }
738
- #n() {
743
+ #e() {
739
744
  const t = this.#t[1] << 17n;
740
745
  this.#t[2] ^= this.#t[0], this.#t[3] ^= this.#t[1], this.#t[1] ^= this.#t[2], this.#t[0] ^= this.#t[3], this.#t[2] ^= t, this.#t[3] = b(this.#t[3], 45n);
741
746
  }
@@ -745,20 +750,20 @@ class x {
745
750
  }
746
751
  getU64Rand() {
747
752
  const t = this.value;
748
- return this.#n(), t;
753
+ return this.#e(), t;
749
754
  }
750
755
  getU32Rand() {
751
756
  const t = BigInt.asUintN(32, this.getU64Rand());
752
757
  return Number(t);
753
758
  }
754
759
  getBoundedU64Rand(t) {
755
- const e = 1n << 64n;
756
- if (t > e)
760
+ const n = 1n << 64n;
761
+ if (t > n)
757
762
  throw Error("'bound' exceeded limit");
758
763
  if (t <= 0n)
759
764
  throw Error("'bound' must be positive");
760
- const r = e % t, o = 1e5;
761
- for (let s = 0; s < o; ++s) {
765
+ const r = n % t, s = 1e5;
766
+ for (let o = 0; o < s; ++o) {
762
767
  const i = this.getU64Rand();
763
768
  if (i >= r)
764
769
  return i % t;
@@ -773,61 +778,99 @@ class x {
773
778
  const r = this.getBoundedU64Rand(BigInt(t));
774
779
  return Number(r);
775
780
  }
776
- *genU64Rands(t, e) {
781
+ *genU64Rands(t, n) {
777
782
  if (t <= 0)
778
783
  throw Error("'step' must be positive");
779
784
  for (let r = 0; r < t; ++r)
780
- yield e === void 0 ? this.getU64Rand() : this.getBoundedU64Rand(e);
785
+ yield n === void 0 ? this.getU64Rand() : this.getBoundedU64Rand(n);
781
786
  }
782
- *genU32Rands(t, e) {
787
+ *genU32Rands(t, n) {
783
788
  if (t <= 0)
784
789
  throw Error("'step' must be positive");
785
790
  for (let r = 0; r < t; ++r)
786
- yield e === void 0 ? this.getU32Rand() : this.getBoundedU32Rand(e);
791
+ yield n === void 0 ? this.getU32Rand() : this.getBoundedU32Rand(n);
792
+ }
793
+ }
794
+ Object.defineProperty(v.prototype, Symbol.toStringTag, {
795
+ value: v.name
796
+ });
797
+ const L = "WorkerStream";
798
+ class z extends ReadableStream {
799
+ close;
800
+ #t;
801
+ static name = L;
802
+ constructor(t, n) {
803
+ let r, s, o;
804
+ super(
805
+ {
806
+ start: (i) => {
807
+ r = (c) => {
808
+ i.enqueue(c.data);
809
+ }, s = (c) => {
810
+ t.removeEventListener("message", r), t.removeEventListener("error", s);
811
+ const a = new m("WorkerStreamError", c.message, {
812
+ cause: c.error
813
+ });
814
+ i.error(a);
815
+ }, o = () => {
816
+ t.removeEventListener("message", r), t.removeEventListener("error", s), i.close();
817
+ }, t.addEventListener("message", r), t.addEventListener("error", s);
818
+ },
819
+ cancel: (i) => {
820
+ console.log("Canceled reason:", i), t.removeEventListener("message", r), t.removeEventListener("error", s);
821
+ }
822
+ },
823
+ n
824
+ ), this.close = o, this.#t = t;
825
+ }
826
+ postMessage(t, n) {
827
+ this.#t.postMessage(t, n);
787
828
  }
788
829
  }
789
- Object.defineProperty(x.prototype, Symbol.toStringTag, {
790
- value: x.name
830
+ Object.defineProperty(z.prototype, Symbol.toStringTag, {
831
+ value: L
791
832
  });
792
833
  export {
793
- R as FloatRng,
794
- U as NamedError,
795
- N as PCGMinimal,
796
- a as Rational,
797
- x as XoshiroMinimal,
798
- T as bailliePSW,
799
- rt as compress,
800
- gt as decodeLEB128,
801
- et as decodeRFC3986URIComponent,
802
- st as decompress,
803
- dt as encodeLEB128,
834
+ q as FloatRng,
835
+ m as NamedError,
836
+ U as PCGMinimal,
837
+ u as Rational,
838
+ z as WorkerStream,
839
+ v as XoshiroMinimal,
840
+ R as bailliePSW,
841
+ st as compress,
842
+ pt as decodeLEB128,
843
+ rt as decodeRFC3986URIComponent,
844
+ ot as decompress,
845
+ mt as encodeLEB128,
804
846
  nt as encodeRFC3986URIComponent,
805
- _ as exEuclidean,
806
- it as factorial,
847
+ T as exEuclidean,
848
+ at as factorial,
807
849
  D as fromBase64,
808
- at as fromBase64Url,
809
- ht as fromOct,
810
- Q as getHash,
811
- A as getRandBIByBitLength,
812
- v as getRandBIByRange,
813
- ft as getRandPrimeByBitLength,
814
- ct as getRandPrimeByRange,
815
- ot as getRndInt,
816
- W as getStringTag,
817
- g as isDeepStrictEqual,
818
- tt as isNode,
819
- O as isSquare,
820
- B as jacobiSymbol,
821
- Y as lazify,
850
+ ht as fromBase64Url,
851
+ gt as fromOct,
852
+ tt as getHash,
853
+ N as getRandBIByBitLength,
854
+ A as getRandBIByRange,
855
+ ut as getRandPrimeByBitLength,
856
+ lt as getRandPrimeByRange,
857
+ ct as getRndInt,
858
+ Y as getStringTag,
859
+ d as isDeepStrictEqual,
860
+ et as isNode,
861
+ _ as isSquare,
862
+ E as jacobiSymbol,
863
+ Z as lazify,
822
864
  p as modPow,
823
- Z as parseCSV,
824
- H as promiseWithResolvers,
825
- m as residue,
826
- P as rot32,
865
+ Q as parseCSV,
866
+ g as residue,
867
+ j as rot32,
827
868
  b as rot64,
828
869
  X as sameValueZero,
870
+ it as setTimeoutPromise,
829
871
  J as sleep,
830
872
  $ as toBase64,
831
- lt as toBase64Url,
832
- ut as toOct
873
+ ft as toBase64Url,
874
+ dt as toOct,
875
+ H as withResolvers
833
876
  };