cafe-utility 35.0.1 → 36.0.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.
Files changed (3) hide show
  1. package/index.d.ts +22 -3
  2. package/index.js +1607 -1478
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -2,31 +2,31 @@
2
2
  var _a
3
3
  Object.defineProperty(exports, '__esModule', { value: !0 }), (exports.Vector = exports.Cache = exports.Assertions = exports.Strings = exports.Types = exports.Objects = exports.Dates = exports.Promises = exports.Numbers = exports.System = exports.Arrays = exports.Random = exports.Elliptic = exports.Binary = exports.Lock = exports.Solver = exports.RollingValueProvider = exports.TrieRouter = exports.AsyncQueue = exports.PubSubChannel = exports.FixedPointNumber = exports.ChunkJoiner = exports.ChunkSplitter = exports.Chunk = exports.Uint8ArrayWriter = exports.Uint8ArrayReader = exports.AsyncLazy = exports.Lazy = exports.Optional = void 0)
4
4
  async function invertPromise(n) {
5
- return new Promise((e, t) => n.then(t, e))
5
+ return new Promise((t, e) => n.then(e, t))
6
6
  }
7
7
  async function raceFulfilled(n) {
8
8
  return invertPromise(Promise.all(n.map(invertPromise)))
9
9
  }
10
- async function runInParallelBatches(n, e = 1) {
11
- const t = splitByCount(n, e),
10
+ async function runInParallelBatches(n, t = 1) {
11
+ const e = splitByCount(n, t),
12
12
  r = [],
13
- i = t.map(async o => {
13
+ i = e.map(async o => {
14
14
  for (const c of o) r.push(await c())
15
15
  })
16
16
  return await Promise.all(i), r
17
17
  }
18
18
  async function sleepMillis(n) {
19
- return new Promise(e =>
19
+ return new Promise(t =>
20
20
  setTimeout(() => {
21
- e(!0)
21
+ t(!0)
22
22
  }, n)
23
23
  )
24
24
  }
25
- function shuffle(n, e = Math.random) {
26
- for (let t = n.length - 1; t > 0; t--) {
27
- const r = Math.floor(e() * (t + 1)),
28
- i = n[t]
29
- ;(n[t] = n[r]), (n[r] = i)
25
+ function shuffle(n, t = Math.random) {
26
+ for (let e = n.length - 1; e > 0; e--) {
27
+ const r = Math.floor(t() * (e + 1)),
28
+ i = n[e]
29
+ ;(n[e] = n[r]), (n[r] = i)
30
30
  }
31
31
  return n
32
32
  }
@@ -44,229 +44,229 @@ function firstOrThrow(n) {
44
44
  if (!n.length) throw Error('Received empty array')
45
45
  return n[0]
46
46
  }
47
- function initializeArray(n, e) {
48
- const t = []
49
- for (let r = 0; r < n; r++) t.push(e(r))
50
- return t
47
+ function initializeArray(n, t) {
48
+ const e = []
49
+ for (let r = 0; r < n; r++) e.push(t(r))
50
+ return e
51
51
  }
52
52
  function rotate2DArray(n) {
53
- const e = []
54
- for (let t = 0; t < n[0].length; t++) {
55
- e.push([])
56
- for (let r = 0; r < n.length; r++) e[t].push(n[r][t])
53
+ const t = []
54
+ for (let e = 0; e < n[0].length; e++) {
55
+ t.push([])
56
+ for (let r = 0; r < n.length; r++) t[e].push(n[r][e])
57
57
  }
58
- return e
58
+ return t
59
59
  }
60
- function initialize2DArray(n, e, t) {
60
+ function initialize2DArray(n, t, e) {
61
61
  const r = []
62
62
  for (let i = 0; i < n; i++) {
63
63
  r.push([])
64
- for (let o = 0; o < e; o++) r[i].push(t)
64
+ for (let o = 0; o < t; o++) r[i].push(e)
65
65
  }
66
66
  return r
67
67
  }
68
- function containsShape(n, e, t, r) {
69
- if (t < 0 || r < 0 || r + e[0].length > n[0].length || t + e.length > n.length) return !1
70
- for (let i = 0; i < e.length; i++) for (let o = 0; o < e[i].length; o++) if (e[i][o] !== void 0 && n[t + i][r + o] !== e[i][o]) return !1
68
+ function containsShape(n, t, e, r) {
69
+ if (e < 0 || r < 0 || r + t[0].length > n[0].length || e + t.length > n.length) return !1
70
+ for (let i = 0; i < t.length; i++) for (let o = 0; o < t[i].length; o++) if (t[i][o] !== void 0 && n[e + i][r + o] !== t[i][o]) return !1
71
71
  return !0
72
72
  }
73
- function pickRandomIndices(n, e, t = Math.random) {
74
- return shuffle(range(0, n.length - 1), t).slice(0, e)
73
+ function pickRandomIndices(n, t, e = Math.random) {
74
+ return shuffle(range(0, n.length - 1), e).slice(0, t)
75
75
  }
76
- function pluck(n, e) {
77
- return n.map(t => t[e])
76
+ function pluck(n, t) {
77
+ return n.map(e => e[t])
78
78
  }
79
79
  function makeSeededRng(n) {
80
- let e = n,
81
- t = 3405648695,
80
+ let t = n,
81
+ e = 3405648695,
82
82
  r = 3735928559
83
83
  return function () {
84
- return (e += t), (t ^= e << 7), (e *= r), (r ^= e << 13), (e ^= t ^ r), (e >>> 0) / 4294967296
84
+ return (t += e), (e ^= t << 7), (t *= r), (r ^= t << 13), (t ^= e ^ r), (t >>> 0) / 4294967296
85
85
  }
86
86
  }
87
- function intBetween(n, e, t = Math.random) {
88
- return Math.floor(t() * (e - n + 1)) + n
87
+ function intBetween(n, t, e = Math.random) {
88
+ return Math.floor(e() * (t - n + 1)) + n
89
89
  }
90
- function floatBetween(n, e, t = Math.random) {
91
- return t() * (e - n) + n
90
+ function floatBetween(n, t, e = Math.random) {
91
+ return e() * (t - n) + n
92
92
  }
93
93
  function signedRandom() {
94
94
  return Math.random() * 2 - 1
95
95
  }
96
- function containsPoint(n, e, t) {
97
- return e >= n.x && e < n.x + n.width && t >= n.y && t < n.y + n.height
96
+ function containsPoint(n, t, e) {
97
+ return t >= n.x && t < n.x + n.width && e >= n.y && e < n.y + n.height
98
98
  }
99
- function randomPoint(n, e, t, r = Math.random) {
99
+ function randomPoint(n, t, e, r = Math.random) {
100
100
  let i, o
101
- do (i = intBetween(0, n - 1, r)), (o = intBetween(0, e - 1, r))
102
- while (t && containsPoint(t, i, o))
101
+ do (i = intBetween(0, n - 1, r)), (o = intBetween(0, t - 1, r))
102
+ while (e && containsPoint(e, i, o))
103
103
  return [i, o]
104
104
  }
105
- function procs(n, e = Math.random) {
106
- const t = Math.floor(n),
107
- r = n - t
108
- return chance(r, e) ? t + 1 : t
105
+ function procs(n, t = Math.random) {
106
+ const e = Math.floor(n),
107
+ r = n - e
108
+ return chance(r, t) ? e + 1 : e
109
109
  }
110
- function chance(n, e = Math.random) {
111
- return e() < n
110
+ function chance(n, t = Math.random) {
111
+ return t() < n
112
112
  }
113
- function pick(n, e = Math.random) {
114
- return n[Math.floor(n.length * e())]
113
+ function pick(n, t = Math.random) {
114
+ return n[Math.floor(n.length * t())]
115
115
  }
116
- function pickMany(n, e, t = Math.random) {
117
- if (e > n.length) throw new Error(`Count (${e}) is greater than array length (${n.length})`)
118
- return pickRandomIndices(n, e, t).map(i => n[i])
116
+ function pickMany(n, t, e = Math.random) {
117
+ if (t > n.length) throw new Error(`Count (${t}) is greater than array length (${n.length})`)
118
+ return pickRandomIndices(n, t, e).map(i => n[i])
119
119
  }
120
- function pickManyUnique(n, e, t, r = Math.random) {
121
- if (e > n.length) throw new Error(`Count (${e}) is greater than array length (${n.length})`)
120
+ function pickManyUnique(n, t, e, r = Math.random) {
121
+ if (t > n.length) throw new Error(`Count (${t}) is greater than array length (${n.length})`)
122
122
  const i = []
123
- for (; i.length < e; ) {
123
+ for (; i.length < t; ) {
124
124
  const o = pick(n, r)
125
- i.some(c => t(c, o)) || i.push(o)
125
+ i.some(c => e(c, o)) || i.push(o)
126
126
  }
127
127
  return i
128
128
  }
129
- function pickGuaranteed(n, e, t, r, i, o = Math.random) {
130
- const c = n.filter(s => s !== e && s !== t),
131
- u = []
132
- for (e !== null && u.push(e); c.length && u.length < r; ) {
133
- const s = exports.Random.intBetween(0, c.length - 1, o)
134
- i(c[s], u) && u.push(c[s]), c.splice(s, 1)
129
+ function pickGuaranteed(n, t, e, r, i, o = Math.random) {
130
+ const c = n.filter(u => u !== t && u !== e),
131
+ s = []
132
+ for (t !== null && s.push(t); c.length && s.length < r; ) {
133
+ const u = exports.Random.intBetween(0, c.length - 1, o)
134
+ i(c[u], s) && s.push(c[u]), c.splice(u, 1)
135
135
  }
136
- return shuffle(u, o), { values: u, indexOfGuaranteed: e !== null ? u.indexOf(e) : -1 }
136
+ return shuffle(s, o), { values: s, indexOfGuaranteed: t !== null ? s.indexOf(t) : -1 }
137
137
  }
138
138
  function last(n) {
139
139
  if (!n.length) throw Error('Received empty array')
140
140
  return n[n.length - 1]
141
141
  }
142
- function pipe(n, e, t) {
143
- return t(e.reduce((r, i) => i(r), n))
142
+ function pipe(n, t, e) {
143
+ return e(t.reduce((r, i) => i(r), n))
144
144
  }
145
- function makePipe(n, e) {
146
- return t => pipe(t, n, e)
145
+ function makePipe(n, t) {
146
+ return e => pipe(e, n, t)
147
147
  }
148
- function pickWeighted(n, e, t) {
149
- if ((t === void 0 && (t = Math.random()), n.length !== e.length)) throw new Error('Array length mismatch')
150
- let r = e.reduce((o, c) => o + c, 0)
151
- const i = t * r
152
- for (let o = 0; o < n.length - 1; o++) if (((r -= e[o]), i >= r)) return n[o]
148
+ function pickWeighted(n, t, e) {
149
+ if ((e === void 0 && (e = Math.random()), n.length !== t.length)) throw new Error('Array length mismatch')
150
+ let r = t.reduce((o, c) => o + c, 0)
151
+ const i = e * r
152
+ for (let o = 0; o < n.length - 1; o++) if (((r -= t[o]), i >= r)) return n[o]
153
153
  return last(n)
154
154
  }
155
- function sortWeighted(n, e, t = Math.random) {
156
- const r = e.map(o => t() * o),
155
+ function sortWeighted(n, t, e = Math.random) {
156
+ const r = t.map(o => e() * o),
157
157
  i = []
158
158
  for (let o = 0; o < n.length; o++) i.push([n[o], r[o]])
159
159
  return i.sort((o, c) => c[1] - o[1]).map(o => o[0])
160
160
  }
161
- function getDeep(n, e) {
161
+ function getDeep(n, t) {
162
162
  if (n == null) return null
163
- const t = e.split('.')
163
+ const e = t.split('.')
164
164
  let r = n
165
- for (const i of t) {
165
+ for (const i of e) {
166
166
  if (r[i] === null || r[i] === void 0) return null
167
167
  r = r[i]
168
168
  }
169
169
  return r
170
170
  }
171
- function setDeep(n, e, t) {
172
- const r = e.split(/\.|\[/)
171
+ function setDeep(n, t, e) {
172
+ const r = t.split(/\.|\[/)
173
173
  let i = n
174
174
  for (let o = 0; o < r.length; o++) {
175
175
  const c = r[o],
176
- u = o < r.length - 1 && r[o + 1].includes(']'),
176
+ s = o < r.length - 1 && r[o + 1].includes(']'),
177
177
  f = c.includes(']') ? c.replace(/\[|\]/g, '') : c
178
- if (o === r.length - 1) return (i[f] = t), t
179
- isObject(i[f]) || (u ? (i[f] = []) : (i[f] = {})), (i = i[f])
178
+ if (o === r.length - 1) return (i[f] = e), e
179
+ isObject(i[f]) || (s ? (i[f] = []) : (i[f] = {})), (i = i[f])
180
180
  }
181
- return t
181
+ return e
182
182
  }
183
- function incrementDeep(n, e, t = 1) {
184
- const r = getDeep(n, e) || 0
185
- return setDeep(n, e, r + t), r
183
+ function incrementDeep(n, t, e = 1) {
184
+ const r = getDeep(n, t) || 0
185
+ return setDeep(n, t, r + e), r
186
186
  }
187
- function ensureDeep(n, e, t) {
188
- return getDeep(n, e) || setDeep(n, e, t)
187
+ function ensureDeep(n, t, e) {
188
+ return getDeep(n, t) || setDeep(n, t, e)
189
189
  }
190
- function deleteDeep(n, e) {
191
- const t = beforeLast(e, '.'),
192
- r = afterLast(e, '.')
193
- if (!t || !r) return
194
- const i = getDeep(n, t)
190
+ function deleteDeep(n, t) {
191
+ const e = beforeLast(t, '.'),
192
+ r = afterLast(t, '.')
193
+ if (!e || !r) return
194
+ const i = getDeep(n, e)
195
195
  i && delete i[r]
196
196
  }
197
- function replaceDeep(n, e, t) {
198
- const r = getDeep(n, e)
199
- if (!r) throw new Error("Key '" + e + "' does not exist.")
200
- return setDeep(n, e, t), r
197
+ function replaceDeep(n, t, e) {
198
+ const r = getDeep(n, t)
199
+ if (!r) throw new Error("Key '" + t + "' does not exist.")
200
+ return setDeep(n, t, e), r
201
201
  }
202
- function getFirstDeep(n, e, t) {
203
- for (const r of e) {
202
+ function getFirstDeep(n, t, e) {
203
+ for (const r of t) {
204
204
  const i = getDeep(n, r)
205
205
  if (i) return i
206
206
  }
207
- if (t) {
207
+ if (e) {
208
208
  const r = Object.values(n)
209
209
  if (r.length) return r[0]
210
210
  }
211
211
  return null
212
212
  }
213
- async function forever(n, e, t) {
213
+ async function forever(n, t, e) {
214
214
  for (;;) {
215
215
  try {
216
216
  await n()
217
217
  } catch (r) {
218
- t && t('Error in forever', r)
218
+ e && e('Error in forever', r)
219
219
  }
220
- await sleepMillis(e)
220
+ await sleepMillis(t)
221
221
  }
222
222
  }
223
- function runAndSetInterval(n, e) {
223
+ function runAndSetInterval(n, t) {
224
224
  n()
225
- const t = setInterval(() => {
225
+ const e = setInterval(() => {
226
226
  n()
227
- }, e)
228
- return () => clearInterval(t)
227
+ }, t)
228
+ return () => clearInterval(e)
229
229
  }
230
230
  function whereAmI() {
231
231
  const n = globalThis.process
232
232
  return n ? (n.browser === !0 ? 'browser' : 'node') : 'browser'
233
233
  }
234
- async function withRetries(n, e, t, r, i, o) {
234
+ async function withRetries(n, t, e, r, i, o) {
235
235
  let c = null
236
- for (let u = 0; u <= e; u++)
236
+ for (let s = 0; s <= t; s++)
237
237
  try {
238
238
  return await n()
239
- } catch (s) {
240
- if (((c = s), u === e)) break
241
- const f = t + (r - t) * (u / (e - 1))
242
- i && i('Error in withRetries, retrying', { attempt: u + 1, allowedFailures: e, delayMillis: f, error: s }), o && o(), await sleepMillis(f)
239
+ } catch (u) {
240
+ if (((c = u), s === t)) break
241
+ const f = e + (r - e) * (s / (t - 1))
242
+ i && i('Error in withRetries, retrying', { attempt: s + 1, allowedFailures: t, delayMillis: f, error: u }), o && o(), await sleepMillis(f)
243
243
  }
244
244
  throw c
245
245
  }
246
246
  function asMegabytes(n) {
247
247
  return n / 1024 / 1024
248
248
  }
249
- function convertBytes(n, e = 1024) {
250
- return n >= e * e * e * e ? (n / e / e / e / e).toFixed(3) + ' TB' : n >= e * e * e ? (n / e / e / e).toFixed(3) + ' GB' : n >= e * e ? (n / e / e).toFixed(3) + ' MB' : n >= e ? (n / e).toFixed(3) + ' KB' : n + ' B'
249
+ function convertBytes(n, t = 1024) {
250
+ return n >= t * t * t * t ? (n / t / t / t / t).toFixed(3) + ' TB' : n >= t * t * t ? (n / t / t / t).toFixed(3) + ' GB' : n >= t * t ? (n / t / t).toFixed(3) + ' MB' : n >= t ? (n / t).toFixed(3) + ' KB' : n + ' B'
251
251
  }
252
252
  function hexToRgb(n) {
253
- const e = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n.toLowerCase())
254
- if (!e) throw new Error('Invalid hex color: ' + n)
255
- return [parseInt(e[1], 16), parseInt(e[2], 16), parseInt(e[3], 16)]
253
+ const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n.toLowerCase())
254
+ if (!t) throw new Error('Invalid hex color: ' + n)
255
+ return [parseInt(t[1], 16), parseInt(t[2], 16), parseInt(t[3], 16)]
256
256
  }
257
257
  function rgbToHex(n) {
258
- return '#' + n.map(e => e.toString(16).padStart(2, '0')).join('')
258
+ return '#' + n.map(t => t.toString(16).padStart(2, '0')).join('')
259
259
  }
260
- function haversineDistanceToMeters(n, e, t, r) {
260
+ function haversineDistanceToMeters(n, t, e, r) {
261
261
  const o = (n * Math.PI) / 180,
262
- c = (t * Math.PI) / 180,
263
- u = ((t - n) * Math.PI) / 180,
264
- s = ((r - e) * Math.PI) / 180,
265
- f = Math.sin(u / 2) * Math.sin(u / 2) + Math.cos(o) * Math.cos(c) * Math.sin(s / 2) * Math.sin(s / 2)
262
+ c = (e * Math.PI) / 180,
263
+ s = ((e - n) * Math.PI) / 180,
264
+ u = ((r - t) * Math.PI) / 180,
265
+ f = Math.sin(s / 2) * Math.sin(s / 2) + Math.cos(o) * Math.cos(c) * Math.sin(u / 2) * Math.sin(u / 2)
266
266
  return 6371e3 * (2 * Math.atan2(Math.sqrt(f), Math.sqrt(1 - f)))
267
267
  }
268
- function roundToNearest(n, e) {
269
- return Math.round(n / e) * e
268
+ function roundToNearest(n, t) {
269
+ return Math.round(n / t) * t
270
270
  }
271
271
  function formatDistance(n) {
272
272
  return n > 1e3 ? (n / 1e3).toFixed(0) + ' km' : n >= 500 ? roundToNearest(n, 100) + ' m' : n >= 100 ? roundToNearest(n, 50) + ' m' : roundToNearest(n, 10) + ' m'
@@ -275,35 +275,35 @@ function triangularNumber(n) {
275
275
  return (n * (n + 1)) / 2
276
276
  }
277
277
  function searchFloat(n) {
278
- const e = n.match(/-?\d+(\.\d+)?/)
279
- if (!e) throw Error('No float found in ' + n)
280
- return parseFloat(e[0])
281
- }
282
- function binomialSample(n, e, t = Math.random) {
283
- const r = n * e,
284
- i = Math.sqrt(n * e * (1 - e)),
285
- c = (t() + t() + t() + t() + t() + t() - 3) * Math.SQRT2,
286
- u = Math.round(r + i * c)
287
- return Math.max(0, Math.min(n, u))
288
- }
289
- function toSignificantDigits(n, e) {
278
+ const t = n.match(/-?\d+(\.\d+)?/)
279
+ if (!t) throw Error('No float found in ' + n)
280
+ return parseFloat(t[0])
281
+ }
282
+ function binomialSample(n, t, e = Math.random) {
283
+ const r = n * t,
284
+ i = Math.sqrt(n * t * (1 - t)),
285
+ c = (e() + e() + e() + e() + e() + e() - 3) * Math.SQRT2,
286
+ s = Math.round(r + i * c)
287
+ return Math.max(0, Math.min(n, s))
288
+ }
289
+ function toSignificantDigits(n, t) {
290
290
  if (!n.includes('.')) return n
291
291
  if (parseFloat(n) === 0) return '0'
292
- const [t, r] = n.split('.'),
293
- i = t.replace('-', ''),
292
+ const [e, r] = n.split('.'),
293
+ i = e.replace('-', ''),
294
294
  o = i.length
295
- if (o >= e) return t
295
+ if (o >= t) return e
296
296
  if (!(i === '0')) {
297
- const f = e - o,
297
+ const f = t - o,
298
298
  l = r.slice(0, f)
299
- return /[1-9]/.test(l) ? `${t}.${l.replace(/0+$/, '')}` : t
299
+ return /[1-9]/.test(l) ? `${e}.${l.replace(/0+$/, '')}` : e
300
300
  }
301
- const u = r.match(/^0*/)?.[0].length ?? 0,
302
- s = e + u
303
- return `${t}.${r.slice(0, s)}`
301
+ const s = r.match(/^0*/)?.[0].length ?? 0,
302
+ u = t + s
303
+ return `${e}.${r.slice(0, u)}`
304
304
  }
305
- function isObject(n, e = !0) {
306
- return !n || (e && !isUndefined(n._readableState)) || (e && n.constructor && (n.constructor.isBuffer || n.constructor.name == 'AbortController' || n.constructor.name == 'AbortSignal' || n.constructor.name == 'Uint8Array' || n.constructor.name === 'ArrayBuffer' || n.constructor.name === 'ReadableStream')) ? !1 : typeof n == 'object'
305
+ function isObject(n, t = !0) {
306
+ return !n || (t && !isUndefined(n._readableState)) || (t && n.constructor && (n.constructor.isBuffer || n.constructor.name == 'AbortController' || n.constructor.name == 'AbortSignal' || n.constructor.name == 'Uint8Array' || n.constructor.name === 'ArrayBuffer' || n.constructor.name === 'ReadableStream')) ? !1 : typeof n == 'object'
307
307
  }
308
308
  function isStrictlyObject(n) {
309
309
  return isObject(n) && !Array.isArray(n)
@@ -353,259 +353,259 @@ const symbols = '!@#$%^&*()_+-=[]{}|;:<>?,./',
353
353
  richAsciiAlphabet = alphanumericAlphabet + symbols,
354
354
  unicodeTestingAlphabet = ['\u2014', '\\', '\u6771', '\u4EAC', '\u90FD', '\u{1D586}', '\u{1D587}', '\u{1D588}', '\u{1F47E}', '\u{1F647}', '\u{1F481}', '\u{1F645}', '\u16A0', '\u16C7', '\u16BB', '\u16E6'],
355
355
  hexAlphabet = '0123456789abcdef'
356
- function randomLetterString(n, e = Math.random) {
357
- let t = ''
358
- for (let r = 0; r < n; r++) t += lowercaseAlphabet[Math.floor(e() * lowercaseAlphabet.length)]
359
- return t
356
+ function randomLetterString(n, t = Math.random) {
357
+ let e = ''
358
+ for (let r = 0; r < n; r++) e += lowercaseAlphabet[Math.floor(t() * lowercaseAlphabet.length)]
359
+ return e
360
360
  }
361
- function randomAlphanumericString(n, e = Math.random) {
362
- let t = ''
363
- for (let r = 0; r < n; r++) t += alphanumericAlphabet[Math.floor(e() * alphanumericAlphabet.length)]
364
- return t
361
+ function randomAlphanumericString(n, t = Math.random) {
362
+ let e = ''
363
+ for (let r = 0; r < n; r++) e += alphanumericAlphabet[Math.floor(t() * alphanumericAlphabet.length)]
364
+ return e
365
365
  }
366
- function randomRichAsciiString(n, e = Math.random) {
367
- let t = ''
368
- for (let r = 0; r < n; r++) t += richAsciiAlphabet[Math.floor(e() * richAsciiAlphabet.length)]
369
- return t
366
+ function randomRichAsciiString(n, t = Math.random) {
367
+ let e = ''
368
+ for (let r = 0; r < n; r++) e += richAsciiAlphabet[Math.floor(t() * richAsciiAlphabet.length)]
369
+ return e
370
370
  }
371
- function randomUnicodeString(n, e = Math.random) {
372
- let t = ''
373
- for (let r = 0; r < n; r++) t += unicodeTestingAlphabet[Math.floor(e() * unicodeTestingAlphabet.length)]
374
- return t
371
+ function randomUnicodeString(n, t = Math.random) {
372
+ let e = ''
373
+ for (let r = 0; r < n; r++) e += unicodeTestingAlphabet[Math.floor(t() * unicodeTestingAlphabet.length)]
374
+ return e
375
375
  }
376
- function searchHex(n, e) {
377
- const t = new RegExp(`[0-9a-f]{${e}}`, 'i'),
378
- r = n.match(t)
376
+ function searchHex(n, t) {
377
+ const e = new RegExp(`[0-9a-f]{${t}}`, 'i'),
378
+ r = n.match(e)
379
379
  return r ? r[0] : null
380
380
  }
381
- function searchSubstring(n, e, t = symbolsArray) {
382
- const r = splitAll(n, t)
383
- for (const i of r) if (e(i)) return i
381
+ function searchSubstring(n, t, e = symbolsArray) {
382
+ const r = splitAll(n, e)
383
+ for (const i of r) if (t(i)) return i
384
384
  return null
385
385
  }
386
- function randomHexString(n, e = Math.random) {
387
- let t = ''
388
- for (let r = 0; r < n; r++) t += hexAlphabet[Math.floor(e() * hexAlphabet.length)]
389
- return t
386
+ function randomHexString(n, t = Math.random) {
387
+ let e = ''
388
+ for (let r = 0; r < n; r++) e += hexAlphabet[Math.floor(t() * hexAlphabet.length)]
389
+ return e
390
390
  }
391
- function asIntegerString(n, e) {
392
- if (!isIntegerString(n)) throw new TypeError(`Expected integer string${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
393
- const t = BigInt(n)
394
- if (e && ((e.min && t < e.min) || (e.max && t > e.max))) throw RangeError(`Expected integer string${e?.name ? ` for ${e.name}` : ''} in range: ${e.min ?? '-inf'}..${e.max ?? 'inf'}; got: ` + t)
391
+ function asIntegerString(n, t) {
392
+ if (!isIntegerString(n)) throw new TypeError(`Expected integer string${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
393
+ const e = BigInt(n)
394
+ if (t && ((t.min && e < t.min) || (t.max && e > t.max))) throw RangeError(`Expected integer string${t?.name ? ` for ${t.name}` : ''} in range: ${t.min ?? '-inf'}..${t.max ?? 'inf'}; got: ` + e)
395
395
  return n
396
396
  }
397
- function asString(n, e) {
398
- if (isBlank(n)) throw new TypeError(`Expected string${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
399
- if (e && ((e.min !== void 0 && n.length < e.min) || (e.max !== void 0 && n.length > e.max))) throw RangeError(`Expected string${e?.name ? ` for ${e.name}` : ''} length in range: ${e.min ?? '-inf'}..${e.max ?? 'inf'}; got: ${n.length}`)
397
+ function asString(n, t) {
398
+ if (isBlank(n)) throw new TypeError(`Expected string${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
399
+ if (t && ((t.min !== void 0 && n.length < t.min) || (t.max !== void 0 && n.length > t.max))) throw RangeError(`Expected string${t?.name ? ` for ${t.name}` : ''} length in range: ${t.min ?? '-inf'}..${t.max ?? 'inf'}; got: ${n.length}`)
400
400
  return n
401
401
  }
402
- function asHexString(n, e) {
403
- if (!isHexString(n)) throw new TypeError(`Expected hex string${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
404
- if (e?.strictPrefix && !n.startsWith('0x') && !n.startsWith('0X')) throw new TypeError(`Expected hex string with 0x prefix${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
405
- const t = n.replace(/^0x/i, '')
406
- if (t.length % 2 !== 0 && !e?.uneven) throw RangeError(`Expected even number of hex digits${e?.name ? ` for ${e.name}` : ''}; got: ` + n)
407
- if (e && e.byteLength && t.length !== e.byteLength * 2) throw RangeError(`Expected hex string${e?.name ? ` for ${e.name}` : ''} of byte length ${e.byteLength}; got: ` + t)
408
- return `0x${t}`
402
+ function asHexString(n, t) {
403
+ if (!isHexString(n)) throw new TypeError(`Expected hex string${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
404
+ if (t?.strictPrefix && !n.startsWith('0x') && !n.startsWith('0X')) throw new TypeError(`Expected hex string with 0x prefix${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
405
+ const e = n.replace(/^0x/i, '')
406
+ if (e.length % 2 !== 0 && !t?.uneven) throw RangeError(`Expected even number of hex digits${t?.name ? ` for ${t.name}` : ''}; got: ` + n)
407
+ if (t && t.byteLength && e.length !== t.byteLength * 2) throw RangeError(`Expected hex string${t?.name ? ` for ${t.name}` : ''} of byte length ${t.byteLength}; got: ` + e)
408
+ return `0x${e}`
409
409
  }
410
- function asSafeString(n, e) {
410
+ function asSafeString(n, t) {
411
411
  if (
412
- !asString(n, e)
412
+ !asString(n, t)
413
413
  .split('')
414
- .every(t => t === '_' || isLetterOrDigit(t))
414
+ .every(e => e === '_' || isLetterOrDigit(e))
415
415
  )
416
- throw new TypeError(`Expected safe string${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
416
+ throw new TypeError(`Expected safe string${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
417
417
  return n
418
418
  }
419
- function checkLimits(n, e) {
420
- if ((e.min !== void 0 && n < e.min) || (e.max !== void 0 && n > e.max)) throw RangeError(`Expected value${e?.name ? ` for ${e.name}` : ''} in range: ${e.min ?? '-inf'}..${e.max ?? 'inf'}; got: ${n}`)
419
+ function checkLimits(n, t) {
420
+ if ((t.min !== void 0 && n < t.min) || (t.max !== void 0 && n > t.max)) throw RangeError(`Expected value${t?.name ? ` for ${t.name}` : ''} in range: ${t.min ?? '-inf'}..${t.max ?? 'inf'}; got: ${n}`)
421
421
  }
422
- function asFunction(n, e) {
423
- if (!isFunction(n)) throw new TypeError(`Expected function${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
422
+ function asFunction(n, t) {
423
+ if (!isFunction(n)) throw new TypeError(`Expected function${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
424
424
  return n
425
425
  }
426
- function asNumber(n, e) {
427
- if (isNumber(n)) return e && checkLimits(n, e), n
428
- if (!isString(n) || !n.match(/^-?\d+(\.\d+)?$/)) throw new TypeError(`Expected number${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
429
- const t = parseFloat(n)
430
- return e && checkLimits(t, e), t
426
+ function asNumber(n, t) {
427
+ if (isNumber(n)) return t && checkLimits(n, t), n
428
+ if (!isString(n) || !n.match(/^-?\d+(\.\d+)?$/)) throw new TypeError(`Expected number${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
429
+ const e = parseFloat(n)
430
+ return t && checkLimits(e, t), e
431
431
  }
432
- function asInteger(n, e) {
433
- return Math.trunc(asNumber(n, e))
432
+ function asInteger(n, t) {
433
+ return Math.trunc(asNumber(n, t))
434
434
  }
435
- function asBoolean(n, e) {
435
+ function asBoolean(n, t) {
436
436
  if (n === 'true') return !0
437
437
  if (n === 'false') return !1
438
- if (!isBoolean(n)) throw new TypeError(`Expected boolean${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
438
+ if (!isBoolean(n)) throw new TypeError(`Expected boolean${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
439
439
  return n
440
440
  }
441
- function asDate(n, e) {
442
- if (!isDate(n)) throw new TypeError(`Expected date${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
441
+ function asDate(n, t) {
442
+ if (!isDate(n)) throw new TypeError(`Expected date${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
443
443
  return n
444
444
  }
445
445
  function asNullableString(n) {
446
446
  return isBlank(n) ? null : n
447
447
  }
448
- function asEmptiableString(n, e) {
449
- if (!isString(n)) throw new TypeError(`Expected string${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
448
+ function asEmptiableString(n, t) {
449
+ if (!isString(n)) throw new TypeError(`Expected string${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
450
450
  return n
451
451
  }
452
- function asId(n, e) {
452
+ function asId(n, t) {
453
453
  if (isId(n)) return n
454
- const t = parseInt(n, 10)
455
- if (!isId(t)) throw new TypeError(`Expected id${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
456
- return t
454
+ const e = parseInt(n, 10)
455
+ if (!isId(e)) throw new TypeError(`Expected id${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
456
+ return e
457
457
  }
458
- function asTime(n, e) {
459
- if (!isString(n)) throw new TypeError(`Expected time${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
460
- const t = n.split(':')
461
- if (t.length !== 2) throw new TypeError(`Expected time${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
462
- const r = parseInt(t[0], 10),
463
- i = parseInt(t[1], 10)
464
- if (!isNumber(r) || !isNumber(i) || r < 0 || r > 23 || i < 0 || i > 59) throw new TypeError(`Expected time, got${e?.name ? ` for ${e.name}` : ''}: ` + n)
458
+ function asTime(n, t) {
459
+ if (!isString(n)) throw new TypeError(`Expected time${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
460
+ const e = n.split(':')
461
+ if (e.length !== 2) throw new TypeError(`Expected time${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
462
+ const r = parseInt(e[0], 10),
463
+ i = parseInt(e[1], 10)
464
+ if (!isNumber(r) || !isNumber(i) || r < 0 || r > 23 || i < 0 || i > 59) throw new TypeError(`Expected time, got${t?.name ? ` for ${t.name}` : ''}: ` + n)
465
465
  return `${String(r).padStart(2, '0')}:${String(i).padStart(2, '0')}`
466
466
  }
467
- function asArray(n, e) {
468
- if (!Array.isArray(n)) throw new TypeError(`Expected array${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
467
+ function asArray(n, t) {
468
+ if (!Array.isArray(n)) throw new TypeError(`Expected array${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
469
469
  return n
470
470
  }
471
- function asObject(n, e) {
472
- if (!isStrictlyObject(n)) throw new TypeError(`Expected object${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
471
+ function asObject(n, t) {
472
+ if (!isStrictlyObject(n)) throw new TypeError(`Expected object${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
473
473
  return n
474
474
  }
475
- function asNullableObject(n, e) {
476
- return n === null ? null : asObject(n, e)
475
+ function asNullableObject(n, t) {
476
+ return n === null ? null : asObject(n, t)
477
477
  }
478
- function asStringMap(n, e) {
479
- const t = asObject(n, e)
480
- for (const r of Object.keys(t)) if (!isString(t[r])) throw new TypeError(`Expected string map${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
481
- return t
478
+ function asStringMap(n, t) {
479
+ const e = asObject(n, t)
480
+ for (const r of Object.keys(e)) if (!isString(e[r])) throw new TypeError(`Expected string map${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
481
+ return e
482
482
  }
483
- function asNumericDictionary(n, e) {
484
- const t = asObject(n),
485
- r = Object.keys(t),
486
- i = Object.values(t)
487
- if (!r.every(isString) || !i.every(isNumber)) throw new TypeError(`Expected numeric dictionary${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
488
- return t
483
+ function asNumericDictionary(n, t) {
484
+ const e = asObject(n),
485
+ r = Object.keys(e),
486
+ i = Object.values(e)
487
+ if (!r.every(isString) || !i.every(isNumber)) throw new TypeError(`Expected numeric dictionary${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
488
+ return e
489
489
  }
490
490
  function isUrl(n) {
491
491
  return isString(n) && n.match(/^https?:\/\/.+/) !== null
492
492
  }
493
- function asUrl(n, e) {
494
- if (!isUrl(n)) throw new TypeError(`Expected url${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
493
+ function asUrl(n, t) {
494
+ if (!isUrl(n)) throw new TypeError(`Expected url${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
495
495
  return n
496
496
  }
497
497
  function isBigint(n) {
498
498
  return typeof n == 'bigint'
499
499
  }
500
- function asBigint(n, e) {
501
- if (!isBigint(n)) throw new TypeError(`Expected bigint${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
502
- if ((e?.min !== void 0 && n < e?.min) || (e?.max !== void 0 && n > e?.max)) throw RangeError(`Expected value${e?.name ? ` for ${e.name}` : ''} in range: ${e.min ?? '-inf'}..${e.max ?? 'inf'}; got: ${n}`)
500
+ function asBigint(n, t) {
501
+ if (!isBigint(n)) throw new TypeError(`Expected bigint${t?.name ? ` for ${t.name}` : ''}, got: ` + n)
502
+ if ((t?.min !== void 0 && n < t?.min) || (t?.max !== void 0 && n > t?.max)) throw RangeError(`Expected value${t?.name ? ` for ${t.name}` : ''} in range: ${t.min ?? '-inf'}..${t.max ?? 'inf'}; got: ${n}`)
503
503
  return n
504
504
  }
505
- function isNullable(n, e) {
506
- return e == null ? !0 : n(e)
505
+ function isNullable(n, t) {
506
+ return t == null ? !0 : n(t)
507
507
  }
508
- function asNullable(n, e) {
509
- return e == null ? null : n(e)
508
+ function asNullable(n, t) {
509
+ return t == null ? null : n(t)
510
510
  }
511
- function asEmptiable(n, e) {
512
- return e === '' ? void 0 : n(e)
511
+ function asEmptiable(n, t) {
512
+ return t === '' ? void 0 : n(t)
513
513
  }
514
- function asOptional(n, e) {
515
- return e == null ? void 0 : n(e)
514
+ function asOptional(n, t) {
515
+ return t == null ? void 0 : n(t)
516
516
  }
517
- function enforceObjectShape(n, e) {
518
- for (const [t, r] of Object.entries(e)) if (!r(n[t])) throw TypeError(`${t} in value does not exist or match shape`)
519
- for (const t of Object.keys(n)) if (!e[t]) throw TypeError(`${t} exists in value but not in shape`)
517
+ function enforceObjectShape(n, t) {
518
+ for (const [e, r] of Object.entries(t)) if (!r(n[e])) throw TypeError(`${e} in value does not exist or match shape`)
519
+ for (const e of Object.keys(n)) if (!t[e]) throw TypeError(`${e} exists in value but not in shape`)
520
520
  return !0
521
521
  }
522
- function enforceArrayShape(n, e) {
523
- return n.every(t => enforceObjectShape(t, e))
522
+ function enforceArrayShape(n, t) {
523
+ return n.every(e => enforceObjectShape(e, t))
524
524
  }
525
- function represent(n, e = 'json', t = 0) {
525
+ function represent(n, t = 'json', e = 0) {
526
526
  if (n && isFunction(n.represent)) {
527
527
  const r = n.represent()
528
- if (isString(r)) return e === 'json' && t === 0 ? JSON.stringify(r) : r
528
+ if (isString(r)) return t === 'json' && e === 0 ? JSON.stringify(r) : r
529
529
  }
530
530
  if (isObject(n, !1)) {
531
- if (t > 1) return '[object Object]'
532
- if (e === 'json') {
531
+ if (e > 1) return '[object Object]'
532
+ if (t === 'json') {
533
533
  if (Array.isArray(n)) {
534
- const i = n.map(o => represent(o, 'json', t + 1))
535
- return t === 0 ? JSON.stringify(i) : i
534
+ const i = n.map(o => represent(o, 'json', e + 1))
535
+ return e === 0 ? JSON.stringify(i) : i
536
536
  }
537
537
  const r = {}
538
- n.message && (r.message = represent(n.message, 'json', t + 1))
539
- for (const [i, o] of Object.entries(n)) r[i] = represent(o, 'json', t + 1)
540
- return t === 0 ? JSON.stringify(r) : r
541
- } else if (e === 'key-value') {
538
+ n.message && (r.message = represent(n.message, 'json', e + 1))
539
+ for (const [i, o] of Object.entries(n)) r[i] = represent(o, 'json', e + 1)
540
+ return e === 0 ? JSON.stringify(r) : r
541
+ } else if (t === 'key-value') {
542
542
  const r = Object.keys(n)
543
- return n.message && !r.includes('message') && r.unshift('message'), r.map(i => `${i}=${JSON.stringify(represent(n[i], 'json', t + 1))}`).join(' ')
543
+ return n.message && !r.includes('message') && r.unshift('message'), r.map(i => `${i}=${JSON.stringify(represent(n[i], 'json', e + 1))}`).join(' ')
544
544
  }
545
545
  }
546
- return isUndefined(n) && (n = 'undefined'), t === 0 ? JSON.stringify(n) : n
546
+ return isUndefined(n) && (n = 'undefined'), e === 0 ? JSON.stringify(n) : n
547
547
  }
548
- function expandError(n, e) {
548
+ function expandError(n, t) {
549
549
  if (isString(n)) return n
550
- const t = Object.keys(n)
551
- n.message && !t.includes('message') && t.push('message')
552
- const r = t.map(i => `${i}: ${n[i]}`).join('; ')
553
- return e && n.stack
550
+ const e = Object.keys(n)
551
+ n.message && !e.includes('message') && e.push('message')
552
+ const r = e.map(i => `${i}: ${n[i]}`).join('; ')
553
+ return t && n.stack
554
554
  ? r +
555
555
  `
556
556
  ` +
557
557
  n.stack
558
558
  : r
559
559
  }
560
- function deepMergeInPlace(n, e) {
561
- if (isStrictlyObject(n) && isStrictlyObject(e)) for (const t in e) isStrictlyObject(e[t]) ? (n[t] || (n[t] = {}), deepMergeInPlace(n[t], e[t])) : Array.isArray(e[t]) ? (n[t] = [...e[t]]) : ((e[t] !== null && e[t] !== void 0) || n[t] === null || n[t] === void 0) && (n[t] = e[t])
560
+ function deepMergeInPlace(n, t) {
561
+ if (isStrictlyObject(n) && isStrictlyObject(t)) for (const e in t) isStrictlyObject(t[e]) ? (n[e] || (n[e] = {}), deepMergeInPlace(n[e], t[e])) : Array.isArray(t[e]) ? (n[e] = [...t[e]]) : ((t[e] !== null && t[e] !== void 0) || n[e] === null || n[e] === void 0) && (n[e] = t[e])
562
562
  return n
563
563
  }
564
- function deepMerge2(n, e) {
565
- const t = {}
566
- return deepMergeInPlace(t, n), deepMergeInPlace(t, e), t
564
+ function deepMerge2(n, t) {
565
+ const e = {}
566
+ return deepMergeInPlace(e, n), deepMergeInPlace(e, t), e
567
567
  }
568
- function deepMerge3(n, e, t) {
568
+ function deepMerge3(n, t, e) {
569
569
  const r = {}
570
- return deepMergeInPlace(r, n), deepMergeInPlace(r, e), deepMergeInPlace(r, t), r
570
+ return deepMergeInPlace(r, n), deepMergeInPlace(r, t), deepMergeInPlace(r, e), r
571
571
  }
572
- function zip(n, e) {
573
- const t = {}
574
- for (const r of n) for (const i of Object.keys(r)) t[i] ? (t[i] = e(t[i], r[i])) : (t[i] = r[i])
575
- return t
572
+ function zip(n, t) {
573
+ const e = {}
574
+ for (const r of n) for (const i of Object.keys(r)) e[i] ? (e[i] = t(e[i], r[i])) : (e[i] = r[i])
575
+ return e
576
576
  }
577
577
  function zipSum(n) {
578
- return zip(n, (e, t) => e + t)
578
+ return zip(n, (t, e) => t + e)
579
579
  }
580
- function pushToBucket(n, e, t) {
581
- n[e] || (n[e] = []), n[e].push(t)
580
+ function pushToBucket(n, t, e) {
581
+ n[t] || (n[t] = []), n[t].push(e)
582
582
  }
583
- function unshiftAndLimit(n, e, t) {
584
- for (n.unshift(e); n.length > t; ) n.pop()
583
+ function unshiftAndLimit(n, t, e) {
584
+ for (n.unshift(t); n.length > e; ) n.pop()
585
585
  }
586
- function atRolling(n, e) {
587
- let t = e % n.length
588
- return t < 0 && (t += n.length), n[t]
586
+ function atRolling(n, t) {
587
+ let e = t % n.length
588
+ return e < 0 && (e += n.length), n[e]
589
589
  }
590
- function pushAll(n, e) {
591
- Array.prototype.push.apply(n, e)
590
+ function pushAll(n, t) {
591
+ Array.prototype.push.apply(n, t)
592
592
  }
593
- function unshiftAll(n, e) {
594
- Array.prototype.unshift.apply(n, e)
593
+ function unshiftAll(n, t) {
594
+ Array.prototype.unshift.apply(n, t)
595
595
  }
596
- async function mapAllAsync(n, e) {
597
- const t = []
598
- for (const r of n) t.push(await e(r))
599
- return t
596
+ async function mapAllAsync(n, t) {
597
+ const e = []
598
+ for (const r of n) e.push(await t(r))
599
+ return e
600
600
  }
601
- function glue(n, e) {
602
- const t = []
603
- for (let r = 0; r < n.length; r++) t.push(n[r]), r < n.length - 1 && (isFunction(e) ? t.push(e()) : t.push(e))
604
- return t
601
+ function glue(n, t) {
602
+ const e = []
603
+ for (let r = 0; r < n.length; r++) e.push(n[r]), r < n.length - 1 && (isFunction(t) ? e.push(t()) : e.push(t))
604
+ return e
605
605
  }
606
- function asEqual(n, e) {
607
- if (n !== e) throw Error(`Expected [${n}] to equal [${e}]`)
608
- return [n, e]
606
+ function asEqual(n, t) {
607
+ if (n !== t) throw Error(`Expected [${n}] to equal [${t}]`)
608
+ return [n, t]
609
609
  }
610
610
  function asTrue(n) {
611
611
  if (n !== !0) throw Error(`Expected [true], got: [${n}]`)
@@ -623,53 +623,53 @@ function asFalsy(n) {
623
623
  if (n) throw Error(`Expected falsy value, got: [${n}]`)
624
624
  return n
625
625
  }
626
- function asEither(n, e) {
627
- if (!e.includes(n)) throw Error(`Expected any of [${e.join(', ')}], got: [${n}]`)
626
+ function asEither(n, t) {
627
+ if (!t.includes(n)) throw Error(`Expected any of [${t.join(', ')}], got: [${n}]`)
628
628
  return n
629
629
  }
630
- function scheduleMany(n, e) {
631
- for (let t = 0; t < n.length; t++) {
632
- const r = n[t],
633
- i = e[t],
630
+ function scheduleMany(n, t) {
631
+ for (let e = 0; e < n.length; e++) {
632
+ const r = n[e],
633
+ i = t[e],
634
634
  o = Math.max(0, i.getTime() - Date.now())
635
635
  setTimeout(r, o)
636
636
  }
637
637
  }
638
- function interpolate(n, e, t) {
639
- return n + (e - n) * t
638
+ function interpolate(n, t, e) {
639
+ return n + (t - n) * e
640
640
  }
641
641
  function sum(n) {
642
- return n.reduce((e, t) => e + t, 0)
642
+ return n.reduce((t, e) => t + e, 0)
643
643
  }
644
644
  function average(n) {
645
- return n.reduce((e, t) => e + t, 0) / n.length
645
+ return n.reduce((t, e) => t + e, 0) / n.length
646
646
  }
647
647
  function median(n) {
648
- const e = [...n].sort((r, i) => r - i),
649
- t = Math.floor(e.length / 2)
650
- return e.length % 2 === 0 ? (e[t] + e[t - 1]) / 2 : e[t]
648
+ const t = [...n].sort((r, i) => r - i),
649
+ e = Math.floor(t.length / 2)
650
+ return t.length % 2 === 0 ? (t[e] + t[e - 1]) / 2 : t[e]
651
651
  }
652
- function getDistanceFromMidpoint(n, e) {
653
- return n - (e - 1) / 2
652
+ function getDistanceFromMidpoint(n, t) {
653
+ return n - (t - 1) / 2
654
654
  }
655
- function range(n, e) {
656
- const t = []
657
- for (let r = n; r <= e; r++) t.push(r)
658
- return t
655
+ function range(n, t) {
656
+ const e = []
657
+ for (let r = n; r <= t; r++) e.push(r)
658
+ return e
659
659
  }
660
- function includesAny(n, e) {
661
- return e.some(t => n.includes(t))
660
+ function includesAny(n, t) {
661
+ return t.some(e => n.includes(e))
662
662
  }
663
663
  function isChinese(n) {
664
664
  return /^[\u4E00-\u9FA5]+$/.test(n)
665
665
  }
666
- function slugify(n, e = () => !1) {
666
+ function slugify(n, t = () => !1) {
667
667
  return n
668
668
  .toLowerCase()
669
669
  .normalize('NFD')
670
670
  .replace(/[\u0300-\u036f]/g, '')
671
671
  .split('')
672
- .map(t => (/[a-z0-9]/.test(t) || e(t) ? t : '-'))
672
+ .map(e => (/[a-z0-9]/.test(e) || t(e) ? e : '-'))
673
673
  .join('')
674
674
  .replace(/-+/g, '-')
675
675
  .replace(/^-|-$/g, '')
@@ -686,107 +686,107 @@ function slugToTitle(n) {
686
686
  function slugToCamel(n) {
687
687
  return decapitalize(n.split('-').map(capitalize).join(''))
688
688
  }
689
- function joinHumanly(n, e = ', ', t = ' and ') {
690
- return !n || !n.length ? '' : n.length === 1 ? n[0] : n.length === 2 ? `${n[0]}${t}${n[1]}` : `${n.slice(0, n.length - 1).join(e)}${t}${n[n.length - 1]}`
689
+ function joinHumanly(n, t = ', ', e = ' and ') {
690
+ return !n || !n.length ? '' : n.length === 1 ? n[0] : n.length === 2 ? `${n[0]}${e}${n[1]}` : `${n.slice(0, n.length - 1).join(t)}${e}${n[n.length - 1]}`
691
691
  }
692
- function surroundInOut(n, e) {
693
- return e + n.split('').join(e) + e
692
+ function surroundInOut(n, t) {
693
+ return t + n.split('').join(t) + t
694
694
  }
695
695
  function enumify(n) {
696
696
  return slugify(n).replace(/-/g, '_').toUpperCase()
697
697
  }
698
- function getFuzzyMatchScore(n, e) {
699
- if (e.length === 0) return 0
700
- const t = n.toLowerCase(),
701
- r = e.toLowerCase()
702
- return n === e ? 1e4 : t.startsWith(r) ? 1e4 - n.length : t.includes(r) ? 5e3 - n.length : new RegExp('.*' + r.split('').join('.*') + '.*').test(t) ? 1e3 - n.length : 0
698
+ function getFuzzyMatchScore(n, t) {
699
+ if (t.length === 0) return 0
700
+ const e = n.toLowerCase(),
701
+ r = t.toLowerCase()
702
+ return n === t ? 1e4 : e.startsWith(r) ? 1e4 - n.length : e.includes(r) ? 5e3 - n.length : new RegExp('.*' + r.split('').join('.*') + '.*').test(e) ? 1e3 - n.length : 0
703
703
  }
704
- function sortByFuzzyScore(n, e) {
705
- return n.filter(t => getFuzzyMatchScore(t, e)).sort((t, r) => getFuzzyMatchScore(r, e) - getFuzzyMatchScore(t, e))
704
+ function sortByFuzzyScore(n, t) {
705
+ return n.filter(e => getFuzzyMatchScore(e, t)).sort((e, r) => getFuzzyMatchScore(r, t) - getFuzzyMatchScore(e, t))
706
706
  }
707
707
  function escapeHtml(n) {
708
708
  return n.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
709
709
  }
710
710
  const htmlEntityMap = { '&amp;': '&', '&quot;': '"', '&apos;': "'", '&gt;': '>', '&lt;': '<' }
711
711
  function decodeHtmlEntities(n) {
712
- let e = n.replace(/&#(\d+);/g, (t, r) => String.fromCharCode(r)).replace(/&#x(\d+);/g, (t, r) => String.fromCharCode(parseInt(r, 16)))
713
- for (const [t, r] of Object.entries(htmlEntityMap)) e = e.replaceAll(t, r)
714
- return e
712
+ let t = n.replace(/&#(\d+);/g, (e, r) => String.fromCharCode(r)).replace(/&#x(\d+);/g, (e, r) => String.fromCharCode(parseInt(r, 16)))
713
+ for (const [e, r] of Object.entries(htmlEntityMap)) t = t.replaceAll(e, r)
714
+ return t
715
715
  }
716
- function before(n, e) {
717
- const t = n.indexOf(e)
718
- return t === -1 ? null : n.slice(0, t)
716
+ function before(n, t) {
717
+ const e = n.indexOf(t)
718
+ return e === -1 ? null : n.slice(0, e)
719
719
  }
720
- function after(n, e) {
721
- const t = n.indexOf(e)
722
- return t === -1 ? null : n.slice(t + e.length)
720
+ function after(n, t) {
721
+ const e = n.indexOf(t)
722
+ return e === -1 ? null : n.slice(e + t.length)
723
723
  }
724
- function beforeLast(n, e) {
725
- const t = n.lastIndexOf(e)
726
- return t === -1 ? null : n.slice(0, t)
724
+ function beforeLast(n, t) {
725
+ const e = n.lastIndexOf(t)
726
+ return e === -1 ? null : n.slice(0, e)
727
727
  }
728
- function afterLast(n, e) {
729
- const t = n.lastIndexOf(e)
730
- return t === -1 ? null : n.slice(t + e.length)
728
+ function afterLast(n, t) {
729
+ const e = n.lastIndexOf(t)
730
+ return e === -1 ? null : n.slice(e + t.length)
731
731
  }
732
- function betweenWide(n, e, t) {
733
- const r = beforeLast(n, t)
734
- return r ? after(r, e) : null
732
+ function betweenWide(n, t, e) {
733
+ const r = beforeLast(n, e)
734
+ return r ? after(r, t) : null
735
735
  }
736
- function betweenNarrow(n, e, t) {
737
- const r = after(n, e)
738
- return r ? before(r, t) : null
736
+ function betweenNarrow(n, t, e) {
737
+ const r = after(n, t)
738
+ return r ? before(r, e) : null
739
739
  }
740
- function splitOnce(n, e, t = !1) {
741
- const r = t ? n.lastIndexOf(e) : n.indexOf(e)
742
- return r === -1 ? (t ? [null, n] : [n, null]) : [n.slice(0, r), n.slice(r + e.length)]
740
+ function splitOnce(n, t, e = !1) {
741
+ const r = e ? n.lastIndexOf(t) : n.indexOf(t)
742
+ return r === -1 ? (e ? [null, n] : [n, null]) : [n.slice(0, r), n.slice(r + t.length)]
743
743
  }
744
- function splitAll(n, e) {
745
- let t = [n]
746
- for (const r of e) t = t.flatMap(i => i.split(r))
747
- return t.filter(r => r)
744
+ function splitAll(n, t) {
745
+ let e = [n]
746
+ for (const r of t) e = e.flatMap(i => i.split(r))
747
+ return e.filter(r => r)
748
748
  }
749
749
  function getExtension(n) {
750
- const e = last(n.split(/\\|\//g)),
751
- t = e.lastIndexOf('.', e.length - 1)
752
- return t <= 0 ? '' : e.slice(t + 1)
750
+ const t = last(n.split(/\\|\//g)),
751
+ e = t.lastIndexOf('.', t.length - 1)
752
+ return e <= 0 ? '' : t.slice(e + 1)
753
753
  }
754
754
  function getBasename(n) {
755
- const e = last(n.split(/\\|\//g)),
756
- t = e.lastIndexOf('.', e.length - 1)
757
- return t <= 0 ? e : e.slice(0, t)
755
+ const t = last(n.split(/\\|\//g)),
756
+ e = t.lastIndexOf('.', t.length - 1)
757
+ return e <= 0 ? t : t.slice(0, e)
758
758
  }
759
759
  function normalizeEmail(n) {
760
- let [e, t] = n.split('@')
761
- e = shrinkTrim(e.replaceAll('.', '').toLowerCase()).replaceAll(' ', '')
762
- const [r] = e.split('+')
763
- if (!r || !t || t.indexOf('.') === -1 || t.indexOf('.') === t.length - 1) throw new Error('Invalid email')
764
- return (t = shrinkTrim(t.toLowerCase()).replaceAll(' ', '')), `${r}@${t}`
760
+ let [t, e] = n.split('@')
761
+ t = shrinkTrim(t.replaceAll('.', '').toLowerCase()).replaceAll(' ', '')
762
+ const [r] = t.split('+')
763
+ if (!r || !e || e.indexOf('.') === -1 || e.indexOf('.') === e.length - 1) throw new Error('Invalid email')
764
+ return (e = shrinkTrim(e.toLowerCase()).replaceAll(' ', '')), `${r}@${e}`
765
765
  }
766
766
  function normalizeFilename(n) {
767
- const e = getBasename(n),
768
- t = getExtension(n)
769
- return t ? `${e}.${t}` : e
767
+ const t = getBasename(n),
768
+ e = getExtension(n)
769
+ return e ? `${t}.${e}` : t
770
770
  }
771
771
  function parseFilename(n) {
772
- const e = getBasename(n),
773
- t = getExtension(n)
774
- return { basename: e, extension: t, filename: t ? `${e}.${t}` : e }
772
+ const t = getBasename(n),
773
+ e = getExtension(n)
774
+ return { basename: t, extension: e, filename: e ? `${t}.${e}` : t }
775
775
  }
776
- function randomize(n, e = Math.random) {
777
- return n.replace(/\{(.+?)\}/g, (t, r) => pick(r.split('|'), e))
776
+ function randomize(n, t = Math.random) {
777
+ return n.replace(/\{(.+?)\}/g, (e, r) => pick(r.split('|'), t))
778
778
  }
779
779
  function expand(n) {
780
- const e = /\{(.+?)\}/,
781
- t = n.match(e)
782
- if (!t || !t.index) return [n]
783
- const r = t[1].split(','),
784
- i = n.slice(0, t.index),
785
- o = n.slice(t.index + t[0].length)
780
+ const t = /\{(.+?)\}/,
781
+ e = n.match(t)
782
+ if (!e || !e.index) return [n]
783
+ const r = e[1].split(','),
784
+ i = n.slice(0, e.index),
785
+ o = n.slice(e.index + e[0].length)
786
786
  let c = []
787
- for (const u of r) {
788
- const s = expand(i + u + o)
789
- c = c.concat(s)
787
+ for (const s of r) {
788
+ const u = expand(i + s + o)
789
+ c = c.concat(u)
790
790
  }
791
791
  return c
792
792
  }
@@ -796,8 +796,8 @@ function shrinkTrim(n) {
796
796
  `
797
797
  `
798
798
  )
799
- .map(e => e.trim().replace(/\s+/g, ' '))
800
- .filter(e => e.length > 0).join(`
799
+ .map(t => t.trim().replace(/\s+/g, ' '))
800
+ .filter(t => t.length > 0).join(`
801
801
  `)
802
802
  }
803
803
  function capitalize(n) {
@@ -808,13 +808,13 @@ function decapitalize(n) {
808
808
  }
809
809
  function isLetter(n) {
810
810
  if (!n) return !1
811
- const e = n.charCodeAt(0)
812
- return (e >= 65 && e <= 90) || (e >= 97 && e <= 122)
811
+ const t = n.charCodeAt(0)
812
+ return (t >= 65 && t <= 90) || (t >= 97 && t <= 122)
813
813
  }
814
814
  function isDigit(n) {
815
815
  if (!n) return !1
816
- const e = n.charCodeAt(0)
817
- return e >= 48 && e <= 57
816
+ const t = n.charCodeAt(0)
817
+ return t >= 48 && t <= 57
818
818
  }
819
819
  function isLetterOrDigit(n) {
820
820
  return isLetter(n) || isDigit(n)
@@ -827,17 +827,17 @@ function isWordBreakCharacter(n) {
827
827
  function isValidObjectPathCharacter(n) {
828
828
  return isLetterOrDigit(n) || n === '.' || n === '[' || n === ']' || n === '_'
829
829
  }
830
- function insertString(n, e, t, r, i) {
831
- return n.slice(0, e) + r + n.slice(e, e + t) + i + n.slice(e + t)
830
+ function insertString(n, t, e, r, i) {
831
+ return n.slice(0, t) + r + n.slice(t, t + e) + i + n.slice(t + e)
832
832
  }
833
- function indexOfRegex(n, e, t = 0) {
834
- const r = e.exec(n.slice(t))
833
+ function indexOfRegex(n, t, e = 0) {
834
+ const r = t.exec(n.slice(e))
835
835
  return r ? { index: r.index, match: r[0] } : null
836
836
  }
837
- function lineMatches(n, e, t = !0) {
838
- if (!t) return e.every(i => (i instanceof RegExp ? i.test(n) : n.indexOf(i, 0) !== -1))
837
+ function lineMatches(n, t, e = !0) {
838
+ if (!e) return t.every(i => (i instanceof RegExp ? i.test(n) : n.indexOf(i, 0) !== -1))
839
839
  let r = 0
840
- for (const i of e)
840
+ for (const i of t)
841
841
  if (i instanceof RegExp) {
842
842
  const o = indexOfRegex(n, i, r)
843
843
  if (!o) return !1
@@ -849,11 +849,11 @@ function lineMatches(n, e, t = !0) {
849
849
  }
850
850
  return !0
851
851
  }
852
- function linesMatchInOrder(n, e, t = !0) {
852
+ function linesMatchInOrder(n, t, e = !0) {
853
853
  let r = 0
854
- for (const i of e) {
854
+ for (const i of t) {
855
855
  let o = !1
856
- for (; !o && r < n.length; ) lineMatches(n[r], i, t) && (o = !0), r++
856
+ for (; !o && r < n.length; ) lineMatches(n[r], i, e) && (o = !0), r++
857
857
  if (!o) return !1
858
858
  }
859
859
  return !0
@@ -861,138 +861,138 @@ function linesMatchInOrder(n, e, t = !0) {
861
861
  function csvEscape(n) {
862
862
  return n.match(/"|,/) ? `"${n.replace(/"/g, '""')}"` : n
863
863
  }
864
- function allIndexOf(n, e, t = 0) {
864
+ function allIndexOf(n, t, e = 0) {
865
865
  const r = []
866
- let i = n.indexOf(e, t)
867
- for (; i !== -1; ) r.push(i), (i = n.indexOf(e, i + e.length))
866
+ let i = n.indexOf(t, e)
867
+ for (; i !== -1; ) r.push(i), (i = n.indexOf(t, i + t.length))
868
868
  return r
869
869
  }
870
- function indexOfEarliest(n, e, t = 0) {
870
+ function indexOfEarliest(n, t, e = 0) {
871
871
  let r = -1
872
- for (const i of e) {
873
- const o = n.indexOf(i, t)
872
+ for (const i of t) {
873
+ const o = n.indexOf(i, e)
874
874
  o !== -1 && (r === -1 || o < r) && (r = o)
875
875
  }
876
876
  return r
877
877
  }
878
- function indexOfWordBreak(n, e = 0) {
879
- for (let t = e; t < n.length; t++) if (isWordBreakCharacter(n[t])) return t
878
+ function indexOfWordBreak(n, t = 0) {
879
+ for (let e = t; e < n.length; e++) if (isWordBreakCharacter(n[e])) return e
880
880
  return -1
881
881
  }
882
- function indexOfHashtag(n, e = 0) {
883
- for (let t = e; t < n.length; t++) if (n[t] === '#' && isLetterOrDigit(n[t + 1])) return t
882
+ function indexOfHashtag(n, t = 0) {
883
+ for (let e = t; e < n.length; e++) if (n[e] === '#' && isLetterOrDigit(n[e + 1])) return e
884
884
  return -1
885
885
  }
886
- function lastIndexOfBefore(n, e, t = 0) {
887
- return n.slice(0, t).lastIndexOf(e)
886
+ function lastIndexOfBefore(n, t, e = 0) {
887
+ return n.slice(0, e).lastIndexOf(t)
888
888
  }
889
- function findWeightedPair(n, e = 0, t = '{', r = '}') {
889
+ function findWeightedPair(n, t = 0, e = '{', r = '}') {
890
890
  let i = 1
891
- for (let o = e; o < n.length; o++)
891
+ for (let o = t; o < n.length; o++)
892
892
  if (n.slice(o, o + r.length) === r) {
893
893
  if (--i === 0) return o
894
- } else n.slice(o, o + t.length) === t && i++
894
+ } else n.slice(o, o + e.length) === e && i++
895
895
  return -1
896
896
  }
897
- function extractBlock(n, e) {
898
- const t = e.wordBoundary
897
+ function extractBlock(n, t) {
898
+ const e = t.wordBoundary
899
899
  ? indexOfEarliest(
900
900
  n,
901
901
  [
902
- `${e.opening} `,
903
- `${e.opening}
902
+ `${t.opening} `,
903
+ `${t.opening}
904
904
  `
905
905
  ],
906
- e.start || 0
906
+ t.start || 0
907
907
  )
908
- : n.indexOf(e.opening, e.start || 0)
909
- if (t === -1) return null
910
- const r = findWeightedPair(n, t + e.opening.length, e.opening, e.closing)
911
- return r === -1 ? null : e.exclusive ? n.slice(t + e.opening.length, r) : n.slice(t, r + e.closing.length)
908
+ : n.indexOf(t.opening, t.start || 0)
909
+ if (e === -1) return null
910
+ const r = findWeightedPair(n, e + t.opening.length, t.opening, t.closing)
911
+ return r === -1 ? null : t.exclusive ? n.slice(e + t.opening.length, r) : n.slice(e, r + t.closing.length)
912
912
  }
913
- function extractAllBlocks(n, e) {
914
- const t = []
915
- let r = e.wordBoundary
913
+ function extractAllBlocks(n, t) {
914
+ const e = []
915
+ let r = t.wordBoundary
916
916
  ? indexOfEarliest(
917
917
  n,
918
918
  [
919
- `${e.opening} `,
920
- `${e.opening}
919
+ `${t.opening} `,
920
+ `${t.opening}
921
921
  `
922
922
  ],
923
- e.start || 0
923
+ t.start || 0
924
924
  )
925
- : n.indexOf(e.opening, e.start || 0)
925
+ : n.indexOf(t.opening, t.start || 0)
926
926
  for (;;) {
927
- if (r === -1) return t
928
- const i = extractBlock(n, { ...e, start: r })
929
- if (!i) return t
930
- t.push(i),
931
- (r = e.wordBoundary
927
+ if (r === -1) return e
928
+ const i = extractBlock(n, { ...t, start: r })
929
+ if (!i) return e
930
+ e.push(i),
931
+ (r = t.wordBoundary
932
932
  ? indexOfEarliest(
933
933
  n,
934
934
  [
935
- `${e.opening} `,
936
- `${e.opening}
935
+ `${t.opening} `,
936
+ `${t.opening}
937
937
  `
938
938
  ],
939
939
  r + i.length
940
940
  )
941
- : n.indexOf(e.opening, r + i.length))
941
+ : n.indexOf(t.opening, r + i.length))
942
942
  }
943
943
  }
944
- function replaceBlocks(n, e, t) {
944
+ function replaceBlocks(n, t, e) {
945
945
  let r = 0
946
946
  for (;;) {
947
- const i = exports.Strings.extractBlock(n, { ...t, start: r })
947
+ const i = exports.Strings.extractBlock(n, { ...e, start: r })
948
948
  if (!i) return n
949
- const o = e(i)
949
+ const o = t(i)
950
950
  ;(r = n.indexOf(i, r) + o.length), (n = n.replace(i, o))
951
951
  }
952
952
  }
953
- function splitFormatting(n, e) {
954
- const t = []
953
+ function splitFormatting(n, t) {
954
+ const e = []
955
955
  let r = 0
956
956
  for (; r < n.length; ) {
957
- const i = n.indexOf(e, r)
957
+ const i = n.indexOf(t, r)
958
958
  if (i === -1) {
959
- t.push({ string: n.slice(r), symbol: null })
959
+ e.push({ string: n.slice(r), symbol: null })
960
960
  break
961
961
  }
962
- const o = n.indexOf(e, i + e.length)
963
- if ((i > r && o !== -1 && t.push({ string: n.slice(r, i), symbol: null }), o === -1)) {
964
- t.push({ string: n.slice(r), symbol: null })
962
+ const o = n.indexOf(t, i + t.length)
963
+ if ((i > r && o !== -1 && e.push({ string: n.slice(r, i), symbol: null }), o === -1)) {
964
+ e.push({ string: n.slice(r), symbol: null })
965
965
  break
966
966
  }
967
- t.push({ string: n.slice(i + e.length, o), symbol: e }), (r = o + e.length)
967
+ e.push({ string: n.slice(i + t.length, o), symbol: t }), (r = o + t.length)
968
968
  }
969
- return t
969
+ return e
970
970
  }
971
971
  function splitHashtags(n) {
972
- const e = []
973
- let t = 0
974
- for (; t < n.length; ) {
975
- const r = indexOfHashtag(n, t)
972
+ const t = []
973
+ let e = 0
974
+ for (; e < n.length; ) {
975
+ const r = indexOfHashtag(n, e)
976
976
  if (r === -1) {
977
- e.push({ string: n.slice(t), symbol: null })
977
+ t.push({ string: n.slice(e), symbol: null })
978
978
  break
979
979
  }
980
980
  const i = indexOfWordBreak(n, r + 1)
981
981
  if (i === -1) {
982
- e.push({ string: n.slice(t, r), symbol: null }), e.push({ string: n.slice(r + 1), symbol: '#' })
982
+ t.push({ string: n.slice(e, r), symbol: null }), t.push({ string: n.slice(r + 1), symbol: '#' })
983
983
  break
984
984
  }
985
- r > t && e.push({ string: n.slice(t, r), symbol: null }), e.push({ string: n.slice(r + 1, i), symbol: '#' }), (t = i)
985
+ r > e && t.push({ string: n.slice(e, r), symbol: null }), t.push({ string: n.slice(r + 1, i), symbol: '#' }), (e = i)
986
986
  }
987
- return e
987
+ return t
988
988
  }
989
989
  function splitUrls(n) {
990
- const e = []
991
- let t = 0
992
- for (; t < n.length; ) {
993
- const r = indexOfEarliest(n, ['http://', 'https://'], t)
990
+ const t = []
991
+ let e = 0
992
+ for (; e < n.length; ) {
993
+ const r = indexOfEarliest(n, ['http://', 'https://'], e)
994
994
  if (r === -1) {
995
- e.push({ string: n.slice(t), symbol: null })
995
+ t.push({ string: n.slice(e), symbol: null })
996
996
  break
997
997
  }
998
998
  const i = indexOfEarliest(
@@ -1005,12 +1005,12 @@ function splitUrls(n) {
1005
1005
  r
1006
1006
  )
1007
1007
  if (i === -1) {
1008
- r > t && e.push({ string: n.slice(t, r), symbol: null }), e.push({ string: n.slice(r), symbol: 'http' })
1008
+ r > e && t.push({ string: n.slice(e, r), symbol: null }), t.push({ string: n.slice(r), symbol: 'http' })
1009
1009
  break
1010
1010
  }
1011
- r > t && e.push({ string: n.slice(t, r), symbol: null }), e.push({ string: n.slice(r, i), symbol: 'http' }), (t = i)
1011
+ r > e && t.push({ string: n.slice(e, r), symbol: null }), t.push({ string: n.slice(r, i), symbol: 'http' }), (e = i)
1012
1012
  }
1013
- return e
1013
+ return t
1014
1014
  }
1015
1015
  const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
1016
1016
  BASE32_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'
@@ -1026,80 +1026,80 @@ function base32ToUint8Array(n) {
1026
1026
  function uint8ArrayToBase32(n) {
1027
1027
  return uint8ArrayToBase(n, BASE32_CHARS)
1028
1028
  }
1029
- function baseToUint8Array(n, e) {
1030
- const t = '=',
1031
- r = e.length
1029
+ function baseToUint8Array(n, t) {
1030
+ const e = '=',
1031
+ r = t.length
1032
1032
  let i = 0,
1033
1033
  o = 0
1034
1034
  const c = []
1035
- for (let u = 0; u < n.length; u++) {
1036
- const s = n[u]
1037
- if (s === t) break
1038
- const f = e.indexOf(s)
1039
- if (f === -1) throw new Error(`Invalid character: ${s}`)
1035
+ for (let s = 0; s < n.length; s++) {
1036
+ const u = n[s]
1037
+ if (u === e) break
1038
+ const f = t.indexOf(u)
1039
+ if (f === -1) throw new Error(`Invalid character: ${u}`)
1040
1040
  ;(o = (o << Math.log2(r)) | f), (i += Math.log2(r)), i >= 8 && ((i -= 8), c.push((o >> i) & 255))
1041
1041
  }
1042
1042
  return new Uint8Array(c)
1043
1043
  }
1044
- function uint8ArrayToBase(n, e) {
1045
- const t = e.length
1044
+ function uint8ArrayToBase(n, t) {
1045
+ const e = t.length
1046
1046
  let r = 0,
1047
1047
  i = 0,
1048
1048
  o = ''
1049
- for (let c = 0; c < n.length; c++) for (i = (i << 8) | n[c], r += 8; r >= Math.log2(t); ) (r -= Math.log2(t)), (o += e[(i >> r) & (t - 1)])
1050
- return r > 0 && (o += e[(i << (Math.log2(t) - r)) & (t - 1)]), o.length % 4 !== 0 && (o += '='.repeat(4 - (o.length % 4))), o
1049
+ for (let c = 0; c < n.length; c++) for (i = (i << 8) | n[c], r += 8; r >= Math.log2(e); ) (r -= Math.log2(e)), (o += t[(i >> r) & (e - 1)])
1050
+ return r > 0 && (o += t[(i << (Math.log2(e) - r)) & (e - 1)]), o.length % 4 !== 0 && (o += '='.repeat(4 - (o.length % 4))), o
1051
1051
  }
1052
1052
  function hexToUint8Array(n) {
1053
1053
  ;(n.startsWith('0x') || n.startsWith('0X')) && (n = n.slice(2))
1054
- const e = n.length / 2,
1055
- t = new Uint8Array(e)
1056
- for (let r = 0; r < e; r++) {
1054
+ const t = n.length / 2,
1055
+ e = new Uint8Array(t)
1056
+ for (let r = 0; r < t; r++) {
1057
1057
  const i = parseInt(n.slice(r * 2, r * 2 + 2), 16)
1058
- t[r] = i
1058
+ e[r] = i
1059
1059
  }
1060
- return t
1060
+ return e
1061
1061
  }
1062
1062
  function uint8ArrayToHex(n) {
1063
1063
  return Array.from(n)
1064
- .map(e => e.toString(16).padStart(2, '0'))
1064
+ .map(t => t.toString(16).padStart(2, '0'))
1065
1065
  .join('')
1066
1066
  }
1067
1067
  function uint8ArrayToBinary(n) {
1068
1068
  return Array.from(n)
1069
- .map(e => e.toString(2).padStart(8, '0'))
1069
+ .map(t => t.toString(2).padStart(8, '0'))
1070
1070
  .join('')
1071
1071
  }
1072
1072
  function binaryToUint8Array(n) {
1073
- const e = Math.ceil(n.length / 8),
1074
- t = new Uint8Array(e)
1075
- for (let r = 0; r < e; r++) {
1073
+ const t = Math.ceil(n.length / 8),
1074
+ e = new Uint8Array(t)
1075
+ for (let r = 0; r < t; r++) {
1076
1076
  const i = parseInt(n.slice(r * 8, r * 8 + 8), 2)
1077
- t[r] = i
1077
+ e[r] = i
1078
1078
  }
1079
- return t
1079
+ return e
1080
1080
  }
1081
- function route(n, e) {
1082
- const t = n.split('/').filter(o => o),
1083
- r = e.split('/').filter(o => o)
1084
- if (t.length !== r.length) return null
1081
+ function route(n, t) {
1082
+ const e = n.split('/').filter(o => o),
1083
+ r = t.split('/').filter(o => o)
1084
+ if (e.length !== r.length) return null
1085
1085
  const i = {}
1086
- for (let o = 0; o < t.length; o++) {
1087
- const c = t[o]
1086
+ for (let o = 0; o < e.length; o++) {
1087
+ const c = e[o]
1088
1088
  if (c.startsWith(':')) i[c.slice(1)] = r[o]
1089
1089
  else if (c !== r[o]) return null
1090
1090
  }
1091
1091
  return i
1092
1092
  }
1093
- function explodeReplace(n, e, t) {
1093
+ function explodeReplace(n, t, e) {
1094
1094
  const r = []
1095
- for (const i of t) i !== e && r.push(n.replace(e, i))
1095
+ for (const i of e) i !== t && r.push(n.replace(t, i))
1096
1096
  return r
1097
1097
  }
1098
- function generateVariants(n, e, t, r = Math.random) {
1098
+ function generateVariants(n, t, e, r = Math.random) {
1099
1099
  const i = exports.Arrays.shuffle(
1100
- e.map(c => ({
1100
+ t.map(c => ({
1101
1101
  variants: exports.Arrays.shuffle(
1102
- c.variants.map(u => u),
1102
+ c.variants.map(s => s),
1103
1103
  r
1104
1104
  ),
1105
1105
  avoid: c.avoid
@@ -1108,241 +1108,241 @@ function generateVariants(n, e, t, r = Math.random) {
1108
1108
  ),
1109
1109
  o = []
1110
1110
  for (const c of i) {
1111
- const u = c.variants.filter(f => f !== c.avoid),
1112
- s = u.find(f => n.includes(f))
1113
- if (s && (pushAll(o, explodeReplace(n, s, u)), o.length >= t)) break
1111
+ const s = c.variants.filter(f => f !== c.avoid),
1112
+ u = s.find(f => n.includes(f))
1113
+ if (u && (pushAll(o, explodeReplace(n, u, s)), o.length >= e)) break
1114
1114
  }
1115
- if (o.length < t)
1115
+ if (o.length < e)
1116
1116
  for (const c of i) {
1117
- const u = c.variants.find(s => n.includes(s))
1118
- if (u && (pushAll(o, explodeReplace(n, u, c.variants)), o.length >= t)) break
1117
+ const s = c.variants.find(u => n.includes(u))
1118
+ if (s && (pushAll(o, explodeReplace(n, s, c.variants)), o.length >= e)) break
1119
1119
  }
1120
- return o.slice(0, t)
1120
+ return o.slice(0, e)
1121
1121
  }
1122
- function replaceWord(n, e, t, r = !1) {
1123
- const i = new RegExp(r ? `(?<=\\s|^)${e}(?=\\s|$)` : `\\b${e}\\b`, 'g')
1124
- return n.replace(i, t)
1122
+ function replaceWord(n, t, e, r = !1) {
1123
+ const i = new RegExp(r ? `(?<=\\s|^)${t}(?=\\s|$)` : `\\b${t}\\b`, 'g')
1124
+ return n.replace(i, e)
1125
1125
  }
1126
- function replacePascalCaseWords(n, e) {
1127
- const t = /\b[A-Z][a-zA-Z0-9]*\b/g
1128
- return n.replace(t, r => (r.toUpperCase() === r ? r : e(r)))
1126
+ function replacePascalCaseWords(n, t) {
1127
+ const e = /\b[A-Z][a-zA-Z0-9]*\b/g
1128
+ return n.replace(e, r => (r.toUpperCase() === r ? r : t(r)))
1129
1129
  }
1130
1130
  function stripHtml(n) {
1131
1131
  return n.replace(/<[^>]*>/g, '')
1132
1132
  }
1133
1133
  function breakLine(n) {
1134
- const e = n.lastIndexOf(' ')
1135
- if (e === -1) return { line: n, rest: '' }
1136
- const t = n.slice(0, e),
1137
- r = n.slice(e + 1)
1138
- return { line: t, rest: r }
1134
+ const t = n.lastIndexOf(' ')
1135
+ if (t === -1) return { line: n, rest: '' }
1136
+ const e = n.slice(0, t),
1137
+ r = n.slice(t + 1)
1138
+ return { line: e, rest: r }
1139
1139
  }
1140
- function measureTextWidth(n, e = {}) {
1141
- return [...n].reduce((t, r) => t + (e[r] || 1), 0)
1140
+ function measureTextWidth(n, t = {}) {
1141
+ return [...n].reduce((e, r) => e + (t[r] || 1), 0)
1142
1142
  }
1143
- function toLines(n, e, t = {}) {
1143
+ function toLines(n, t, e = {}) {
1144
1144
  const r = []
1145
1145
  let i = '',
1146
1146
  o = 0
1147
1147
  for (let c = 0; c < n.length; c++) {
1148
- const u = n[c],
1149
- s = t[u] || 1
1150
- if (((i += u), (o += s), o > e)) {
1148
+ const s = n[c],
1149
+ u = e[s] || 1
1150
+ if (((i += s), (o += u), o > t)) {
1151
1151
  const { line: f, rest: l } = breakLine(i)
1152
1152
  r.push(f),
1153
1153
  (i = l),
1154
1154
  (o = l
1155
1155
  .split('')
1156
- .map(a => t[a] || 1)
1156
+ .map(a => e[a] || 1)
1157
1157
  .reduce((a, h) => a + h, 0))
1158
1158
  }
1159
1159
  }
1160
1160
  return i && r.push(i), r
1161
1161
  }
1162
- function levenshteinDistance(n, e) {
1163
- const t = []
1164
- for (let r = 0; r <= n.length; r++) t[r] = [r]
1165
- for (let r = 0; r <= e.length; r++) t[0][r] = r
1162
+ function levenshteinDistance(n, t) {
1163
+ const e = []
1164
+ for (let r = 0; r <= n.length; r++) e[r] = [r]
1165
+ for (let r = 0; r <= t.length; r++) e[0][r] = r
1166
1166
  for (let r = 1; r <= n.length; r++)
1167
- for (let i = 1; i <= e.length; i++) {
1168
- const o = n[r - 1] === e[i - 1] ? 0 : 1
1169
- t[r][i] = Math.min(t[r - 1][i] + 1, t[r][i - 1] + 1, t[r - 1][i - 1] + o)
1167
+ for (let i = 1; i <= t.length; i++) {
1168
+ const o = n[r - 1] === t[i - 1] ? 0 : 1
1169
+ e[r][i] = Math.min(e[r - 1][i] + 1, e[r][i - 1] + 1, e[r - 1][i - 1] + o)
1170
1170
  }
1171
- return t[n.length][e.length]
1171
+ return e[n.length][t.length]
1172
1172
  }
1173
1173
  function findCommonPrefix(n) {
1174
- const e = n.reduce((r, i) => (r.length < i.length ? r : i))
1175
- let t = ''
1176
- for (let r = 0; r < e.length; r++) {
1177
- const i = e[r]
1178
- if (n.every(o => o[r] === i)) t += i
1174
+ const t = n.reduce((r, i) => (r.length < i.length ? r : i))
1175
+ let e = ''
1176
+ for (let r = 0; r < t.length; r++) {
1177
+ const i = t[r]
1178
+ if (n.every(o => o[r] === i)) e += i
1179
1179
  else break
1180
1180
  }
1181
- return t
1181
+ return e
1182
1182
  }
1183
1183
  function findCommonDirectory(n) {
1184
- const e = findCommonPrefix(n),
1185
- t = e.lastIndexOf('/')
1186
- return t === -1 ? '' : e.slice(0, t + 1)
1184
+ const t = findCommonPrefix(n),
1185
+ e = t.lastIndexOf('/')
1186
+ return e === -1 ? '' : t.slice(0, e + 1)
1187
1187
  }
1188
- function containsWord(n, e) {
1189
- return new RegExp(`\\b${e}\\b`).test(n)
1188
+ function containsWord(n, t) {
1189
+ return new RegExp(`\\b${t}\\b`).test(n)
1190
1190
  }
1191
- function containsWords(n, e, t) {
1192
- return t === 'any' ? e.some(r => containsWord(n, r)) : e.every(r => containsWord(n, r))
1191
+ function containsWords(n, t, e) {
1192
+ return e === 'any' ? t.some(r => containsWord(n, r)) : t.every(r => containsWord(n, r))
1193
1193
  }
1194
1194
  function parseHtmlAttributes(n) {
1195
- const e = {},
1196
- t = n.match(/([a-z\-]+)="([^"]+)"/g)
1197
- if (t)
1198
- for (const r of t) {
1195
+ const t = {},
1196
+ e = n.match(/([a-z\-]+)="([^"]+)"/g)
1197
+ if (e)
1198
+ for (const r of e) {
1199
1199
  const [i, o] = splitOnce(r, '=')
1200
- e[i] = o.slice(1, o.length - 1)
1200
+ t[i] = o.slice(1, o.length - 1)
1201
1201
  }
1202
- return e
1202
+ return t
1203
1203
  }
1204
- function readNextWord(n, e, t = []) {
1204
+ function readNextWord(n, t, e = []) {
1205
1205
  let r = ''
1206
- for (; e < n.length && (isLetterOrDigit(n[e]) || t.includes(n[e])); ) r += n[e++]
1206
+ for (; t < n.length && (isLetterOrDigit(n[t]) || e.includes(n[t])); ) r += n[t++]
1207
1207
  return r
1208
1208
  }
1209
- function readWordsAfterAll(n, e, t = []) {
1210
- const r = allIndexOf(n, e),
1209
+ function readWordsAfterAll(n, t, e = []) {
1210
+ const r = allIndexOf(n, t),
1211
1211
  i = []
1212
- for (const o of r) i.push(readNextWord(n, o + e.length, t))
1212
+ for (const o of r) i.push(readNextWord(n, o + t.length, e))
1213
1213
  return i
1214
1214
  }
1215
- function resolveVariables(n, e, t = '$', r = ':') {
1216
- for (const i in e) n = resolveVariableWithDefaultSyntax(n, i, e[i], t, r)
1215
+ function resolveVariables(n, t, e = '$', r = ':') {
1216
+ for (const i in t) n = resolveVariableWithDefaultSyntax(n, i, t[i], e, r)
1217
1217
  return (n = resolveRemainingVariablesWithDefaults(n)), n
1218
1218
  }
1219
- function resolveVariableWithDefaultSyntax(n, e, t, r = '$', i = ':') {
1220
- if (t === '') return n
1221
- let o = n.indexOf(`${r}${e}`)
1219
+ function resolveVariableWithDefaultSyntax(n, t, e, r = '$', i = ':') {
1220
+ if (e === '') return n
1221
+ let o = n.indexOf(`${r}${t}`)
1222
1222
  for (; o !== -1; ) {
1223
- if (n[o + e.length + 1] === i)
1224
- if (n[o + e.length + 2] === i) n = n.replace(`${r}${e}${i}${i}`, t)
1223
+ if (n[o + t.length + 1] === i)
1224
+ if (n[o + t.length + 2] === i) n = n.replace(`${r}${t}${i}${i}`, e)
1225
1225
  else {
1226
- const u = readNextWord(n, o + e.length + 2, ['_'])
1227
- n = n.replace(`${r}${e}${i}${u}`, t)
1226
+ const s = readNextWord(n, o + t.length + 2, ['_'])
1227
+ n = n.replace(`${r}${t}${i}${s}`, e)
1228
1228
  }
1229
- else n = n.replace(`${r}${e}`, t)
1230
- o = n.indexOf(`${r}${e}`, o + t.length)
1229
+ else n = n.replace(`${r}${t}`, e)
1230
+ o = n.indexOf(`${r}${t}`, o + e.length)
1231
1231
  }
1232
1232
  return n
1233
1233
  }
1234
- function resolveRemainingVariablesWithDefaults(n, e = '$', t = ':') {
1235
- let r = n.indexOf(e)
1234
+ function resolveRemainingVariablesWithDefaults(n, t = '$', e = ':') {
1235
+ let r = n.indexOf(t)
1236
1236
  for (; r !== -1; ) {
1237
1237
  const i = readNextWord(n, r + 1)
1238
- if (n[r + i.length + 1] === t)
1239
- if (n[r + i.length + 2] === t) n = n.replace(`${e}${i}${t}${t}`, '')
1238
+ if (n[r + i.length + 1] === e)
1239
+ if (n[r + i.length + 2] === e) n = n.replace(`${t}${i}${e}${e}`, '')
1240
1240
  else {
1241
1241
  const c = readNextWord(n, r + i.length + 2)
1242
- n = n.replace(`${e}${i}${t}${c}`, c)
1242
+ n = n.replace(`${t}${i}${e}${c}`, c)
1243
1243
  }
1244
- r = n.indexOf(e, r + 1)
1244
+ r = n.indexOf(t, r + 1)
1245
1245
  }
1246
1246
  return n
1247
1247
  }
1248
- function resolveMarkdownLinks(n, e) {
1249
- let t = n.indexOf('](')
1250
- for (; t !== -1; ) {
1251
- const r = lastIndexOfBefore(n, '[', t),
1252
- i = n.indexOf(')', t)
1248
+ function resolveMarkdownLinks(n, t) {
1249
+ let e = n.indexOf('](')
1250
+ for (; e !== -1; ) {
1251
+ const r = lastIndexOfBefore(n, '[', e),
1252
+ i = n.indexOf(')', e)
1253
1253
  if (r !== -1 && i !== -1) {
1254
1254
  const [o, c] = n.slice(r + 1, i).split(']('),
1255
- u = e(o, c)
1256
- n = n.slice(0, r) + u + n.slice(i + 1)
1255
+ s = t(o, c)
1256
+ n = n.slice(0, r) + s + n.slice(i + 1)
1257
1257
  }
1258
- t = n.indexOf('](', t + 1)
1258
+ e = n.indexOf('](', e + 1)
1259
1259
  }
1260
1260
  return n
1261
1261
  }
1262
- function toQueryString(n, e = !0) {
1263
- const t = Object.entries(n)
1262
+ function toQueryString(n, t = !0) {
1263
+ const e = Object.entries(n)
1264
1264
  .filter(([r, i]) => i != null)
1265
1265
  .map(([r, i]) => `${r}=${encodeURIComponent(i)}`)
1266
1266
  .join('&')
1267
- return t ? (e ? '?' : '') + t : ''
1267
+ return e ? (t ? '?' : '') + e : ''
1268
1268
  }
1269
1269
  function parseQueryString(n) {
1270
- const e = {},
1271
- t = n.split('&')
1272
- for (const r of t) {
1270
+ const t = {},
1271
+ e = n.split('&')
1272
+ for (const r of e) {
1273
1273
  const [i, o] = r.split('=')
1274
- i && o && (e[i] = decodeURIComponent(o))
1274
+ i && o && (t[i] = decodeURIComponent(o))
1275
1275
  }
1276
- return e
1276
+ return t
1277
1277
  }
1278
- function hasKey(n, e) {
1279
- return Object.prototype.hasOwnProperty.call(n, e)
1278
+ function hasKey(n, t) {
1279
+ return Object.prototype.hasOwnProperty.call(n, t)
1280
1280
  }
1281
- function selectMax(n, e) {
1282
- let t = null,
1281
+ function selectMax(n, t) {
1282
+ let e = null,
1283
1283
  r = -1 / 0
1284
1284
  for (const [i, o] of Object.entries(n)) {
1285
- const c = e(o)
1286
- c > r && ((r = c), (t = i))
1285
+ const c = t(o)
1286
+ c > r && ((r = c), (e = i))
1287
1287
  }
1288
- return t ? [t, n[t]] : null
1288
+ return e ? [e, n[e]] : null
1289
1289
  }
1290
- function reposition(n, e, t, r) {
1291
- const i = n.find(c => c[e] === t),
1292
- o = n.find(c => c[e] === t + r)
1293
- i && o ? ((i[e] = t + r), (o[e] = t)) : i && (i[e] = t + r), n.sort((c, u) => asNumber(c[e]) - asNumber(u[e])), n.forEach((c, u) => (c[e] = u + 1))
1290
+ function reposition(n, t, e, r) {
1291
+ const i = n.find(c => c[t] === e),
1292
+ o = n.find(c => c[t] === e + r)
1293
+ i && o ? ((i[t] = e + r), (o[t] = e)) : i && (i[t] = e + r), n.sort((c, s) => asNumber(c[t]) - asNumber(s[t])), n.forEach((c, s) => (c[t] = s + 1))
1294
1294
  }
1295
1295
  function unwrapSingleKey(n) {
1296
- const e = Object.keys(n)
1297
- if (e.length === 1) return n[e[0]]
1296
+ const t = Object.keys(n)
1297
+ if (t.length === 1) return n[t[0]]
1298
1298
  throw new Error('Expected object to have a single key')
1299
1299
  }
1300
- function parseKeyValues(n, e = ':') {
1300
+ function parseKeyValues(n, t = ':') {
1301
1301
  return Object.fromEntries(
1302
1302
  n
1303
- .map(t => splitOnce(t, e))
1304
- .map(t => (t[0] && t[1] ? [shrinkTrim(t[0]), shrinkTrim(t[1])] : null))
1305
- .filter(t => t)
1303
+ .map(e => splitOnce(e, t))
1304
+ .map(e => (e[0] && e[1] ? [shrinkTrim(e[0]), shrinkTrim(e[1])] : null))
1305
+ .filter(e => e)
1306
1306
  )
1307
1307
  }
1308
- function errorMatches(n, e) {
1308
+ function errorMatches(n, t) {
1309
1309
  if (!n) return !1
1310
- const t = n.message
1311
- return typeof t == 'string' && t.includes(e)
1310
+ const e = n.message
1311
+ return typeof e == 'string' && e.includes(t)
1312
1312
  }
1313
- function buildUrl(n, e, t) {
1314
- return joinUrl([n, e]) + toQueryString(t || {})
1313
+ function buildUrl(n, t, e) {
1314
+ return joinUrl([n, t]) + toQueryString(e || {})
1315
1315
  }
1316
- function parseCsv(n, e = ',', t = '"') {
1316
+ function parseCsv(n, t = ',', e = '"') {
1317
1317
  const r = []
1318
1318
  let i = '',
1319
1319
  o = !1
1320
1320
  const c = n.split('')
1321
- for (const u of c) u === e && !o ? (r.push(i), (i = '')) : u === t && ((!i && !o) || o) ? (o = !o) : (i += u)
1321
+ for (const s of c) s === t && !o ? (r.push(i), (i = '')) : s === e && ((!i && !o) || o) ? (o = !o) : (i += s)
1322
1322
  return r.push(i), r
1323
1323
  }
1324
1324
  function humanizeProgress(n) {
1325
1325
  return `[${Math.floor(n.progress * 100)}%] ${humanizeTime(n.deltaMs)} out of ${humanizeTime(n.totalTimeMs)} (${humanizeTime(n.remainingTimeMs)} left) [${Math.round(n.baseTimeMs)} ms each]`
1326
1326
  }
1327
- async function waitFor(n, e) {
1328
- let t = e.requiredConsecutivePasses || 1,
1327
+ async function waitFor(n, t) {
1328
+ let e = t.requiredConsecutivePasses || 1,
1329
1329
  r = 0
1330
- for (let i = 0; i < e.attempts; i++) {
1330
+ for (let i = 0; i < t.attempts; i++) {
1331
1331
  try {
1332
1332
  if (await n()) {
1333
- if ((r++, r >= t)) return
1333
+ if ((r++, r >= e)) return
1334
1334
  } else r = 0
1335
1335
  } catch {
1336
1336
  r = 0
1337
1337
  }
1338
- i < e.attempts - 1 && (await sleepMillis(e.waitMillis))
1338
+ i < t.attempts - 1 && (await sleepMillis(t.waitMillis))
1339
1339
  }
1340
1340
  throw Error('Timed out waiting for predicate')
1341
1341
  }
1342
- function filterAndRemove(n, e) {
1343
- const t = []
1344
- for (let r = n.length - 1; r >= 0; r--) e(n[r]) && t.push(n.splice(r, 1)[0])
1345
- return t
1342
+ function filterAndRemove(n, t) {
1343
+ const e = []
1344
+ for (let r = n.length - 1; r >= 0; r--) t(n[r]) && e.push(n.splice(r, 1)[0])
1345
+ return e
1346
1346
  }
1347
1347
  function cloneWithJson(n) {
1348
1348
  return JSON.parse(JSON.stringify(n))
@@ -1357,8 +1357,8 @@ function dateTimeSlug(n) {
1357
1357
  return (n || new Date()).toISOString().slice(0, 19).replace(/T|:/g, '-')
1358
1358
  }
1359
1359
  function fromUtcString(n) {
1360
- const e = new Date(n)
1361
- return new Date(e.getTime() - e.getTimezoneOffset() * 6e4)
1360
+ const t = new Date(n)
1361
+ return new Date(t.getTime() - t.getTimezoneOffset() * 6e4)
1362
1362
  }
1363
1363
  function fromMillis(n) {
1364
1364
  return new Date(n)
@@ -1367,66 +1367,66 @@ function createTimeDigits(n) {
1367
1367
  return String(Math.floor(n)).padStart(2, '0')
1368
1368
  }
1369
1369
  function normalizeTime(n) {
1370
- let [e, t] = n.split(':')
1371
- isNumber(parseInt(e, 10)) || (e = '0'), isNumber(parseInt(t, 10)) || (t = '0')
1372
- let r = clamp(asInteger(e), 0, 23),
1373
- i = clamp(asInteger(t), 0, 59)
1370
+ let [t, e] = n.split(':')
1371
+ isNumber(parseInt(t, 10)) || (t = '0'), isNumber(parseInt(e, 10)) || (e = '0')
1372
+ let r = clamp(asInteger(t), 0, 23),
1373
+ i = clamp(asInteger(e), 0, 59)
1374
1374
  return `${createTimeDigits(r)}:${createTimeDigits(i)}`
1375
1375
  }
1376
1376
  function humanizeTime(n) {
1377
- const e = Math.floor(n / 36e5)
1377
+ const t = Math.floor(n / 36e5)
1378
1378
  n = n % 36e5
1379
- const t = Math.floor(n / 6e4)
1379
+ const e = Math.floor(n / 6e4)
1380
1380
  n = n % 6e4
1381
1381
  const r = Math.floor(n / 1e3)
1382
- return e ? `${createTimeDigits(e)}:${createTimeDigits(t)}:${createTimeDigits(r)}` : `${createTimeDigits(t)}:${createTimeDigits(r)}`
1382
+ return t ? `${createTimeDigits(t)}:${createTimeDigits(e)}:${createTimeDigits(r)}` : `${createTimeDigits(e)}:${createTimeDigits(r)}`
1383
1383
  }
1384
1384
  function absoluteDays(n) {
1385
1385
  return Math.floor((isDate(n) ? n.getTime() : n) / 864e5)
1386
1386
  }
1387
- const DefaultTimestampLabels = { today: (n, e) => createTimeDigits(n) + ':' + createTimeDigits(e), yesterday: () => 'Yesterday', monday: () => 'Mon', tuesday: () => 'Tue', wednesday: () => 'Wed', thursday: () => 'Thu', friday: () => 'Fri', saturday: () => 'Sat', sunday: () => 'Sun', weeks: n => `${n}w` }
1388
- function getTimestamp(n, e) {
1389
- const t = new Date(e?.now || Date.now()),
1390
- r = e?.labels || DefaultTimestampLabels,
1387
+ const DefaultTimestampLabels = { today: (n, t) => createTimeDigits(n) + ':' + createTimeDigits(t), yesterday: () => 'Yesterday', monday: () => 'Mon', tuesday: () => 'Tue', wednesday: () => 'Wed', thursday: () => 'Thu', friday: () => 'Fri', saturday: () => 'Sat', sunday: () => 'Sun', weeks: n => `${n}w` }
1388
+ function getTimestamp(n, t) {
1389
+ const e = new Date(t?.now || Date.now()),
1390
+ r = t?.labels || DefaultTimestampLabels,
1391
1391
  i = isDate(n) ? n : new Date(n)
1392
- if (absoluteDays(t) === absoluteDays(i)) return r.today(i.getUTCHours(), i.getUTCMinutes(), i.getUTCHours() > 12)
1393
- if (absoluteDays(t) - absoluteDays(i) === 1) return r.yesterday()
1392
+ if (absoluteDays(e) === absoluteDays(i)) return r.today(i.getUTCHours(), i.getUTCMinutes(), i.getUTCHours() > 12)
1393
+ if (absoluteDays(e) - absoluteDays(i) === 1) return r.yesterday()
1394
1394
  const o = getDayInfoFromDate(i)
1395
- return absoluteDays(t) - absoluteDays(i) < 7 ? r[o.day]() : r.weeks(Math.round((t.getTime() - i.getTime()) / 6048e5))
1395
+ return absoluteDays(e) - absoluteDays(i) < 7 ? r[o.day]() : r.weeks(Math.round((e.getTime() - i.getTime()) / 6048e5))
1396
1396
  }
1397
1397
  const DefaultTimeDeltaLabels = { now: () => 'A few seconds', seconds: n => `${n} seconds`, minutes: n => `${n} minutes`, hours: n => `${n} hours`, days: n => `${n} days`, weeks: n => `${n} weeks` }
1398
- function getTimeDelta(n, e) {
1399
- const t = e?.now ?? Date.now(),
1400
- r = e?.labels || DefaultTimeDeltaLabels,
1398
+ function getTimeDelta(n, t) {
1399
+ const e = t?.now ?? Date.now(),
1400
+ r = t?.labels || DefaultTimeDeltaLabels,
1401
1401
  i = exports.Types.isDate(n) ? n.getTime() : n
1402
- let o = (t - i) / 1e3
1402
+ let o = (e - i) / 1e3
1403
1403
  return o < 10 ? r.now() : o < 120 ? r.seconds(Math.floor(o)) : ((o /= 60), o < 120 ? r.minutes(Math.floor(o)) : ((o /= 60), o < 48 ? r.hours(Math.floor(o)) : ((o /= 24), o < 14 ? r.days(Math.floor(o)) : ((o /= 7), r.weeks(Math.floor(o))))))
1404
1404
  }
1405
- function secondsToHumanTime(n, e = DefaultTimeDeltaLabels) {
1406
- return getTimeDelta(0, { now: n * 1e3, labels: e })
1405
+ function secondsToHumanTime(n, t = DefaultTimeDeltaLabels) {
1406
+ return getTimeDelta(0, { now: n * 1e3, labels: t })
1407
1407
  }
1408
- function countCycles(n, e, t) {
1409
- const i = (t?.now ?? Date.now()) - n,
1410
- o = Math.floor(i / e),
1411
- c = e / (t?.precision ?? 1) - Math.ceil((i % e) / (t?.precision ?? 1))
1408
+ function countCycles(n, t, e) {
1409
+ const i = (e?.now ?? Date.now()) - n,
1410
+ o = Math.floor(i / t),
1411
+ c = t / (e?.precision ?? 1) - Math.ceil((i % t) / (e?.precision ?? 1))
1412
1412
  return { cycles: o, remaining: c }
1413
1413
  }
1414
1414
  const throttleTimers = {}
1415
- function throttle(n, e) {
1416
- return !throttleTimers[n] || Date.now() > throttleTimers[n] ? ((throttleTimers[n] = Date.now() + e), !0) : !1
1415
+ function throttle(n, t) {
1416
+ return !throttleTimers[n] || Date.now() > throttleTimers[n] ? ((throttleTimers[n] = Date.now() + t), !0) : !1
1417
1417
  }
1418
1418
  const timeUnits = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 }
1419
- function timeSince(n, e, t) {
1420
- return (e = isDate(e) ? e.getTime() : e), (t = t ? (isDate(t) ? t.getTime() : t) : Date.now()), (t - e) / timeUnits[n]
1419
+ function timeSince(n, t, e) {
1420
+ return (t = isDate(t) ? t.getTime() : t), (e = e ? (isDate(e) ? e.getTime() : e) : Date.now()), (e - t) / timeUnits[n]
1421
1421
  }
1422
- function getProgress(n, e, t, r) {
1422
+ function getProgress(n, t, e, r) {
1423
1423
  r || (r = Date.now())
1424
- const i = e / t,
1424
+ const i = t / e,
1425
1425
  o = r - n,
1426
- c = o / e,
1427
- u = c * t,
1428
- s = u - o
1429
- return { deltaMs: o, progress: i, baseTimeMs: c, totalTimeMs: u, remainingTimeMs: s }
1426
+ c = o / t,
1427
+ s = c * e,
1428
+ u = s - o
1429
+ return { deltaMs: o, progress: i, baseTimeMs: c, totalTimeMs: s, remainingTimeMs: u }
1430
1430
  }
1431
1431
  const dayNumberIndex = { 0: 'sunday', 1: 'monday', 2: 'tuesday', 3: 'wednesday', 4: 'thursday', 5: 'friday', 6: 'saturday' }
1432
1432
  function mapDayNumber(n) {
@@ -1452,54 +1452,54 @@ function days(n) {
1452
1452
  }
1453
1453
  const dateUnits = { ms: 1, milli: 1, millis: 1, millisecond: 1, milliseconds: 1, s: 1e3, sec: 1e3, second: 1e3, seconds: 1e3, m: 6e4, min: 6e4, minute: 6e4, minutes: 6e4, h: 36e5, hour: 36e5, hours: 36e5, d: 864e5, day: 864e5, days: 864e5, w: 6048e5, week: 6048e5, weeks: 6048e5, month: 2592e6, months: 2592e6, y: 31536e6, year: 31536e6, years: 31536e6 }
1454
1454
  function makeDate(n) {
1455
- const e = parseFloat(n)
1456
- if (isNaN(e)) throw Error('makeDate got NaN for input')
1457
- const t = n
1455
+ const t = parseFloat(n)
1456
+ if (isNaN(t)) throw Error('makeDate got NaN for input')
1457
+ const e = n
1458
1458
  .replace(/^-?[0-9.]+/, '')
1459
1459
  .trim()
1460
1460
  .toLowerCase(),
1461
- r = t === '' ? 1 : dateUnits[t]
1462
- if (!r) throw Error(`Unknown unit: "${t}"`)
1463
- return Math.ceil(e * r)
1461
+ r = e === '' ? 1 : dateUnits[e]
1462
+ if (!r) throw Error(`Unknown unit: "${e}"`)
1463
+ return Math.ceil(t * r)
1464
1464
  }
1465
1465
  const storageUnitExponents = { b: 0, byte: 0, bytes: 0, kb: 1, kilobyte: 1, kilobytes: 1, mb: 2, megabyte: 2, megabytes: 2, gb: 3, gigabyte: 3, gigabytes: 3, tb: 4, terabyte: 4, terabytes: 4 }
1466
- function makeStorage(n, e = 1024) {
1467
- const t = parseFloat(n)
1468
- if (isNaN(t)) throw Error('makeStorage got NaN for input')
1466
+ function makeStorage(n, t = 1024) {
1467
+ const e = parseFloat(n)
1468
+ if (isNaN(e)) throw Error('makeStorage got NaN for input')
1469
1469
  const r = n
1470
1470
  .replace(/^-?[0-9.]+/, '')
1471
1471
  .trim()
1472
1472
  .toLowerCase(),
1473
1473
  i = r === '' ? 0 : storageUnitExponents[r]
1474
1474
  if (i == null) throw Error(`Unknown unit: "${r}"`)
1475
- return Math.ceil(t * e ** i)
1475
+ return Math.ceil(e * t ** i)
1476
1476
  }
1477
1477
  function getPreLine(n) {
1478
1478
  return n.replace(/ +/g, ' ').replace(/^ /gm, '')
1479
1479
  }
1480
1480
  const tinyCache = new Map()
1481
- async function getCached(n, e, t, r) {
1481
+ async function getCached(n, t, e, r) {
1482
1482
  const i = Date.now(),
1483
1483
  o = tinyCache.get(n)
1484
1484
  if (o && o.validUntil > i) return o.value
1485
1485
  r?.onMiss?.()
1486
1486
  try {
1487
- const c = await t()
1488
- return tinyCache.set(n, { value: c, validUntil: i + e }), c
1487
+ const c = await e()
1488
+ return tinyCache.set(n, { value: c, validUntil: i + t }), c
1489
1489
  } catch (c) {
1490
1490
  throw (r?.onFailure?.(c), c)
1491
1491
  }
1492
1492
  }
1493
- function getCachedDeferred(n, e, t, r) {
1493
+ function getCachedDeferred(n, t, e, r) {
1494
1494
  const i = Date.now(),
1495
1495
  o = tinyCache.get(n)
1496
1496
  if (o && o.validUntil > i) return o.value
1497
1497
  r?.onMiss?.()
1498
- const c = t()
1498
+ const c = e()
1499
1499
  return (
1500
- tinyCache.set(n, { value: c, validUntil: i + e }),
1501
- c.catch(u => {
1502
- tinyCache.delete(n), r?.onFailure?.(u)
1500
+ tinyCache.set(n, { value: c, validUntil: i + t }),
1501
+ c.catch(s => {
1502
+ tinyCache.delete(n), r?.onFailure?.(s)
1503
1503
  }),
1504
1504
  c
1505
1505
  )
@@ -1512,64 +1512,64 @@ function clearCache() {
1512
1512
  }
1513
1513
  function deleteExpiredFromCache() {
1514
1514
  const n = Date.now()
1515
- for (const [e, t] of tinyCache.entries()) t.validUntil <= n && tinyCache.delete(e)
1515
+ for (const [t, e] of tinyCache.entries()) e.validUntil <= n && tinyCache.delete(t)
1516
1516
  }
1517
1517
  function cacheSize() {
1518
1518
  return tinyCache.size
1519
1519
  }
1520
- function joinUrl(n, e = !1) {
1521
- ;(n = n.filter(o => o)), e && isString(n[1]) && (n[1] = '../' + n[1])
1522
- let t = ''
1523
- isString(n[0]) && n[0].includes('://') && ((t = before(n[0], '://') ?? ''), (n[0] = after(n[0], '://') ?? ''))
1520
+ function joinUrl(n, t = !1) {
1521
+ ;(n = n.filter(o => o)), t && isString(n[1]) && (n[1] = '../' + n[1])
1522
+ let e = ''
1523
+ isString(n[0]) && n[0].includes('://') && ((e = before(n[0], '://') ?? ''), (n[0] = after(n[0], '://') ?? ''))
1524
1524
  const r = n.map(o => String(o)).flatMap(o => o.split('/')),
1525
1525
  i = []
1526
- for (let o = 0; o < r.length; o++) r[o] !== '.' && (r[o] === '..' ? (!t || i.length > 1) && i.pop() : i.push(r[o]))
1527
- return (t ? t + '://' : '') + i.join('/').replaceAll(/\/{2,}/g, '/')
1526
+ for (let o = 0; o < r.length; o++) r[o] !== '.' && (r[o] === '..' ? (!e || i.length > 1) && i.pop() : i.push(r[o]))
1527
+ return (e ? e + '://' : '') + i.join('/').replaceAll(/\/{2,}/g, '/')
1528
1528
  }
1529
- function replaceBetweenStrings(n, e, t, r, i = !0) {
1530
- const o = n.indexOf(e),
1531
- c = n.indexOf(t, o + e.length)
1529
+ function replaceBetweenStrings(n, t, e, r, i = !0) {
1530
+ const o = n.indexOf(t),
1531
+ c = n.indexOf(e, o + t.length)
1532
1532
  if (o === -1 || c === -1) throw Error('Start or end not found')
1533
- return i ? n.substring(0, o + e.length) + r + n.substring(c) : n.substring(0, o) + r + n.substring(c + t.length)
1533
+ return i ? n.substring(0, o + t.length) + r + n.substring(c) : n.substring(0, o) + r + n.substring(c + e.length)
1534
1534
  }
1535
1535
  function describeMarkdown(n) {
1536
- let e = 'p'
1537
- n.startsWith('#') ? ((e = 'h1'), (n = n.slice(1).trim())) : n.startsWith('-') && ((e = 'li'), (n = n.slice(1).trim()))
1538
- const t = n[0] === n[0].toUpperCase(),
1536
+ let t = 'p'
1537
+ n.startsWith('#') ? ((t = 'h1'), (n = n.slice(1).trim())) : n.startsWith('-') && ((t = 'li'), (n = n.slice(1).trim()))
1538
+ const e = n[0] === n[0].toUpperCase(),
1539
1539
  r = /[.?!]$/.test(n),
1540
1540
  i = /:$/.test(n)
1541
- return { type: e, isCapitalized: t, hasPunctuation: r, endsWithColon: i }
1541
+ return { type: t, isCapitalized: e, hasPunctuation: r, endsWithColon: i }
1542
1542
  }
1543
- function isBalanced(n, e = '(', t = ')') {
1543
+ function isBalanced(n, t = '(', e = ')') {
1544
1544
  let r = 0,
1545
1545
  i = 0
1546
- for (; i < n.length; ) if ((n.startsWith(e, i) ? (r++, (i += e.length)) : n.startsWith(t, i) ? (r--, (i += t.length)) : i++, r < 0)) return !1
1547
- return e === t ? r % 2 === 0 : r === 0
1546
+ for (; i < n.length; ) if ((n.startsWith(t, i) ? (r++, (i += t.length)) : n.startsWith(e, i) ? (r--, (i += e.length)) : i++, r < 0)) return !1
1547
+ return t === e ? r % 2 === 0 : r === 0
1548
1548
  }
1549
1549
  function textToFormat(n) {
1550
1550
  n = n.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
1551
- let e = n.length
1552
- for (; (n = n.replace(/(\w+)[\s,']+\w+/g, '$1')), n.length !== e; ) e = n.length
1551
+ let t = n.length
1552
+ for (; (n = n.replace(/(\w+)[\s,']+\w+/g, '$1')), n.length !== t; ) t = n.length
1553
1553
  return (n = n.replaceAll(/[A-Z][a-zA-Z0-9]*/g, 'A')), (n = n.replaceAll(/[a-z][a-zA-Z0-9]*/g, 'a')), (n = n.replaceAll(/[\u4E00-\u9FA5]+/g, 'Z')), n
1554
1554
  }
1555
1555
  function sortObject(n) {
1556
- const t = Object.keys(n).sort((i, o) => i.localeCompare(o)),
1556
+ const e = Object.keys(n).sort((i, o) => i.localeCompare(o)),
1557
1557
  r = {}
1558
- for (const i of t) r[i] = sortAny(n[i])
1558
+ for (const i of e) r[i] = sortAny(n[i])
1559
1559
  return r
1560
1560
  }
1561
1561
  function sortArray(n) {
1562
- const e = []
1563
- return n.sort((t, r) => JSON.stringify(sortAny(t)).localeCompare(JSON.stringify(sortAny(r)))).forEach(t => e.push(sortAny(t))), e
1562
+ const t = []
1563
+ return n.sort((e, r) => JSON.stringify(sortAny(e)).localeCompare(JSON.stringify(sortAny(r)))).forEach(e => t.push(sortAny(e))), t
1564
1564
  }
1565
1565
  function sortAny(n) {
1566
1566
  return Array.isArray(n) ? sortArray(n) : isObject(n) ? sortObject(n) : n
1567
1567
  }
1568
- function deepEquals(n, e) {
1569
- return JSON.stringify(sortAny(n)) === JSON.stringify(sortAny(e))
1568
+ function deepEquals(n, t) {
1569
+ return JSON.stringify(sortAny(n)) === JSON.stringify(sortAny(t))
1570
1570
  }
1571
1571
  function deepEqualsEvery(...n) {
1572
- for (let e = 1; e < n.length; e++) if (!deepEquals(n[e - 1], n[e])) return !1
1572
+ for (let t = 1; t < n.length; t++) if (!deepEquals(n[t - 1], n[t])) return !1
1573
1573
  return !0
1574
1574
  }
1575
1575
  function safeParse(n) {
@@ -1584,39 +1584,39 @@ function createSequence() {
1584
1584
  return { next: () => n++ }
1585
1585
  }
1586
1586
  function createOscillator(n) {
1587
- let e = 0
1588
- return { next: () => n[e++ % n.length] }
1587
+ let t = 0
1588
+ return { next: () => n[t++ % n.length] }
1589
1589
  }
1590
1590
  function createStatefulToggle(n) {
1591
- let e
1592
- return t => {
1593
- const r = t === n && e !== n
1594
- return (e = t), r
1591
+ let t
1592
+ return e => {
1593
+ const r = e === n && t !== n
1594
+ return (t = e), r
1595
1595
  }
1596
1596
  }
1597
- function organiseWithLimits(n, e, t, r, i) {
1597
+ function organiseWithLimits(n, t, e, r, i) {
1598
1598
  const o = {}
1599
- for (const c of Object.keys(e)) o[c] = []
1599
+ for (const c of Object.keys(t)) o[c] = []
1600
1600
  ;(o[r] = []), i && (n = n.sort(i))
1601
1601
  for (const c of n) {
1602
- const u = c[t],
1603
- s = e[u] ? u : r
1604
- o[s].length >= e[s] ? o[r].push(c) : o[s].push(c)
1602
+ const s = c[e],
1603
+ u = t[s] ? s : r
1604
+ o[u].length >= t[u] ? o[r].push(c) : o[u].push(c)
1605
1605
  }
1606
1606
  return o
1607
1607
  }
1608
- function diffKeys(n, e) {
1609
- const t = Object.keys(n),
1610
- r = Object.keys(e)
1611
- return { uniqueToA: t.filter(i => !r.includes(i)), uniqueToB: r.filter(i => !t.includes(i)) }
1608
+ function diffKeys(n, t) {
1609
+ const e = Object.keys(n),
1610
+ r = Object.keys(t)
1611
+ return { uniqueToA: e.filter(i => !r.includes(i)), uniqueToB: r.filter(i => !e.includes(i)) }
1612
1612
  }
1613
1613
  function pickRandomKey(n) {
1614
- const e = Object.keys(n)
1615
- return e[Math.floor(Math.random() * e.length)]
1614
+ const t = Object.keys(n)
1615
+ return t[Math.floor(Math.random() * t.length)]
1616
1616
  }
1617
- function mapRandomKey(n, e) {
1618
- const t = pickRandomKey(n)
1619
- return (n[t] = e(n[t])), t
1617
+ function mapRandomKey(n, t) {
1618
+ const e = pickRandomKey(n)
1619
+ return (n[e] = t(n[e])), e
1620
1620
  }
1621
1621
  function fromObjectString(n) {
1622
1622
  return (
@@ -1625,14 +1625,14 @@ function fromObjectString(n) {
1625
1625
  `
1626
1626
  `
1627
1627
  )),
1628
- (n = n.replace(/(\w+)\((.+)\)/g, (e, t, r) => `${t}(${r.replaceAll(',', '&comma;')})`)),
1628
+ (n = n.replace(/(\w+)\((.+)\)/g, (t, e, r) => `${e}(${r.replaceAll(',', '&comma;')})`)),
1629
1629
  (n = n.replace(/(,)(\s+})/g, '$2')),
1630
1630
  (n = n.replace(/\.\.\..+?,/g, '')),
1631
1631
  (n = n.replace(/({\s+)([a-zA-Z]\w+),/g, "$1$2: '$2',")),
1632
1632
  (n = n.replace(/(,\s+)([a-zA-Z]\w+),/g, "$1$2: '$2',")),
1633
- (n = n.replace(/:(.+)\?(.+):/g, (e, t, r) => `: (${t.trim()} && ${r.trim()}) ||`)),
1633
+ (n = n.replace(/:(.+)\?(.+):/g, (t, e, r) => `: (${e.trim()} && ${r.trim()}) ||`)),
1634
1634
  (n = n.replace(/([a-zA-Z0-9]+)( ?: ?{)/g, '"$1"$2')),
1635
- (n = n.replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g, (e, t, r, i) => `"${t}":"${r.trim()}"${i}`)),
1635
+ (n = n.replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g, (t, e, r, i) => `"${e}":"${r.trim()}"${i}`)),
1636
1636
  (n = n.replace(/("'|'")/g, '"')),
1637
1637
  (n = n.replaceAll('&comma;', ',')),
1638
1638
  JSON.parse(n)
@@ -1641,228 +1641,228 @@ function fromObjectString(n) {
1641
1641
  const thresholds = [1e3, 1e6, 1e9, 1e12, 1e15, 1e18, 1e21, 1e24, 1e27, 1e30, 1e9, 1e16, 1e18, 1e18, 1e18, 1e33],
1642
1642
  longNumberUnits = ['thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion', 'sextillion', 'septillion', 'octillion', 'nonillion', 'gwei', 'bzz', 'btc', 'eth', 'dai', 'decillion'],
1643
1643
  shortNumberUnits = ['K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'O', 'N', 'gwei', 'bzz', 'eth', 'btc', 'dai', 'D']
1644
- function fromDecimals(n, e, t) {
1645
- let r = n.length - e
1646
- if (r <= 0) return '0.' + '0'.repeat(-r) + n + (t ? ' ' + t : '')
1644
+ function fromDecimals(n, t, e) {
1645
+ let r = n.length - t
1646
+ if (r <= 0) return '0.' + '0'.repeat(-r) + n + (e ? ' ' + e : '')
1647
1647
  let i = n.substring(0, r),
1648
1648
  o = n.substring(r)
1649
- return i === '' && (i = '0'), i + '.' + o + (t ? ' ' + t : '')
1649
+ return i === '' && (i = '0'), i + '.' + o + (e ? ' ' + e : '')
1650
1650
  }
1651
- function formatNumber(n, e) {
1652
- const t = e?.longForm ?? !1,
1653
- r = e?.unit ? ` ${e.unit}` : '',
1654
- i = t ? longNumberUnits : shortNumberUnits,
1655
- o = e?.precision ?? 1
1651
+ function formatNumber(n, t) {
1652
+ const e = t?.longForm ?? !1,
1653
+ r = t?.unit ? ` ${t.unit}` : '',
1654
+ i = e ? longNumberUnits : shortNumberUnits,
1655
+ o = t?.precision ?? 1
1656
1656
  if (n < thresholds[0]) return `${n}${r}`
1657
- for (let c = 0; c < thresholds.length - 1; c++) if (n < thresholds[c + 1]) return `${(n / thresholds[c]).toFixed(o)}${t ? ' ' : ''}${i[c]}${r}`
1658
- return `${(n / thresholds[thresholds.length - 1]).toFixed(o)}${t ? ' ' : ''}${i[thresholds.length - 1]}${r}`
1657
+ for (let c = 0; c < thresholds.length - 1; c++) if (n < thresholds[c + 1]) return `${(n / thresholds[c]).toFixed(o)}${e ? ' ' : ''}${i[c]}${r}`
1658
+ return `${(n / thresholds[thresholds.length - 1]).toFixed(o)}${e ? ' ' : ''}${i[thresholds.length - 1]}${r}`
1659
1659
  }
1660
1660
  function makeNumber(n) {
1661
- const e = parseFloat(n)
1662
- if (isNaN(e)) throw Error('makeNumber got NaN for input')
1663
- const t = n.replace(/^-?[0-9.]+/, '').trim(),
1664
- r = shortNumberUnits.findIndex(i => i.toLowerCase() === t.toLowerCase())
1665
- return r === -1 ? e : e * thresholds[r]
1661
+ const t = parseFloat(n)
1662
+ if (isNaN(t)) throw Error('makeNumber got NaN for input')
1663
+ const e = n.replace(/^-?[0-9.]+/, '').trim(),
1664
+ r = shortNumberUnits.findIndex(i => i.toLowerCase() === e.toLowerCase())
1665
+ return r === -1 ? t : t * thresholds[r]
1666
1666
  }
1667
- function clamp(n, e, t) {
1668
- return n < e ? e : n > t ? t : n
1667
+ function clamp(n, t, e) {
1668
+ return n < t ? t : n > e ? e : n
1669
1669
  }
1670
- function increment(n, e, t) {
1671
- const r = n + e
1672
- return r > t ? t : r
1670
+ function increment(n, t, e) {
1671
+ const r = n + t
1672
+ return r > e ? e : r
1673
1673
  }
1674
- function decrement(n, e, t) {
1675
- const r = n - e
1676
- return r < t ? t : r
1674
+ function decrement(n, t, e) {
1675
+ const r = n - t
1676
+ return r < e ? e : r
1677
1677
  }
1678
- function runOn(n, e) {
1679
- return e(n), n
1678
+ function runOn(n, t) {
1679
+ return t(n), n
1680
1680
  }
1681
- function ifPresent(n, e) {
1682
- n && e(n)
1681
+ function ifPresent(n, t) {
1682
+ n && t(n)
1683
1683
  }
1684
- function mergeArrays(n, e) {
1685
- const t = Object.keys(e)
1686
- for (const r of t) Array.isArray(e[r]) && Array.isArray(n[r]) && pushAll(n[r], e[r])
1684
+ function mergeArrays(n, t) {
1685
+ const e = Object.keys(t)
1686
+ for (const r of e) Array.isArray(t[r]) && Array.isArray(n[r]) && pushAll(n[r], t[r])
1687
1687
  }
1688
1688
  function empty(n) {
1689
1689
  return n.splice(0, n.length), n
1690
1690
  }
1691
1691
  function removeEmptyArrays(n) {
1692
- for (const e of Object.keys(n)) (isEmptyArray(n[e]) || (Array.isArray(n[e]) && n[e].every(t => t == null))) && delete n[e]
1692
+ for (const t of Object.keys(n)) (isEmptyArray(n[t]) || (Array.isArray(n[t]) && n[t].every(e => e == null))) && delete n[t]
1693
1693
  return n
1694
1694
  }
1695
1695
  function removeEmptyValues(n) {
1696
- for (const e of Object.entries(n)) (e[1] === null || e[1] === void 0 || (isString(e[1]) && isBlank(e[1]))) && delete n[e[0]]
1696
+ for (const t of Object.entries(n)) (t[1] === null || t[1] === void 0 || (isString(t[1]) && isBlank(t[1]))) && delete n[t[0]]
1697
1697
  return n
1698
1698
  }
1699
- function filterObjectKeys(n, e) {
1700
- const t = {}
1701
- for (const [r, i] of Object.entries(n)) e(r) && (t[r] = i)
1702
- return t
1699
+ function filterObjectKeys(n, t) {
1700
+ const e = {}
1701
+ for (const [r, i] of Object.entries(n)) t(r) && (e[r] = i)
1702
+ return e
1703
1703
  }
1704
- function filterObjectValues(n, e) {
1705
- const t = {}
1706
- for (const [r, i] of Object.entries(n)) e(i) && (t[r] = i)
1707
- return t
1704
+ function filterObjectValues(n, t) {
1705
+ const e = {}
1706
+ for (const [r, i] of Object.entries(n)) t(i) && (e[r] = i)
1707
+ return e
1708
1708
  }
1709
- function mapObject(n, e) {
1710
- const t = {}
1711
- for (const r of Object.entries(n)) t[r[0]] = e(r[1])
1712
- return t
1709
+ function mapObject(n, t) {
1710
+ const e = {}
1711
+ for (const r of Object.entries(n)) e[r[0]] = t(r[1])
1712
+ return e
1713
1713
  }
1714
- function mapIterable(n, e) {
1715
- const t = []
1714
+ function mapIterable(n, t) {
1715
+ const e = []
1716
1716
  let r = 0
1717
- for (const i of n) t.push(e(i, r++))
1718
- return t
1717
+ for (const i of n) e.push(t(i, r++))
1718
+ return e
1719
1719
  }
1720
- async function rethrow(n, e) {
1720
+ async function rethrow(n, t) {
1721
1721
  try {
1722
1722
  return await n()
1723
1723
  } catch {
1724
- throw e
1724
+ throw t
1725
1725
  }
1726
1726
  }
1727
- function setSomeOnObject(n, e, t) {
1728
- t != null && (n[e] = t)
1727
+ function setSomeOnObject(n, t, e) {
1728
+ e != null && (n[t] = e)
1729
1729
  }
1730
- function setSomeDeep(n, e, t, r) {
1731
- const i = getDeep(t, r)
1732
- i != null && setDeep(n, e, i)
1730
+ function setSomeDeep(n, t, e, r) {
1731
+ const i = getDeep(e, r)
1732
+ i != null && setDeep(n, t, i)
1733
1733
  }
1734
1734
  function flip(n) {
1735
- const e = {}
1736
- for (const [t, r] of Object.entries(n)) e[r] = t
1737
- return e
1735
+ const t = {}
1736
+ for (const [e, r] of Object.entries(n)) t[r] = e
1737
+ return t
1738
1738
  }
1739
1739
  function getAllPermutations(n) {
1740
- const e = Object.keys(n),
1741
- t = e.map(u => n[u].length),
1742
- r = t.reduce((u, s) => (u *= s))
1740
+ const t = Object.keys(n),
1741
+ e = t.map(s => n[s].length),
1742
+ r = e.reduce((s, u) => (s *= u))
1743
1743
  let i = 1
1744
1744
  const o = [1]
1745
- for (let u = 0; u < t.length - 1; u++) (i *= t[u]), o.push(i)
1745
+ for (let s = 0; s < e.length - 1; s++) (i *= e[s]), o.push(i)
1746
1746
  const c = []
1747
- for (let u = 0; u < r; u++) {
1748
- const s = {}
1749
- for (let f = 0; f < e.length; f++) {
1750
- const l = n[e[f]],
1751
- a = Math.floor(u / o[f]) % l.length
1752
- s[e[f]] = l[a]
1747
+ for (let s = 0; s < r; s++) {
1748
+ const u = {}
1749
+ for (let f = 0; f < t.length; f++) {
1750
+ const l = n[t[f]],
1751
+ a = Math.floor(s / o[f]) % l.length
1752
+ u[t[f]] = l[a]
1753
1753
  }
1754
- c.push(s)
1754
+ c.push(u)
1755
1755
  }
1756
1756
  return c
1757
1757
  }
1758
1758
  function countTruthyValues(n) {
1759
- return Object.values(n).filter(e => e).length
1759
+ return Object.values(n).filter(t => t).length
1760
1760
  }
1761
- function getFlatNotation(n, e, t) {
1762
- return n + (t ? '[' + e + ']' : (n.length ? '.' : '') + e)
1761
+ function getFlatNotation(n, t, e) {
1762
+ return n + (e ? '[' + t + ']' : (n.length ? '.' : '') + t)
1763
1763
  }
1764
- function flattenInner(n, e, t, r, i) {
1765
- if (!isObject(e)) return e
1766
- for (const [o, c] of Object.entries(e)) {
1767
- const u = getFlatNotation(t, o, r)
1768
- Array.isArray(c) ? (i ? flattenInner(n, c, u, !0, i) : (n[u] = c.map(s => flattenInner(Array.isArray(s) ? [] : {}, s, '', !1, i)))) : isObject(c) ? flattenInner(n, c, u, !1, i) : (n[u] = c)
1764
+ function flattenInner(n, t, e, r, i) {
1765
+ if (!isObject(t)) return t
1766
+ for (const [o, c] of Object.entries(t)) {
1767
+ const s = getFlatNotation(e, o, r)
1768
+ Array.isArray(c) ? (i ? flattenInner(n, c, s, !0, i) : (n[s] = c.map(u => flattenInner(Array.isArray(u) ? [] : {}, u, '', !1, i)))) : isObject(c) ? flattenInner(n, c, s, !1, i) : (n[s] = c)
1769
1769
  }
1770
1770
  return n
1771
1771
  }
1772
- function flatten(n, e = !1, t) {
1773
- return flattenInner({}, n, t || '', !1, e)
1772
+ function flatten(n, t = !1, e) {
1773
+ return flattenInner({}, n, e || '', !1, t)
1774
1774
  }
1775
1775
  function unflatten(n) {
1776
1776
  if (!isObject(n)) return n
1777
- const e = Array.isArray(n) ? [] : {}
1778
- for (const [t, r] of Object.entries(n))
1777
+ const t = Array.isArray(n) ? [] : {}
1778
+ for (const [e, r] of Object.entries(n))
1779
1779
  Array.isArray(r)
1780
1780
  ? setDeep(
1781
- e,
1782
1781
  t,
1782
+ e,
1783
1783
  r.map(i => unflatten(i))
1784
1784
  )
1785
- : setDeep(e, t, r)
1786
- return e
1785
+ : setDeep(t, e, r)
1786
+ return t
1787
1787
  }
1788
- function match(n, e, t) {
1789
- return e[n] ? e[n] : t
1788
+ function match(n, t, e) {
1789
+ return t[n] ? t[n] : e
1790
1790
  }
1791
- function indexArray(n, e) {
1792
- const t = {}
1791
+ function indexArray(n, t) {
1792
+ const e = {}
1793
1793
  for (const r of n) {
1794
- const i = e(r)
1795
- t[i] = r
1794
+ const i = t(r)
1795
+ e[i] = r
1796
1796
  }
1797
- return t
1797
+ return e
1798
1798
  }
1799
- function indexArrayToCollection(n, e) {
1800
- const t = {}
1799
+ function indexArrayToCollection(n, t) {
1800
+ const e = {}
1801
1801
  for (const r of n) {
1802
- const i = e(r)
1803
- t[i] || (t[i] = []), t[i].push(r)
1802
+ const i = t(r)
1803
+ e[i] || (e[i] = []), e[i].push(r)
1804
1804
  }
1805
- return t
1805
+ return e
1806
1806
  }
1807
- function splitBySize(n, e) {
1808
- const t = []
1809
- for (let r = 0; r < n.length; r += e) t.push(n.slice(r, r + e))
1810
- return t
1807
+ function splitBySize(n, t) {
1808
+ const e = []
1809
+ for (let r = 0; r < n.length; r += t) e.push(n.slice(r, r + t))
1810
+ return e
1811
1811
  }
1812
- function splitByCount(n, e) {
1813
- const t = Math.ceil(n.length / e),
1812
+ function splitByCount(n, t) {
1813
+ const e = Math.ceil(n.length / t),
1814
1814
  r = []
1815
- for (let i = 0; i < n.length; i += t) r.push(n.slice(i, i + t))
1815
+ for (let i = 0; i < n.length; i += e) r.push(n.slice(i, i + e))
1816
1816
  return r
1817
1817
  }
1818
- function tokenizeByLength(n, e) {
1819
- const t = [],
1820
- r = Math.ceil(n.length / e)
1821
- for (let i = 0; i < r; i++) t.push(n.slice(i * e, i * e + e))
1822
- return t
1818
+ function tokenizeByLength(n, t) {
1819
+ const e = [],
1820
+ r = Math.ceil(n.length / t)
1821
+ for (let i = 0; i < r; i++) e.push(n.slice(i * t, i * t + t))
1822
+ return e
1823
1823
  }
1824
- function tokenizeByCount(n, e) {
1825
- const t = Math.ceil(n.length / e)
1826
- return tokenizeByLength(n, t)
1824
+ function tokenizeByCount(n, t) {
1825
+ const e = Math.ceil(n.length / t)
1826
+ return tokenizeByLength(n, e)
1827
1827
  }
1828
- function makeUnique(n, e) {
1829
- return Object.values(indexArray(n, e))
1828
+ function makeUnique(n, t) {
1829
+ return Object.values(indexArray(n, t))
1830
1830
  }
1831
- function countUnique(n, e, t, r, i) {
1832
- const o = e ? n.map(e) : n,
1831
+ function countUnique(n, t, e, r, i) {
1832
+ const o = t ? n.map(t) : n,
1833
1833
  c = {}
1834
- for (const s of o) c[s] = (c[s] || 0) + 1
1835
- const u = r ? sortObjectValues(c, i ? (s, f) => s[1] - f[1] : (s, f) => f[1] - s[1]) : c
1836
- return t ? Object.keys(u) : u
1834
+ for (const u of o) c[u] = (c[u] || 0) + 1
1835
+ const s = r ? sortObjectValues(c, i ? (u, f) => u[1] - f[1] : (u, f) => f[1] - u[1]) : c
1836
+ return e ? Object.keys(s) : s
1837
1837
  }
1838
- function sortObjectValues(n, e) {
1839
- return Object.fromEntries(Object.entries(n).sort(e))
1838
+ function sortObjectValues(n, t) {
1839
+ return Object.fromEntries(Object.entries(n).sort(t))
1840
1840
  }
1841
1841
  function transformToArray(n) {
1842
- const e = [],
1843
- t = Object.keys(n),
1844
- r = n[t[0]].length
1842
+ const t = [],
1843
+ e = Object.keys(n),
1844
+ r = n[e[0]].length
1845
1845
  for (let i = 0; i < r; i++) {
1846
1846
  const o = {}
1847
- for (const c of t) o[c] = n[c][i]
1848
- e.push(o)
1847
+ for (const c of e) o[c] = n[c][i]
1848
+ t.push(o)
1849
1849
  }
1850
- return e
1850
+ return t
1851
1851
  }
1852
- function incrementMulti(n, e, t = 1) {
1853
- for (const r of n) r[e] += t
1852
+ function incrementMulti(n, t, e = 1) {
1853
+ for (const r of n) r[t] += e
1854
1854
  }
1855
- function setMulti(n, e, t) {
1856
- for (const r of n) r[e] = t
1855
+ function setMulti(n, t, e) {
1856
+ for (const r of n) r[t] = e
1857
1857
  }
1858
- function group(n, e) {
1859
- const t = []
1858
+ function group(n, t) {
1859
+ const e = []
1860
1860
  let r = []
1861
1861
  return (
1862
1862
  n.forEach((i, o) => {
1863
- ;(o === 0 || !e(i, n[o - 1])) && ((r = []), t.push(r)), r.push(i)
1863
+ ;(o === 0 || !t(i, n[o - 1])) && ((r = []), e.push(r)), r.push(i)
1864
1864
  }),
1865
- t
1865
+ e
1866
1866
  )
1867
1867
  }
1868
1868
  function createBidirectionalMap() {
@@ -1871,66 +1871,66 @@ function createBidirectionalMap() {
1871
1871
  function createTemporalBidirectionalMap() {
1872
1872
  return { map: new Map(), keys: [] }
1873
1873
  }
1874
- function pushToBidirectionalMap(n, e, t, r = 100) {
1875
- if (n.map.has(e)) {
1876
- const i = n.keys.indexOf(e)
1874
+ function pushToBidirectionalMap(n, t, e, r = 100) {
1875
+ if (n.map.has(t)) {
1876
+ const i = n.keys.indexOf(t)
1877
1877
  n.keys.splice(i, 1)
1878
1878
  }
1879
- if ((n.map.set(e, t), n.keys.push(e), n.keys.length > r)) {
1879
+ if ((n.map.set(t, e), n.keys.push(t), n.keys.length > r)) {
1880
1880
  const i = n.keys.shift()
1881
1881
  i && n.map.delete(i)
1882
1882
  }
1883
1883
  }
1884
- function unshiftToBidirectionalMap(n, e, t, r = 100) {
1885
- if (n.map.has(e)) {
1886
- const i = n.keys.indexOf(e)
1884
+ function unshiftToBidirectionalMap(n, t, e, r = 100) {
1885
+ if (n.map.has(t)) {
1886
+ const i = n.keys.indexOf(t)
1887
1887
  n.keys.splice(i, 1)
1888
1888
  }
1889
- if ((n.map.set(e, t), n.keys.unshift(e), n.keys.length > r)) {
1889
+ if ((n.map.set(t, e), n.keys.unshift(t), n.keys.length > r)) {
1890
1890
  const i = n.keys.shift()
1891
1891
  i && n.map.delete(i)
1892
1892
  }
1893
1893
  }
1894
- function addToTemporalBidirectionalMap(n, e, t, r, i = 100) {
1895
- pushToBidirectionalMap(n, e, { validUntil: Date.now() + r, data: t }, i)
1894
+ function addToTemporalBidirectionalMap(n, t, e, r, i = 100) {
1895
+ pushToBidirectionalMap(n, t, { validUntil: Date.now() + r, data: e }, i)
1896
1896
  }
1897
- function getFromTemporalBidirectionalMap(n, e) {
1898
- const t = n.map.get(e)
1899
- return t && t.validUntil > Date.now() ? t.data : null
1897
+ function getFromTemporalBidirectionalMap(n, t) {
1898
+ const e = n.map.get(t)
1899
+ return e && e.validUntil > Date.now() ? e.data : null
1900
1900
  }
1901
1901
  class Optional {
1902
- constructor(e) {
1903
- this.value = e
1902
+ constructor(t) {
1903
+ this.value = t
1904
1904
  }
1905
- static of(e) {
1906
- return new Optional(e)
1905
+ static of(t) {
1906
+ return new Optional(t)
1907
1907
  }
1908
1908
  static empty() {
1909
1909
  return new Optional(null)
1910
1910
  }
1911
- map(e) {
1912
- return new Optional(this.value !== null && this.value !== void 0 ? e(this.value) : null)
1911
+ map(t) {
1912
+ return new Optional(this.value !== null && this.value !== void 0 ? t(this.value) : null)
1913
1913
  }
1914
- mapAsync(e) {
1915
- return this.value !== null && this.value !== void 0 ? e(this.value).then(t => Optional.of(t)) : Promise.resolve(Optional.empty())
1914
+ mapAsync(t) {
1915
+ return this.value !== null && this.value !== void 0 ? t(this.value).then(e => Optional.of(e)) : Promise.resolve(Optional.empty())
1916
1916
  }
1917
- ifPresent(e) {
1918
- return this.value !== null && this.value !== void 0 && e(this.value), this
1917
+ ifPresent(t) {
1918
+ return this.value !== null && this.value !== void 0 && t(this.value), this
1919
1919
  }
1920
- ifPresentAsync(e) {
1921
- return this.value !== null && this.value !== void 0 ? e(this.value).then(() => this) : Promise.resolve(this)
1920
+ ifPresentAsync(t) {
1921
+ return this.value !== null && this.value !== void 0 ? t(this.value).then(() => this) : Promise.resolve(this)
1922
1922
  }
1923
- ifAbsent(e) {
1924
- return (this.value === null || this.value === void 0) && e(), this
1923
+ ifAbsent(t) {
1924
+ return (this.value === null || this.value === void 0) && t(), this
1925
1925
  }
1926
- ifAbsentAsync(e) {
1927
- return this.value === null || this.value === void 0 ? e().then(() => this) : Promise.resolve(this)
1926
+ ifAbsentAsync(t) {
1927
+ return this.value === null || this.value === void 0 ? t().then(() => this) : Promise.resolve(this)
1928
1928
  }
1929
- getOrFallback(e) {
1930
- return this.value ?? e()
1929
+ getOrFallback(t) {
1930
+ return this.value ?? t()
1931
1931
  }
1932
- getOrFallbackAsync(e) {
1933
- return this.value !== null && this.value !== void 0 ? Promise.resolve(this.value) : e()
1932
+ getOrFallbackAsync(t) {
1933
+ return this.value !== null && this.value !== void 0 ? Promise.resolve(this.value) : t()
1934
1934
  }
1935
1935
  getOrThrow() {
1936
1936
  if (this.value === null || this.value === void 0) throw Error('Optional.value is empty')
@@ -1939,8 +1939,8 @@ class Optional {
1939
1939
  }
1940
1940
  exports.Optional = Optional
1941
1941
  class Lazy {
1942
- constructor(e) {
1943
- ;(this.supplier = e), (this.value = null)
1942
+ constructor(t) {
1943
+ ;(this.supplier = t), (this.value = null)
1944
1944
  }
1945
1945
  get() {
1946
1946
  return this.value || (this.value = this.supplier()), this.value
@@ -1948,8 +1948,8 @@ class Lazy {
1948
1948
  }
1949
1949
  exports.Lazy = Lazy
1950
1950
  class AsyncLazy {
1951
- constructor(e) {
1952
- ;(this.supplier = e), (this.value = null)
1951
+ constructor(t) {
1952
+ ;(this.supplier = t), (this.value = null)
1953
1953
  }
1954
1954
  async get() {
1955
1955
  return this.value || (this.value = await this.supplier()), this.value
@@ -1957,92 +1957,92 @@ class AsyncLazy {
1957
1957
  }
1958
1958
  exports.AsyncLazy = AsyncLazy
1959
1959
  function multicall(n) {
1960
- return () => n.forEach(e => e())
1960
+ return () => n.forEach(t => t())
1961
1961
  }
1962
- function maxBy(n, e) {
1963
- return n.reduce((t, r) => (e(t) > e(r) ? t : r))
1962
+ function maxBy(n, t) {
1963
+ return n.reduce((e, r) => (t(e) > t(r) ? e : r))
1964
1964
  }
1965
- function minBy(n, e) {
1966
- return n.reduce((t, r) => (e(t) < e(r) ? t : r))
1965
+ function minBy(n, t) {
1966
+ return n.reduce((e, r) => (t(e) < t(r) ? e : r))
1967
1967
  }
1968
- function allArrayIndexOf(n, e) {
1969
- const t = []
1968
+ function allArrayIndexOf(n, t) {
1969
+ const e = []
1970
1970
  return (
1971
1971
  n.forEach((r, i) => {
1972
- e(r) && t.push(i)
1972
+ t(r) && e.push(i)
1973
1973
  }),
1974
- t
1974
+ e
1975
1975
  )
1976
1976
  }
1977
- function findInstance(n, e) {
1978
- const t = n.find(r => r instanceof e)
1979
- return Optional.of(t)
1977
+ function findInstance(n, t) {
1978
+ const e = n.find(r => r instanceof t)
1979
+ return Optional.of(e)
1980
1980
  }
1981
- function filterInstances(n, e) {
1982
- return n.filter(t => t instanceof e)
1981
+ function filterInstances(n, t) {
1982
+ return n.filter(e => e instanceof t)
1983
1983
  }
1984
- function interleave(n, e) {
1985
- const t = [],
1986
- r = Math.max(n.length, e.length)
1987
- for (let i = 0; i < r; i++) n[i] && t.push(n[i]), e[i] && t.push(e[i])
1988
- return t
1984
+ function interleave(n, t) {
1985
+ const e = [],
1986
+ r = Math.max(n.length, t.length)
1987
+ for (let i = 0; i < r; i++) n[i] && e.push(n[i]), t[i] && e.push(t[i])
1988
+ return e
1989
1989
  }
1990
- function toggle(n, e) {
1991
- return n.includes(e) ? n.filter(t => t !== e) : [...n, e]
1990
+ function toggle(n, t) {
1991
+ return n.includes(t) ? n.filter(e => e !== t) : [...n, t]
1992
1992
  }
1993
1993
  class Node {
1994
- constructor(e) {
1995
- ;(this.value = e), (this.children = [])
1994
+ constructor(t) {
1995
+ ;(this.value = t), (this.children = [])
1996
1996
  }
1997
1997
  }
1998
- function createHierarchy(n, e, t, r, i = !1) {
1998
+ function createHierarchy(n, t, e, r, i = !1) {
1999
1999
  const o = new Map(),
2000
2000
  c = []
2001
- n.forEach(s => {
2002
- const f = new Node(s)
2003
- o.set(s[e], f)
2001
+ n.forEach(u => {
2002
+ const f = new Node(u)
2003
+ o.set(u[t], f)
2004
2004
  }),
2005
- n.forEach(s => {
2006
- const f = o.get(s[e])
2005
+ n.forEach(u => {
2006
+ const f = o.get(u[t])
2007
2007
  if (!f) return
2008
- const l = s[t]
2008
+ const l = u[e]
2009
2009
  if (l) {
2010
2010
  const a = o.get(l)
2011
2011
  a && a.children.push(f)
2012
2012
  } else c.push(f)
2013
2013
  })
2014
- const u = s => {
2015
- s.children.sort((f, l) => {
2014
+ const s = u => {
2015
+ u.children.sort((f, l) => {
2016
2016
  const a = f.value[r],
2017
2017
  h = l.value[r]
2018
2018
  return i ? h - a : a - h
2019
2019
  }),
2020
- s.children.forEach(u)
2020
+ u.children.forEach(s)
2021
2021
  }
2022
- return c.forEach(u), c
2022
+ return c.forEach(s), c
2023
2023
  }
2024
- function log2Reduce(n, e) {
2024
+ function log2Reduce(n, t) {
2025
2025
  if (Math.log2(n.length) % 1 !== 0) throw new Error('Array length must be a power of 2')
2026
- let t = [...n]
2027
- for (; t.length > 1; ) {
2026
+ let e = [...n]
2027
+ for (; e.length > 1; ) {
2028
2028
  const r = []
2029
- for (let i = 0; i < t.length; i += 2) {
2030
- const o = t[i + 1]
2031
- r.push(e(t[i], o))
2029
+ for (let i = 0; i < e.length; i += 2) {
2030
+ const o = e[i + 1]
2031
+ r.push(t(e[i], o))
2032
2032
  }
2033
- t = r
2033
+ e = r
2034
2034
  }
2035
- return t[0]
2035
+ return e[0]
2036
2036
  }
2037
2037
  function concatBytes(...n) {
2038
- const e = n.reduce((i, o) => i + o.length, 0),
2039
- t = new Uint8Array(e)
2038
+ const t = n.reduce((i, o) => i + o.length, 0),
2039
+ e = new Uint8Array(t)
2040
2040
  let r = 0
2041
2041
  return (
2042
2042
  n.forEach(i => {
2043
- t.set(i, r), (r += i.length)
2043
+ e.set(i, r), (r += i.length)
2044
2044
  }),
2045
- t
2045
+ e
2046
2046
  )
2047
2047
  }
2048
2048
  function isPng(n) {
@@ -2063,169 +2063,169 @@ function numberToUint8(n) {
2063
2063
  function uint8ToNumber(n) {
2064
2064
  return n[0]
2065
2065
  }
2066
- function numberToUint16(n, e) {
2067
- const t = new ArrayBuffer(2)
2068
- return new DataView(t).setUint16(0, n, e === 'LE'), new Uint8Array(t)
2066
+ function numberToUint16(n, t) {
2067
+ const e = new ArrayBuffer(2)
2068
+ return new DataView(e).setUint16(0, n, t === 'LE'), new Uint8Array(e)
2069
2069
  }
2070
- function uint16ToNumber(n, e) {
2071
- return new DataView(n.buffer).getUint16(n.byteOffset, e === 'LE')
2070
+ function uint16ToNumber(n, t) {
2071
+ return new DataView(n.buffer).getUint16(n.byteOffset, t === 'LE')
2072
2072
  }
2073
- function numberToUint32(n, e) {
2074
- const t = new ArrayBuffer(4)
2075
- return new DataView(t).setUint32(0, n, e === 'LE'), new Uint8Array(t)
2073
+ function numberToUint32(n, t) {
2074
+ const e = new ArrayBuffer(4)
2075
+ return new DataView(e).setUint32(0, n, t === 'LE'), new Uint8Array(e)
2076
2076
  }
2077
- function uint32ToNumber(n, e) {
2078
- return new DataView(n.buffer).getUint32(n.byteOffset, e === 'LE')
2077
+ function uint32ToNumber(n, t) {
2078
+ return new DataView(n.buffer).getUint32(n.byteOffset, t === 'LE')
2079
2079
  }
2080
- function numberToUint64(n, e) {
2081
- const t = new ArrayBuffer(8)
2082
- return new DataView(t).setBigUint64(0, BigInt(n), e === 'LE'), new Uint8Array(t)
2080
+ function numberToUint64(n, t) {
2081
+ const e = new ArrayBuffer(8)
2082
+ return new DataView(e).setBigUint64(0, BigInt(n), t === 'LE'), new Uint8Array(e)
2083
2083
  }
2084
- function uint64ToNumber(n, e) {
2085
- return new DataView(n.buffer).getBigUint64(n.byteOffset, e === 'LE')
2084
+ function uint64ToNumber(n, t) {
2085
+ return new DataView(n.buffer).getBigUint64(n.byteOffset, t === 'LE')
2086
2086
  }
2087
- function numberToUint256(n, e) {
2087
+ function numberToUint256(n, t) {
2088
2088
  const r = new Uint8Array(32)
2089
2089
  let i = n
2090
- if (e === 'LE') {
2090
+ if (t === 'LE') {
2091
2091
  for (let o = 0; o < 32; o++) (r[o] = Number(i & 0xffn)), (i >>= 8n)
2092
2092
  return r
2093
2093
  }
2094
2094
  for (let o = 31; o >= 0; o--) (r[o] = Number(i & 0xffn)), (i >>= 8n)
2095
2095
  return r
2096
2096
  }
2097
- function uint256ToNumber(n, e) {
2097
+ function uint256ToNumber(n, t) {
2098
2098
  let r = 0n
2099
- if (e === 'LE') {
2099
+ if (t === 'LE') {
2100
2100
  for (let i = 31; i >= 0; i--) r = (r << 8n) | BigInt(n[i])
2101
2101
  return r
2102
2102
  }
2103
2103
  for (let i = 0; i < 32; i++) r = (r << 8n) | BigInt(n[i])
2104
2104
  return r
2105
2105
  }
2106
- function sliceBytes(n, e) {
2107
- const t = []
2106
+ function sliceBytes(n, t) {
2107
+ const e = []
2108
2108
  let r = 0
2109
- for (const i of e) t.push(n.subarray(r, r + i)), (r += i)
2110
- return t
2109
+ for (const i of t) e.push(n.subarray(r, r + i)), (r += i)
2110
+ return e
2111
2111
  }
2112
- function partition(n, e) {
2113
- const t = []
2114
- for (let r = 0; r < n.length; r += e) t.push(n.subarray(r, r + e))
2115
- return t
2112
+ function partition(n, t) {
2113
+ const e = []
2114
+ for (let r = 0; r < n.length; r += t) e.push(n.subarray(r, r + t))
2115
+ return e
2116
2116
  }
2117
2117
  const IOTA_CONSTANTS = [0, 1, 0, 32898, 2147483648, 32906, 2147483648, 2147516416, 0, 32907, 0, 2147483649, 2147483648, 2147516545, 2147483648, 32777, 0, 138, 0, 136, 0, 2147516425, 0, 2147483658, 0, 2147516555, 2147483648, 139, 2147483648, 32905, 2147483648, 32771, 2147483648, 32770, 2147483648, 128, 0, 32778, 2147483648, 2147483658, 2147483648, 2147516545, 2147483648, 32896, 0, 2147483649, 2147483648, 2147516424]
2118
2118
  function keccakPermutate(n) {
2119
- for (let e = 0; e < 24; e++) {
2120
- const t = n[0] ^ n[10] ^ n[20] ^ n[30] ^ n[40],
2119
+ for (let t = 0; t < 24; t++) {
2120
+ const e = n[0] ^ n[10] ^ n[20] ^ n[30] ^ n[40],
2121
2121
  r = n[1] ^ n[11] ^ n[21] ^ n[31] ^ n[41],
2122
2122
  i = n[2] ^ n[12] ^ n[22] ^ n[32] ^ n[42],
2123
2123
  o = n[3] ^ n[13] ^ n[23] ^ n[33] ^ n[43],
2124
2124
  c = n[4] ^ n[14] ^ n[24] ^ n[34] ^ n[44],
2125
- u = n[5] ^ n[15] ^ n[25] ^ n[35] ^ n[45],
2126
- s = n[6] ^ n[16] ^ n[26] ^ n[36] ^ n[46],
2125
+ s = n[5] ^ n[15] ^ n[25] ^ n[35] ^ n[45],
2126
+ u = n[6] ^ n[16] ^ n[26] ^ n[36] ^ n[46],
2127
2127
  f = n[7] ^ n[17] ^ n[27] ^ n[37] ^ n[47],
2128
2128
  l = n[8] ^ n[18] ^ n[28] ^ n[38] ^ n[48],
2129
2129
  a = n[9] ^ n[19] ^ n[29] ^ n[39] ^ n[49],
2130
2130
  h = (i << 1) | (o >>> 31),
2131
- bn = (o << 1) | (i >>> 31),
2131
+ p = (o << 1) | (i >>> 31),
2132
2132
  d = l ^ h,
2133
- p = a ^ bn,
2134
- $n = (c << 1) | (u >>> 31),
2135
- An = (u << 1) | (c >>> 31),
2136
- m = t ^ $n,
2137
- g = r ^ An,
2138
- En = (s << 1) | (f >>> 31),
2139
- Sn = (f << 1) | (s >>> 31),
2140
- w = i ^ En,
2141
- x = o ^ Sn,
2142
- Mn = (l << 1) | (a >>> 31),
2133
+ m = a ^ p,
2134
+ w = (c << 1) | (s >>> 31),
2135
+ x = (s << 1) | (c >>> 31),
2136
+ g = e ^ w,
2137
+ y = r ^ x,
2138
+ En = (u << 1) | (f >>> 31),
2139
+ Mn = (f << 1) | (u >>> 31),
2140
+ b = i ^ En,
2141
+ A = o ^ Mn,
2142
+ Sn = (l << 1) | (a >>> 31),
2143
2143
  kn = (a << 1) | (l >>> 31),
2144
- y = c ^ Mn,
2145
- b = u ^ kn,
2146
- On = (t << 1) | (r >>> 31),
2147
- Tn = (r << 1) | (t >>> 31),
2148
- $ = s ^ On,
2149
- A = f ^ Tn
2150
- ;(n[0] ^= d), (n[1] ^= p), (n[2] ^= m), (n[3] ^= g), (n[4] ^= w), (n[5] ^= x), (n[6] ^= y), (n[7] ^= b), (n[8] ^= $), (n[9] ^= A), (n[10] ^= d), (n[11] ^= p), (n[12] ^= m), (n[13] ^= g), (n[14] ^= w), (n[15] ^= x), (n[16] ^= y), (n[17] ^= b), (n[18] ^= $), (n[19] ^= A), (n[20] ^= d), (n[21] ^= p), (n[22] ^= m), (n[23] ^= g), (n[24] ^= w), (n[25] ^= x), (n[26] ^= y), (n[27] ^= b), (n[28] ^= $), (n[29] ^= A), (n[30] ^= d), (n[31] ^= p), (n[32] ^= m), (n[33] ^= g), (n[34] ^= w), (n[35] ^= x), (n[36] ^= y), (n[37] ^= b), (n[38] ^= $), (n[39] ^= A), (n[40] ^= d), (n[41] ^= p), (n[42] ^= m), (n[43] ^= g), (n[44] ^= w), (n[45] ^= x), (n[46] ^= y), (n[47] ^= b), (n[48] ^= $), (n[49] ^= A)
2151
- const E = n[0],
2152
- S = n[1],
2153
- M = (n[2] << 1) | (n[3] >>> 31),
2154
- k = (n[3] << 1) | (n[2] >>> 31),
2155
- O = (n[5] << 30) | (n[4] >>> 2),
2156
- T = (n[4] << 30) | (n[5] >>> 2),
2157
- C = (n[6] << 28) | (n[7] >>> 4),
2158
- R = (n[7] << 28) | (n[6] >>> 4),
2159
- I = (n[8] << 27) | (n[9] >>> 5),
2160
- D = (n[9] << 27) | (n[8] >>> 5),
2161
- P = (n[11] << 4) | (n[10] >>> 28),
2162
- B = (n[10] << 4) | (n[11] >>> 28),
2163
- v = (n[13] << 12) | (n[12] >>> 20),
2164
- U = (n[12] << 12) | (n[13] >>> 20),
2165
- L = (n[14] << 6) | (n[15] >>> 26),
2166
- j = (n[15] << 6) | (n[14] >>> 26),
2167
- N = (n[17] << 23) | (n[16] >>> 9),
2168
- F = (n[16] << 23) | (n[17] >>> 9),
2169
- z = (n[18] << 20) | (n[19] >>> 12),
2170
- q = (n[19] << 20) | (n[18] >>> 12),
2171
- W = (n[20] << 3) | (n[21] >>> 29),
2172
- H = (n[21] << 3) | (n[20] >>> 29),
2173
- V = (n[22] << 10) | (n[23] >>> 22),
2174
- J = (n[23] << 10) | (n[22] >>> 22),
2175
- K = (n[25] << 11) | (n[24] >>> 21),
2176
- Z = (n[24] << 11) | (n[25] >>> 21),
2177
- Q = (n[26] << 25) | (n[27] >>> 7),
2178
- G = (n[27] << 25) | (n[26] >>> 7),
2179
- Y = (n[29] << 7) | (n[28] >>> 25),
2180
- X = (n[28] << 7) | (n[29] >>> 25),
2181
- _ = (n[31] << 9) | (n[30] >>> 23),
2182
- nn = (n[30] << 9) | (n[31] >>> 23),
2183
- en = (n[33] << 13) | (n[32] >>> 19),
2184
- tn = (n[32] << 13) | (n[33] >>> 19),
2185
- rn = (n[34] << 15) | (n[35] >>> 17),
2186
- on = (n[35] << 15) | (n[34] >>> 17),
2187
- cn = (n[36] << 21) | (n[37] >>> 11),
2188
- sn = (n[37] << 21) | (n[36] >>> 11),
2189
- un = (n[38] << 8) | (n[39] >>> 24),
2190
- fn = (n[39] << 8) | (n[38] >>> 24),
2191
- ln = (n[40] << 18) | (n[41] >>> 14),
2192
- an = (n[41] << 18) | (n[40] >>> 14),
2193
- hn = (n[42] << 2) | (n[43] >>> 30),
2194
- dn = (n[43] << 2) | (n[42] >>> 30),
2195
- pn = (n[45] << 29) | (n[44] >>> 3),
2196
- mn = (n[44] << 29) | (n[45] >>> 3),
2197
- gn = (n[47] << 24) | (n[46] >>> 8),
2198
- wn = (n[46] << 24) | (n[47] >>> 8),
2199
- xn = (n[48] << 14) | (n[49] >>> 18),
2200
- yn = (n[49] << 14) | (n[48] >>> 18)
2201
- ;(n[0] = E ^ (~v & K)), (n[1] = S ^ (~U & Z)), (n[2] = v ^ (~K & cn)), (n[3] = U ^ (~Z & sn)), (n[4] = K ^ (~cn & xn)), (n[5] = Z ^ (~sn & yn)), (n[6] = cn ^ (~xn & E)), (n[7] = sn ^ (~yn & S)), (n[8] = xn ^ (~E & v)), (n[9] = yn ^ (~S & U)), (n[10] = C ^ (~z & W)), (n[11] = R ^ (~q & H)), (n[12] = z ^ (~W & en)), (n[13] = q ^ (~H & tn)), (n[14] = W ^ (~en & pn)), (n[15] = H ^ (~tn & mn)), (n[16] = en ^ (~pn & C)), (n[17] = tn ^ (~mn & R)), (n[18] = pn ^ (~C & z)), (n[19] = mn ^ (~R & q)), (n[20] = M ^ (~L & Q)), (n[21] = k ^ (~j & G)), (n[22] = L ^ (~Q & un)), (n[23] = j ^ (~G & fn)), (n[24] = Q ^ (~un & ln)), (n[25] = G ^ (~fn & an)), (n[26] = un ^ (~ln & M)), (n[27] = fn ^ (~an & k)), (n[28] = ln ^ (~M & L)), (n[29] = an ^ (~k & j)), (n[30] = I ^ (~P & V)), (n[31] = D ^ (~B & J)), (n[32] = P ^ (~V & rn)), (n[33] = B ^ (~J & on)), (n[34] = V ^ (~rn & gn)), (n[35] = J ^ (~on & wn)), (n[36] = rn ^ (~gn & I)), (n[37] = on ^ (~wn & D)), (n[38] = gn ^ (~I & P)), (n[39] = wn ^ (~D & B)), (n[40] = O ^ (~N & Y)), (n[41] = T ^ (~F & X)), (n[42] = N ^ (~Y & _)), (n[43] = F ^ (~X & nn)), (n[44] = Y ^ (~_ & hn)), (n[45] = X ^ (~nn & dn)), (n[46] = _ ^ (~hn & O)), (n[47] = nn ^ (~dn & T)), (n[48] = hn ^ (~O & N)), (n[49] = dn ^ (~T & F)), (n[0] ^= IOTA_CONSTANTS[e * 2]), (n[1] ^= IOTA_CONSTANTS[e * 2 + 1])
2144
+ $ = c ^ Sn,
2145
+ E = s ^ kn,
2146
+ On = (e << 1) | (r >>> 31),
2147
+ Tn = (r << 1) | (e >>> 31),
2148
+ M = u ^ On,
2149
+ S = f ^ Tn
2150
+ ;(n[0] ^= d), (n[1] ^= m), (n[2] ^= g), (n[3] ^= y), (n[4] ^= b), (n[5] ^= A), (n[6] ^= $), (n[7] ^= E), (n[8] ^= M), (n[9] ^= S), (n[10] ^= d), (n[11] ^= m), (n[12] ^= g), (n[13] ^= y), (n[14] ^= b), (n[15] ^= A), (n[16] ^= $), (n[17] ^= E), (n[18] ^= M), (n[19] ^= S), (n[20] ^= d), (n[21] ^= m), (n[22] ^= g), (n[23] ^= y), (n[24] ^= b), (n[25] ^= A), (n[26] ^= $), (n[27] ^= E), (n[28] ^= M), (n[29] ^= S), (n[30] ^= d), (n[31] ^= m), (n[32] ^= g), (n[33] ^= y), (n[34] ^= b), (n[35] ^= A), (n[36] ^= $), (n[37] ^= E), (n[38] ^= M), (n[39] ^= S), (n[40] ^= d), (n[41] ^= m), (n[42] ^= g), (n[43] ^= y), (n[44] ^= b), (n[45] ^= A), (n[46] ^= $), (n[47] ^= E), (n[48] ^= M), (n[49] ^= S)
2151
+ const k = n[0],
2152
+ O = n[1],
2153
+ T = (n[2] << 1) | (n[3] >>> 31),
2154
+ C = (n[3] << 1) | (n[2] >>> 31),
2155
+ R = (n[5] << 30) | (n[4] >>> 2),
2156
+ I = (n[4] << 30) | (n[5] >>> 2),
2157
+ D = (n[6] << 28) | (n[7] >>> 4),
2158
+ B = (n[7] << 28) | (n[6] >>> 4),
2159
+ P = (n[8] << 27) | (n[9] >>> 5),
2160
+ U = (n[9] << 27) | (n[8] >>> 5),
2161
+ v = (n[11] << 4) | (n[10] >>> 28),
2162
+ j = (n[10] << 4) | (n[11] >>> 28),
2163
+ L = (n[13] << 12) | (n[12] >>> 20),
2164
+ N = (n[12] << 12) | (n[13] >>> 20),
2165
+ F = (n[14] << 6) | (n[15] >>> 26),
2166
+ z = (n[15] << 6) | (n[14] >>> 26),
2167
+ W = (n[17] << 23) | (n[16] >>> 9),
2168
+ H = (n[16] << 23) | (n[17] >>> 9),
2169
+ q = (n[18] << 20) | (n[19] >>> 12),
2170
+ V = (n[19] << 20) | (n[18] >>> 12),
2171
+ J = (n[20] << 3) | (n[21] >>> 29),
2172
+ K = (n[21] << 3) | (n[20] >>> 29),
2173
+ Z = (n[22] << 10) | (n[23] >>> 22),
2174
+ Q = (n[23] << 10) | (n[22] >>> 22),
2175
+ G = (n[25] << 11) | (n[24] >>> 21),
2176
+ _ = (n[24] << 11) | (n[25] >>> 21),
2177
+ Y = (n[26] << 25) | (n[27] >>> 7),
2178
+ X = (n[27] << 25) | (n[26] >>> 7),
2179
+ nn = (n[29] << 7) | (n[28] >>> 25),
2180
+ tn = (n[28] << 7) | (n[29] >>> 25),
2181
+ en = (n[31] << 9) | (n[30] >>> 23),
2182
+ rn = (n[30] << 9) | (n[31] >>> 23),
2183
+ on = (n[33] << 13) | (n[32] >>> 19),
2184
+ cn = (n[32] << 13) | (n[33] >>> 19),
2185
+ sn = (n[34] << 15) | (n[35] >>> 17),
2186
+ un = (n[35] << 15) | (n[34] >>> 17),
2187
+ fn = (n[36] << 21) | (n[37] >>> 11),
2188
+ ln = (n[37] << 21) | (n[36] >>> 11),
2189
+ an = (n[38] << 8) | (n[39] >>> 24),
2190
+ hn = (n[39] << 8) | (n[38] >>> 24),
2191
+ dn = (n[40] << 18) | (n[41] >>> 14),
2192
+ pn = (n[41] << 18) | (n[40] >>> 14),
2193
+ mn = (n[42] << 2) | (n[43] >>> 30),
2194
+ gn = (n[43] << 2) | (n[42] >>> 30),
2195
+ wn = (n[45] << 29) | (n[44] >>> 3),
2196
+ xn = (n[44] << 29) | (n[45] >>> 3),
2197
+ yn = (n[47] << 24) | (n[46] >>> 8),
2198
+ bn = (n[46] << 24) | (n[47] >>> 8),
2199
+ An = (n[48] << 14) | (n[49] >>> 18),
2200
+ $n = (n[49] << 14) | (n[48] >>> 18)
2201
+ ;(n[0] = k ^ (~L & G)), (n[1] = O ^ (~N & _)), (n[2] = L ^ (~G & fn)), (n[3] = N ^ (~_ & ln)), (n[4] = G ^ (~fn & An)), (n[5] = _ ^ (~ln & $n)), (n[6] = fn ^ (~An & k)), (n[7] = ln ^ (~$n & O)), (n[8] = An ^ (~k & L)), (n[9] = $n ^ (~O & N)), (n[10] = D ^ (~q & J)), (n[11] = B ^ (~V & K)), (n[12] = q ^ (~J & on)), (n[13] = V ^ (~K & cn)), (n[14] = J ^ (~on & wn)), (n[15] = K ^ (~cn & xn)), (n[16] = on ^ (~wn & D)), (n[17] = cn ^ (~xn & B)), (n[18] = wn ^ (~D & q)), (n[19] = xn ^ (~B & V)), (n[20] = T ^ (~F & Y)), (n[21] = C ^ (~z & X)), (n[22] = F ^ (~Y & an)), (n[23] = z ^ (~X & hn)), (n[24] = Y ^ (~an & dn)), (n[25] = X ^ (~hn & pn)), (n[26] = an ^ (~dn & T)), (n[27] = hn ^ (~pn & C)), (n[28] = dn ^ (~T & F)), (n[29] = pn ^ (~C & z)), (n[30] = P ^ (~v & Z)), (n[31] = U ^ (~j & Q)), (n[32] = v ^ (~Z & sn)), (n[33] = j ^ (~Q & un)), (n[34] = Z ^ (~sn & yn)), (n[35] = Q ^ (~un & bn)), (n[36] = sn ^ (~yn & P)), (n[37] = un ^ (~bn & U)), (n[38] = yn ^ (~P & v)), (n[39] = bn ^ (~U & j)), (n[40] = R ^ (~W & nn)), (n[41] = I ^ (~H & tn)), (n[42] = W ^ (~nn & en)), (n[43] = H ^ (~tn & rn)), (n[44] = nn ^ (~en & mn)), (n[45] = tn ^ (~rn & gn)), (n[46] = en ^ (~mn & R)), (n[47] = rn ^ (~gn & I)), (n[48] = mn ^ (~R & W)), (n[49] = gn ^ (~I & H)), (n[0] ^= IOTA_CONSTANTS[t * 2]), (n[1] ^= IOTA_CONSTANTS[t * 2 + 1])
2202
2202
  }
2203
2203
  }
2204
2204
  function bytesToNumbers(n) {
2205
- const e = []
2206
- for (let t = 0; t < n.length; t += 4) e.push(n[t] | (n[t + 1] << 8) | (n[t + 2] << 16) | (n[t + 3] << 24))
2207
- return e
2205
+ const t = []
2206
+ for (let e = 0; e < n.length; e += 4) t.push(n[e] | (n[e + 1] << 8) | (n[e + 2] << 16) | (n[e + 3] << 24))
2207
+ return t
2208
2208
  }
2209
- function divideToBlocks(n, e) {
2209
+ function divideToBlocks(n, t) {
2210
2210
  if (!n.length) {
2211
2211
  const i = new Uint8Array(136)
2212
- return (i[0] = e), (i[135] = 128), [bytesToNumbers(i)]
2212
+ return (i[0] = t), (i[135] = 128), [bytesToNumbers(i)]
2213
2213
  }
2214
- const t = partition(n, 136),
2215
- r = t[t.length - 1]
2214
+ const e = partition(n, 136),
2215
+ r = e[e.length - 1]
2216
2216
  if (r.length < 136) {
2217
2217
  const i = new Uint8Array(136)
2218
- i.set(r), (i[r.length] = e), (i[135] |= 128), (t[t.length - 1] = i)
2218
+ i.set(r), (i[r.length] = t), (i[135] |= 128), (e[e.length - 1] = i)
2219
2219
  }
2220
2220
  if (r.length === 136) {
2221
2221
  const i = new Uint8Array(136)
2222
- ;(i[0] = e), (i[135] = 128), t.push(i)
2222
+ ;(i[0] = t), (i[135] = 128), e.push(i)
2223
2223
  }
2224
- return t.map(bytesToNumbers)
2224
+ return e.map(bytesToNumbers)
2225
2225
  }
2226
- function absorb(n, e) {
2227
- for (const t of e) {
2228
- for (let r = 0; r < 34; r += 2) (n[r] ^= t[r + 1]), (n[r + 1] ^= t[r])
2226
+ function absorb(n, t) {
2227
+ for (const e of t) {
2228
+ for (let r = 0; r < 34; r += 2) (n[r] ^= e[r + 1]), (n[r + 1] ^= e[r])
2229
2229
  keccakPermutate(n)
2230
2230
  }
2231
2231
  return n
@@ -2233,248 +2233,364 @@ function absorb(n, e) {
2233
2233
  function squeeze(n) {
2234
2234
  return new Uint8Array([n[1], n[1] >> -24, n[1] >> -16, n[1] >> -8, n[0], n[0] >> 8, n[0] >> 16, n[0] >> 24, n[3], n[3] >> -24, n[3] >> -16, n[3] >> -8, n[2], n[2] >> 8, n[2] >> 16, n[2] >> 24, n[5], n[5] >> -24, n[5] >> -16, n[5] >> -8, n[4], n[4] >> 8, n[4] >> 16, n[4] >> 24, n[7], n[7] >> -24, n[7] >> -16, n[7] >> -8, n[6], n[6] >> 8, n[6] >> 16, n[6] >> 24])
2235
2235
  }
2236
- function squeezeInto(n, e, t) {
2237
- ;(e[t] = n[1]), (e[t + 1] = n[1] >> 8), (e[t + 2] = n[1] >> 16), (e[t + 3] = n[1] >> 24), (e[t + 4] = n[0]), (e[t + 5] = n[0] >> 8), (e[t + 6] = n[0] >> 16), (e[t + 7] = n[0] >> 24), (e[t + 8] = n[3]), (e[t + 9] = n[3] >> 8), (e[t + 10] = n[3] >> 16), (e[t + 11] = n[3] >> 24), (e[t + 12] = n[2]), (e[t + 13] = n[2] >> 8), (e[t + 14] = n[2] >> 16), (e[t + 15] = n[2] >> 24), (e[t + 16] = n[5]), (e[t + 17] = n[5] >> 8), (e[t + 18] = n[5] >> 16), (e[t + 19] = n[5] >> 24), (e[t + 20] = n[4]), (e[t + 21] = n[4] >> 8), (e[t + 22] = n[4] >> 16), (e[t + 23] = n[4] >> 24), (e[t + 24] = n[7]), (e[t + 25] = n[7] >> 8), (e[t + 26] = n[7] >> 16), (e[t + 27] = n[7] >> 24), (e[t + 28] = n[6]), (e[t + 29] = n[6] >> 8), (e[t + 30] = n[6] >> 16), (e[t + 31] = n[6] >> 24)
2236
+ function squeezeInto(n, t, e) {
2237
+ ;(t[e] = n[1]), (t[e + 1] = n[1] >> 8), (t[e + 2] = n[1] >> 16), (t[e + 3] = n[1] >> 24), (t[e + 4] = n[0]), (t[e + 5] = n[0] >> 8), (t[e + 6] = n[0] >> 16), (t[e + 7] = n[0] >> 24), (t[e + 8] = n[3]), (t[e + 9] = n[3] >> 8), (t[e + 10] = n[3] >> 16), (t[e + 11] = n[3] >> 24), (t[e + 12] = n[2]), (t[e + 13] = n[2] >> 8), (t[e + 14] = n[2] >> 16), (t[e + 15] = n[2] >> 24), (t[e + 16] = n[5]), (t[e + 17] = n[5] >> 8), (t[e + 18] = n[5] >> 16), (t[e + 19] = n[5] >> 24), (t[e + 20] = n[4]), (t[e + 21] = n[4] >> 8), (t[e + 22] = n[4] >> 16), (t[e + 23] = n[4] >> 24), (t[e + 24] = n[7]), (t[e + 25] = n[7] >> 8), (t[e + 26] = n[7] >> 16), (t[e + 27] = n[7] >> 24), (t[e + 28] = n[6]), (t[e + 29] = n[6] >> 8), (t[e + 30] = n[6] >> 16), (t[e + 31] = n[6] >> 24)
2238
2238
  }
2239
2239
  function keccak256(n) {
2240
2240
  return squeeze(absorb(new Array(50).fill(0), divideToBlocks(n, 1)))
2241
2241
  }
2242
2242
  function bmtRoot(n) {
2243
- const e = new Uint8Array(n),
2244
- t = new Array(50).fill(0),
2243
+ const t = new Uint8Array(n),
2244
+ e = new Array(50).fill(0),
2245
2245
  r = new Uint8Array(136)
2246
2246
  ;(r[64] = 1), (r[135] = 128)
2247
- let i = e.length >>> 5
2247
+ let i = t.length >>> 5
2248
2248
  for (; i > 1; ) {
2249
2249
  const o = i >>> 1
2250
2250
  for (let c = 0; c < o; c++) {
2251
- r.set(e.subarray(c << 6, (c + 1) << 6)), t.fill(0)
2252
- for (let u = 0, s = 0; u < 34; u += 2, s += 8) (t[u] ^= r[s + 4] | (r[s + 5] << 8) | (r[s + 6] << 16) | (r[s + 7] << 24)), (t[u + 1] ^= r[s] | (r[s + 1] << 8) | (r[s + 2] << 16) | (r[s + 3] << 24))
2253
- keccakPermutate(t), squeezeInto(t, e, c << 5)
2251
+ r.set(t.subarray(c << 6, (c + 1) << 6)), e.fill(0)
2252
+ for (let s = 0, u = 0; s < 34; s += 2, u += 8) (e[s] ^= r[u + 4] | (r[u + 5] << 8) | (r[u + 6] << 16) | (r[u + 7] << 24)), (e[s + 1] ^= r[u] | (r[u + 1] << 8) | (r[u + 2] << 16) | (r[u + 3] << 24))
2253
+ keccakPermutate(e), squeezeInto(e, t, c << 5)
2254
2254
  }
2255
2255
  i = o
2256
2256
  }
2257
- return e.subarray(0, 32)
2257
+ return t.subarray(0, 32)
2258
2258
  }
2259
2259
  const SPAN_ENCRYPT_INIT_CTR = 128
2260
- function encryptSegments(n, e, t) {
2261
- const r = new Uint8Array(t.length),
2260
+ function encryptSegments(n, t, e) {
2261
+ const r = new Uint8Array(e.length),
2262
2262
  i = new Uint8Array(36)
2263
2263
  i.set(n)
2264
- for (let o = 0, c = 0; c < t.length; o++, c += 32) {
2265
- const u = (e + o) >>> 0
2266
- ;(i[32] = u & 255), (i[33] = (u >>> 8) & 255), (i[34] = (u >>> 16) & 255), (i[35] = (u >>> 24) & 255)
2267
- const s = keccak256(keccak256(i)),
2268
- f = Math.min(c + 32, t.length)
2269
- for (let l = c; l < f; l++) r[l] = t[l] ^ s[l - c]
2264
+ for (let o = 0, c = 0; c < e.length; o++, c += 32) {
2265
+ const s = (t + o) >>> 0
2266
+ ;(i[32] = s & 255), (i[33] = (s >>> 8) & 255), (i[34] = (s >>> 16) & 255), (i[35] = (s >>> 24) & 255)
2267
+ const u = keccak256(keccak256(i)),
2268
+ f = Math.min(c + 32, e.length)
2269
+ for (let l = c; l < f; l++) r[l] = e[l] ^ u[l - c]
2270
2270
  }
2271
2271
  return r
2272
2272
  }
2273
- function encryptSpan(n, e) {
2274
- return encryptSegments(n, SPAN_ENCRYPT_INIT_CTR, e)
2273
+ function encryptSpan(n, t) {
2274
+ return encryptSegments(n, SPAN_ENCRYPT_INIT_CTR, t)
2275
2275
  }
2276
- function encryptData(n, e) {
2277
- return encryptSegments(n, 0, e)
2276
+ function encryptData(n, t) {
2277
+ return encryptSegments(n, 0, t)
2278
2278
  }
2279
- function decryptChunk(n, e) {
2280
- return { span: uint64ToNumber(encryptSpan(e, n.subarray(0, 8)), 'LE'), data: encryptData(e, n.subarray(8, 4104)) }
2279
+ function decryptChunk(n, t) {
2280
+ return { span: uint64ToNumber(encryptSpan(t, n.subarray(0, 8)), 'LE'), data: encryptData(t, n.subarray(8, 4104)) }
2281
2281
  }
2282
2282
  function sha3_256(n) {
2283
2283
  return squeeze(absorb(new Array(50).fill(0), divideToBlocks(n, 6)))
2284
2284
  }
2285
- function proximity(n, e) {
2286
- const t = Math.min(n.length, e.length)
2287
- for (let r = 0; r < t; r++) {
2288
- const i = n[r] ^ e[r]
2285
+ function proximity(n, t) {
2286
+ const e = Math.min(n.length, t.length)
2287
+ for (let r = 0; r < e; r++) {
2288
+ const i = n[r] ^ t[r]
2289
2289
  for (let o = 0; o < 8; o++) if ((i >> (7 - o)) & 1) return r * 8 + o
2290
2290
  }
2291
- return Math.min(n.length, e.length) * 8
2291
+ return Math.min(n.length, t.length) * 8
2292
2292
  }
2293
- function commonPrefix(n, e) {
2294
- const t = Math.min(n.length, e.length)
2295
- for (let r = 0; r < t; r++) if (n[r] !== e[r]) return n.subarray(0, r)
2296
- return n.subarray(0, t)
2293
+ function commonPrefix(n, t) {
2294
+ const e = Math.min(n.length, t.length)
2295
+ for (let r = 0; r < e; r++) if (n[r] !== t[r]) return n.subarray(0, r)
2296
+ return n.subarray(0, e)
2297
2297
  }
2298
- function setBit(n, e, t, r) {
2299
- const i = Math.floor(e / 8),
2300
- o = e % 8
2301
- t === 1 ? (n[i] |= 1 << (r === 'BE' ? 7 - o : o)) : (n[i] &= ~(1 << (r === 'BE' ? 7 - o : o)))
2298
+ function setBit(n, t, e, r) {
2299
+ const i = Math.floor(t / 8),
2300
+ o = t % 8
2301
+ e === 1 ? (n[i] |= 1 << (r === 'BE' ? 7 - o : o)) : (n[i] &= ~(1 << (r === 'BE' ? 7 - o : o)))
2302
2302
  }
2303
- function getBit(n, e, t) {
2304
- const r = Math.floor(e / 8),
2305
- i = e % 8
2306
- return (n[r] >> (t === 'BE' ? 7 - i : i)) & 1
2303
+ function getBit(n, t, e) {
2304
+ const r = Math.floor(t / 8),
2305
+ i = t % 8
2306
+ return (n[r] >> (e === 'BE' ? 7 - i : i)) & 1
2307
2307
  }
2308
- function binaryIndexOf(n, e, t = 0) {
2309
- for (let r = t; r < n.length; r++) for (let i = 0; i < e.length && n[r + i] === e[i]; i++) if (i === e.length - 1) return r
2308
+ function binaryIndexOf(n, t, e = 0) {
2309
+ for (let r = e; r < n.length; r++) for (let i = 0; i < t.length && n[r + i] === t[i]; i++) if (i === t.length - 1) return r
2310
2310
  return -1
2311
2311
  }
2312
- function binaryPadStart(n, e, t = 0) {
2313
- if (n.length >= e) return n
2314
- const r = new Uint8Array(e)
2315
- return r.fill(t), r.set(n, e - n.length), r
2312
+ function binaryPadStart(n, t, e = 0) {
2313
+ if (n.length >= t) return n
2314
+ const r = new Uint8Array(t)
2315
+ return r.fill(e), r.set(n, t - n.length), r
2316
2316
  }
2317
- function binaryPadStartToMultiple(n, e, t = 0) {
2318
- const r = n.length % e
2319
- return r === 0 ? n : binaryPadStart(n, n.length + e - r, t)
2317
+ function binaryPadStartToMultiple(n, t, e = 0) {
2318
+ const r = n.length % t
2319
+ return r === 0 ? n : binaryPadStart(n, n.length + t - r, e)
2320
2320
  }
2321
- function binaryPadEnd(n, e, t = 0) {
2322
- if (n.length >= e) return n
2323
- const r = new Uint8Array(e)
2324
- return r.fill(t), r.set(n, 0), r
2321
+ function binaryPadEnd(n, t, e = 0) {
2322
+ if (n.length >= t) return n
2323
+ const r = new Uint8Array(t)
2324
+ return r.fill(e), r.set(n, 0), r
2325
2325
  }
2326
- function binaryPadEndToMultiple(n, e, t = 0) {
2327
- const r = n.length % e
2328
- return r === 0 ? n : binaryPadEnd(n, n.length + e - r, t)
2326
+ function binaryPadEndToMultiple(n, t, e = 0) {
2327
+ const r = n.length % t
2328
+ return r === 0 ? n : binaryPadEnd(n, n.length + t - r, e)
2329
2329
  }
2330
- function xorCypher(n, e) {
2331
- const t = new Uint8Array(n.length)
2332
- for (let r = 0; r < n.length; r++) t[r] = n[r] ^ e[r % e.length]
2333
- return t
2330
+ function xorCypher(n, t) {
2331
+ const e = new Uint8Array(n.length)
2332
+ for (let r = 0; r < n.length; r++) e[r] = n[r] ^ t[r % t.length]
2333
+ return e
2334
2334
  }
2335
2335
  function isUtf8(n) {
2336
- for (let e = 0; e < n.length; e++) {
2337
- const t = n[e]
2338
- if (!(t < 128))
2339
- if ((t & 224) === 192) {
2340
- if (e + 1 >= n.length || (n[e + 1] & 192) !== 128) return !1
2341
- e += 1
2342
- } else if ((t & 240) === 224) {
2343
- if (e + 2 >= n.length || (n[e + 1] & 192) !== 128 || (n[e + 2] & 192) !== 128) return !1
2344
- e += 2
2345
- } else if ((t & 248) === 240) {
2346
- if (e + 3 >= n.length || (n[e + 1] & 192) !== 128 || (n[e + 2] & 192) !== 128 || (n[e + 3] & 192) !== 128) return !1
2347
- e += 3
2336
+ for (let t = 0; t < n.length; t++) {
2337
+ const e = n[t]
2338
+ if (!(e < 128))
2339
+ if ((e & 224) === 192) {
2340
+ if (t + 1 >= n.length || (n[t + 1] & 192) !== 128) return !1
2341
+ t += 1
2342
+ } else if ((e & 240) === 224) {
2343
+ if (t + 2 >= n.length || (n[t + 1] & 192) !== 128 || (n[t + 2] & 192) !== 128) return !1
2344
+ t += 2
2345
+ } else if ((e & 248) === 240) {
2346
+ if (t + 3 >= n.length || (n[t + 1] & 192) !== 128 || (n[t + 2] & 192) !== 128 || (n[t + 3] & 192) !== 128) return !1
2347
+ t += 3
2348
2348
  } else return !1
2349
2349
  }
2350
2350
  return !0
2351
2351
  }
2352
- function binaryEquals(n, e) {
2353
- if (n.length !== e.length) return !1
2354
- for (let t = 0; t < n.length; t++) if (n[t] !== e[t]) return !1
2352
+ function binaryEquals(n, t) {
2353
+ if (n.length !== t.length) return !1
2354
+ for (let e = 0; e < n.length; e++) if (n[e] !== t[e]) return !1
2355
2355
  return !0
2356
2356
  }
2357
- function mod(n, e) {
2358
- return ((n % e) + e) % e
2357
+ function mod(n, t) {
2358
+ return ((n % t) + t) % t
2359
2359
  }
2360
- function modInverse(n, e) {
2361
- n = mod(n, e)
2362
- let [t, r] = [0n, 1n],
2363
- [i, o] = [e, n]
2360
+ function modInverse(n, t) {
2361
+ n = mod(n, t)
2362
+ let [e, r] = [0n, 1n],
2363
+ [i, o] = [t, n]
2364
2364
  for (; o !== 0n; ) {
2365
2365
  const c = i / o
2366
- ;([t, r] = [r, t - c * r]), ([i, o] = [o, i - c * o])
2366
+ ;([e, r] = [r, e - c * r]), ([i, o] = [o, i - c * o])
2367
2367
  }
2368
2368
  if (i > 1n) throw new Error('a is not invertible')
2369
- return t < 0n && (t += e), t
2369
+ return e < 0n && (e += t), e
2370
2370
  }
2371
- function modPow(n, e, t) {
2371
+ function modPow(n, t, e) {
2372
2372
  let r = 1n
2373
- for (n = mod(n, t); e > 0; ) e % 2n === 1n && (r = mod(r * n, t)), (n = mod(n * n, t)), (e = e / 2n)
2373
+ for (n = mod(n, e); t > 0; ) t % 2n === 1n && (r = mod(r * n, e)), (n = mod(n * n, e)), (t = t / 2n)
2374
2374
  return r
2375
2375
  }
2376
- function modSqrt(n, e) {
2377
- return mod(n, e) === 0n ? 0n : e % 4n === 3n ? modPow(n, (e + 1n) / 4n, e) : null
2376
+ function modSqrt(n, t) {
2377
+ return mod(n, t) === 0n ? 0n : t % 4n === 3n ? modPow(n, (t + 1n) / 4n, t) : null
2378
2378
  }
2379
2379
  const SECP256K1_P = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,
2380
2380
  SECP256K1_N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,
2381
2381
  SECP256K1_X = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,
2382
- SECP256K1_Y = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n
2383
- function ellipticDouble(n, e, t) {
2384
- if (e === 0n) return [0n, 0n]
2385
- const r = mod(3n * n * n * modInverse(2n * e, t), t),
2386
- i = mod(r * r - 2n * n, t),
2387
- o = mod(r * (n - i) - e, t)
2382
+ SECP256K1_Y = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,
2383
+ SECP256K1_BETA = 0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501een
2384
+ function ellipticDouble(n, t, e) {
2385
+ if (t === 0n) return [0n, 0n]
2386
+ const r = mod(3n * n * n * modInverse(2n * t, e), e),
2387
+ i = mod(r * r - 2n * n, e),
2388
+ o = mod(r * (n - i) - t, e)
2388
2389
  return [i, o]
2389
2390
  }
2390
- function ellipticAdd(n, e, t, r, i) {
2391
- if (n === 0n && e === 0n) return [t, r]
2392
- if (t === 0n && r === 0n) return [n, e]
2393
- if (n === t && e === mod(-r, i)) return [0n, 0n]
2394
- if (n === t && e === r) return ellipticDouble(n, e, i)
2395
- const o = mod((r - e) * modInverse(t - n, i), i),
2396
- c = mod(o * o - n - t, i),
2397
- u = mod(o * (n - c) - e, i)
2398
- return [c, u]
2391
+ function ellipticAdd(n, t, e, r, i) {
2392
+ if (n === 0n && t === 0n) return [e, r]
2393
+ if (e === 0n && r === 0n) return [n, t]
2394
+ if (n === e && t === mod(-r, i)) return [0n, 0n]
2395
+ if (n === e && t === r) return ellipticDouble(n, t, i)
2396
+ const o = mod((r - t) * modInverse(e - n, i), i),
2397
+ c = mod(o * o - n - e, i),
2398
+ s = mod(o * (n - c) - t, i)
2399
+ return [c, s]
2399
2400
  }
2400
2401
  function privateKeyToPublicKey(n) {
2401
2402
  if (n <= 0n || n >= SECP256K1_N) throw new Error('Invalid private key')
2402
- return doubleAndAdd(SECP256K1_X, SECP256K1_Y, n, SECP256K1_P)
2403
+ return doubleAndAdd(SECP256K1_X, SECP256K1_Y, n)
2403
2404
  }
2404
2405
  function compressPublicKey(n) {
2405
- const t = n[1] % 2n === 0n ? 2 : 3
2406
- return new Uint8Array([t, ...numberToUint256(n[0], 'BE')])
2406
+ const e = n[1] % 2n === 0n ? 2 : 3
2407
+ return new Uint8Array([e, ...numberToUint256(n[0], 'BE')])
2407
2408
  }
2408
2409
  function publicKeyFromCompressed(n) {
2409
2410
  if (n.length !== 33 || (n[0] !== 2 && n[0] !== 3)) throw new Error('Invalid compressed public key')
2410
- const e = uint256ToNumber(n.slice(1), 'BE'),
2411
- t = modSqrt(mod(e ** 3n + 7n, SECP256K1_P), SECP256K1_P)
2412
- if (!t) throw Error('Invalid x: does not correspond to a valid curve point')
2413
- const r = mod(-t, SECP256K1_P),
2414
- i = t % 2n === 0n
2415
- return [e, n[0] === 2 ? (i ? t : r) : i ? r : t]
2411
+ const t = uint256ToNumber(n.slice(1), 'BE'),
2412
+ e = modSqrt(mod(t ** 3n + 7n, SECP256K1_P), SECP256K1_P)
2413
+ if (!e) throw Error('Invalid x: does not correspond to a valid curve point')
2414
+ const r = mod(-e, SECP256K1_P),
2415
+ i = e % 2n === 0n
2416
+ return [t, n[0] === 2 ? (i ? e : r) : i ? r : e]
2416
2417
  }
2417
2418
  function publicKeyToAddress(n) {
2418
- const e = new Uint8Array(20),
2419
- t = keccak256(concatBytes(numberToUint256(n[0], 'BE'), numberToUint256(n[1], 'BE')))
2420
- return e.set(t.subarray(12)), e
2419
+ const t = new Uint8Array(20),
2420
+ e = keccak256(concatBytes(numberToUint256(n[0], 'BE'), numberToUint256(n[1], 'BE')))
2421
+ return t.set(e.subarray(12)), t
2421
2422
  }
2422
2423
  function checksumEncode(n) {
2423
- const e = exports.Binary.uint8ArrayToHex(n),
2424
- t = exports.Binary.uint8ArrayToHex(exports.Binary.keccak256(new Uint8Array([...e].map(i => i.charCodeAt(0)))))
2424
+ const t = exports.Binary.uint8ArrayToHex(n),
2425
+ e = exports.Binary.uint8ArrayToHex(exports.Binary.keccak256(new Uint8Array([...t].map(i => i.charCodeAt(0)))))
2425
2426
  let r = '0x'
2426
- for (let i = 0; i < e.length; i++) parseInt(t[i], 16) > 7 ? (r += e[i].toUpperCase()) : (r += e[i])
2427
+ for (let i = 0; i < t.length; i++) parseInt(e[i], 16) > 7 ? (r += t[i].toUpperCase()) : (r += t[i])
2427
2428
  return r
2428
2429
  }
2429
- function doubleAndAdd(n, e, t, r) {
2430
- let i = [0n, 0n],
2431
- o = [n, e]
2432
- const c = t.toString(2)
2433
- for (const u of c) u === '0' ? ((o = ellipticAdd(i[0], i[1], o[0], o[1], r)), (i = ellipticDouble(i[0], i[1], r))) : ((i = ellipticAdd(i[0], i[1], o[0], o[1], r)), (o = ellipticDouble(o[0], o[1], r)))
2430
+ function jacobianDouble(n, t, e) {
2431
+ if (e === 0n) return [0n, 0n, 0n]
2432
+ const r = SECP256K1_P,
2433
+ i = (t * t) % r,
2434
+ o = (4n * n * i) % r,
2435
+ c = (3n * n * n) % r,
2436
+ s = mod(c * c - 2n * o, r),
2437
+ u = mod(c * (o - s) - 8n * i * i, r),
2438
+ f = (2n * t * e) % r
2439
+ return [s, u, f]
2440
+ }
2441
+ function jacobianAddMixed(n, t, e, r, i) {
2442
+ if (e === 0n) return [r, i, 1n]
2443
+ const o = SECP256K1_P,
2444
+ c = (e * e) % o,
2445
+ s = (r * c) % o,
2446
+ u = (((i * c) % o) * e) % o,
2447
+ f = mod(s - n, o),
2448
+ l = mod(u - t, o)
2449
+ if (f === 0n) return l === 0n ? jacobianDouble(n, t, e) : [0n, 0n, 0n]
2450
+ const a = (f * f) % o,
2451
+ h = (f * a) % o,
2452
+ p = (n * a) % o,
2453
+ d = mod(l * l - h - 2n * p, o),
2454
+ m = mod(l * (p - d) - t * h, o),
2455
+ w = (f * e) % o
2456
+ return [d, m, w]
2457
+ }
2458
+ function jacobianToAffine(n, t, e) {
2459
+ if (e === 0n) return [0n, 0n]
2460
+ const r = SECP256K1_P,
2461
+ i = modInverse(e, r),
2462
+ o = (i * i) % r
2463
+ return [(n * o) % r, (((t * o) % r) * i) % r]
2464
+ }
2465
+ function glvDecompose(n) {
2466
+ const t = SECP256K1_N,
2467
+ e = 0x3086d221a7d46bcde86c90e49284eb15n,
2468
+ r = 0xe4437ed6010e88286f547fa90abfe4c3n,
2469
+ i = 0x114ca50f7a8e2f3f657c1108d9d44cfd8n,
2470
+ o = 0x3086d221a7d46bcde86c90e49284eb15n,
2471
+ c = (o * n + t / 2n) / t,
2472
+ s = (r * n + t / 2n) / t
2473
+ let u = mod(n - c * e - s * i, t),
2474
+ f = mod(c * r - s * o, t)
2475
+ const l = u > 1n << 128n,
2476
+ a = f > 1n << 128n
2477
+ return l && (u = t - u), a && (f = t - f), [u, l, f, a]
2478
+ }
2479
+ const WNAF_W = 4
2480
+ function toWNAF(n) {
2481
+ const t = 1 << WNAF_W,
2482
+ e = t >> 1,
2483
+ r = BigInt(t - 1),
2484
+ i = []
2485
+ for (; n > 0n; ) {
2486
+ if (n & 1n) {
2487
+ let o = Number(n & r)
2488
+ o >= e && (o -= t), i.push(o), (n -= BigInt(o))
2489
+ } else i.push(0)
2490
+ n >>= 1n
2491
+ }
2434
2492
  return i
2435
2493
  }
2436
- function signMessage(n, e, t) {
2437
- return signHash(uint256ToNumber(keccak256(n), 'BE'), e, t)
2494
+ function batchToAffine(n) {
2495
+ const t = SECP256K1_P,
2496
+ e = n.length
2497
+ if (e === 1) return [jacobianToAffine(n[0][0], n[0][1], n[0][2])]
2498
+ const r = new Array(e)
2499
+ r[0] = n[0][2]
2500
+ for (let s = 1; s < e; s++) r[s] = (r[s - 1] * n[s][2]) % t
2501
+ let i = modInverse(r[e - 1], t)
2502
+ const o = new Array(e)
2503
+ for (let s = e - 1; s > 0; s--) {
2504
+ const u = (i * r[s - 1]) % t,
2505
+ f = (u * u) % t
2506
+ ;(o[s] = [(n[s][0] * f) % t, (((n[s][1] * f) % t) * u) % t]), (i = (i * n[s][2]) % t)
2507
+ }
2508
+ const c = (i * i) % t
2509
+ return (o[0] = [(n[0][0] * c) % t, (((n[0][1] * c) % t) * i) % t]), o
2510
+ }
2511
+ function precomputeOddMultiples(n, t) {
2512
+ const e = 1 << (WNAF_W - 2),
2513
+ [r, i] = jacobianToAffine(...jacobianDouble(n, t, 1n)),
2514
+ o = [[n, t, 1n]]
2515
+ for (let c = 1; c < e; c++) {
2516
+ const [s, u, f] = o[c - 1]
2517
+ o.push(jacobianAddMixed(s, u, f, r, i))
2518
+ }
2519
+ return batchToAffine(o)
2520
+ }
2521
+ function shamirWNAF(n, t, e, r, i, o) {
2522
+ const c = toWNAF(n),
2523
+ s = toWNAF(r),
2524
+ u = precomputeOddMultiples(t, e),
2525
+ f = precomputeOddMultiples(i, o),
2526
+ l = Math.max(c.length, s.length)
2527
+ let a = 0n,
2528
+ h = 0n,
2529
+ p = 0n
2530
+ for (let d = l - 1; d >= 0; d--) {
2531
+ ;[a, h, p] = jacobianDouble(a, h, p)
2532
+ const m = d < c.length ? c[d] : 0
2533
+ if (m !== 0) {
2534
+ const [x, g] = u[(Math.abs(m) - 1) >> 1]
2535
+ ;[a, h, p] = jacobianAddMixed(a, h, p, x, m > 0 ? g : SECP256K1_P - g)
2536
+ }
2537
+ const w = d < s.length ? s[d] : 0
2538
+ if (w !== 0) {
2539
+ const [x, g] = f[(Math.abs(w) - 1) >> 1]
2540
+ ;[a, h, p] = jacobianAddMixed(a, h, p, x, w > 0 ? g : SECP256K1_P - g)
2541
+ }
2542
+ }
2543
+ return jacobianToAffine(a, h, p)
2544
+ }
2545
+ function doubleAndAdd(n, t, e) {
2546
+ const [r, i, o, c] = glvDecompose(e),
2547
+ s = i ? SECP256K1_P - t : t,
2548
+ u = (SECP256K1_BETA * n) % SECP256K1_P,
2549
+ f = c ? SECP256K1_P - t : t
2550
+ return shamirWNAF(r, n, s, o, u, f)
2438
2551
  }
2439
- function signHash(n, e, t) {
2440
- if (e <= 0n || e >= SECP256K1_N) throw new Error('Invalid private key')
2441
- if ((t || (t = mod(uint256ToNumber(keccak256(concatBytes(keccak256(numberToUint256(e, 'BE')), numberToUint256(n, 'BE'))), 'BE'), SECP256K1_N)), t <= 0n || t >= SECP256K1_N)) throw new Error('Invalid nonce')
2552
+ function signMessage(n, t, e) {
2553
+ return signHash(uint256ToNumber(keccak256(n), 'BE'), t, e)
2554
+ }
2555
+ function signHash(n, t, e) {
2556
+ if (t <= 0n || t >= SECP256K1_N) throw new Error('Invalid private key')
2557
+ if ((e || (e = mod(uint256ToNumber(keccak256(concatBytes(keccak256(numberToUint256(t, 'BE')), numberToUint256(n, 'BE'))), 'BE'), SECP256K1_N)), e <= 0n || e >= SECP256K1_N)) throw new Error('Invalid nonce')
2442
2558
  const r = mod(n, SECP256K1_N),
2443
- i = doubleAndAdd(SECP256K1_X, SECP256K1_Y, t, SECP256K1_P),
2559
+ i = doubleAndAdd(SECP256K1_X, SECP256K1_Y, e),
2444
2560
  o = mod(i[0], SECP256K1_N)
2445
- let c = mod((r + mod(o, SECP256K1_N) * e) * modInverse(t, SECP256K1_N), SECP256K1_N)
2561
+ let c = mod((r + mod(o, SECP256K1_N) * t) * modInverse(e, SECP256K1_N), SECP256K1_N)
2446
2562
  if (o === 0n || c === 0n) throw new Error('Invalid r or s value')
2447
- let u = i[1] % 2n === 0n ? 27n : 28n
2448
- return c > SECP256K1_N / 2n && ((c = SECP256K1_N - c), (u = u === 27n ? 28n : 27n)), [o, c, u]
2563
+ let s = i[1] % 2n === 0n ? 27n : 28n
2564
+ return c > SECP256K1_N / 2n && ((c = SECP256K1_N - c), (s = s === 27n ? 28n : 27n)), [o, c, s]
2449
2565
  }
2450
- function recoverPublicKey(n, e, t, r) {
2451
- const i = modSqrt(mod(e ** 3n + 7n, SECP256K1_P), SECP256K1_P)
2566
+ function recoverPublicKey(n, t, e, r) {
2567
+ const i = modSqrt(mod(t ** 3n + 7n, SECP256K1_P), SECP256K1_P)
2452
2568
  if (!i) throw new Error('Invalid r: does not correspond to a valid curve point')
2453
2569
  const o = r === 27n ? 0n : 1n,
2454
2570
  c = i % 2n === o ? i : SECP256K1_P - i,
2455
- u = mod(uint256ToNumber(keccak256(n), 'BE'), SECP256K1_N),
2456
- s = doubleAndAdd(e, c, t, SECP256K1_P),
2457
- f = doubleAndAdd(SECP256K1_X, SECP256K1_Y, u, SECP256K1_P),
2458
- l = ellipticAdd(s[0], s[1], f[0], mod(-f[1], SECP256K1_P), SECP256K1_P)
2459
- return doubleAndAdd(l[0], l[1], modInverse(e, SECP256K1_N), SECP256K1_P)
2571
+ s = mod(uint256ToNumber(keccak256(n), 'BE'), SECP256K1_N),
2572
+ u = doubleAndAdd(t, c, e),
2573
+ f = doubleAndAdd(SECP256K1_X, SECP256K1_Y, s),
2574
+ l = ellipticAdd(u[0], u[1], f[0], mod(-f[1], SECP256K1_P), SECP256K1_P)
2575
+ return doubleAndAdd(l[0], l[1], modInverse(t, SECP256K1_N))
2460
2576
  }
2461
- function verifySignature(n, e, t, r) {
2577
+ function verifySignature(n, t, e, r) {
2462
2578
  const i = mod(uint256ToNumber(keccak256(n), 'BE'), SECP256K1_N),
2463
2579
  o = modInverse(r, SECP256K1_N),
2464
2580
  c = mod(i * o, SECP256K1_N),
2465
- u = mod(t * o, SECP256K1_N),
2466
- s = doubleAndAdd(SECP256K1_X, SECP256K1_Y, c, SECP256K1_P),
2467
- f = doubleAndAdd(e[0], e[1], u, SECP256K1_P),
2468
- l = ellipticAdd(s[0], s[1], f[0], f[1], SECP256K1_P)
2469
- return t === mod(l[0], SECP256K1_N)
2581
+ s = mod(e * o, SECP256K1_N),
2582
+ u = doubleAndAdd(SECP256K1_X, SECP256K1_Y, c),
2583
+ f = doubleAndAdd(t[0], t[1], s),
2584
+ l = ellipticAdd(u[0], u[1], f[0], f[1], SECP256K1_P)
2585
+ return e === mod(l[0], SECP256K1_N)
2470
2586
  }
2471
2587
  class Uint8ArrayReader {
2472
- constructor(e) {
2473
- ;(this.cursor = 0), (this.buffer = e)
2588
+ constructor(t) {
2589
+ ;(this.cursor = 0), (this.buffer = t)
2474
2590
  }
2475
- read(e) {
2476
- const t = this.buffer.subarray(this.cursor, this.cursor + e)
2477
- return (this.cursor += e), t
2591
+ read(t) {
2592
+ const e = this.buffer.subarray(this.cursor, this.cursor + t)
2593
+ return (this.cursor += t), e
2478
2594
  }
2479
2595
  max() {
2480
2596
  return this.buffer.length - this.cursor
@@ -2482,12 +2598,12 @@ class Uint8ArrayReader {
2482
2598
  }
2483
2599
  exports.Uint8ArrayReader = Uint8ArrayReader
2484
2600
  class Uint8ArrayWriter {
2485
- constructor(e) {
2486
- ;(this.buffer = e), (this.cursor = 0)
2601
+ constructor(t) {
2602
+ ;(this.buffer = t), (this.cursor = 0)
2487
2603
  }
2488
- write(e) {
2489
- const t = Math.min(this.max(), e.max())
2490
- return this.buffer.set(e.read(t), this.cursor), (this.cursor += t), t
2604
+ write(t) {
2605
+ const e = Math.min(this.max(), t.max())
2606
+ return this.buffer.set(t.read(e), this.cursor), (this.cursor += e), e
2491
2607
  }
2492
2608
  max() {
2493
2609
  return this.buffer.length - this.cursor
@@ -2495,91 +2611,104 @@ class Uint8ArrayWriter {
2495
2611
  }
2496
2612
  exports.Uint8ArrayWriter = Uint8ArrayWriter
2497
2613
  class Chunk {
2498
- constructor(e = 0n) {
2499
- ;(this.span = e), (this.writer = new Uint8ArrayWriter(new Uint8Array(4096)))
2614
+ constructor(t = 0n) {
2615
+ ;(this.span = t), (this.writer = new Uint8ArrayWriter(new Uint8Array(4096)))
2500
2616
  }
2501
2617
  build() {
2502
2618
  return concatBytes(numberToUint64(this.span, 'LE'), this.writer.buffer)
2503
2619
  }
2504
2620
  hash() {
2505
- const e = new Uint8Array(40)
2506
- return e.set(numberToUint64(this.span, 'LE')), e.set(bmtRoot(this.writer.buffer), 8), Chunk.hashFunction(e)
2621
+ const t = new Uint8Array(40)
2622
+ return t.set(numberToUint64(this.span, 'LE')), t.set(bmtRoot(this.writer.buffer), 8), Chunk.hashFunction(t)
2507
2623
  }
2508
- encryptedHash(e) {
2509
- e || ((e = new Uint8Array(32)), crypto.getRandomValues(e))
2510
- const t = encryptSpan(e, numberToUint64(this.span, 'LE')),
2624
+ encryptedHash(t) {
2625
+ t || ((t = new Uint8Array(32)), crypto.getRandomValues(t))
2626
+ const e = encryptSpan(t, numberToUint64(this.span, 'LE')),
2511
2627
  r = new Uint8Array(40)
2512
- return r.set(t), r.set(bmtRoot(encryptData(e, this.writer.buffer)), 8), { address: Chunk.hashFunction(r), key: e }
2628
+ return r.set(e), r.set(bmtRoot(encryptData(t, this.writer.buffer)), 8), { address: Chunk.hashFunction(r), key: t }
2513
2629
  }
2514
- static encryptSpan(e, t) {
2515
- return encryptSpan(e, t)
2630
+ static encryptSpan(t, e) {
2631
+ return encryptSpan(t, e)
2516
2632
  }
2517
- static encryptData(e, t) {
2518
- return encryptData(e, t)
2633
+ static encryptData(t, e) {
2634
+ return encryptData(t, e)
2519
2635
  }
2520
- static decrypt(e, t) {
2521
- return decryptChunk(e, t)
2636
+ static decrypt(t, e) {
2637
+ return decryptChunk(t, e)
2522
2638
  }
2523
2639
  }
2524
2640
  ;(exports.Chunk = Chunk), (Chunk.hashFunction = keccak256)
2525
2641
  class ChunkSplitter {
2526
- constructor(e, t = !1) {
2527
- ;(this.counters = [1]), (this.encrypted = t), (this.refSize = t ? 64 : 32), (this.chunks = [new Chunk()]), (this.onChunk = e)
2642
+ constructor(t, e, r = !1) {
2643
+ ;(this.counters = [1]), (this.pending = [[]]), (this.encrypted = r), (this.refSize = r ? 64 : 32), (this.maxShards = e ?? 4096 / this.refSize), (this.chunks = [new Chunk()]), (this.onBatch = t)
2528
2644
  }
2529
- static async root(e) {
2530
- const t = new _a(_a.NOOP)
2531
- return await t.append(e), t.finalize()
2645
+ static async root(t) {
2646
+ const e = new _a(_a.NOOP)
2647
+ return await e.append(t), e.finalize()
2532
2648
  }
2533
- static async encryptedRoot(e) {
2534
- const t = new _a(_a.NOOP, !0)
2535
- return await t.append(e), (await t.finalize()).encryptedHash()
2649
+ static async encryptedRoot(t) {
2650
+ const e = new _a(_a.NOOP, void 0, !0)
2651
+ return await e.append(t), (await e.finalize()).encryptedHash()
2536
2652
  }
2537
- async append(e, t = 0, r = 0n) {
2538
- const i = new Uint8ArrayReader(e)
2653
+ async append(t, e = 0, r = 0n) {
2654
+ const i = new Uint8ArrayReader(t)
2539
2655
  for (; i.max() > 0; ) {
2540
- this.chunks[t].writer.max() === 0 && (await this.elevate(t))
2541
- const o = this.chunks[t].writer.write(i)
2542
- r ? (this.chunks[t].span += r) : (this.chunks[0].span += BigInt(o))
2656
+ this.chunks[e].writer.max() === 0 && (await this.elevate(e))
2657
+ const o = this.chunks[e].writer.write(i)
2658
+ r ? (this.chunks[e].span += r) : (this.chunks[0].span += BigInt(o))
2543
2659
  }
2544
2660
  }
2545
- async elevate(e) {
2546
- if (((this.counters[e] = ++this.counters[e] % (4096 / this.refSize)), this.chunks[e + 1] || (this.chunks.push(new Chunk()), this.counters.push(1)), this.encrypted)) {
2547
- const { address: t, key: r } = this.chunks[e].encryptedHash(),
2661
+ async elevate(t) {
2662
+ if (((this.counters[t] = ++this.counters[t] % (4096 / this.refSize)), this.pending[t] || (this.pending[t] = []), this.encrypted)) {
2663
+ const { address: e, key: r } = this.chunks[t].encryptedHash(),
2548
2664
  i = new Uint8Array(64)
2549
- i.set(t), i.set(r, 32), await this.append(i, e + 1, this.chunks[e].span), await this.onChunk(this.chunks[e], r)
2550
- } else await this.append(this.chunks[e].hash(), e + 1, this.chunks[e].span), await this.onChunk(this.chunks[e])
2551
- this.chunks[e] = new Chunk()
2665
+ i.set(e), i.set(r, 32), this.pending[t].push({ entry: { chunk: this.chunks[t], key: r }, ref: i, span: this.chunks[t].span })
2666
+ } else this.pending[t].push({ entry: { chunk: this.chunks[t] }, ref: this.chunks[t].hash(), span: this.chunks[t].span })
2667
+ ;(this.chunks[t] = new Chunk()), this.pending[t].length >= this.maxShards && (await this.flushBatch(t))
2668
+ }
2669
+ async flushBatch(t) {
2670
+ this.chunks[t + 1] || (this.chunks.push(new Chunk()), this.counters.push(1), this.pending.push([]))
2671
+ const e = this.pending[t]
2672
+ this.pending[t] = []
2673
+ const r = await this.onBatch(e.map(i => i.entry))
2674
+ for (const { ref: i, span: o } of e) await this.append(i, t + 1, o)
2675
+ for (const { chunk: i, key: o } of r)
2676
+ if (this.encrypted) {
2677
+ const { address: c, key: s } = i.encryptedHash(o),
2678
+ u = new Uint8Array(64)
2679
+ u.set(c), u.set(s, 32), await this.append(u, t + 1, i.span)
2680
+ } else await this.append(i.hash(), t + 1, i.span)
2552
2681
  }
2553
- async finalize(e = 0) {
2554
- if (!this.chunks[e + 1]) {
2682
+ async finalize(t = 0) {
2683
+ if ((this.pending[t]?.length && (await this.flushBatch(t)), !this.chunks[t + 1])) {
2555
2684
  if (this.encrypted) {
2556
- const { key: t } = this.chunks[e].encryptedHash()
2557
- await this.onChunk(this.chunks[e], t)
2558
- } else await this.onChunk(this.chunks[e])
2559
- return this.chunks[e]
2685
+ const { key: e } = this.chunks[t].encryptedHash()
2686
+ await this.onBatch([{ chunk: this.chunks[t], key: e }])
2687
+ } else await this.onBatch([{ chunk: this.chunks[t] }])
2688
+ return this.chunks[t]
2560
2689
  }
2561
- return this.counters[e] === 1 ? (await this.elevate(e + 1), (this.chunks[e + 1] = this.chunks[e]), this.finalize(e + 1)) : (await this.elevate(e), this.finalize(e + 1))
2690
+ return this.counters[t] === 1 ? (await this.elevate(t + 1), await this.flushBatch(t + 1), (this.chunks[t + 1] = this.chunks[t]), this.finalize(t + 1)) : (await this.elevate(t), await this.flushBatch(t), this.finalize(t + 1))
2562
2691
  }
2563
2692
  }
2564
- ;(exports.ChunkSplitter = ChunkSplitter), (_a = ChunkSplitter), (ChunkSplitter.NOOP = async (n, e) => {})
2693
+ ;(exports.ChunkSplitter = ChunkSplitter), (_a = ChunkSplitter), (ChunkSplitter.NOOP = async n => [])
2565
2694
  function isAllZero(n) {
2566
- for (let e = 0; e < n.length; e++) if (n[e] !== 0) return !1
2695
+ for (let t = 0; t < n.length; t++) if (n[t] !== 0) return !1
2567
2696
  return !0
2568
2697
  }
2569
2698
  class ChunkJoiner {
2570
- constructor(e, t, r = !1) {
2571
- ;(this.fetch = e), (this.onData = t), (this.encrypted = r), (this.refSize = r ? 64 : 32)
2699
+ constructor(t, e, r = !1) {
2700
+ ;(this.fetch = t), (this.onData = e), (this.encrypted = r), (this.refSize = r ? 64 : 32)
2572
2701
  }
2573
- static async collect(e, t) {
2702
+ static async collect(t, e) {
2574
2703
  const r = []
2575
2704
  return (
2576
- await new ChunkJoiner(t, async i => {
2705
+ await new ChunkJoiner(e, async i => {
2577
2706
  r.push(i)
2578
- }).join(e),
2707
+ }).join(t),
2579
2708
  concatBytes(...r)
2580
2709
  )
2581
2710
  }
2582
- static async collectEncrypted(e, t, r) {
2711
+ static async collectEncrypted(t, e, r) {
2583
2712
  const i = []
2584
2713
  return (
2585
2714
  await new ChunkJoiner(
@@ -2588,77 +2717,77 @@ class ChunkJoiner {
2588
2717
  i.push(o)
2589
2718
  },
2590
2719
  !0
2591
- ).join(e, t),
2720
+ ).join(t, e),
2592
2721
  concatBytes(...i)
2593
2722
  )
2594
2723
  }
2595
- async join(e, t) {
2596
- const r = await this.fetch(e)
2724
+ async join(t, e) {
2725
+ const r = await this.fetch(t)
2597
2726
  let i, o
2598
- if ((this.encrypted && t ? ({ span: i, data: o } = decryptChunk(r, t)) : ((i = uint64ToNumber(r.subarray(0, 8), 'LE')), (o = r.subarray(8, 4104))), i <= 4096n)) await this.onData(o.subarray(0, Number(i)))
2727
+ if ((this.encrypted && e ? ({ span: i, data: o } = decryptChunk(r, e)) : ((i = uint64ToNumber(r.subarray(0, 8), 'LE')), (o = r.subarray(8, 4104))), i <= 4096n)) await this.onData(o.subarray(0, Number(i)))
2599
2728
  else
2600
2729
  for (let c = 0; c < 4096 / this.refSize; c++) {
2601
- const u = o.subarray(c * this.refSize, (c + 1) * this.refSize),
2602
- s = u.subarray(0, 32)
2603
- if (isAllZero(s)) break
2604
- await this.join(s, this.encrypted ? u.subarray(32, 64) : void 0)
2730
+ const s = o.subarray(c * this.refSize, (c + 1) * this.refSize),
2731
+ u = s.subarray(0, 32)
2732
+ if (isAllZero(u)) break
2733
+ await this.join(u, this.encrypted ? s.subarray(32, 64) : void 0)
2605
2734
  }
2606
2735
  }
2607
2736
  }
2608
2737
  exports.ChunkJoiner = ChunkJoiner
2609
2738
  class FixedPointNumber {
2610
- constructor(e, t) {
2611
- if (t < 0) throw Error('Scale must be non-negative')
2612
- ;(this.value = BigInt(e)), (this.scale = t)
2613
- }
2614
- static cast(e) {
2615
- if (!e) throw Error('Cannot cast falsy value to FixedPointNumber')
2616
- if (e instanceof FixedPointNumber) return e
2617
- const t = asBigint(e.value),
2618
- r = asNumber(e.scale)
2619
- return new FixedPointNumber(t, r)
2620
- }
2621
- static fromDecimalString(e, t) {
2622
- ;/e\-\d+$/i.test(e) && (e = parseFloat(e).toFixed(t))
2623
- let [r, i] = e.split('.')
2624
- return (i = (i || '').padEnd(t, '0').slice(0, t)), new FixedPointNumber(BigInt(r + i), t)
2625
- }
2626
- static fromFloat(e, t) {
2627
- return FixedPointNumber.fromDecimalString(e.toString(), t)
2628
- }
2629
- add(e) {
2630
- return this.assertSameScale(e), new FixedPointNumber(this.value + e.value, this.scale)
2631
- }
2632
- subtract(e) {
2633
- return this.assertSameScale(e), new FixedPointNumber(this.value - e.value, this.scale)
2634
- }
2635
- multiply(e) {
2636
- return new FixedPointNumber(this.value * e, this.scale)
2637
- }
2638
- divmod(e) {
2639
- if (e === 0n) throw new Error('Division by zero is not allowed')
2640
- const t = this.value / e,
2641
- r = this.value % e
2642
- return [new FixedPointNumber(t, this.scale), new FixedPointNumber(r, this.scale)]
2643
- }
2644
- exchange(e, t, r) {
2645
- if (e === '*') {
2646
- const o = (this.value * t.value) / 10n ** BigInt(this.scale)
2739
+ constructor(t, e) {
2740
+ if (e < 0) throw Error('Scale must be non-negative')
2741
+ ;(this.value = BigInt(t)), (this.scale = e)
2742
+ }
2743
+ static cast(t) {
2744
+ if (!t) throw Error('Cannot cast falsy value to FixedPointNumber')
2745
+ if (t instanceof FixedPointNumber) return t
2746
+ const e = asBigint(t.value),
2747
+ r = asNumber(t.scale)
2748
+ return new FixedPointNumber(e, r)
2749
+ }
2750
+ static fromDecimalString(t, e) {
2751
+ ;/e\-\d+$/i.test(t) && (t = parseFloat(t).toFixed(e))
2752
+ let [r, i] = t.split('.')
2753
+ return (i = (i || '').padEnd(e, '0').slice(0, e)), new FixedPointNumber(BigInt(r + i), e)
2754
+ }
2755
+ static fromFloat(t, e) {
2756
+ return FixedPointNumber.fromDecimalString(t.toString(), e)
2757
+ }
2758
+ add(t) {
2759
+ return this.assertSameScale(t), new FixedPointNumber(this.value + t.value, this.scale)
2760
+ }
2761
+ subtract(t) {
2762
+ return this.assertSameScale(t), new FixedPointNumber(this.value - t.value, this.scale)
2763
+ }
2764
+ multiply(t) {
2765
+ return new FixedPointNumber(this.value * t, this.scale)
2766
+ }
2767
+ divmod(t) {
2768
+ if (t === 0n) throw new Error('Division by zero is not allowed')
2769
+ const e = this.value / t,
2770
+ r = this.value % t
2771
+ return [new FixedPointNumber(e, this.scale), new FixedPointNumber(r, this.scale)]
2772
+ }
2773
+ exchange(t, e, r) {
2774
+ if (t === '*') {
2775
+ const o = (this.value * e.value) / 10n ** BigInt(this.scale)
2647
2776
  return new FixedPointNumber(o, r)
2648
2777
  }
2649
- this.assertSameScale(t)
2650
- const i = (this.value * 10n ** BigInt(r)) / t.value
2778
+ this.assertSameScale(e)
2779
+ const i = (this.value * 10n ** BigInt(r)) / e.value
2651
2780
  return new FixedPointNumber(i, r)
2652
2781
  }
2653
- compare(e) {
2654
- return this.assertSameScale(e), this.value > e.value ? 1 : this.value < e.value ? -1 : 0
2782
+ compare(t) {
2783
+ return this.assertSameScale(t), this.value > t.value ? 1 : this.value < t.value ? -1 : 0
2655
2784
  }
2656
2785
  toDecimalString() {
2657
2786
  if (this.scale === 0) return this.value.toString()
2658
- const e = this.value.toString(),
2659
- t = e.slice(0, -this.scale) || '0',
2660
- r = e.slice(-this.scale).padStart(this.scale, '0')
2661
- return `${t}.${r}`
2787
+ const t = this.value.toString(),
2788
+ e = t.slice(0, -this.scale) || '0',
2789
+ r = t.slice(-this.scale).padStart(this.scale, '0')
2790
+ return `${e}.${r}`
2662
2791
  }
2663
2792
  toString() {
2664
2793
  return this.value.toString()
@@ -2669,173 +2798,173 @@ class FixedPointNumber {
2669
2798
  toFloat() {
2670
2799
  return parseFloat(this.toDecimalString())
2671
2800
  }
2672
- assertSameScale(e) {
2673
- if (this.scale !== e.scale) throw new Error(`Scale mismatch: expected ${this.scale}, but got ${e.scale}`)
2801
+ assertSameScale(t) {
2802
+ if (this.scale !== t.scale) throw new Error(`Scale mismatch: expected ${this.scale}, but got ${t.scale}`)
2674
2803
  }
2675
2804
  }
2676
2805
  exports.FixedPointNumber = FixedPointNumber
2677
2806
  function tickPlaybook(n) {
2678
2807
  if (n.length === 0) return null
2679
- const e = n[0]
2680
- return e.ttlMax ? --e.ttl <= 0 && n.shift() : (e.ttlMax = e.ttl), { progress: (e.ttlMax - e.ttl) / e.ttlMax, data: e.data }
2808
+ const t = n[0]
2809
+ return t.ttlMax ? --t.ttl <= 0 && n.shift() : (t.ttlMax = t.ttl), { progress: (t.ttlMax - t.ttl) / t.ttlMax, data: t.data }
2681
2810
  }
2682
- function getArgument(n, e, t, r) {
2683
- const i = n.findIndex(u => u === `--${e}` || u.startsWith(`--${e}=`)),
2811
+ function getArgument(n, t, e, r) {
2812
+ const i = n.findIndex(s => s === `--${t}` || s.startsWith(`--${t}=`)),
2684
2813
  o = n[i]
2685
- if (!o) return (t || {})[r || e || ''] || null
2814
+ if (!o) return (e || {})[r || t || ''] || null
2686
2815
  if (o.includes('=')) return o.split('=')[1]
2687
2816
  const c = n[i + 1]
2688
- return c && !c.startsWith('-') ? c : (t || {})[r || e || ''] || null
2817
+ return c && !c.startsWith('-') ? c : (e || {})[r || t || ''] || null
2689
2818
  }
2690
- function getNumberArgument(n, e, t, r) {
2691
- const i = getArgument(n, e, t, r)
2819
+ function getNumberArgument(n, t, e, r) {
2820
+ const i = getArgument(n, t, e, r)
2692
2821
  if (!i) return null
2693
2822
  try {
2694
2823
  return makeNumber(i)
2695
2824
  } catch {
2696
- throw new Error(`Invalid number argument ${e}: ${i}`)
2825
+ throw new Error(`Invalid number argument ${t}: ${i}`)
2697
2826
  }
2698
2827
  }
2699
- function getBooleanArgument(n, e, t, r) {
2700
- const i = n.some(s => s.endsWith('-' + e)),
2701
- o = getArgument(n, e, t, r)
2828
+ function getBooleanArgument(n, t, e, r) {
2829
+ const i = n.some(u => u.endsWith('-' + t)),
2830
+ o = getArgument(n, t, e, r)
2702
2831
  if (!o && i) return !0
2703
2832
  if (!o && !i) return null
2704
2833
  const c = ['true', '1', 'yes', 'y', 'on'],
2705
- u = ['false', '0', 'no', 'n', 'off']
2834
+ s = ['false', '0', 'no', 'n', 'off']
2706
2835
  if (c.includes(o.toLowerCase())) return !0
2707
- if (u.includes(o.toLowerCase())) return !1
2708
- throw Error(`Invalid boolean argument ${e}: ${o}`)
2836
+ if (s.includes(o.toLowerCase())) return !1
2837
+ throw Error(`Invalid boolean argument ${t}: ${o}`)
2709
2838
  }
2710
- function requireStringArgument(n, e, t, r) {
2711
- const i = getArgument(n, e, t, r)
2712
- if (!i) throw new Error(`Missing argument ${e}`)
2839
+ function requireStringArgument(n, t, e, r) {
2840
+ const i = getArgument(n, t, e, r)
2841
+ if (!i) throw new Error(`Missing argument ${t}`)
2713
2842
  return i
2714
2843
  }
2715
- function requireNumberArgument(n, e, t, r) {
2716
- const i = requireStringArgument(n, e, t, r)
2844
+ function requireNumberArgument(n, t, e, r) {
2845
+ const i = requireStringArgument(n, t, e, r)
2717
2846
  try {
2718
2847
  return makeNumber(i)
2719
2848
  } catch {
2720
- throw new Error(`Invalid argument ${e}: ${i}`)
2849
+ throw new Error(`Invalid argument ${t}: ${i}`)
2721
2850
  }
2722
2851
  }
2723
- function bringToFrontInPlace(n, e) {
2724
- const t = n[e]
2725
- n.splice(e, 1), n.unshift(t)
2852
+ function bringToFrontInPlace(n, t) {
2853
+ const e = n[t]
2854
+ n.splice(t, 1), n.unshift(e)
2726
2855
  }
2727
- function bringToFront(n, e) {
2728
- const t = [...n]
2729
- return bringToFrontInPlace(t, e), t
2856
+ function bringToFront(n, t) {
2857
+ const e = [...n]
2858
+ return bringToFrontInPlace(e, t), e
2730
2859
  }
2731
- function addPoint(n, e) {
2732
- return { x: n.x + e.x, y: n.y + e.y }
2860
+ function addPoint(n, t) {
2861
+ return { x: n.x + t.x, y: n.y + t.y }
2733
2862
  }
2734
- function subtractPoint(n, e) {
2735
- return { x: n.x - e.x, y: n.y - e.y }
2863
+ function subtractPoint(n, t) {
2864
+ return { x: n.x - t.x, y: n.y - t.y }
2736
2865
  }
2737
- function multiplyPoint(n, e) {
2738
- return { x: n.x * e, y: n.y * e }
2866
+ function multiplyPoint(n, t) {
2867
+ return { x: n.x * t, y: n.y * t }
2739
2868
  }
2740
2869
  function normalizePoint(n) {
2741
- const e = Math.sqrt(n.x * n.x + n.y * n.y)
2742
- return { x: n.x / e, y: n.y / e }
2870
+ const t = Math.sqrt(n.x * n.x + n.y * n.y)
2871
+ return { x: n.x / t, y: n.y / t }
2743
2872
  }
2744
- function pushPoint(n, e, t) {
2745
- return { x: n.x + Math.cos(e) * t, y: n.y + Math.sin(e) * t }
2873
+ function pushPoint(n, t, e) {
2874
+ return { x: n.x + Math.cos(t) * e, y: n.y + Math.sin(t) * e }
2746
2875
  }
2747
- function getDistanceBetweenPoints(n, e) {
2748
- return Math.sqrt((n.x - e.x) ** 2 + (n.y - e.y) ** 2)
2876
+ function getDistanceBetweenPoints(n, t) {
2877
+ return Math.sqrt((n.x - t.x) ** 2 + (n.y - t.y) ** 2)
2749
2878
  }
2750
- function filterCoordinates(n, e, t = 'row-first') {
2879
+ function filterCoordinates(n, t, e = 'row-first') {
2751
2880
  const r = []
2752
- if (t === 'column-first') for (let i = 0; i < n.length; i++) for (let o = 0; o < n[0].length; o++) e(i, o) && r.push({ x: i, y: o })
2753
- else for (let i = 0; i < n[0].length; i++) for (let o = 0; o < n.length; o++) e(o, i) && r.push({ x: o, y: i })
2881
+ if (e === 'column-first') for (let i = 0; i < n.length; i++) for (let o = 0; o < n[0].length; o++) t(i, o) && r.push({ x: i, y: o })
2882
+ else for (let i = 0; i < n[0].length; i++) for (let o = 0; o < n.length; o++) t(o, i) && r.push({ x: o, y: i })
2754
2883
  return r
2755
2884
  }
2756
- function isHorizontalLine(n, e, t) {
2757
- return n[e + 1]?.[t] && n[e - 1]?.[t] && !n[e][t - 1] && !n[e][t + 1]
2885
+ function isHorizontalLine(n, t, e) {
2886
+ return n[t + 1]?.[e] && n[t - 1]?.[e] && !n[t][e - 1] && !n[t][e + 1]
2758
2887
  }
2759
- function isVerticalLine(n, e, t) {
2760
- return n[e][t + 1] && n[e][t - 1] && !n[e - 1]?.[t] && !n[e + 1]?.[t]
2888
+ function isVerticalLine(n, t, e) {
2889
+ return n[t][e + 1] && n[t][e - 1] && !n[t - 1]?.[e] && !n[t + 1]?.[e]
2761
2890
  }
2762
- function isLeftmost(n, e, t) {
2763
- return !n[e - 1]?.[t]
2891
+ function isLeftmost(n, t, e) {
2892
+ return !n[t - 1]?.[e]
2764
2893
  }
2765
- function isRightmost(n, e, t) {
2766
- return !n[e + 1]?.[t]
2894
+ function isRightmost(n, t, e) {
2895
+ return !n[t + 1]?.[e]
2767
2896
  }
2768
- function isTopmost(n, e, t) {
2769
- return !n[e][t - 1]
2897
+ function isTopmost(n, t, e) {
2898
+ return !n[t][e - 1]
2770
2899
  }
2771
- function isBottommost(n, e, t) {
2772
- return !n[e][t + 1]
2900
+ function isBottommost(n, t, e) {
2901
+ return !n[t][e + 1]
2773
2902
  }
2774
- function getCorners(n, e, t) {
2903
+ function getCorners(n, t, e) {
2775
2904
  const r = []
2776
- return n[e][t] ? (isHorizontalLine(n, e, t) || isVerticalLine(n, e, t) ? [] : (!n[e - 1]?.[t - 1] && isLeftmost(n, e, t) && isTopmost(n, e, t) && r.push({ x: e, y: t }), !n[e + 1]?.[t - 1] && isRightmost(n, e, t) && isTopmost(n, e, t) && r.push({ x: e + 1, y: t }), !n[e - 1]?.[t + 1] && isLeftmost(n, e, t) && isBottommost(n, e, t) && r.push({ x: e, y: t + 1 }), !n[e + 1]?.[t + 1] && isRightmost(n, e, t) && isBottommost(n, e, t) && r.push({ x: e + 1, y: t + 1 }), r)) : (n[e - 1]?.[t] && n[e][t - 1] && r.push({ x: e, y: t }), n[e + 1]?.[t] && n[e][t - 1] && r.push({ x: e + 1, y: t }), n[e - 1]?.[t] && n[e][t + 1] && r.push({ x: e, y: t + 1 }), n[e + 1]?.[t] && n[e][t + 1] && r.push({ x: e + 1, y: t + 1 }), r)
2905
+ return n[t][e] ? (isHorizontalLine(n, t, e) || isVerticalLine(n, t, e) ? [] : (!n[t - 1]?.[e - 1] && isLeftmost(n, t, e) && isTopmost(n, t, e) && r.push({ x: t, y: e }), !n[t + 1]?.[e - 1] && isRightmost(n, t, e) && isTopmost(n, t, e) && r.push({ x: t + 1, y: e }), !n[t - 1]?.[e + 1] && isLeftmost(n, t, e) && isBottommost(n, t, e) && r.push({ x: t, y: e + 1 }), !n[t + 1]?.[e + 1] && isRightmost(n, t, e) && isBottommost(n, t, e) && r.push({ x: t + 1, y: e + 1 }), r)) : (n[t - 1]?.[e] && n[t][e - 1] && r.push({ x: t, y: e }), n[t + 1]?.[e] && n[t][e - 1] && r.push({ x: t + 1, y: e }), n[t - 1]?.[e] && n[t][e + 1] && r.push({ x: t, y: e + 1 }), n[t + 1]?.[e] && n[t][e + 1] && r.push({ x: t + 1, y: e + 1 }), r)
2777
2906
  }
2778
- function findCorners(n, e, t, r) {
2907
+ function findCorners(n, t, e, r) {
2779
2908
  const i = [
2780
2909
  { x: 0, y: 0 },
2781
- { x: t, y: 0 },
2910
+ { x: e, y: 0 },
2782
2911
  { x: 0, y: r },
2783
- { x: t, y: r }
2912
+ { x: e, y: r }
2784
2913
  ]
2785
2914
  for (let o = 0; o < n.length; o++)
2786
2915
  for (let c = 0; c < n[0].length; c++) {
2787
- const u = getCorners(n, o, c)
2788
- for (const s of u) i.some(f => f.x === s.x && f.y === s.y) || i.push(s)
2916
+ const s = getCorners(n, o, c)
2917
+ for (const u of s) i.some(f => f.x === u.x && f.y === u.y) || i.push(u)
2789
2918
  }
2790
- return i.map(o => ({ x: o.x * e, y: o.y * e }))
2791
- }
2792
- function findLines(n, e) {
2793
- const t = filterCoordinates(n, (s, f) => n[s][f] === 0 && n[s][f + 1] !== 0, 'row-first').map(s => ({ ...s, dx: 1, dy: 0 })),
2794
- r = filterCoordinates(n, (s, f) => n[s][f] === 0 && n[s][f - 1] !== 0, 'row-first').map(s => ({ ...s, dx: 1, dy: 0 })),
2795
- i = filterCoordinates(n, (s, f) => n[s][f] === 0 && n[s - 1]?.[f] !== 0, 'column-first').map(s => ({ ...s, dx: 0, dy: 1 })),
2796
- o = filterCoordinates(n, (s, f) => n[s][f] === 0 && n[s + 1]?.[f] !== 0, 'column-first').map(s => ({ ...s, dx: 0, dy: 1 }))
2797
- t.forEach(s => s.y++), o.forEach(s => s.x++)
2798
- const c = group([...i, ...o], (s, f) => s.x === f.x && s.y - 1 === f.y),
2799
- u = group([...r, ...t], (s, f) => s.y === f.y && s.x - 1 === f.x)
2800
- return [...c, ...u].map(s => ({ start: s[0], end: last(s) })).map(s => ({ start: multiplyPoint(s.start, e), end: multiplyPoint(addPoint(s.end, { x: s.start.dx, y: s.start.dy }), e) }))
2801
- }
2802
- function getAngleInRadians(n, e) {
2803
- return Math.atan2(e.y - n.y, e.x - n.x)
2804
- }
2805
- function getSortedRayAngles(n, e) {
2806
- return e.map(t => getAngleInRadians(n, t)).sort((t, r) => t - r)
2807
- }
2808
- function getLineIntersectionPoint(n, e, t, r) {
2809
- const i = (r.y - t.y) * (e.x - n.x) - (r.x - t.x) * (e.y - n.y)
2919
+ return i.map(o => ({ x: o.x * t, y: o.y * t }))
2920
+ }
2921
+ function findLines(n, t) {
2922
+ const e = filterCoordinates(n, (u, f) => n[u][f] === 0 && n[u][f + 1] !== 0, 'row-first').map(u => ({ ...u, dx: 1, dy: 0 })),
2923
+ r = filterCoordinates(n, (u, f) => n[u][f] === 0 && n[u][f - 1] !== 0, 'row-first').map(u => ({ ...u, dx: 1, dy: 0 })),
2924
+ i = filterCoordinates(n, (u, f) => n[u][f] === 0 && n[u - 1]?.[f] !== 0, 'column-first').map(u => ({ ...u, dx: 0, dy: 1 })),
2925
+ o = filterCoordinates(n, (u, f) => n[u][f] === 0 && n[u + 1]?.[f] !== 0, 'column-first').map(u => ({ ...u, dx: 0, dy: 1 }))
2926
+ e.forEach(u => u.y++), o.forEach(u => u.x++)
2927
+ const c = group([...i, ...o], (u, f) => u.x === f.x && u.y - 1 === f.y),
2928
+ s = group([...r, ...e], (u, f) => u.y === f.y && u.x - 1 === f.x)
2929
+ return [...c, ...s].map(u => ({ start: u[0], end: last(u) })).map(u => ({ start: multiplyPoint(u.start, t), end: multiplyPoint(addPoint(u.end, { x: u.start.dx, y: u.start.dy }), t) }))
2930
+ }
2931
+ function getAngleInRadians(n, t) {
2932
+ return Math.atan2(t.y - n.y, t.x - n.x)
2933
+ }
2934
+ function getSortedRayAngles(n, t) {
2935
+ return t.map(e => getAngleInRadians(n, e)).sort((e, r) => e - r)
2936
+ }
2937
+ function getLineIntersectionPoint(n, t, e, r) {
2938
+ const i = (r.y - e.y) * (t.x - n.x) - (r.x - e.x) * (t.y - n.y)
2810
2939
  if (i === 0) return null
2811
- let o = n.y - t.y,
2812
- c = n.x - t.x
2813
- const u = (r.x - t.x) * o - (r.y - t.y) * c,
2814
- s = (e.x - n.x) * o - (e.y - n.y) * c
2815
- return (o = u / i), (c = s / i), o > 0 && o < 1 && c > 0 && c < 1 ? { x: n.x + o * (e.x - n.x), y: n.y + o * (e.y - n.y) } : null
2940
+ let o = n.y - e.y,
2941
+ c = n.x - e.x
2942
+ const s = (r.x - e.x) * o - (r.y - e.y) * c,
2943
+ u = (t.x - n.x) * o - (t.y - n.y) * c
2944
+ return (o = s / i), (c = u / i), o > 0 && o < 1 && c > 0 && c < 1 ? { x: n.x + o * (t.x - n.x), y: n.y + o * (t.y - n.y) } : null
2816
2945
  }
2817
- function raycast(n, e, t) {
2946
+ function raycast(n, t, e) {
2818
2947
  const r = [],
2819
- i = pushPoint(n, t, 1e4)
2820
- for (const o of e) {
2948
+ i = pushPoint(n, e, 1e4)
2949
+ for (const o of t) {
2821
2950
  const c = getLineIntersectionPoint(n, i, o.start, o.end)
2822
2951
  c && r.push(c)
2823
2952
  }
2824
2953
  return r.length
2825
2954
  ? r.reduce((o, c) => {
2826
- const u = getDistanceBetweenPoints(n, c),
2827
- s = getDistanceBetweenPoints(n, o)
2828
- return u < s ? c : o
2955
+ const s = getDistanceBetweenPoints(n, c),
2956
+ u = getDistanceBetweenPoints(n, o)
2957
+ return s < u ? c : o
2829
2958
  })
2830
2959
  : null
2831
2960
  }
2832
- function raycastCircle(n, e, t) {
2833
- const i = getSortedRayAngles(n, t),
2961
+ function raycastCircle(n, t, e) {
2962
+ const i = getSortedRayAngles(n, e),
2834
2963
  o = []
2835
2964
  for (const c of i) {
2836
- const u = raycast(n, e, c - 0.001),
2837
- s = raycast(n, e, c + 0.001)
2838
- u && o.push(u), s && o.push(s)
2965
+ const s = raycast(n, t, c - 0.001),
2966
+ u = raycast(n, t, c + 0.001)
2967
+ s && o.push(s), u && o.push(u)
2839
2968
  }
2840
2969
  return o
2841
2970
  }
@@ -2843,16 +2972,16 @@ class PubSubChannel {
2843
2972
  constructor() {
2844
2973
  this.subscribers = []
2845
2974
  }
2846
- subscribe(e) {
2975
+ subscribe(t) {
2847
2976
  return (
2848
- this.subscribers.push(e),
2977
+ this.subscribers.push(t),
2849
2978
  () => {
2850
- this.subscribers = this.subscribers.filter(t => t !== e)
2979
+ this.subscribers = this.subscribers.filter(e => e !== t)
2851
2980
  }
2852
2981
  )
2853
2982
  }
2854
- publish(e) {
2855
- this.subscribers.forEach(t => t(e))
2983
+ publish(t) {
2984
+ this.subscribers.forEach(e => e(t))
2856
2985
  }
2857
2986
  clear() {
2858
2987
  this.subscribers = []
@@ -2863,33 +2992,33 @@ class PubSubChannel {
2863
2992
  }
2864
2993
  exports.PubSubChannel = PubSubChannel
2865
2994
  class AsyncQueue {
2866
- constructor(e, t) {
2867
- ;(this.queue = []), (this.running = 0), (this.onProcessed = new PubSubChannel()), (this.onDrained = new PubSubChannel()), (this.concurrency = e), (this.capacity = t)
2995
+ constructor(t, e) {
2996
+ ;(this.queue = []), (this.running = 0), (this.onProcessed = new PubSubChannel()), (this.onDrained = new PubSubChannel()), (this.concurrency = t), (this.capacity = e)
2868
2997
  }
2869
2998
  process() {
2870
2999
  if (this.running >= this.concurrency) return
2871
- const e = this.queue.shift()
2872
- e &&
3000
+ const t = this.queue.shift()
3001
+ t &&
2873
3002
  (this.running++,
2874
- e().finally(() => {
3003
+ t().finally(() => {
2875
3004
  this.running--, this.process(), this.onProcessed.publish(), this.running === 0 && this.onDrained.publish()
2876
3005
  }))
2877
3006
  }
2878
- enqueue(e) {
2879
- if (this.queue.length < this.capacity) return this.queue.push(e), this.process(), Promise.resolve()
3007
+ enqueue(t) {
3008
+ if (this.queue.length < this.capacity) return this.queue.push(t), this.process(), Promise.resolve()
2880
3009
  if (this.onProcessed.getSubscriberCount()) throw Error('Queue capacity is full')
2881
- return new Promise(t => {
3010
+ return new Promise(e => {
2882
3011
  this.onProcessed.subscribe(() => {
2883
- this.queue.length < this.capacity && (this.queue.push(e), this.process(), this.onProcessed.clear(), t())
3012
+ this.queue.length < this.capacity && (this.queue.push(t), this.process(), this.onProcessed.clear(), e())
2884
3013
  })
2885
3014
  })
2886
3015
  }
2887
3016
  drain() {
2888
3017
  if (this.running === 0) return Promise.resolve()
2889
3018
  if (this.onDrained.getSubscriberCount()) throw Error('Already draining')
2890
- return new Promise(e => {
3019
+ return new Promise(t => {
2891
3020
  this.onDrained.subscribe(() => {
2892
- this.onDrained.clear(), e()
3021
+ this.onDrained.clear(), t()
2893
3022
  })
2894
3023
  })
2895
3024
  }
@@ -2899,35 +3028,35 @@ class TrieRouter {
2899
3028
  constructor() {
2900
3029
  this.forks = new Map()
2901
3030
  }
2902
- insert(e, t) {
2903
- if (e.length === 0) {
2904
- this.handler = t
3031
+ insert(t, e) {
3032
+ if (t.length === 0) {
3033
+ this.handler = e
2905
3034
  return
2906
3035
  }
2907
- const r = e[0]
3036
+ const r = t[0]
2908
3037
  let i = r,
2909
3038
  o
2910
3039
  if ((r.startsWith(':') && ((i = ':'), (o = r.slice(1))), !this.forks.has(i))) {
2911
3040
  const c = new TrieRouter()
2912
3041
  o && (c.variableName = o), this.forks.set(i, c)
2913
3042
  }
2914
- this.forks.get(i).insert(e.slice(1), t)
3043
+ this.forks.get(i).insert(t.slice(1), e)
2915
3044
  }
2916
- async handle(e, t, r, i) {
2917
- if (e.length === 0) return this.handler ? (await this.handler(t, r, i), !0) : !1
2918
- const o = e[0],
3045
+ async handle(t, e, r, i) {
3046
+ if (t.length === 0) return this.handler ? (await this.handler(e, r, i), !0) : !1
3047
+ const o = t[0],
2919
3048
  c = this.forks.get(o)
2920
- if (c) return c.handle(e.slice(1), t, r, i)
2921
- const u = this.forks.get(':')
2922
- if (u) return u.variableName && i.set(u.variableName, decodeURIComponent(o)), u.handle(e.slice(1), t, r, i)
2923
- const s = this.forks.get('*')
2924
- return s ? (i.set('wildcard', e.join('/')), s.handler ? (await s.handler(t, r, i), !0) : !1) : !1
3049
+ if (c) return c.handle(t.slice(1), e, r, i)
3050
+ const s = this.forks.get(':')
3051
+ if (s) return s.variableName && i.set(s.variableName, decodeURIComponent(o)), s.handle(t.slice(1), e, r, i)
3052
+ const u = this.forks.get('*')
3053
+ return u ? (i.set('wildcard', t.join('/')), u.handler ? (await u.handler(e, r, i), !0) : !1) : !1
2925
3054
  }
2926
3055
  }
2927
3056
  exports.TrieRouter = TrieRouter
2928
3057
  class RollingValueProvider {
2929
- constructor(e) {
2930
- ;(this.index = 0), (this.values = e)
3058
+ constructor(t) {
3059
+ ;(this.index = 0), (this.values = t)
2931
3060
  }
2932
3061
  current() {
2933
3062
  return this.values[this.index]
@@ -2945,51 +3074,51 @@ class Solver {
2945
3074
  return this.status
2946
3075
  }
2947
3076
  createInitialState() {
2948
- return Object.fromEntries(this.steps.map(e => [e.name, 'pending']))
3077
+ return Object.fromEntries(this.steps.map(t => [t.name, 'pending']))
2949
3078
  }
2950
- setHooks(e) {
2951
- e.onStatusChange && (this.onStatusChange = e.onStatusChange), e.onStepChange && (this.onStepChange = e.onStepChange), e.onFinish && (this.onFinish = e.onFinish), e.onError && (this.onError = e.onError)
3079
+ setHooks(t) {
3080
+ t.onStatusChange && (this.onStatusChange = t.onStatusChange), t.onStepChange && (this.onStepChange = t.onStepChange), t.onFinish && (this.onFinish = t.onFinish), t.onError && (this.onError = t.onError)
2952
3081
  }
2953
- addStep(e) {
2954
- if (this.steps.find(t => t.name === e.name)) throw Error(`Step with name ${e.name} already exists`)
2955
- this.steps.push(e)
3082
+ addStep(t) {
3083
+ if (this.steps.find(e => e.name === t.name)) throw Error(`Step with name ${t.name} already exists`)
3084
+ this.steps.push(t)
2956
3085
  }
2957
3086
  async execute() {
2958
3087
  if (this.status !== 'pending') throw Error(`Cannot execute solver in status ${this.status}`)
2959
3088
  ;(this.status = 'in-progress'), await this.onStatusChange(this.status)
2960
- let e = this.createInitialState()
2961
- for (const t of this.steps)
3089
+ let t = this.createInitialState()
3090
+ for (const e of this.steps)
2962
3091
  try {
2963
- if (t.transientSkipStepName) {
2964
- const i = e[t.transientSkipStepName]
3092
+ if (e.transientSkipStepName) {
3093
+ const i = t[e.transientSkipStepName]
2965
3094
  if (i === 'skipped' || i === 'failed') {
2966
- ;(e = { ...e, [t.name]: 'skipped' }), await this.onStepChange(e)
3095
+ ;(t = { ...t, [e.name]: 'skipped' }), await this.onStepChange(t)
2967
3096
  continue
2968
3097
  }
2969
3098
  }
2970
- if (!(t.precondition ? await t.precondition(this.context) : !0)) {
2971
- ;(e = { ...e, [t.name]: 'skipped' }), await this.onStepChange(e)
3099
+ if (!(e.precondition ? await e.precondition(this.context) : !0)) {
3100
+ ;(t = { ...t, [e.name]: 'skipped' }), await this.onStepChange(t)
2972
3101
  continue
2973
3102
  }
2974
- ;(e = { ...e, [t.name]: 'in-progress' }), await this.onStepChange(e)
2975
- for (let i = 0; (await t.action(this.context, i)) === 'retry'; i++);
2976
- ;(e = { ...e, [t.name]: 'completed' }), await this.onStepChange(e)
3103
+ ;(t = { ...t, [e.name]: 'in-progress' }), await this.onStepChange(t)
3104
+ for (let i = 0; (await e.action(this.context, i)) === 'retry'; i++);
3105
+ ;(t = { ...t, [e.name]: 'completed' }), await this.onStepChange(t)
2977
3106
  } catch (r) {
2978
- throw ((e = { ...e, [t.name]: 'failed' }), (this.status = 'failed'), await this.onStatusChange(this.status), await this.onStepChange(e), await this.onError(r), r)
3107
+ throw ((t = { ...t, [e.name]: 'failed' }), (this.status = 'failed'), await this.onStatusChange(this.status), await this.onStepChange(t), await this.onError(r), r)
2979
3108
  }
2980
3109
  return (this.status = 'completed'), await this.onStatusChange(this.status), await this.onFinish(), this.context
2981
3110
  }
2982
3111
  }
2983
3112
  exports.Solver = Solver
2984
3113
  class Lock {
2985
- constructor(e) {
2986
- ;(this.queryFunction = e.queryFunction), (this.lockFunction = e.lockFunction), (this.unlockFunction = e.unlockFunction), (this.timeoutMillis = e.timeoutMillis)
3114
+ constructor(t) {
3115
+ ;(this.queryFunction = t.queryFunction), (this.lockFunction = t.lockFunction), (this.unlockFunction = t.unlockFunction), (this.timeoutMillis = t.timeoutMillis)
2987
3116
  }
2988
3117
  async couldLock() {
2989
- const e = await this.queryFunction()
3118
+ const t = await this.queryFunction()
2990
3119
  try {
2991
- const t = asInteger(e)
2992
- if (Date.now() < t + this.timeoutMillis) return new Date(t + this.timeoutMillis)
3120
+ const e = asInteger(t)
3121
+ if (Date.now() < e + this.timeoutMillis) return new Date(e + this.timeoutMillis)
2993
3122
  } catch {}
2994
3123
  return await this.lockFunction(Date.now().toString()), !0
2995
3124
  }