@tktb-tess/util-fns 0.11.3 → 0.11.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/bundle.js +211 -203
- package/dist/bundle.min.js +2 -2
- package/dist/fraction.d.ts +5 -5
- package/dist/leb128.d.ts +2 -0
- package/dist/main.d.ts +1 -0
- package/dist/math.d.ts +2 -2
- package/dist/named_error.d.ts +2 -2
- package/dist/u8arr_ext.d.ts +0 -2
- package/dist/worker_stream.d.ts +1 -1
- package/package.json +4 -4
package/dist/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const J = (n, t) => [n].includes(t), h = (n, t) => {
|
|
2
2
|
if (typeof n != typeof t) return !1;
|
|
3
3
|
const e = Object.prototype.toString.call(n), r = Object.prototype.toString.call(t);
|
|
4
4
|
if (e !== r) return !1;
|
|
@@ -27,17 +27,17 @@ const T = new TextEncoder(), H = (n, t) => [n].includes(t), h = (n, t) => {
|
|
|
27
27
|
if (e === "[object Object]") {
|
|
28
28
|
const s = n, o = t, i = Object.keys(s), c = Object.keys(o);
|
|
29
29
|
for (const l of i) {
|
|
30
|
-
const u = c.find((
|
|
30
|
+
const u = c.find((L) => L === l);
|
|
31
31
|
if (u === void 0) return !1;
|
|
32
|
-
const [f,
|
|
33
|
-
if (!h(f,
|
|
32
|
+
const [f, d] = [s[l], o[u]];
|
|
33
|
+
if (!h(f, d)) return !1;
|
|
34
34
|
}
|
|
35
35
|
return !0;
|
|
36
36
|
}
|
|
37
|
-
throw
|
|
37
|
+
throw TypeError(`comparing these objects is unavailable: ${n}, ${t}`, {
|
|
38
38
|
cause: [n, t]
|
|
39
39
|
});
|
|
40
|
-
},
|
|
40
|
+
}, Y = () => {
|
|
41
41
|
let n, t;
|
|
42
42
|
return {
|
|
43
43
|
promise: new Promise((r, s) => {
|
|
@@ -46,12 +46,9 @@ const T = new TextEncoder(), H = (n, t) => [n].includes(t), h = (n, t) => {
|
|
|
46
46
|
resolve: n,
|
|
47
47
|
reject: t
|
|
48
48
|
};
|
|
49
|
-
},
|
|
50
|
-
setTimeout(
|
|
51
|
-
}), Z = (n) => {
|
|
52
|
-
const t = Object.prototype.toString.call(n);
|
|
53
|
-
return t.slice(8, t.length - 1);
|
|
54
|
-
}, Q = (n) => (...t) => () => n(...t), tt = (n) => {
|
|
49
|
+
}, k = (n) => new Promise((t) => {
|
|
50
|
+
setTimeout(t, n);
|
|
51
|
+
}), Z = (n) => Object.prototype.toString.call(n).slice(8, -1), Q = (n) => (...t) => () => n(...t), tt = (n) => {
|
|
55
52
|
const t = [];
|
|
56
53
|
let e = [], r = "", s = !1;
|
|
57
54
|
for (let o = 0; o < n.length; o++) {
|
|
@@ -61,21 +58,21 @@ const T = new TextEncoder(), H = (n, t) => [n].includes(t), h = (n, t) => {
|
|
|
61
58
|
}
|
|
62
59
|
return e.push(r.trim()), t.push(e), t;
|
|
63
60
|
}, nt = async (n, t) => {
|
|
64
|
-
const e =
|
|
61
|
+
const e = new TextEncoder().encode(n), r = await crypto.subtle.digest(t, e);
|
|
65
62
|
return new Uint8Array(r);
|
|
66
63
|
}, et = (n) => encodeURIComponent(n).replace(
|
|
67
64
|
/[!'()*]/g,
|
|
68
65
|
(e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`
|
|
69
66
|
), rt = (n) => {
|
|
70
67
|
if (n.includes("+"))
|
|
71
|
-
throw
|
|
68
|
+
throw URIError("an input string must not include `+`");
|
|
72
69
|
return decodeURIComponent(n);
|
|
73
|
-
}, st =
|
|
74
|
-
const
|
|
75
|
-
return new Response(
|
|
76
|
-
}, ot =
|
|
77
|
-
const
|
|
78
|
-
return new Response(
|
|
70
|
+
}, st = (n, t) => {
|
|
71
|
+
const e = new Blob([n]).stream().pipeThrough(new CompressionStream(t));
|
|
72
|
+
return new Response(e).bytes();
|
|
73
|
+
}, ot = (n, t) => {
|
|
74
|
+
const e = new Blob([n]).stream().pipeThrough(new DecompressionStream(t));
|
|
75
|
+
return new Response(e).bytes();
|
|
79
76
|
}, it = (n, t) => new Promise((e, r) => {
|
|
80
77
|
setTimeout(async () => {
|
|
81
78
|
try {
|
|
@@ -85,62 +82,40 @@ const T = new TextEncoder(), H = (n, t) => [n].includes(t), h = (n, t) => {
|
|
|
85
82
|
r(s);
|
|
86
83
|
}
|
|
87
84
|
}, t);
|
|
88
|
-
}),
|
|
89
|
-
class I extends Error {
|
|
90
|
-
constructor(t, e, r) {
|
|
91
|
-
super(e, r), this.errName = t;
|
|
92
|
-
}
|
|
93
|
-
static name = N;
|
|
94
|
-
toJSON() {
|
|
95
|
-
const t = (() => {
|
|
96
|
-
const o = this.cause;
|
|
97
|
-
if (o != null)
|
|
98
|
-
return typeof o == "string" || typeof o == "number" || typeof o == "boolean" ? o : typeof o == "bigint" ? o.toString() : typeof o == "object" ? o instanceof Set || o instanceof Map ? Object.fromEntries(o) : o : void 0;
|
|
99
|
-
})(), { errName: e, message: r, stack: s } = this;
|
|
100
|
-
return {
|
|
101
|
-
errName: e,
|
|
102
|
-
message: r,
|
|
103
|
-
stack: s,
|
|
104
|
-
cause: t
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
Object.defineProperty(I.prototype, Symbol.toStringTag, {
|
|
109
|
-
value: N
|
|
110
|
-
});
|
|
111
|
-
const ct = (n, t) => Math.floor(Math.random() * (t - n) + n), d = (n, t) => {
|
|
85
|
+
}), ct = (n, t) => Math.floor(Math.random() * (t - n) + n), g = (n, t) => {
|
|
112
86
|
t < 0n && (t *= -1n);
|
|
113
87
|
const e = n % t;
|
|
114
88
|
return e < 0n ? e + t : e;
|
|
115
|
-
},
|
|
116
|
-
if (!Number.isFinite(n))
|
|
117
|
-
|
|
89
|
+
}, S = (n, t = !1) => {
|
|
90
|
+
if (!Number.isFinite(n))
|
|
91
|
+
throw RangeError("`length` is not a valid number");
|
|
92
|
+
if (n <= 0) throw RangeError("`length` must be positive");
|
|
118
93
|
const e = Math.ceil(n / 8), r = crypto.getRandomValues(new Uint8Array(e));
|
|
119
94
|
let s = Array.from(r, (o) => o.toString(2).padStart(8, "0")).join("").slice(0, n);
|
|
120
95
|
return t && (s = s.replace(/^\d/, "1")), BigInt("0b" + s);
|
|
121
|
-
},
|
|
96
|
+
}, T = (n, t) => {
|
|
122
97
|
if (n >= t)
|
|
123
|
-
throw
|
|
98
|
+
throw RangeError("`min` must be smaller than `max`");
|
|
124
99
|
const e = t - n, r = e.toString(2).length, s = (() => {
|
|
125
100
|
for (let i = 0; i < 1e5; i++) {
|
|
126
|
-
const c =
|
|
127
|
-
if (c >=
|
|
101
|
+
const c = S(r);
|
|
102
|
+
if (c >= p(2n, BigInt(r), e))
|
|
128
103
|
return c % e;
|
|
129
104
|
}
|
|
130
105
|
throw Error("Failed to generate a random bigint");
|
|
131
106
|
})();
|
|
132
107
|
return n + s;
|
|
133
|
-
},
|
|
134
|
-
if (e < 1n) throw
|
|
135
|
-
if (t < 0n) throw
|
|
136
|
-
if (n =
|
|
108
|
+
}, p = (n, t, e) => {
|
|
109
|
+
if (e < 1n) throw RangeError("`mod` must be positive");
|
|
110
|
+
if (t < 0n) throw RangeError("`power` must not be negative");
|
|
111
|
+
if (n = g(n, e), e === 1n) return 0n;
|
|
137
112
|
if (n % e === 1n || n % e === 0n) return n;
|
|
138
113
|
if (n === e - 1n) return t & 1n ? e - 1n : 1n;
|
|
139
114
|
let r = 1n;
|
|
140
115
|
for (; t > 0n; )
|
|
141
116
|
t & 1n && (r = r * n % e), n = n * n % e, t >>= 1n;
|
|
142
117
|
return r;
|
|
143
|
-
},
|
|
118
|
+
}, M = (n, t) => {
|
|
144
119
|
if (n === 0n && t === 0n) return { x: 0n, y: 0n, gcd: 0n };
|
|
145
120
|
if (n === 0n)
|
|
146
121
|
return t > 0n ? { x: 0n, y: -1n, gcd: t } : { x: 0n, y: 1n, gcd: -t };
|
|
@@ -164,7 +139,7 @@ const ct = (n, t) => Math.floor(Math.random() * (t - n) + n), d = (n, t) => {
|
|
|
164
139
|
}
|
|
165
140
|
const s = n + r | 1n, o = y(n, s), i = y(s, t);
|
|
166
141
|
return o * i;
|
|
167
|
-
},
|
|
142
|
+
}, A = (n) => {
|
|
168
143
|
let t = 3n, e = 1n, r = 1n;
|
|
169
144
|
const s = BigInt(n.toString(2).length) - 1n;
|
|
170
145
|
for (let o = s - 1n; o > -1n; --o) {
|
|
@@ -173,13 +148,13 @@ const ct = (n, t) => Math.floor(Math.random() * (t - n) + n), d = (n, t) => {
|
|
|
173
148
|
}
|
|
174
149
|
return e;
|
|
175
150
|
}, lt = (n) => {
|
|
176
|
-
if (n < 0n) throw
|
|
151
|
+
if (n < 0n) throw RangeError("'n' must be non-negative");
|
|
177
152
|
if (n === 0n) return 1n;
|
|
178
153
|
const t = n - BigInt(n.toString(2).match(/1/g)?.length ?? 0);
|
|
179
|
-
return
|
|
180
|
-
},
|
|
154
|
+
return A(n) << t;
|
|
155
|
+
}, j = (n, t) => (n >>> (t & 31) | n << (-t & 31)) >>> 0, w = (n, t) => BigInt.asUintN(64, n >> (t & 63n) | n << (-t & 63n)), I = (n, t) => {
|
|
181
156
|
if (t < 1n || t % 2n === 0n)
|
|
182
|
-
throw
|
|
157
|
+
throw RangeError("`n` is out of range");
|
|
183
158
|
for (; n < 0n; )
|
|
184
159
|
n += t;
|
|
185
160
|
n %= t;
|
|
@@ -193,7 +168,7 @@ const ct = (n, t) => Math.floor(Math.random() * (t - n) + n), d = (n, t) => {
|
|
|
193
168
|
[n, t] = [t, n], n % 4n === 3n && t % 4n === 3n && (e *= -1n), n %= t;
|
|
194
169
|
}
|
|
195
170
|
return t === 1n ? e : 0n;
|
|
196
|
-
},
|
|
171
|
+
}, P = (n) => {
|
|
197
172
|
if (n < 0n) return !1;
|
|
198
173
|
if (n === 0n) return !0;
|
|
199
174
|
let t = 1n, e = n;
|
|
@@ -202,50 +177,50 @@ const ct = (n, t) => Math.floor(Math.random() * (t - n) + n), d = (n, t) => {
|
|
|
202
177
|
r * r < n ? t = r : e = r;
|
|
203
178
|
}
|
|
204
179
|
return n === t ** 2n || n === (t + 1n) ** 2n;
|
|
205
|
-
},
|
|
180
|
+
}, _ = (n) => {
|
|
206
181
|
if (n <= 1n) return !1;
|
|
207
182
|
if (n % 2n === 0n) return n === 2n;
|
|
208
183
|
let t = n - 1n, e = 0n;
|
|
209
184
|
for (; t % 2n === 0n; )
|
|
210
185
|
t >>= 1n, e += 1n;
|
|
211
186
|
const [r, s] = [t, e];
|
|
212
|
-
let i =
|
|
187
|
+
let i = p(2n, r, n);
|
|
213
188
|
if (i === 1n) return !0;
|
|
214
189
|
for (let c = 0n; c < s; c++) {
|
|
215
190
|
if (i === n - 1n) return !0;
|
|
216
191
|
i = i * i % n;
|
|
217
192
|
}
|
|
218
193
|
return !1;
|
|
219
|
-
},
|
|
220
|
-
let t = 5n, e =
|
|
194
|
+
}, C = (n) => {
|
|
195
|
+
let t = 5n, e = I(t, n);
|
|
221
196
|
for (; e > 0n; ) {
|
|
222
|
-
if (t = t > 0n ? t + 2n : t - 2n, t *= -1n, t === -15n &&
|
|
197
|
+
if (t = t > 0n ? t + 2n : t - 2n, t *= -1n, t === -15n && P(n))
|
|
223
198
|
return [0n, 0n];
|
|
224
|
-
e =
|
|
199
|
+
e = I(t, n);
|
|
225
200
|
}
|
|
226
201
|
return [t, e];
|
|
227
|
-
},
|
|
202
|
+
}, m = (n, t) => (n & 1n) === 1n ? g(n + t >> 1n, t) : g(n >> 1n, t), O = (n, t, e, r) => {
|
|
228
203
|
let s = 1n, o = e;
|
|
229
204
|
const i = n.toString(2).slice(1);
|
|
230
205
|
for (const c of i)
|
|
231
|
-
[s, o] = [
|
|
206
|
+
[s, o] = [g(s * o, t), m(o * o + r * s * s, t)], c === "1" && ([s, o] = [m(e * s + o, t), m(r * s + e * o, t)]);
|
|
232
207
|
return [s, o];
|
|
233
|
-
},
|
|
208
|
+
}, V = (n, t, e, r) => {
|
|
234
209
|
if (n % 2n !== 1n)
|
|
235
|
-
throw
|
|
210
|
+
throw RangeError("`n` must be odd");
|
|
236
211
|
let s = n + 1n, o = 0n;
|
|
237
212
|
for (; s % 2n === 0n; )
|
|
238
213
|
s >>= 1n, o += 1n;
|
|
239
|
-
const [i, c] =
|
|
214
|
+
const [i, c] = O(s, n, e, t);
|
|
240
215
|
let l = c;
|
|
241
216
|
if (i === 0n) return !0;
|
|
242
|
-
r =
|
|
217
|
+
r = p(r, s, n);
|
|
243
218
|
for (let u = 0n; u < o; u++) {
|
|
244
219
|
if (l === 0n) return !0;
|
|
245
|
-
l =
|
|
220
|
+
l = g(l * l - 2n * r, n), r = p(r, 2n, n);
|
|
246
221
|
}
|
|
247
222
|
return !1;
|
|
248
|
-
},
|
|
223
|
+
}, B = (n) => {
|
|
249
224
|
if (n <= 1n) return !1;
|
|
250
225
|
if (n % 2n === 0n) return n === 2n;
|
|
251
226
|
const t = [
|
|
@@ -279,33 +254,33 @@ const ct = (n, t) => Math.floor(Math.random() * (t - n) + n), d = (n, t) => {
|
|
|
279
254
|
for (const o of t)
|
|
280
255
|
if (n % o === 0n)
|
|
281
256
|
return n === o;
|
|
282
|
-
if (!
|
|
257
|
+
if (!_(n))
|
|
283
258
|
return !1;
|
|
284
|
-
const [e, r] =
|
|
259
|
+
const [e, r] = C(n);
|
|
285
260
|
if (r === 0n) return !1;
|
|
286
261
|
const s = (1n - e) / 4n;
|
|
287
|
-
return
|
|
262
|
+
return V(n, e, 1n, s);
|
|
288
263
|
}, ut = (n, t) => {
|
|
289
264
|
if (t < 2n)
|
|
290
|
-
throw
|
|
265
|
+
throw RangeError("`max` must be 2 or larger");
|
|
291
266
|
for (let r = 0; r < 1e5; r++) {
|
|
292
|
-
const s =
|
|
293
|
-
if (
|
|
267
|
+
const s = T(n, t);
|
|
268
|
+
if (B(s)) return s;
|
|
294
269
|
}
|
|
295
|
-
throw Error("
|
|
270
|
+
throw Error("No primes were found");
|
|
296
271
|
}, at = (n, t = !1) => {
|
|
297
272
|
if (n < 2)
|
|
298
|
-
throw
|
|
273
|
+
throw RangeError("`bitLength` must be 2 or larger");
|
|
299
274
|
for (let r = 0; r < 1e5; r++) {
|
|
300
|
-
const s =
|
|
301
|
-
if (
|
|
275
|
+
const s = S(n, t);
|
|
276
|
+
if (B(s)) return s;
|
|
302
277
|
}
|
|
303
278
|
throw Error("NoPrimesFound");
|
|
304
|
-
},
|
|
279
|
+
}, R = "Rational";
|
|
305
280
|
class a {
|
|
306
281
|
#t;
|
|
307
282
|
#n;
|
|
308
|
-
static name =
|
|
283
|
+
static name = R;
|
|
309
284
|
/**
|
|
310
285
|
* fraction (rational) class
|
|
311
286
|
* @param numerator
|
|
@@ -332,10 +307,10 @@ class a {
|
|
|
332
307
|
t = 1 / o;
|
|
333
308
|
let [i, c] = [1n, s], [l, u] = [0n, 1n];
|
|
334
309
|
for (; `${u}`.length < e + 1; ) {
|
|
335
|
-
const f = BigInt(Math.floor(t)),
|
|
336
|
-
if ([i, c] = [c, f * c + i], [l, u] = [u, f * u + l],
|
|
310
|
+
const f = BigInt(Math.floor(t)), d = t - Number(f);
|
|
311
|
+
if ([i, c] = [c, f * c + i], [l, u] = [u, f * u + l], d === 0)
|
|
337
312
|
return new a(r ? -c : c, u);
|
|
338
|
-
t = 1 /
|
|
313
|
+
t = 1 / d;
|
|
339
314
|
}
|
|
340
315
|
return new a(r ? -i : i, l);
|
|
341
316
|
}
|
|
@@ -343,7 +318,7 @@ class a {
|
|
|
343
318
|
* reduction
|
|
344
319
|
*/
|
|
345
320
|
#e() {
|
|
346
|
-
const { gcd: t } =
|
|
321
|
+
const { gcd: t } = M(this.#t, this.#n);
|
|
347
322
|
t !== 0n && (this.#t /= t, this.#n /= t);
|
|
348
323
|
}
|
|
349
324
|
/**
|
|
@@ -396,9 +371,9 @@ class a {
|
|
|
396
371
|
}
|
|
397
372
|
/**
|
|
398
373
|
* returns mediant
|
|
399
|
-
* @param this `a/b`
|
|
400
|
-
* @param right `c/d`
|
|
401
|
-
* @returns `(a+c)/(b+d)`
|
|
374
|
+
* @param this `a / b`
|
|
375
|
+
* @param right `c / d`
|
|
376
|
+
* @returns `(a + c) / (b + d)`
|
|
402
377
|
*/
|
|
403
378
|
mediant(t) {
|
|
404
379
|
const e = this.#n + t.#n, r = this.#t + t.#t;
|
|
@@ -452,84 +427,79 @@ class a {
|
|
|
452
427
|
}
|
|
453
428
|
}
|
|
454
429
|
Object.defineProperty(a.prototype, Symbol.toStringTag, {
|
|
455
|
-
value:
|
|
430
|
+
value: R
|
|
456
431
|
});
|
|
457
|
-
const
|
|
432
|
+
const $ = (n) => {
|
|
458
433
|
const t = Array.from(n, (e) => String.fromCharCode(e));
|
|
459
434
|
return btoa(t.join(""));
|
|
460
|
-
},
|
|
435
|
+
}, F = (n) => {
|
|
461
436
|
const t = atob(n);
|
|
462
437
|
return Uint8Array.from(t, (e) => e.charCodeAt(0));
|
|
463
|
-
}, ft = (n) =>
|
|
464
|
-
const t = n.length & 3;
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
const e = t.length % 6;
|
|
471
|
-
e && (t = "0".repeat(6 - e) + t);
|
|
472
|
-
const r = t.matchAll(/.{6}/g);
|
|
438
|
+
}, ft = (n) => $(n).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, ""), ht = (n) => {
|
|
439
|
+
const t = 4 - (n.length & 3) & 3, e = n.concat("=".repeat(t)).replaceAll("-", "+").replaceAll("_", "/");
|
|
440
|
+
return F(e);
|
|
441
|
+
}, gt = (n) => {
|
|
442
|
+
const t = Array.from(n, (i) => i.toString(16).padStart(2, "0")).join(
|
|
443
|
+
""
|
|
444
|
+
), e = (6 - t.length % 6) % 6, s = "0".repeat(e).concat(t).matchAll(/.{6}/g);
|
|
473
445
|
return Array.from(
|
|
474
|
-
|
|
475
|
-
(
|
|
446
|
+
s,
|
|
447
|
+
(i) => Number.parseInt(i[0], 16).toString(8).padStart(8, "0")
|
|
476
448
|
).join("").replace(/^0+/, "");
|
|
477
|
-
},
|
|
478
|
-
const t = n.length & 7;
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
const t = n < 0n;
|
|
487
|
-
t && (n *= -1n);
|
|
488
|
-
const e = n.toString(2).length, r = n === 1n << BigInt(e - 1) && !(e % 7) && t, s = Math.floor(e / 7) + 1;
|
|
489
|
-
return r ? s - 1 : s;
|
|
490
|
-
}, mt = (n) => {
|
|
491
|
-
const t = K(n);
|
|
492
|
-
n = BigInt.asUintN(t * 7, n);
|
|
493
|
-
const e = new Uint8Array(t);
|
|
494
|
-
for (let s = 0; s < t - 1; ++s) {
|
|
495
|
-
const o = Number(n & 127n) | 128;
|
|
496
|
-
e[s] = o, n >>= 7n;
|
|
449
|
+
}, dt = (n) => {
|
|
450
|
+
const t = 8 - (n.length & 7) & 7, r = "0".repeat(t).concat(n).matchAll(/.{8}/g), o = Array.from(r, (i) => Number.parseInt(i[0], 8).toString(16).padStart(6, "0")).join("").matchAll(/.{2}/g);
|
|
451
|
+
return Uint8Array.from(o, (i) => Number.parseInt(i[0], 16));
|
|
452
|
+
}, N = "NamedError";
|
|
453
|
+
class D extends Error {
|
|
454
|
+
static name = N;
|
|
455
|
+
errName;
|
|
456
|
+
constructor(t, e, r) {
|
|
457
|
+
super(e, r), this.errName = t;
|
|
497
458
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
459
|
+
toJSON() {
|
|
460
|
+
const t = (() => {
|
|
461
|
+
const o = this.cause;
|
|
462
|
+
if (o != null)
|
|
463
|
+
return typeof o == "string" || typeof o == "number" || typeof o == "boolean" ? o : typeof o == "bigint" ? o.toString() : typeof o == "object" ? o instanceof Set || o instanceof Map ? Object.fromEntries(o) : o : void 0;
|
|
464
|
+
})(), { errName: e, message: r, stack: s } = this;
|
|
465
|
+
return {
|
|
466
|
+
name: e,
|
|
467
|
+
message: r,
|
|
468
|
+
stack: s,
|
|
469
|
+
cause: t
|
|
470
|
+
};
|
|
506
471
|
}
|
|
507
|
-
|
|
508
|
-
|
|
472
|
+
}
|
|
473
|
+
Object.defineProperty(D.prototype, Symbol.toStringTag, {
|
|
474
|
+
value: N
|
|
475
|
+
});
|
|
476
|
+
const E = (n) => {
|
|
509
477
|
if (n === 0n) return 64n;
|
|
510
478
|
let t = 0n;
|
|
511
479
|
for (; n > 0n && !(n & 1n); )
|
|
512
480
|
++t, n >>= 1n;
|
|
513
481
|
return BigInt.asUintN(64, t);
|
|
514
|
-
},
|
|
482
|
+
}, b = (n, t) => {
|
|
515
483
|
const e = 0n, r = 1023n, s = n & 0x7ffn;
|
|
516
484
|
let o = r - 1n;
|
|
517
485
|
if (s > 0n)
|
|
518
|
-
return o -=
|
|
486
|
+
return o -= E(s), o;
|
|
519
487
|
o -= 11n;
|
|
520
488
|
const i = 1e5;
|
|
521
489
|
for (let c = 0; c < i; ++c) {
|
|
522
490
|
const l = t();
|
|
523
491
|
if (l > 0n)
|
|
524
|
-
return o -=
|
|
492
|
+
return o -= E(l), o;
|
|
525
493
|
if (o -= 64n, o < e)
|
|
526
494
|
return e;
|
|
527
495
|
}
|
|
528
496
|
throw Error("loop exceeded limit");
|
|
529
|
-
},
|
|
497
|
+
}, pt = (n) => {
|
|
530
498
|
const t = () => BigInt.asUintN(64, n()), e = () => {
|
|
531
|
-
const r = t(), s = BigInt.asUintN(52, r >> 11n), i = s === 0n && r >> 63n === 1n ?
|
|
532
|
-
|
|
499
|
+
const r = t(), s = BigInt.asUintN(52, r >> 11n), i = s === 0n && r >> 63n === 1n ? b(r, t) + 1n : b(r, t), { buffer: c } = BigUint64Array.from([i << 52n | s]), l = new Float64Array(c)[0];
|
|
500
|
+
if (l == null)
|
|
501
|
+
throw Error("unexpected");
|
|
502
|
+
return l;
|
|
533
503
|
};
|
|
534
504
|
return () => {
|
|
535
505
|
for (let s = 0; s < 1e5; ++s) {
|
|
@@ -539,13 +509,13 @@ const D = (n) => {
|
|
|
539
509
|
}
|
|
540
510
|
throw Error("Loop limit exceeded");
|
|
541
511
|
};
|
|
542
|
-
},
|
|
543
|
-
class
|
|
512
|
+
}, q = [0x853c49e6748fea9bn, 0xda3e39cb94b95bdbn], K = 0x5851f42d4c957f2dn, U = "PCGMinimal";
|
|
513
|
+
class G {
|
|
544
514
|
/**
|
|
545
515
|
* length = 2, `[state, increment]`
|
|
546
516
|
*/
|
|
547
517
|
#t;
|
|
548
|
-
static name =
|
|
518
|
+
static name = U;
|
|
549
519
|
/**
|
|
550
520
|
* @param seeds
|
|
551
521
|
* `BigUint64Array` with length 2. \
|
|
@@ -560,16 +530,25 @@ class X {
|
|
|
560
530
|
* const betterRng = new PCGMinimal(seed);
|
|
561
531
|
*/
|
|
562
532
|
constructor(t) {
|
|
563
|
-
|
|
533
|
+
if (t && t[0] != null && t[1] != null) {
|
|
534
|
+
if (this.#t = new BigUint64Array(2), this.#t[0] == null || this.#t[1] == null)
|
|
535
|
+
throw TypeError("unexpected");
|
|
536
|
+
this.#t[1] = t[1] << 1n | 1n, this.#n(), this.#t[0] += t[0], this.#n();
|
|
537
|
+
} else
|
|
538
|
+
this.#t = BigUint64Array.from(q);
|
|
564
539
|
}
|
|
565
540
|
/** step inner state */
|
|
566
541
|
#n() {
|
|
567
|
-
|
|
542
|
+
if (this.#t[0] == null || this.#t[1] == null)
|
|
543
|
+
throw TypeError("unexpected");
|
|
544
|
+
this.#t[0] = this.#t[0] * K + this.#t[1];
|
|
568
545
|
}
|
|
569
546
|
/** 32bit 乱数を返す (内部状態は変わらない) */
|
|
570
547
|
get #e() {
|
|
548
|
+
if (this.#t[0] == null || this.#t[1] == null)
|
|
549
|
+
throw TypeError("unexpected");
|
|
571
550
|
const t = this.#t[0], e = Number(t >> 59n), r = Number(BigInt.asUintN(32, (t ^ t >> 18n) >> 27n));
|
|
572
|
-
return
|
|
551
|
+
return j(r, e);
|
|
573
552
|
}
|
|
574
553
|
/**
|
|
575
554
|
*
|
|
@@ -582,9 +561,9 @@ class X {
|
|
|
582
561
|
* @returns a random 32-bit unsigned integer less than `bound`
|
|
583
562
|
*/
|
|
584
563
|
getBoundedRandU32(t) {
|
|
585
|
-
if (t > 4294967296) throw
|
|
564
|
+
if (t > 4294967296) throw RangeError("`bound` exceeded limit (2^32)");
|
|
586
565
|
if (t <= 0)
|
|
587
|
-
throw
|
|
566
|
+
throw RangeError("'bound' must be positive");
|
|
588
567
|
const r = 4294967296 % t, s = 1e5;
|
|
589
568
|
for (let o = 0; o < s; ++o) {
|
|
590
569
|
const i = this.getRandU32();
|
|
@@ -603,24 +582,24 @@ class X {
|
|
|
603
582
|
*/
|
|
604
583
|
*genRandU32s(t, e) {
|
|
605
584
|
if (t <= 0)
|
|
606
|
-
throw
|
|
585
|
+
throw RangeError("'step' must be positive");
|
|
607
586
|
for (let r = 0; r < t; r++)
|
|
608
587
|
yield typeof e == "number" ? this.getBoundedRandU32(e) : this.getRandU32();
|
|
609
588
|
}
|
|
610
589
|
}
|
|
611
|
-
Object.defineProperty(
|
|
612
|
-
value:
|
|
590
|
+
Object.defineProperty(G.prototype, Symbol.toStringTag, {
|
|
591
|
+
value: U
|
|
613
592
|
});
|
|
614
|
-
const
|
|
593
|
+
const W = [
|
|
615
594
|
0xbe562cb412e2260en,
|
|
616
595
|
0x2e4284137d641affn,
|
|
617
596
|
0x4e19b36ee933e27en,
|
|
618
597
|
0x7581cf8c4f4d4f7dn
|
|
619
|
-
];
|
|
620
|
-
class
|
|
598
|
+
], x = "XoshiroMinimal";
|
|
599
|
+
class X {
|
|
621
600
|
bits = 64;
|
|
622
601
|
#t;
|
|
623
|
-
static name =
|
|
602
|
+
static name = x;
|
|
624
603
|
/**
|
|
625
604
|
* @param seeds
|
|
626
605
|
* `BigUint64Array` with length 4. \
|
|
@@ -635,13 +614,22 @@ class B {
|
|
|
635
614
|
* const betterRng = new XoshiroMinimal(seed);
|
|
636
615
|
*/
|
|
637
616
|
constructor(t) {
|
|
638
|
-
|
|
617
|
+
if (t && t[0] != null && t[1] != null && t[2] != null && t[3] != null) {
|
|
618
|
+
if (this.#t = new BigUint64Array(4), this.#t[0] = t[0], this.#t[1] = t[1], this.#n(), this.#t[2] == null || this.#t[3] == null)
|
|
619
|
+
throw TypeError("unexpected");
|
|
620
|
+
this.#t[2] += t[2], this.#t[3] += t[3];
|
|
621
|
+
} else
|
|
622
|
+
this.#t = BigUint64Array.from(W);
|
|
639
623
|
}
|
|
640
624
|
#n() {
|
|
625
|
+
if (this.#t[0] == null || this.#t[1] == null || this.#t[2] == null || this.#t[3] == null)
|
|
626
|
+
throw TypeError("unexpected");
|
|
641
627
|
const t = this.#t[1] << 17n;
|
|
642
628
|
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] = w(this.#t[3], 45n);
|
|
643
629
|
}
|
|
644
630
|
get value() {
|
|
631
|
+
if (this.#t[0] == null || this.#t[3] == null)
|
|
632
|
+
throw TypeError("unexpected");
|
|
645
633
|
const t = w(this.#t[0] + this.#t[3], 23n) + this.#t[0];
|
|
646
634
|
return BigInt.asUintN(64, t);
|
|
647
635
|
}
|
|
@@ -656,9 +644,9 @@ class B {
|
|
|
656
644
|
getBoundedRandU64(t) {
|
|
657
645
|
const e = 1n << 64n;
|
|
658
646
|
if (t > e)
|
|
659
|
-
throw
|
|
647
|
+
throw RangeError("`bound` exceeded limit");
|
|
660
648
|
if (t <= 0n)
|
|
661
|
-
throw
|
|
649
|
+
throw RangeError("`bound` must be positive");
|
|
662
650
|
const r = e % t, s = 1e5;
|
|
663
651
|
for (let o = 0; o < s; ++o) {
|
|
664
652
|
const i = this.getRandU64();
|
|
@@ -669,33 +657,33 @@ class B {
|
|
|
669
657
|
}
|
|
670
658
|
getBoundedRandU32(t) {
|
|
671
659
|
if (t > 4294967296)
|
|
672
|
-
throw
|
|
660
|
+
throw RangeError("`bound` exceeded limit");
|
|
673
661
|
if (t <= 0n)
|
|
674
|
-
throw
|
|
662
|
+
throw RangeError("`bound` must be positive");
|
|
675
663
|
const r = this.getBoundedRandU64(BigInt(t));
|
|
676
664
|
return Number(r);
|
|
677
665
|
}
|
|
678
666
|
*genRandU64s(t, e) {
|
|
679
667
|
if (t <= 0)
|
|
680
|
-
throw
|
|
668
|
+
throw RangeError("`step` must be positive");
|
|
681
669
|
for (let r = 0; r < t; ++r)
|
|
682
670
|
yield e === void 0 ? this.getRandU64() : this.getBoundedRandU64(e);
|
|
683
671
|
}
|
|
684
672
|
*genRandU32s(t, e) {
|
|
685
673
|
if (t <= 0)
|
|
686
|
-
throw
|
|
674
|
+
throw RangeError("`step` must be positive");
|
|
687
675
|
for (let r = 0; r < t; ++r)
|
|
688
676
|
yield e === void 0 ? this.getRandU32() : this.getBoundedRandU32(e);
|
|
689
677
|
}
|
|
690
678
|
}
|
|
691
|
-
Object.defineProperty(
|
|
692
|
-
value:
|
|
679
|
+
Object.defineProperty(X.prototype, Symbol.toStringTag, {
|
|
680
|
+
value: x
|
|
693
681
|
});
|
|
694
|
-
const
|
|
682
|
+
const v = "WorkerStream";
|
|
695
683
|
class z extends ReadableStream {
|
|
696
684
|
close;
|
|
697
685
|
#t;
|
|
698
|
-
static name =
|
|
686
|
+
static name = v;
|
|
699
687
|
constructor(t, e) {
|
|
700
688
|
let r, s, o;
|
|
701
689
|
super(
|
|
@@ -704,69 +692,89 @@ class z extends ReadableStream {
|
|
|
704
692
|
r = (c) => {
|
|
705
693
|
i.enqueue(c.data);
|
|
706
694
|
}, s = (c) => {
|
|
707
|
-
t.removeEventListener("message", r), t.removeEventListener("error", s);
|
|
708
|
-
const l = new I("WorkerStreamError", c.message, {
|
|
709
|
-
cause: c.error
|
|
710
|
-
});
|
|
711
|
-
i.error(l);
|
|
695
|
+
t.removeEventListener("message", r), t.removeEventListener("error", s), i.error(Error(c.message, { cause: c.error }));
|
|
712
696
|
}, o = () => {
|
|
713
697
|
t.removeEventListener("message", r), t.removeEventListener("error", s), i.close();
|
|
714
698
|
}, t.addEventListener("message", r), t.addEventListener("error", s);
|
|
715
699
|
},
|
|
716
|
-
cancel: (
|
|
717
|
-
|
|
700
|
+
cancel: () => {
|
|
701
|
+
t.removeEventListener("message", r), t.removeEventListener("error", s);
|
|
718
702
|
}
|
|
719
703
|
},
|
|
720
704
|
e
|
|
721
705
|
), this.close = o, this.#t = t;
|
|
722
706
|
}
|
|
723
|
-
postMessage(t, e) {
|
|
707
|
+
postMessage = (t, e) => {
|
|
724
708
|
this.#t.postMessage(t, e);
|
|
725
|
-
}
|
|
709
|
+
};
|
|
726
710
|
}
|
|
727
711
|
Object.defineProperty(z.prototype, Symbol.toStringTag, {
|
|
728
|
-
value:
|
|
712
|
+
value: v
|
|
729
713
|
});
|
|
714
|
+
const H = (n) => {
|
|
715
|
+
const t = n < 0n;
|
|
716
|
+
t && (n *= -1n);
|
|
717
|
+
const e = n.toString(2).length, r = n === 1n << BigInt(e - 1) && !(e % 7) && t, s = Math.floor(e / 7) + 1;
|
|
718
|
+
return r ? s - 1 : s;
|
|
719
|
+
}, mt = (n) => {
|
|
720
|
+
const t = H(n);
|
|
721
|
+
n = BigInt.asUintN(t * 7, n);
|
|
722
|
+
const e = new Uint8Array(t);
|
|
723
|
+
for (let s = 0; s < t - 1; ++s) {
|
|
724
|
+
const o = Number(n & 127n) | 128;
|
|
725
|
+
e[s] = o, n >>= 7n;
|
|
726
|
+
}
|
|
727
|
+
const r = Number(n & 127n);
|
|
728
|
+
return e[t - 1] = r, n >>= 7n, e;
|
|
729
|
+
}, yt = (n) => {
|
|
730
|
+
const t = n.length;
|
|
731
|
+
let e = 0n;
|
|
732
|
+
for (const [r, s] of n.entries()) {
|
|
733
|
+
const o = BigInt(s & 127);
|
|
734
|
+
e += o << BigInt(7 * r);
|
|
735
|
+
}
|
|
736
|
+
return BigInt.asIntN(7 * t, e);
|
|
737
|
+
};
|
|
730
738
|
export {
|
|
731
|
-
|
|
732
|
-
|
|
739
|
+
D as NamedError,
|
|
740
|
+
G as PCGMinimal,
|
|
733
741
|
a as Rational,
|
|
734
742
|
z as WorkerStream,
|
|
735
|
-
|
|
736
|
-
|
|
743
|
+
X as XoshiroMinimal,
|
|
744
|
+
B as bailliePSW,
|
|
737
745
|
st as compress,
|
|
738
|
-
|
|
746
|
+
yt as decodeLEB128,
|
|
739
747
|
rt as decodeRFC3986URIComponent,
|
|
740
748
|
ot as decompress,
|
|
741
749
|
mt as encodeLEB128,
|
|
742
750
|
et as encodeRFC3986URIComponent,
|
|
743
|
-
|
|
751
|
+
M as exEuclidean,
|
|
744
752
|
lt as factorial,
|
|
745
|
-
|
|
746
|
-
|
|
753
|
+
pt as floatRng,
|
|
754
|
+
F as fromBase64,
|
|
747
755
|
ht as fromBase64Url,
|
|
748
|
-
|
|
756
|
+
dt as fromOct,
|
|
749
757
|
nt as getHash,
|
|
750
|
-
|
|
751
|
-
|
|
758
|
+
S as getRandBIByBitLength,
|
|
759
|
+
T as getRandBIByRange,
|
|
752
760
|
at as getRandPrimeByBitLength,
|
|
753
761
|
ut as getRandPrimeByRange,
|
|
754
762
|
ct as getRndInt,
|
|
755
763
|
Z as getStringTag,
|
|
756
764
|
h as isDeepStrictEqual,
|
|
757
|
-
|
|
758
|
-
|
|
765
|
+
P as isSquare,
|
|
766
|
+
I as jacobiSymbol,
|
|
759
767
|
Q as lazify,
|
|
760
|
-
|
|
768
|
+
p as modPow,
|
|
761
769
|
tt as parseCSV,
|
|
762
|
-
|
|
763
|
-
|
|
770
|
+
g as residue,
|
|
771
|
+
j as rot32,
|
|
764
772
|
w as rot64,
|
|
765
|
-
|
|
773
|
+
J as sameValueZero,
|
|
766
774
|
it as setTimeoutPromise,
|
|
767
|
-
|
|
768
|
-
|
|
775
|
+
k as sleep,
|
|
776
|
+
$ as toBase64,
|
|
769
777
|
ft as toBase64Url,
|
|
770
|
-
|
|
771
|
-
|
|
778
|
+
gt as toOct,
|
|
779
|
+
Y as withResolvers
|
|
772
780
|
};
|
package/dist/bundle.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var UtilFns=(function(c){"use strict";const
|
|
2
|
-
`&&!s?(e.push(r.trim()),t.push(e),e=[],r=""):r+=i}return e.push(r.trim()),t.push(e),t},k=async(n,t)=>{const e=$.encode(n),r=await crypto.subtle.digest(t,e);return new Uint8Array(r)},z=n=>encodeURIComponent(n).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),H=n=>{if(n.includes("+"))throw Error("An input string has '+'");return decodeURIComponent(n)},J=async(n,t)=>{const r=new Blob([n]).stream().pipeThrough(new CompressionStream(t));return new Response(r).bytes()},Y=async(n,t)=>{const r=new Blob([n]).stream().pipeThrough(new DecompressionStream(t));return new Response(r).bytes()},Z=(n,t)=>new Promise((e,r)=>{setTimeout(async()=>{try{const s=await n();e(s)}catch(s){r(s)}},t)}),N="NamedError";class y extends Error{constructor(t,e,r){super(e,r),this.errName=t}static name=N;toJSON(){const t=(()=>{const o=this.cause;if(o!=null)return typeof o=="string"||typeof o=="number"||typeof o=="boolean"?o:typeof o=="bigint"?o.toString():typeof o=="object"?o instanceof Set||o instanceof Map?Object.fromEntries(o):o:void 0})(),{errName:e,message:r,stack:s}=this;return{errName:e,message:r,stack:s,cause:t}}}Object.defineProperty(y.prototype,Symbol.toStringTag,{value:N});const Q=(n,t)=>Math.floor(Math.random()*(t-n)+n),d=(n,t)=>{t<0n&&(t*=-1n);const e=n%t;return e<0n?e+t:e},I=(n,t=!1)=>{if(!Number.isFinite(n))throw Error("`length` is not a valid number");if(n<=0)throw Error("`length` must be positive");const e=Math.ceil(n/8),r=crypto.getRandomValues(new Uint8Array(e));let s=Array.from(r,o=>o.toString(2).padStart(8,"0")).join("").slice(0,n);return t&&(s=s.replace(/^\d/,"1")),BigInt("0b"+s)},R=(n,t)=>{if(n>=t)throw new y("RangeError","min is larger than max");const e=t-n,r=e.toString(2).length,s=(()=>{for(let i=0;i<1e5;i++){const a=I(r);if(a>=g(2n,BigInt(r),e))return a%e}throw Error("Failed to generate a random bigint")})();return n+s},g=(n,t,e)=>{if(e<1n)throw Error("`mod` must be positive");if(t<0n)throw Error("`power` must not be negative");if(n=d(n,e),e===1n)return 0n;if(n%e===1n||n%e===0n)return n;if(n===e-1n)return t&1n?e-1n:1n;let r=1n;for(;t>0n;)t&1n&&(r=r*n%e),n=n*n%e,t>>=1n;return r},v=(n,t)=>{if(n===0n&&t===0n)return{x:0n,y:0n,gcd:0n};if(n===0n)return t>0n?{x:0n,y:-1n,gcd:t}:{x:0n,y:1n,gcd:-t};if(t===0n)return n>0n?{x:1n,y:0n,gcd:n}:{x:-1n,y:0n,gcd:-n};let[e,r,s]=[1n,0n,n],[o,i,a]=[0n,-1n,t];for(;;){const l=s/a,f=s-l*a;if(f===0n)break;[e,o]=[o,e-l*o],[r,i]=[i,r-l*i],[s,a]=[a,f]}return a<0n&&(o*=-1n,i*=-1n,a*=-1n),{x:o,y:i,gcd:a}},w=(n,t)=>{if(n>=t)return 1n;const e=BigInt((t-2n).toString(2).length),r=(t-n)/2n;if(e*r<63n){let a=n;for(let l=n+2n;l<t;l+=2n)a*=l;return a}const s=n+r|1n,o=w(n,s),i=w(s,t);return o*i},x=n=>{let t=3n,e=1n,r=1n;const s=BigInt(n.toString(2).length)-1n;for(let o=s-1n;o>-1n;--o){const i=(n>>o)+1n|1n;r*=w(t,i),t=i,e*=r}return e},tt=n=>{if(n<0n)throw Error("'n' must be non-negative");if(n===0n)return 1n;const t=n-BigInt(n.toString(2).match(/1/g)?.length??0);return x(n)<<t},L=(n,t)=>(n>>>(t&31)|n<<(-t&31))>>>0,B=(n,t)=>BigInt.asUintN(64,n>>(t&63n)|n<<(-t&63n)),E=(n,t)=>{if(t<1n||t%2n===0n)throw Error("`n` is invalid");for(;n<0n;)n+=t;n%=t;let e=1n;for(;n!==0n;){for(;n%2n===0n;){n/=2n;const r=t%8n;(r===3n||r===5n)&&(e*=-1n)}[n,t]=[t,n],n%4n===3n&&t%4n===3n&&(e*=-1n),n%=t}return t===1n?e:0n},M=n=>{if(n<0n)return!1;if(n===0n)return!0;let t=1n,e=n;for(;t+1n<e;){const r=(t+e)/2n;r*r<n?t=r:e=r}return n===t**2n||n===(t+1n)**2n},nt=n=>{if(n<=1n)return!1;if(n%2n===0n)return n===2n;let t=n-1n,e=0n;for(;t%2n===0n;)t>>=1n,e+=1n;const[r,s]=[t,e];let i=g(2n,r,n);if(i===1n)return!0;for(let a=0n;a<s;a++){if(i===n-1n)return!0;i=i*i%n}return!1},et=n=>{let t=5n,e=E(t,n);for(;e>0n;){if(t=t>0n?t+2n:t-2n,t*=-1n,t===-15n&&M(n))return[0n,0n];e=E(t,n)}return[t,e]},b=(n,t)=>(n&1n)===1n?d(n+t>>1n,t):d(n>>1n,t),rt=(n,t,e,r)=>{let s=1n,o=e;const i=n.toString(2).slice(1);for(const a of i)[s,o]=[d(s*o,t),b(o*o+r*s*s,t)],a==="1"&&([s,o]=[b(e*s+o,t),b(r*s+e*o,t)]);return[s,o]},st=(n,t,e,r)=>{if(n%2n!==1n)throw Error("`n` must be odd");let s=n+1n,o=0n;for(;s%2n===0n;)s>>=1n,o+=1n;const[i,a]=rt(s,n,e,t);let l=a;if(i===0n)return!0;r=g(r,s,n);for(let f=0n;f<o;f++){if(l===0n)return!0;l=d(l*l-2n*r,n),r=g(r,2n,n)}return!1},S=n=>{if(n<=1n)return!1;if(n%2n===0n)return n===2n;const t=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n];for(const o of t)if(n%o===0n)return n===o;if(!nt(n))return!1;const[e,r]=et(n);if(r===0n)return!1;const s=(1n-e)/4n;return st(n,e,1n,s)},ot=(n,t)=>{if(t<2n)throw Error("NoPrimesFound");for(let r=0;r<1e5;r++){const s=R(n,t);if(S(s))return s}throw Error("NoPrimesFound")},it=(n,t=!1)=>{if(n<2)throw Error("NoPrimesFound");for(let r=0;r<1e5;r++){const s=I(n,t);if(S(s))return s}throw Error("NoPrimesFound")},A="Rational";class u{#t;#n;static name=A;constructor(t,e){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()}static fromDecimal(t,e=5){if(Number.isNaN(t))return new u(0n,0n);if(Math.abs(t)===1/0)return new u(t>0?1n:-1n,0n);const r=t<0;r&&(t*=-1);const s=BigInt(Math.floor(t)),o=t-Number(s);if(o===0)return new u(r?-s:s,1n);t=1/o;let[i,a]=[1n,s],[l,f]=[0n,1n];for(;`${f}`.length<e+1;){const m=BigInt(Math.floor(t)),p=t-Number(m);if([i,a]=[a,m*a+i],[l,f]=[f,m*f+l],p===0)return new u(r?-a:a,f);t=1/p}return new u(r?-i:i,l)}#e(){const{gcd:t}=v(this.#t,this.#n);t!==0n&&(this.#t/=t,this.#n/=t)}minus(){return new u(-this.#t,this.#n)}inverse(){return new u(this.#n,this.#t)}add(t){const e=this.#n*t.#n,r=this.#t*t.#n+t.#t*this.#n;return new u(r,e)}substr(t){return this.add(t.minus())}multiply(t){const e=this.#n*t.#n,r=this.#t*t.#t;return new u(r,e)}divide(t){return this.multiply(t.inverse())}mediant(t){const e=this.#n+t.#n,r=this.#t+t.#t;return new u(r,e)}toDecimal(){return Number(this.#t)/Number(this.#n)}toString(){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}`}valueOf(){return this.toDecimal()}toJSON(){return{type:"Rational",value:["0x"+this.#t.toString(16),"0x"+this.#n.toString(16)]}}static fromData(t){const e=BigInt(t.value[0]),r=BigInt(t.value[1]);return new u(e,r)}static parse(t){const r=/^\s*(\d+)\s*\/\s*(\d+)\s*$/.exec(t);if(!r)throw Error("cannot parse");const s=r.at(1),o=r.at(2);if(!s||!o)throw Error("cannot parse");return new u(BigInt(s),BigInt(o))}}Object.defineProperty(u.prototype,Symbol.toStringTag,{value:A});const T=n=>{const t=Array.from(n,e=>String.fromCharCode(e));return btoa(t.join(""))},P=n=>{const t=atob(n);return Uint8Array.from(t,e=>e.charCodeAt(0))},ct=n=>T(n).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,""),at=n=>{const t=n.length&3;t>0&&(n=n+"=".repeat(4-t));const e=n.replaceAll("-","+").replaceAll("_","/");return P(e)},lt=n=>{let t=Array.from(n,o=>o.toString(16).padStart(2,"0")).join("");const e=t.length%6;e&&(t="0".repeat(6-e)+t);const r=t.matchAll(/.{6}/g);return Array.from(r,o=>Number.parseInt(o[0],16).toString(8).padStart(8,"0")).join("").replace(/^0+/,"")},ut=n=>{const t=n.length&7;t&&(n="0".repeat(8-t)+n);const e=n.matchAll(/.{8}/g),s=Array.from(e,o=>{const i=o[0];return Number.parseInt(i,8).toString(16).padStart(6,"0")}).join("").matchAll(/.{2}/g);return Uint8Array.from(s,o=>Number.parseInt(o[0],16))},ft=n=>{const t=n<0n;t&&(n*=-1n);const e=n.toString(2).length,r=n===1n<<BigInt(e-1)&&!(e%7)&&t,s=Math.floor(e/7)+1;return r?s-1:s},ht=n=>{const t=ft(n);n=BigInt.asUintN(t*7,n);const e=new Uint8Array(t);for(let s=0;s<t-1;++s){const o=Number(n&127n)|128;e[s]=o,n>>=7n}const r=Number(n&127n);return e[t-1]=r,n>>=7n,e},dt=n=>{const t=n.length;let e=0n;for(let r=0;r<t;++r){const s=BigInt(n[r]&127);e+=s<<BigInt(7*r)}return BigInt.asIntN(7*t,e)},C=n=>{if(n===0n)return 64n;let t=0n;for(;n>0n&&!(n&1n);)++t,n>>=1n;return BigInt.asUintN(64,t)},j=(n,t)=>{const e=0n,r=1023n,s=n&0x7ffn;let o=r-1n;if(s>0n)return o-=C(s),o;o-=11n;const i=1e5;for(let a=0;a<i;++a){const l=t();if(l>0n)return o-=C(l),o;if(o-=64n,o<e)return e}throw Error("loop exceeded limit")},gt=n=>{const t=()=>BigInt.asUintN(64,n()),e=()=>{const r=t(),s=BigInt.asUintN(52,r>>11n),i=s===0n&&r>>63n===1n?j(r,t)+1n:j(r,t),{buffer:a}=BigUint64Array.from([i<<52n|s]);return new Float64Array(a)[0]};return()=>{for(let s=0;s<1e5;++s){const o=e();if(o<1)return o}throw Error("Loop limit exceeded")}},mt=[0x853c49e6748fea9bn,0xda3e39cb94b95bdbn],yt=0x5851f42d4c957f2dn,O="PCGMinimal";class _{#t;static name=O;constructor(t){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(mt)}#n(){this.#t[0]=this.#t[0]*yt+this.#t[1]}get#e(){const t=this.#t[0],e=Number(t>>59n),r=Number(BigInt.asUintN(32,(t^t>>18n)>>27n));return L(r,e)}getRandU32(){return this.#n(),this.#e}getBoundedRandU32(t){if(t>4294967296)throw Error("`bound` exceeded limit (2^32)");if(t<=0)throw Error("'bound' must be positive");const r=4294967296%t,s=1e5;for(let o=0;o<s;++o){const i=this.getRandU32();if(i>=r)return i%t}throw Error("exceeded loop limit")}*genRandU32s(t,e){if(t<=0)throw Error("'step' must be positive");for(let r=0;r<t;r++)yield typeof e=="number"?this.getBoundedRandU32(e):this.getRandU32()}}Object.defineProperty(_.prototype,Symbol.toStringTag,{value:O});const pt=[0xbe562cb412e2260en,0x2e4284137d641affn,0x4e19b36ee933e27en,0x7581cf8c4f4d4f7dn];class U{bits=64;#t;static name="XoshiroMinimal";constructor(t){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(pt)}#n(){const t=this.#t[1]<<17n;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)}get value(){const t=B(this.#t[0]+this.#t[3],23n)+this.#t[0];return BigInt.asUintN(64,t)}getRandU64(){const t=this.value;return this.#n(),t}getRandU32(){const t=BigInt.asUintN(32,this.getRandU64());return Number(t)}getBoundedRandU64(t){const e=1n<<64n;if(t>e)throw Error("'bound' exceeded limit");if(t<=0n)throw Error("'bound' must be positive");const r=e%t,s=1e5;for(let o=0;o<s;++o){const i=this.getRandU64();if(i>=r)return i%t}throw Error("exceeded loop limit")}getBoundedRandU32(t){if(t>4294967296)throw Error("'bound' exceeded limit");if(t<=0n)throw Error("'bound' must be positive");const r=this.getBoundedRandU64(BigInt(t));return Number(r)}*genRandU64s(t,e){if(t<=0)throw Error("'step' must be positive");for(let r=0;r<t;++r)yield e===void 0?this.getRandU64():this.getBoundedRandU64(e)}*genRandU32s(t,e){if(t<=0)throw Error("'step' must be positive");for(let r=0;r<t;++r)yield e===void 0?this.getRandU32():this.getBoundedRandU32(e)}}Object.defineProperty(U.prototype,Symbol.toStringTag,{value:U.name});const F="WorkerStream";class V extends ReadableStream{close;#t;static name=F;constructor(t,e){let r,s,o;super({start:i=>{r=a=>{i.enqueue(a.data)},s=a=>{t.removeEventListener("message",r),t.removeEventListener("error",s);const l=new y("WorkerStreamError",a.message,{cause:a.error});i.error(l)},o=()=>{t.removeEventListener("message",r),t.removeEventListener("error",s),i.close()},t.addEventListener("message",r),t.addEventListener("error",s)},cancel:i=>{console.log("Canceled reason:",i),t.removeEventListener("message",r),t.removeEventListener("error",s)}},e),this.close=o,this.#t=t}postMessage(t,e){this.#t.postMessage(t,e)}}return Object.defineProperty(V.prototype,Symbol.toStringTag,{value:F}),c.NamedError=y,c.PCGMinimal=_,c.Rational=u,c.WorkerStream=V,c.XoshiroMinimal=U,c.bailliePSW=S,c.compress=J,c.decodeLEB128=dt,c.decodeRFC3986URIComponent=H,c.decompress=Y,c.encodeLEB128=ht,c.encodeRFC3986URIComponent=z,c.exEuclidean=v,c.factorial=tt,c.floatRng=gt,c.fromBase64=P,c.fromBase64Url=at,c.fromOct=ut,c.getHash=k,c.getRandBIByBitLength=I,c.getRandBIByRange=R,c.getRandPrimeByBitLength=it,c.getRandPrimeByRange=ot,c.getRndInt=Q,c.getStringTag=W,c.isDeepStrictEqual=h,c.isSquare=M,c.jacobiSymbol=E,c.lazify=G,c.modPow=g,c.parseCSV=X,c.residue=d,c.rot32=L,c.rot64=B,c.sameValueZero=D,c.setTimeoutPromise=Z,c.sleep=K,c.toBase64=T,c.toBase64Url=ct,c.toOct=lt,c.withResolvers=q,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),c})({});
|
|
1
|
+
var UtilFns=(function(c){"use strict";const D=(n,t)=>[n].includes(t),h=(n,t)=>{if(typeof n!=typeof t)return!1;const e=Object.prototype.toString.call(n),r=Object.prototype.toString.call(t);if(e!==r)return!1;if(typeof n=="string"||typeof n=="bigint"||typeof n=="boolean"||typeof n=="symbol"||n==null)return n===t;if(typeof n=="number")return n!==n&&t!==t||n===t;if(typeof n=="function")return!1;if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return!1;for(let s=0;s<n.length;s++)if(!h(n[s],t[s]))return!1;return!0}if(n instanceof Set&&t instanceof Set){const s=[...n.values()],o=[...t.values()];return!!h(s,o)}if(n instanceof Map&&t instanceof Map){const s=[...n.keys()],o=[...t.keys()];if(!h(s,o))return!1;const i=[...n.values()],l=[...t.values()];return!!h(i,l)}if(e==="[object Object]"){const s=n,o=t,i=Object.keys(s),l=Object.keys(o);for(const a of i){const f=l.find(It=>It===a);if(f===void 0)return!1;const[m,y]=[s[a],o[f]];if(!h(m,y))return!1}return!0}throw TypeError(`comparing these objects is unavailable: ${n}, ${t}`,{cause:[n,t]})},q=()=>{let n,t;return{promise:new Promise((r,s)=>{n=r,t=s}),resolve:n,reject:t}},K=n=>new Promise(t=>{setTimeout(t,n)}),G=n=>Object.prototype.toString.call(n).slice(8,-1),W=n=>(...t)=>()=>n(...t),X=n=>{const t=[];let e=[],r="",s=!1;for(let o=0;o<n.length;o++){const i=n[o];i==='"'&&(o===0||n[o-1]!=="\\")?s=!s:i===","&&!s?(e.push(r.trim()),r=""):i===`
|
|
2
|
+
`&&!s?(e.push(r.trim()),t.push(e),e=[],r=""):r+=i}return e.push(r.trim()),t.push(e),t},x=async(n,t)=>{const e=new TextEncoder().encode(n),r=await crypto.subtle.digest(t,e);return new Uint8Array(r)},z=n=>encodeURIComponent(n).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),H=n=>{if(n.includes("+"))throw URIError("an input string must not include `+`");return decodeURIComponent(n)},k=(n,t)=>{const e=new Blob([n]).stream().pipeThrough(new CompressionStream(t));return new Response(e).bytes()},J=(n,t)=>{const e=new Blob([n]).stream().pipeThrough(new DecompressionStream(t));return new Response(e).bytes()},Y=(n,t)=>new Promise((e,r)=>{setTimeout(async()=>{try{const s=await n();e(s)}catch(s){r(s)}},t)}),Z=(n,t)=>Math.floor(Math.random()*(t-n)+n),g=(n,t)=>{t<0n&&(t*=-1n);const e=n%t;return e<0n?e+t:e},p=(n,t=!1)=>{if(!Number.isFinite(n))throw RangeError("`length` is not a valid number");if(n<=0)throw RangeError("`length` must be positive");const e=Math.ceil(n/8),r=crypto.getRandomValues(new Uint8Array(e));let s=Array.from(r,o=>o.toString(2).padStart(8,"0")).join("").slice(0,n);return t&&(s=s.replace(/^\d/,"1")),BigInt("0b"+s)},R=(n,t)=>{if(n>=t)throw RangeError("`min` must be smaller than `max`");const e=t-n,r=e.toString(2).length,s=(()=>{for(let i=0;i<1e5;i++){const l=p(r);if(l>=d(2n,BigInt(r),e))return l%e}throw Error("Failed to generate a random bigint")})();return n+s},d=(n,t,e)=>{if(e<1n)throw RangeError("`mod` must be positive");if(t<0n)throw RangeError("`power` must not be negative");if(n=g(n,e),e===1n)return 0n;if(n%e===1n||n%e===0n)return n;if(n===e-1n)return t&1n?e-1n:1n;let r=1n;for(;t>0n;)t&1n&&(r=r*n%e),n=n*n%e,t>>=1n;return r},S=(n,t)=>{if(n===0n&&t===0n)return{x:0n,y:0n,gcd:0n};if(n===0n)return t>0n?{x:0n,y:-1n,gcd:t}:{x:0n,y:1n,gcd:-t};if(t===0n)return n>0n?{x:1n,y:0n,gcd:n}:{x:-1n,y:0n,gcd:-n};let[e,r,s]=[1n,0n,n],[o,i,l]=[0n,-1n,t];for(;;){const a=s/l,f=s-a*l;if(f===0n)break;[e,o]=[o,e-a*o],[r,i]=[i,r-a*i],[s,l]=[l,f]}return l<0n&&(o*=-1n,i*=-1n,l*=-1n),{x:o,y:i,gcd:l}},I=(n,t)=>{if(n>=t)return 1n;const e=BigInt((t-2n).toString(2).length),r=(t-n)/2n;if(e*r<63n){let l=n;for(let a=n+2n;a<t;a+=2n)l*=a;return l}const s=n+r|1n,o=I(n,s),i=I(s,t);return o*i},Q=n=>{let t=3n,e=1n,r=1n;const s=BigInt(n.toString(2).length)-1n;for(let o=s-1n;o>-1n;--o){const i=(n>>o)+1n|1n;r*=I(t,i),t=i,e*=r}return e},tt=n=>{if(n<0n)throw RangeError("'n' must be non-negative");if(n===0n)return 1n;const t=n-BigInt(n.toString(2).match(/1/g)?.length??0);return Q(n)<<t},U=(n,t)=>(n>>>(t&31)|n<<(-t&31))>>>0,w=(n,t)=>BigInt.asUintN(64,n>>(t&63n)|n<<(-t&63n)),E=(n,t)=>{if(t<1n||t%2n===0n)throw RangeError("`n` is out of range");for(;n<0n;)n+=t;n%=t;let e=1n;for(;n!==0n;){for(;n%2n===0n;){n/=2n;const r=t%8n;(r===3n||r===5n)&&(e*=-1n)}[n,t]=[t,n],n%4n===3n&&t%4n===3n&&(e*=-1n),n%=t}return t===1n?e:0n},N=n=>{if(n<0n)return!1;if(n===0n)return!0;let t=1n,e=n;for(;t+1n<e;){const r=(t+e)/2n;r*r<n?t=r:e=r}return n===t**2n||n===(t+1n)**2n},nt=n=>{if(n<=1n)return!1;if(n%2n===0n)return n===2n;let t=n-1n,e=0n;for(;t%2n===0n;)t>>=1n,e+=1n;const[r,s]=[t,e];let i=d(2n,r,n);if(i===1n)return!0;for(let l=0n;l<s;l++){if(i===n-1n)return!0;i=i*i%n}return!1},et=n=>{let t=5n,e=E(t,n);for(;e>0n;){if(t=t>0n?t+2n:t-2n,t*=-1n,t===-15n&&N(n))return[0n,0n];e=E(t,n)}return[t,e]},b=(n,t)=>(n&1n)===1n?g(n+t>>1n,t):g(n>>1n,t),rt=(n,t,e,r)=>{let s=1n,o=e;const i=n.toString(2).slice(1);for(const l of i)[s,o]=[g(s*o,t),b(o*o+r*s*s,t)],l==="1"&&([s,o]=[b(e*s+o,t),b(r*s+e*o,t)]);return[s,o]},st=(n,t,e,r)=>{if(n%2n!==1n)throw RangeError("`n` must be odd");let s=n+1n,o=0n;for(;s%2n===0n;)s>>=1n,o+=1n;const[i,l]=rt(s,n,e,t);let a=l;if(i===0n)return!0;r=d(r,s,n);for(let f=0n;f<o;f++){if(a===0n)return!0;a=g(a*a-2n*r,n),r=d(r,2n,n)}return!1},B=n=>{if(n<=1n)return!1;if(n%2n===0n)return n===2n;const t=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n];for(const o of t)if(n%o===0n)return n===o;if(!nt(n))return!1;const[e,r]=et(n);if(r===0n)return!1;const s=(1n-e)/4n;return st(n,e,1n,s)},ot=(n,t)=>{if(t<2n)throw RangeError("`max` must be 2 or larger");for(let r=0;r<1e5;r++){const s=R(n,t);if(B(s))return s}throw Error("No primes were found")},it=(n,t=!1)=>{if(n<2)throw RangeError("`bitLength` must be 2 or larger");for(let r=0;r<1e5;r++){const s=p(n,t);if(B(s))return s}throw Error("NoPrimesFound")},v="Rational";class u{#t;#n;static name=v;constructor(t,e){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()}static fromDecimal(t,e=5){if(Number.isNaN(t))return new u(0n,0n);if(Math.abs(t)===1/0)return new u(t>0?1n:-1n,0n);const r=t<0;r&&(t*=-1);const s=BigInt(Math.floor(t)),o=t-Number(s);if(o===0)return new u(r?-s:s,1n);t=1/o;let[i,l]=[1n,s],[a,f]=[0n,1n];for(;`${f}`.length<e+1;){const m=BigInt(Math.floor(t)),y=t-Number(m);if([i,l]=[l,m*l+i],[a,f]=[f,m*f+a],y===0)return new u(r?-l:l,f);t=1/y}return new u(r?-i:i,a)}#e(){const{gcd:t}=S(this.#t,this.#n);t!==0n&&(this.#t/=t,this.#n/=t)}minus(){return new u(-this.#t,this.#n)}inverse(){return new u(this.#n,this.#t)}add(t){const e=this.#n*t.#n,r=this.#t*t.#n+t.#t*this.#n;return new u(r,e)}substr(t){return this.add(t.minus())}multiply(t){const e=this.#n*t.#n,r=this.#t*t.#t;return new u(r,e)}divide(t){return this.multiply(t.inverse())}mediant(t){const e=this.#n+t.#n,r=this.#t+t.#t;return new u(r,e)}toDecimal(){return Number(this.#t)/Number(this.#n)}toString(){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}`}valueOf(){return this.toDecimal()}toJSON(){return{type:"Rational",value:["0x"+this.#t.toString(16),"0x"+this.#n.toString(16)]}}static fromData(t){const e=BigInt(t.value[0]),r=BigInt(t.value[1]);return new u(e,r)}static parse(t){const r=/^\s*(\d+)\s*\/\s*(\d+)\s*$/.exec(t);if(!r)throw Error("cannot parse");const s=r.at(1),o=r.at(2);if(!s||!o)throw Error("cannot parse");return new u(BigInt(s),BigInt(o))}}Object.defineProperty(u.prototype,Symbol.toStringTag,{value:v});const L=n=>{const t=Array.from(n,e=>String.fromCharCode(e));return btoa(t.join(""))},T=n=>{const t=atob(n);return Uint8Array.from(t,e=>e.charCodeAt(0))},ct=n=>L(n).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,""),lt=n=>{const t=4-(n.length&3)&3,e=n.concat("=".repeat(t)).replaceAll("-","+").replaceAll("_","/");return T(e)},at=n=>{const t=Array.from(n,i=>i.toString(16).padStart(2,"0")).join(""),e=(6-t.length%6)%6,s="0".repeat(e).concat(t).matchAll(/.{6}/g);return Array.from(s,i=>Number.parseInt(i[0],16).toString(8).padStart(8,"0")).join("").replace(/^0+/,"")},ut=n=>{const t=8-(n.length&7)&7,r="0".repeat(t).concat(n).matchAll(/.{8}/g),o=Array.from(r,i=>Number.parseInt(i[0],8).toString(16).padStart(6,"0")).join("").matchAll(/.{2}/g);return Uint8Array.from(o,i=>Number.parseInt(i[0],16))},M="NamedError";class A extends Error{static name=M;errName;constructor(t,e,r){super(e,r),this.errName=t}toJSON(){const t=(()=>{const o=this.cause;if(o!=null)return typeof o=="string"||typeof o=="number"||typeof o=="boolean"?o:typeof o=="bigint"?o.toString():typeof o=="object"?o instanceof Set||o instanceof Map?Object.fromEntries(o):o:void 0})(),{errName:e,message:r,stack:s}=this;return{name:e,message:r,stack:s,cause:t}}}Object.defineProperty(A.prototype,Symbol.toStringTag,{value:M});const P=n=>{if(n===0n)return 64n;let t=0n;for(;n>0n&&!(n&1n);)++t,n>>=1n;return BigInt.asUintN(64,t)},C=(n,t)=>{const e=0n,r=1023n,s=n&0x7ffn;let o=r-1n;if(s>0n)return o-=P(s),o;o-=11n;const i=1e5;for(let l=0;l<i;++l){const a=t();if(a>0n)return o-=P(a),o;if(o-=64n,o<e)return e}throw Error("loop exceeded limit")},ft=n=>{const t=()=>BigInt.asUintN(64,n()),e=()=>{const r=t(),s=BigInt.asUintN(52,r>>11n),i=s===0n&&r>>63n===1n?C(r,t)+1n:C(r,t),{buffer:l}=BigUint64Array.from([i<<52n|s]),a=new Float64Array(l)[0];if(a==null)throw Error("unexpected");return a};return()=>{for(let s=0;s<1e5;++s){const o=e();if(o<1)return o}throw Error("Loop limit exceeded")}},ht=[0x853c49e6748fea9bn,0xda3e39cb94b95bdbn],gt=0x5851f42d4c957f2dn,j="PCGMinimal";class O{#t;static name=j;constructor(t){if(t&&t[0]!=null&&t[1]!=null){if(this.#t=new BigUint64Array(2),this.#t[0]==null||this.#t[1]==null)throw TypeError("unexpected");this.#t[1]=t[1]<<1n|1n,this.#n(),this.#t[0]+=t[0],this.#n()}else this.#t=BigUint64Array.from(ht)}#n(){if(this.#t[0]==null||this.#t[1]==null)throw TypeError("unexpected");this.#t[0]=this.#t[0]*gt+this.#t[1]}get#e(){if(this.#t[0]==null||this.#t[1]==null)throw TypeError("unexpected");const t=this.#t[0],e=Number(t>>59n),r=Number(BigInt.asUintN(32,(t^t>>18n)>>27n));return U(r,e)}getRandU32(){return this.#n(),this.#e}getBoundedRandU32(t){if(t>4294967296)throw RangeError("`bound` exceeded limit (2^32)");if(t<=0)throw RangeError("'bound' must be positive");const r=4294967296%t,s=1e5;for(let o=0;o<s;++o){const i=this.getRandU32();if(i>=r)return i%t}throw Error("exceeded loop limit")}*genRandU32s(t,e){if(t<=0)throw RangeError("'step' must be positive");for(let r=0;r<t;r++)yield typeof e=="number"?this.getBoundedRandU32(e):this.getRandU32()}}Object.defineProperty(O.prototype,Symbol.toStringTag,{value:j});const dt=[0xbe562cb412e2260en,0x2e4284137d641affn,0x4e19b36ee933e27en,0x7581cf8c4f4d4f7dn],_="XoshiroMinimal";class V{bits=64;#t;static name=_;constructor(t){if(t&&t[0]!=null&&t[1]!=null&&t[2]!=null&&t[3]!=null){if(this.#t=new BigUint64Array(4),this.#t[0]=t[0],this.#t[1]=t[1],this.#n(),this.#t[2]==null||this.#t[3]==null)throw TypeError("unexpected");this.#t[2]+=t[2],this.#t[3]+=t[3]}else this.#t=BigUint64Array.from(dt)}#n(){if(this.#t[0]==null||this.#t[1]==null||this.#t[2]==null||this.#t[3]==null)throw TypeError("unexpected");const t=this.#t[1]<<17n;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]=w(this.#t[3],45n)}get value(){if(this.#t[0]==null||this.#t[3]==null)throw TypeError("unexpected");const t=w(this.#t[0]+this.#t[3],23n)+this.#t[0];return BigInt.asUintN(64,t)}getRandU64(){const t=this.value;return this.#n(),t}getRandU32(){const t=BigInt.asUintN(32,this.getRandU64());return Number(t)}getBoundedRandU64(t){const e=1n<<64n;if(t>e)throw RangeError("`bound` exceeded limit");if(t<=0n)throw RangeError("`bound` must be positive");const r=e%t,s=1e5;for(let o=0;o<s;++o){const i=this.getRandU64();if(i>=r)return i%t}throw Error("exceeded loop limit")}getBoundedRandU32(t){if(t>4294967296)throw RangeError("`bound` exceeded limit");if(t<=0n)throw RangeError("`bound` must be positive");const r=this.getBoundedRandU64(BigInt(t));return Number(r)}*genRandU64s(t,e){if(t<=0)throw RangeError("`step` must be positive");for(let r=0;r<t;++r)yield e===void 0?this.getRandU64():this.getBoundedRandU64(e)}*genRandU32s(t,e){if(t<=0)throw RangeError("`step` must be positive");for(let r=0;r<t;++r)yield e===void 0?this.getRandU32():this.getBoundedRandU32(e)}}Object.defineProperty(V.prototype,Symbol.toStringTag,{value:_});const $="WorkerStream";class F extends ReadableStream{close;#t;static name=$;constructor(t,e){let r,s,o;super({start:i=>{r=l=>{i.enqueue(l.data)},s=l=>{t.removeEventListener("message",r),t.removeEventListener("error",s),i.error(Error(l.message,{cause:l.error}))},o=()=>{t.removeEventListener("message",r),t.removeEventListener("error",s),i.close()},t.addEventListener("message",r),t.addEventListener("error",s)},cancel:()=>{t.removeEventListener("message",r),t.removeEventListener("error",s)}},e),this.close=o,this.#t=t}postMessage=(t,e)=>{this.#t.postMessage(t,e)}}Object.defineProperty(F.prototype,Symbol.toStringTag,{value:$});const mt=n=>{const t=n<0n;t&&(n*=-1n);const e=n.toString(2).length,r=n===1n<<BigInt(e-1)&&!(e%7)&&t,s=Math.floor(e/7)+1;return r?s-1:s},yt=n=>{const t=mt(n);n=BigInt.asUintN(t*7,n);const e=new Uint8Array(t);for(let s=0;s<t-1;++s){const o=Number(n&127n)|128;e[s]=o,n>>=7n}const r=Number(n&127n);return e[t-1]=r,n>>=7n,e},pt=n=>{const t=n.length;let e=0n;for(const[r,s]of n.entries()){const o=BigInt(s&127);e+=o<<BigInt(7*r)}return BigInt.asIntN(7*t,e)};return c.NamedError=A,c.PCGMinimal=O,c.Rational=u,c.WorkerStream=F,c.XoshiroMinimal=V,c.bailliePSW=B,c.compress=k,c.decodeLEB128=pt,c.decodeRFC3986URIComponent=H,c.decompress=J,c.encodeLEB128=yt,c.encodeRFC3986URIComponent=z,c.exEuclidean=S,c.factorial=tt,c.floatRng=ft,c.fromBase64=T,c.fromBase64Url=lt,c.fromOct=ut,c.getHash=x,c.getRandBIByBitLength=p,c.getRandBIByRange=R,c.getRandPrimeByBitLength=it,c.getRandPrimeByRange=ot,c.getRndInt=Z,c.getStringTag=G,c.isDeepStrictEqual=h,c.isSquare=N,c.jacobiSymbol=E,c.lazify=W,c.modPow=d,c.parseCSV=X,c.residue=g,c.rot32=U,c.rot64=w,c.sameValueZero=D,c.setTimeoutPromise=Y,c.sleep=K,c.toBase64=L,c.toBase64Url=ct,c.toOct=at,c.withResolvers=q,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),c})({});
|
package/dist/fraction.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface RationalData {
|
|
2
2
|
type: 'Rational';
|
|
3
3
|
/** `[numerator, denominator]` */
|
|
4
4
|
value: [string, string];
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
6
|
export declare class Rational {
|
|
7
7
|
#private;
|
|
8
8
|
static readonly name = "Rational";
|
|
@@ -54,9 +54,9 @@ export declare class Rational {
|
|
|
54
54
|
divide(right: Rational): Rational;
|
|
55
55
|
/**
|
|
56
56
|
* returns mediant
|
|
57
|
-
* @param this `a/b`
|
|
58
|
-
* @param right `c/d`
|
|
59
|
-
* @returns `(a+c)/(b+d)`
|
|
57
|
+
* @param this `a / b`
|
|
58
|
+
* @param right `c / d`
|
|
59
|
+
* @returns `(a + c) / (b + d)`
|
|
60
60
|
*/
|
|
61
61
|
mediant(right: Rational): Rational;
|
|
62
62
|
/**
|
package/dist/leb128.d.ts
ADDED
package/dist/main.d.ts
CHANGED
package/dist/math.d.ts
CHANGED
|
@@ -51,8 +51,8 @@ export declare const exEuclidean: (a: bigint, b: bigint) => {
|
|
|
51
51
|
/**
|
|
52
52
|
* returns factorial of an input \
|
|
53
53
|
* ref: https://qiita.com/AkariLuminous/items/1b2e964ebabde9419224
|
|
54
|
-
* @param n
|
|
55
|
-
* @returns
|
|
54
|
+
* @param n integer
|
|
55
|
+
* @returns factorial of `n`
|
|
56
56
|
*/
|
|
57
57
|
export declare const factorial: (n: bigint) => bigint;
|
|
58
58
|
/**
|
package/dist/named_error.d.ts
CHANGED
|
@@ -4,11 +4,11 @@ interface NamedError<EName extends string> {
|
|
|
4
4
|
readonly cause?: unknown;
|
|
5
5
|
}
|
|
6
6
|
declare class NamedError<EName extends string> extends Error {
|
|
7
|
-
readonly errName: EName;
|
|
8
7
|
static readonly name = "NamedError";
|
|
8
|
+
readonly errName: EName;
|
|
9
9
|
constructor(errName: EName, message: string, options?: ErrorOptions);
|
|
10
10
|
toJSON(): {
|
|
11
|
-
|
|
11
|
+
name: EName;
|
|
12
12
|
message: string;
|
|
13
13
|
stack: string | undefined;
|
|
14
14
|
cause: string | number | boolean | object | undefined;
|
package/dist/u8arr_ext.d.ts
CHANGED
|
@@ -4,5 +4,3 @@ export declare const toBase64Url: (bin: Uint8Array) => string;
|
|
|
4
4
|
export declare const fromBase64Url: (base64Url: string) => Uint8Array<ArrayBuffer>;
|
|
5
5
|
export declare const toOct: (bin: Uint8Array) => string;
|
|
6
6
|
export declare const fromOct: (oct: string) => Uint8Array<ArrayBuffer>;
|
|
7
|
-
export declare const encodeLEB128: (bigint: bigint) => Uint8Array<ArrayBuffer>;
|
|
8
|
-
export declare const decodeLEB128: (leb128: Uint8Array<ArrayBuffer>) => bigint;
|
package/dist/worker_stream.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export declare class WorkerStream<TPost = unknown, TRecv = unknown> extends Read
|
|
|
3
3
|
readonly close: () => void;
|
|
4
4
|
static readonly name = "WorkerStream";
|
|
5
5
|
constructor(worker: Worker, strategy?: CountQueuingStrategy);
|
|
6
|
-
postMessage(message: TPost, options?: StructuredSerializeOptions)
|
|
6
|
+
postMessage: (message: TPost, options?: StructuredSerializeOptions) => void;
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tktb-tess/util-fns",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"description": "Utility functions for personal use",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/tktb-tess/util-fns/blob/main/README.md",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/node": "^25.0
|
|
29
|
+
"@types/node": "^25.5.0",
|
|
30
30
|
"tsx": "^4.21.0",
|
|
31
31
|
"typescript": "^5.9.3",
|
|
32
|
+
"unplugin-dts": "1.0.0-beta.6",
|
|
32
33
|
"vite": "^7.3.1",
|
|
33
|
-
"
|
|
34
|
-
"vitest": "^4.0.17"
|
|
34
|
+
"vitest": "^4.1.0"
|
|
35
35
|
},
|
|
36
36
|
"volta": {
|
|
37
37
|
"node": "24.13.0",
|