iosignal 5.1.3 → 5.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/iosignal.js CHANGED
@@ -2,7 +2,7 @@ import require$$0$2, { Transform } from 'stream';
2
2
  import net from 'net';
3
3
  import require$$0$3 from 'events';
4
4
  import require$$1$1 from 'https';
5
- import require$$2$1 from 'http';
5
+ import require$$2$2 from 'http';
6
6
  import require$$4 from 'tls';
7
7
  import require$$1 from 'crypto';
8
8
  import require$$7 from 'url';
@@ -11,3048 +11,26 @@ import fs, { readFileSync } from 'fs';
11
11
  import path from 'path';
12
12
  import require$$2, { networkInterfaces } from 'os';
13
13
  import require$$0$1 from 'buffer';
14
+ import require$$2$1 from 'util';
14
15
  import { memoryUsage } from 'process';
15
16
 
16
- var version$1 = "5.1.3";
17
+ var version$1 = "5.1.4";
17
18
  var pkg = {
18
19
  version: version$1};
19
20
 
20
- function getDefaultExportFromCjs (x) {
21
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
22
- }
23
-
24
- var buffer = {};
25
-
26
- var base64Js = {};
27
-
28
- var hasRequiredBase64Js;
29
-
30
- function requireBase64Js () {
31
- if (hasRequiredBase64Js) return base64Js;
32
- hasRequiredBase64Js = 1;
33
-
34
- base64Js.byteLength = byteLength;
35
- base64Js.toByteArray = toByteArray;
36
- base64Js.fromByteArray = fromByteArray;
37
-
38
- var lookup = [];
39
- var revLookup = [];
40
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
41
-
42
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
43
- for (var i = 0, len = code.length; i < len; ++i) {
44
- lookup[i] = code[i];
45
- revLookup[code.charCodeAt(i)] = i;
46
- }
47
-
48
- // Support decoding URL-safe base64 strings, as Node.js does.
49
- // See: https://en.wikipedia.org/wiki/Base64#URL_applications
50
- revLookup['-'.charCodeAt(0)] = 62;
51
- revLookup['_'.charCodeAt(0)] = 63;
52
-
53
- function getLens (b64) {
54
- var len = b64.length;
55
-
56
- if (len % 4 > 0) {
57
- throw new Error('Invalid string. Length must be a multiple of 4')
58
- }
59
-
60
- // Trim off extra bytes after placeholder bytes are found
61
- // See: https://github.com/beatgammit/base64-js/issues/42
62
- var validLen = b64.indexOf('=');
63
- if (validLen === -1) validLen = len;
64
-
65
- var placeHoldersLen = validLen === len
66
- ? 0
67
- : 4 - (validLen % 4);
68
-
69
- return [validLen, placeHoldersLen]
70
- }
71
-
72
- // base64 is 4/3 + up to two characters of the original data
73
- function byteLength (b64) {
74
- var lens = getLens(b64);
75
- var validLen = lens[0];
76
- var placeHoldersLen = lens[1];
77
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
78
- }
79
-
80
- function _byteLength (b64, validLen, placeHoldersLen) {
81
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
82
- }
83
-
84
- function toByteArray (b64) {
85
- var tmp;
86
- var lens = getLens(b64);
87
- var validLen = lens[0];
88
- var placeHoldersLen = lens[1];
89
-
90
- var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
91
-
92
- var curByte = 0;
93
-
94
- // if there are placeholders, only get up to the last complete 4 chars
95
- var len = placeHoldersLen > 0
96
- ? validLen - 4
97
- : validLen;
98
-
99
- var i;
100
- for (i = 0; i < len; i += 4) {
101
- tmp =
102
- (revLookup[b64.charCodeAt(i)] << 18) |
103
- (revLookup[b64.charCodeAt(i + 1)] << 12) |
104
- (revLookup[b64.charCodeAt(i + 2)] << 6) |
105
- revLookup[b64.charCodeAt(i + 3)];
106
- arr[curByte++] = (tmp >> 16) & 0xFF;
107
- arr[curByte++] = (tmp >> 8) & 0xFF;
108
- arr[curByte++] = tmp & 0xFF;
109
- }
110
-
111
- if (placeHoldersLen === 2) {
112
- tmp =
113
- (revLookup[b64.charCodeAt(i)] << 2) |
114
- (revLookup[b64.charCodeAt(i + 1)] >> 4);
115
- arr[curByte++] = tmp & 0xFF;
116
- }
117
-
118
- if (placeHoldersLen === 1) {
119
- tmp =
120
- (revLookup[b64.charCodeAt(i)] << 10) |
121
- (revLookup[b64.charCodeAt(i + 1)] << 4) |
122
- (revLookup[b64.charCodeAt(i + 2)] >> 2);
123
- arr[curByte++] = (tmp >> 8) & 0xFF;
124
- arr[curByte++] = tmp & 0xFF;
125
- }
126
-
127
- return arr
128
- }
129
-
130
- function tripletToBase64 (num) {
131
- return lookup[num >> 18 & 0x3F] +
132
- lookup[num >> 12 & 0x3F] +
133
- lookup[num >> 6 & 0x3F] +
134
- lookup[num & 0x3F]
135
- }
136
-
137
- function encodeChunk (uint8, start, end) {
138
- var tmp;
139
- var output = [];
140
- for (var i = start; i < end; i += 3) {
141
- tmp =
142
- ((uint8[i] << 16) & 0xFF0000) +
143
- ((uint8[i + 1] << 8) & 0xFF00) +
144
- (uint8[i + 2] & 0xFF);
145
- output.push(tripletToBase64(tmp));
146
- }
147
- return output.join('')
148
- }
149
-
150
- function fromByteArray (uint8) {
151
- var tmp;
152
- var len = uint8.length;
153
- var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
154
- var parts = [];
155
- var maxChunkLength = 16383; // must be multiple of 3
156
-
157
- // go through the array every three bytes, we'll deal with trailing stuff later
158
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
159
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
160
- }
161
-
162
- // pad the end with zeros, but make sure to not forget the extra bytes
163
- if (extraBytes === 1) {
164
- tmp = uint8[len - 1];
165
- parts.push(
166
- lookup[tmp >> 2] +
167
- lookup[(tmp << 4) & 0x3F] +
168
- '=='
169
- );
170
- } else if (extraBytes === 2) {
171
- tmp = (uint8[len - 2] << 8) + uint8[len - 1];
172
- parts.push(
173
- lookup[tmp >> 10] +
174
- lookup[(tmp >> 4) & 0x3F] +
175
- lookup[(tmp << 2) & 0x3F] +
176
- '='
177
- );
178
- }
179
-
180
- return parts.join('')
181
- }
182
- return base64Js;
183
- }
184
-
185
- var ieee754 = {};
186
-
187
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
188
-
189
- var hasRequiredIeee754;
190
-
191
- function requireIeee754 () {
192
- if (hasRequiredIeee754) return ieee754;
193
- hasRequiredIeee754 = 1;
194
- ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
195
- var e, m;
196
- var eLen = (nBytes * 8) - mLen - 1;
197
- var eMax = (1 << eLen) - 1;
198
- var eBias = eMax >> 1;
199
- var nBits = -7;
200
- var i = isLE ? (nBytes - 1) : 0;
201
- var d = isLE ? -1 : 1;
202
- var s = buffer[offset + i];
203
-
204
- i += d;
205
-
206
- e = s & ((1 << (-nBits)) - 1);
207
- s >>= (-nBits);
208
- nBits += eLen;
209
- for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
210
-
211
- m = e & ((1 << (-nBits)) - 1);
212
- e >>= (-nBits);
213
- nBits += mLen;
214
- for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
215
-
216
- if (e === 0) {
217
- e = 1 - eBias;
218
- } else if (e === eMax) {
219
- return m ? NaN : ((s ? -1 : 1) * Infinity)
220
- } else {
221
- m = m + Math.pow(2, mLen);
222
- e = e - eBias;
223
- }
224
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
225
- };
226
-
227
- ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
228
- var e, m, c;
229
- var eLen = (nBytes * 8) - mLen - 1;
230
- var eMax = (1 << eLen) - 1;
231
- var eBias = eMax >> 1;
232
- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
233
- var i = isLE ? 0 : (nBytes - 1);
234
- var d = isLE ? 1 : -1;
235
- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
236
-
237
- value = Math.abs(value);
238
-
239
- if (isNaN(value) || value === Infinity) {
240
- m = isNaN(value) ? 1 : 0;
241
- e = eMax;
242
- } else {
243
- e = Math.floor(Math.log(value) / Math.LN2);
244
- if (value * (c = Math.pow(2, -e)) < 1) {
245
- e--;
246
- c *= 2;
247
- }
248
- if (e + eBias >= 1) {
249
- value += rt / c;
250
- } else {
251
- value += rt * Math.pow(2, 1 - eBias);
252
- }
253
- if (value * c >= 2) {
254
- e++;
255
- c /= 2;
256
- }
257
-
258
- if (e + eBias >= eMax) {
259
- m = 0;
260
- e = eMax;
261
- } else if (e + eBias >= 1) {
262
- m = ((value * c) - 1) * Math.pow(2, mLen);
263
- e = e + eBias;
264
- } else {
265
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
266
- e = 0;
267
- }
268
- }
269
-
270
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
271
-
272
- e = (e << mLen) | m;
273
- eLen += mLen;
274
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
275
-
276
- buffer[offset + i - d] |= s * 128;
277
- };
278
- return ieee754;
279
- }
280
-
281
- /*!
282
- * The buffer module from node.js, for the browser.
283
- *
284
- * @author Feross Aboukhadijeh <https://feross.org>
285
- * @license MIT
286
- */
287
-
288
- var hasRequiredBuffer;
289
-
290
- function requireBuffer () {
291
- if (hasRequiredBuffer) return buffer;
292
- hasRequiredBuffer = 1;
293
- (function (exports$1) {
294
-
295
- const base64 = requireBase64Js();
296
- const ieee754 = requireIeee754();
297
- const customInspectSymbol =
298
- (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
299
- ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
300
- : null;
301
-
302
- exports$1.Buffer = Buffer;
303
- exports$1.SlowBuffer = SlowBuffer;
304
- exports$1.INSPECT_MAX_BYTES = 50;
305
-
306
- const K_MAX_LENGTH = 0x7fffffff;
307
- exports$1.kMaxLength = K_MAX_LENGTH;
308
-
309
- /**
310
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
311
- * === true Use Uint8Array implementation (fastest)
312
- * === false Print warning and recommend using `buffer` v4.x which has an Object
313
- * implementation (most compatible, even IE6)
314
- *
315
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
316
- * Opera 11.6+, iOS 4.2+.
317
- *
318
- * We report that the browser does not support typed arrays if the are not subclassable
319
- * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
320
- * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
321
- * for __proto__ and has a buggy typed array implementation.
322
- */
323
- Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
324
-
325
- if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
326
- typeof console.error === 'function') {
327
- console.error(
328
- 'This browser lacks typed array (Uint8Array) support which is required by ' +
329
- '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
330
- );
331
- }
332
-
333
- function typedArraySupport () {
334
- // Can typed array instances can be augmented?
335
- try {
336
- const arr = new Uint8Array(1);
337
- const proto = { foo: function () { return 42 } };
338
- Object.setPrototypeOf(proto, Uint8Array.prototype);
339
- Object.setPrototypeOf(arr, proto);
340
- return arr.foo() === 42
341
- } catch (e) {
342
- return false
343
- }
344
- }
345
-
346
- Object.defineProperty(Buffer.prototype, 'parent', {
347
- enumerable: true,
348
- get: function () {
349
- if (!Buffer.isBuffer(this)) return undefined
350
- return this.buffer
351
- }
352
- });
353
-
354
- Object.defineProperty(Buffer.prototype, 'offset', {
355
- enumerable: true,
356
- get: function () {
357
- if (!Buffer.isBuffer(this)) return undefined
358
- return this.byteOffset
359
- }
360
- });
361
-
362
- function createBuffer (length) {
363
- if (length > K_MAX_LENGTH) {
364
- throw new RangeError('The value "' + length + '" is invalid for option "size"')
365
- }
366
- // Return an augmented `Uint8Array` instance
367
- const buf = new Uint8Array(length);
368
- Object.setPrototypeOf(buf, Buffer.prototype);
369
- return buf
370
- }
371
-
372
- /**
373
- * The Buffer constructor returns instances of `Uint8Array` that have their
374
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
375
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
376
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
377
- * returns a single octet.
378
- *
379
- * The `Uint8Array` prototype remains unmodified.
380
- */
381
-
382
- function Buffer (arg, encodingOrOffset, length) {
383
- // Common case.
384
- if (typeof arg === 'number') {
385
- if (typeof encodingOrOffset === 'string') {
386
- throw new TypeError(
387
- 'The "string" argument must be of type string. Received type number'
388
- )
389
- }
390
- return allocUnsafe(arg)
391
- }
392
- return from(arg, encodingOrOffset, length)
393
- }
394
-
395
- Buffer.poolSize = 8192; // not used by this implementation
396
-
397
- function from (value, encodingOrOffset, length) {
398
- if (typeof value === 'string') {
399
- return fromString(value, encodingOrOffset)
400
- }
401
-
402
- if (ArrayBuffer.isView(value)) {
403
- return fromArrayView(value)
404
- }
405
-
406
- if (value == null) {
407
- throw new TypeError(
408
- 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
409
- 'or Array-like Object. Received type ' + (typeof value)
410
- )
411
- }
412
-
413
- if (isInstance(value, ArrayBuffer) ||
414
- (value && isInstance(value.buffer, ArrayBuffer))) {
415
- return fromArrayBuffer(value, encodingOrOffset, length)
416
- }
417
-
418
- if (typeof SharedArrayBuffer !== 'undefined' &&
419
- (isInstance(value, SharedArrayBuffer) ||
420
- (value && isInstance(value.buffer, SharedArrayBuffer)))) {
421
- return fromArrayBuffer(value, encodingOrOffset, length)
422
- }
423
-
424
- if (typeof value === 'number') {
425
- throw new TypeError(
426
- 'The "value" argument must not be of type number. Received type number'
427
- )
428
- }
429
-
430
- const valueOf = value.valueOf && value.valueOf();
431
- if (valueOf != null && valueOf !== value) {
432
- return Buffer.from(valueOf, encodingOrOffset, length)
433
- }
434
-
435
- const b = fromObject(value);
436
- if (b) return b
437
-
438
- if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
439
- typeof value[Symbol.toPrimitive] === 'function') {
440
- return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
441
- }
442
-
443
- throw new TypeError(
444
- 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
445
- 'or Array-like Object. Received type ' + (typeof value)
446
- )
447
- }
448
-
449
- /**
450
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
451
- * if value is a number.
452
- * Buffer.from(str[, encoding])
453
- * Buffer.from(array)
454
- * Buffer.from(buffer)
455
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
456
- **/
457
- Buffer.from = function (value, encodingOrOffset, length) {
458
- return from(value, encodingOrOffset, length)
459
- };
460
-
461
- // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
462
- // https://github.com/feross/buffer/pull/148
463
- Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
464
- Object.setPrototypeOf(Buffer, Uint8Array);
465
-
466
- function assertSize (size) {
467
- if (typeof size !== 'number') {
468
- throw new TypeError('"size" argument must be of type number')
469
- } else if (size < 0) {
470
- throw new RangeError('The value "' + size + '" is invalid for option "size"')
471
- }
472
- }
473
-
474
- function alloc (size, fill, encoding) {
475
- assertSize(size);
476
- if (size <= 0) {
477
- return createBuffer(size)
478
- }
479
- if (fill !== undefined) {
480
- // Only pay attention to encoding if it's a string. This
481
- // prevents accidentally sending in a number that would
482
- // be interpreted as a start offset.
483
- return typeof encoding === 'string'
484
- ? createBuffer(size).fill(fill, encoding)
485
- : createBuffer(size).fill(fill)
486
- }
487
- return createBuffer(size)
488
- }
489
-
490
- /**
491
- * Creates a new filled Buffer instance.
492
- * alloc(size[, fill[, encoding]])
493
- **/
494
- Buffer.alloc = function (size, fill, encoding) {
495
- return alloc(size, fill, encoding)
496
- };
497
-
498
- function allocUnsafe (size) {
499
- assertSize(size);
500
- return createBuffer(size < 0 ? 0 : checked(size) | 0)
501
- }
502
-
503
- /**
504
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
505
- * */
506
- Buffer.allocUnsafe = function (size) {
507
- return allocUnsafe(size)
508
- };
509
- /**
510
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
511
- */
512
- Buffer.allocUnsafeSlow = function (size) {
513
- return allocUnsafe(size)
514
- };
515
-
516
- function fromString (string, encoding) {
517
- if (typeof encoding !== 'string' || encoding === '') {
518
- encoding = 'utf8';
519
- }
520
-
521
- if (!Buffer.isEncoding(encoding)) {
522
- throw new TypeError('Unknown encoding: ' + encoding)
523
- }
524
-
525
- const length = byteLength(string, encoding) | 0;
526
- let buf = createBuffer(length);
527
-
528
- const actual = buf.write(string, encoding);
529
-
530
- if (actual !== length) {
531
- // Writing a hex string, for example, that contains invalid characters will
532
- // cause everything after the first invalid character to be ignored. (e.g.
533
- // 'abxxcd' will be treated as 'ab')
534
- buf = buf.slice(0, actual);
535
- }
536
-
537
- return buf
538
- }
539
-
540
- function fromArrayLike (array) {
541
- const length = array.length < 0 ? 0 : checked(array.length) | 0;
542
- const buf = createBuffer(length);
543
- for (let i = 0; i < length; i += 1) {
544
- buf[i] = array[i] & 255;
545
- }
546
- return buf
547
- }
548
-
549
- function fromArrayView (arrayView) {
550
- if (isInstance(arrayView, Uint8Array)) {
551
- const copy = new Uint8Array(arrayView);
552
- return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
553
- }
554
- return fromArrayLike(arrayView)
555
- }
556
-
557
- function fromArrayBuffer (array, byteOffset, length) {
558
- if (byteOffset < 0 || array.byteLength < byteOffset) {
559
- throw new RangeError('"offset" is outside of buffer bounds')
560
- }
561
-
562
- if (array.byteLength < byteOffset + (length || 0)) {
563
- throw new RangeError('"length" is outside of buffer bounds')
564
- }
565
-
566
- let buf;
567
- if (byteOffset === undefined && length === undefined) {
568
- buf = new Uint8Array(array);
569
- } else if (length === undefined) {
570
- buf = new Uint8Array(array, byteOffset);
571
- } else {
572
- buf = new Uint8Array(array, byteOffset, length);
573
- }
574
-
575
- // Return an augmented `Uint8Array` instance
576
- Object.setPrototypeOf(buf, Buffer.prototype);
577
-
578
- return buf
579
- }
580
-
581
- function fromObject (obj) {
582
- if (Buffer.isBuffer(obj)) {
583
- const len = checked(obj.length) | 0;
584
- const buf = createBuffer(len);
585
-
586
- if (buf.length === 0) {
587
- return buf
588
- }
589
-
590
- obj.copy(buf, 0, 0, len);
591
- return buf
592
- }
593
-
594
- if (obj.length !== undefined) {
595
- if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
596
- return createBuffer(0)
597
- }
598
- return fromArrayLike(obj)
599
- }
600
-
601
- if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
602
- return fromArrayLike(obj.data)
603
- }
604
- }
605
-
606
- function checked (length) {
607
- // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
608
- // length is NaN (which is otherwise coerced to zero.)
609
- if (length >= K_MAX_LENGTH) {
610
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
611
- 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
612
- }
613
- return length | 0
614
- }
615
-
616
- function SlowBuffer (length) {
617
- if (+length != length) { // eslint-disable-line eqeqeq
618
- length = 0;
619
- }
620
- return Buffer.alloc(+length)
621
- }
622
-
623
- Buffer.isBuffer = function isBuffer (b) {
624
- return b != null && b._isBuffer === true &&
625
- b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
626
- };
627
-
628
- Buffer.compare = function compare (a, b) {
629
- if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
630
- if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
631
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
632
- throw new TypeError(
633
- 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
634
- )
635
- }
636
-
637
- if (a === b) return 0
638
-
639
- let x = a.length;
640
- let y = b.length;
641
-
642
- for (let i = 0, len = Math.min(x, y); i < len; ++i) {
643
- if (a[i] !== b[i]) {
644
- x = a[i];
645
- y = b[i];
646
- break
647
- }
648
- }
649
-
650
- if (x < y) return -1
651
- if (y < x) return 1
652
- return 0
653
- };
654
-
655
- Buffer.isEncoding = function isEncoding (encoding) {
656
- switch (String(encoding).toLowerCase()) {
657
- case 'hex':
658
- case 'utf8':
659
- case 'utf-8':
660
- case 'ascii':
661
- case 'latin1':
662
- case 'binary':
663
- case 'base64':
664
- case 'ucs2':
665
- case 'ucs-2':
666
- case 'utf16le':
667
- case 'utf-16le':
668
- return true
669
- default:
670
- return false
671
- }
672
- };
673
-
674
- Buffer.concat = function concat (list, length) {
675
- if (!Array.isArray(list)) {
676
- throw new TypeError('"list" argument must be an Array of Buffers')
677
- }
678
-
679
- if (list.length === 0) {
680
- return Buffer.alloc(0)
681
- }
682
-
683
- let i;
684
- if (length === undefined) {
685
- length = 0;
686
- for (i = 0; i < list.length; ++i) {
687
- length += list[i].length;
688
- }
689
- }
690
-
691
- const buffer = Buffer.allocUnsafe(length);
692
- let pos = 0;
693
- for (i = 0; i < list.length; ++i) {
694
- let buf = list[i];
695
- if (isInstance(buf, Uint8Array)) {
696
- if (pos + buf.length > buffer.length) {
697
- if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
698
- buf.copy(buffer, pos);
699
- } else {
700
- Uint8Array.prototype.set.call(
701
- buffer,
702
- buf,
703
- pos
704
- );
705
- }
706
- } else if (!Buffer.isBuffer(buf)) {
707
- throw new TypeError('"list" argument must be an Array of Buffers')
708
- } else {
709
- buf.copy(buffer, pos);
710
- }
711
- pos += buf.length;
712
- }
713
- return buffer
714
- };
715
-
716
- function byteLength (string, encoding) {
717
- if (Buffer.isBuffer(string)) {
718
- return string.length
719
- }
720
- if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
721
- return string.byteLength
722
- }
723
- if (typeof string !== 'string') {
724
- throw new TypeError(
725
- 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
726
- 'Received type ' + typeof string
727
- )
728
- }
729
-
730
- const len = string.length;
731
- const mustMatch = (arguments.length > 2 && arguments[2] === true);
732
- if (!mustMatch && len === 0) return 0
733
-
734
- // Use a for loop to avoid recursion
735
- let loweredCase = false;
736
- for (;;) {
737
- switch (encoding) {
738
- case 'ascii':
739
- case 'latin1':
740
- case 'binary':
741
- return len
742
- case 'utf8':
743
- case 'utf-8':
744
- return utf8ToBytes(string).length
745
- case 'ucs2':
746
- case 'ucs-2':
747
- case 'utf16le':
748
- case 'utf-16le':
749
- return len * 2
750
- case 'hex':
751
- return len >>> 1
752
- case 'base64':
753
- return base64ToBytes(string).length
754
- default:
755
- if (loweredCase) {
756
- return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
757
- }
758
- encoding = ('' + encoding).toLowerCase();
759
- loweredCase = true;
760
- }
761
- }
762
- }
763
- Buffer.byteLength = byteLength;
764
-
765
- function slowToString (encoding, start, end) {
766
- let loweredCase = false;
767
-
768
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
769
- // property of a typed array.
770
-
771
- // This behaves neither like String nor Uint8Array in that we set start/end
772
- // to their upper/lower bounds if the value passed is out of range.
773
- // undefined is handled specially as per ECMA-262 6th Edition,
774
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
775
- if (start === undefined || start < 0) {
776
- start = 0;
777
- }
778
- // Return early if start > this.length. Done here to prevent potential uint32
779
- // coercion fail below.
780
- if (start > this.length) {
781
- return ''
782
- }
783
-
784
- if (end === undefined || end > this.length) {
785
- end = this.length;
786
- }
787
-
788
- if (end <= 0) {
789
- return ''
790
- }
791
-
792
- // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
793
- end >>>= 0;
794
- start >>>= 0;
795
-
796
- if (end <= start) {
797
- return ''
798
- }
799
-
800
- if (!encoding) encoding = 'utf8';
801
-
802
- while (true) {
803
- switch (encoding) {
804
- case 'hex':
805
- return hexSlice(this, start, end)
806
-
807
- case 'utf8':
808
- case 'utf-8':
809
- return utf8Slice(this, start, end)
810
-
811
- case 'ascii':
812
- return asciiSlice(this, start, end)
813
-
814
- case 'latin1':
815
- case 'binary':
816
- return latin1Slice(this, start, end)
817
-
818
- case 'base64':
819
- return base64Slice(this, start, end)
820
-
821
- case 'ucs2':
822
- case 'ucs-2':
823
- case 'utf16le':
824
- case 'utf-16le':
825
- return utf16leSlice(this, start, end)
826
-
827
- default:
828
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
829
- encoding = (encoding + '').toLowerCase();
830
- loweredCase = true;
831
- }
832
- }
833
- }
834
-
835
- // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
836
- // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
837
- // reliably in a browserify context because there could be multiple different
838
- // copies of the 'buffer' package in use. This method works even for Buffer
839
- // instances that were created from another copy of the `buffer` package.
840
- // See: https://github.com/feross/buffer/issues/154
841
- Buffer.prototype._isBuffer = true;
842
-
843
- function swap (b, n, m) {
844
- const i = b[n];
845
- b[n] = b[m];
846
- b[m] = i;
847
- }
848
-
849
- Buffer.prototype.swap16 = function swap16 () {
850
- const len = this.length;
851
- if (len % 2 !== 0) {
852
- throw new RangeError('Buffer size must be a multiple of 16-bits')
853
- }
854
- for (let i = 0; i < len; i += 2) {
855
- swap(this, i, i + 1);
856
- }
857
- return this
858
- };
859
-
860
- Buffer.prototype.swap32 = function swap32 () {
861
- const len = this.length;
862
- if (len % 4 !== 0) {
863
- throw new RangeError('Buffer size must be a multiple of 32-bits')
864
- }
865
- for (let i = 0; i < len; i += 4) {
866
- swap(this, i, i + 3);
867
- swap(this, i + 1, i + 2);
868
- }
869
- return this
870
- };
871
-
872
- Buffer.prototype.swap64 = function swap64 () {
873
- const len = this.length;
874
- if (len % 8 !== 0) {
875
- throw new RangeError('Buffer size must be a multiple of 64-bits')
876
- }
877
- for (let i = 0; i < len; i += 8) {
878
- swap(this, i, i + 7);
879
- swap(this, i + 1, i + 6);
880
- swap(this, i + 2, i + 5);
881
- swap(this, i + 3, i + 4);
882
- }
883
- return this
884
- };
885
-
886
- Buffer.prototype.toString = function toString () {
887
- const length = this.length;
888
- if (length === 0) return ''
889
- if (arguments.length === 0) return utf8Slice(this, 0, length)
890
- return slowToString.apply(this, arguments)
891
- };
892
-
893
- Buffer.prototype.toLocaleString = Buffer.prototype.toString;
894
-
895
- Buffer.prototype.equals = function equals (b) {
896
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
897
- if (this === b) return true
898
- return Buffer.compare(this, b) === 0
899
- };
900
-
901
- Buffer.prototype.inspect = function inspect () {
902
- let str = '';
903
- const max = exports$1.INSPECT_MAX_BYTES;
904
- str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
905
- if (this.length > max) str += ' ... ';
906
- return '<Buffer ' + str + '>'
907
- };
908
- if (customInspectSymbol) {
909
- Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
910
- }
911
-
912
- Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
913
- if (isInstance(target, Uint8Array)) {
914
- target = Buffer.from(target, target.offset, target.byteLength);
915
- }
916
- if (!Buffer.isBuffer(target)) {
917
- throw new TypeError(
918
- 'The "target" argument must be one of type Buffer or Uint8Array. ' +
919
- 'Received type ' + (typeof target)
920
- )
921
- }
922
-
923
- if (start === undefined) {
924
- start = 0;
925
- }
926
- if (end === undefined) {
927
- end = target ? target.length : 0;
928
- }
929
- if (thisStart === undefined) {
930
- thisStart = 0;
931
- }
932
- if (thisEnd === undefined) {
933
- thisEnd = this.length;
934
- }
935
-
936
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
937
- throw new RangeError('out of range index')
938
- }
939
-
940
- if (thisStart >= thisEnd && start >= end) {
941
- return 0
942
- }
943
- if (thisStart >= thisEnd) {
944
- return -1
945
- }
946
- if (start >= end) {
947
- return 1
948
- }
949
-
950
- start >>>= 0;
951
- end >>>= 0;
952
- thisStart >>>= 0;
953
- thisEnd >>>= 0;
954
-
955
- if (this === target) return 0
956
-
957
- let x = thisEnd - thisStart;
958
- let y = end - start;
959
- const len = Math.min(x, y);
960
-
961
- const thisCopy = this.slice(thisStart, thisEnd);
962
- const targetCopy = target.slice(start, end);
963
-
964
- for (let i = 0; i < len; ++i) {
965
- if (thisCopy[i] !== targetCopy[i]) {
966
- x = thisCopy[i];
967
- y = targetCopy[i];
968
- break
969
- }
970
- }
971
-
972
- if (x < y) return -1
973
- if (y < x) return 1
974
- return 0
975
- };
976
-
977
- // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
978
- // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
979
- //
980
- // Arguments:
981
- // - buffer - a Buffer to search
982
- // - val - a string, Buffer, or number
983
- // - byteOffset - an index into `buffer`; will be clamped to an int32
984
- // - encoding - an optional encoding, relevant is val is a string
985
- // - dir - true for indexOf, false for lastIndexOf
986
- function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
987
- // Empty buffer means no match
988
- if (buffer.length === 0) return -1
989
-
990
- // Normalize byteOffset
991
- if (typeof byteOffset === 'string') {
992
- encoding = byteOffset;
993
- byteOffset = 0;
994
- } else if (byteOffset > 0x7fffffff) {
995
- byteOffset = 0x7fffffff;
996
- } else if (byteOffset < -2147483648) {
997
- byteOffset = -2147483648;
998
- }
999
- byteOffset = +byteOffset; // Coerce to Number.
1000
- if (numberIsNaN(byteOffset)) {
1001
- // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1002
- byteOffset = dir ? 0 : (buffer.length - 1);
1003
- }
1004
-
1005
- // Normalize byteOffset: negative offsets start from the end of the buffer
1006
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
1007
- if (byteOffset >= buffer.length) {
1008
- if (dir) return -1
1009
- else byteOffset = buffer.length - 1;
1010
- } else if (byteOffset < 0) {
1011
- if (dir) byteOffset = 0;
1012
- else return -1
1013
- }
1014
-
1015
- // Normalize val
1016
- if (typeof val === 'string') {
1017
- val = Buffer.from(val, encoding);
1018
- }
1019
-
1020
- // Finally, search either indexOf (if dir is true) or lastIndexOf
1021
- if (Buffer.isBuffer(val)) {
1022
- // Special case: looking for empty string/buffer always fails
1023
- if (val.length === 0) {
1024
- return -1
1025
- }
1026
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
1027
- } else if (typeof val === 'number') {
1028
- val = val & 0xFF; // Search for a byte value [0-255]
1029
- if (typeof Uint8Array.prototype.indexOf === 'function') {
1030
- if (dir) {
1031
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
1032
- } else {
1033
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
1034
- }
1035
- }
1036
- return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
1037
- }
1038
-
1039
- throw new TypeError('val must be string, number or Buffer')
1040
- }
1041
-
1042
- function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1043
- let indexSize = 1;
1044
- let arrLength = arr.length;
1045
- let valLength = val.length;
1046
-
1047
- if (encoding !== undefined) {
1048
- encoding = String(encoding).toLowerCase();
1049
- if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1050
- encoding === 'utf16le' || encoding === 'utf-16le') {
1051
- if (arr.length < 2 || val.length < 2) {
1052
- return -1
1053
- }
1054
- indexSize = 2;
1055
- arrLength /= 2;
1056
- valLength /= 2;
1057
- byteOffset /= 2;
1058
- }
1059
- }
1060
-
1061
- function read (buf, i) {
1062
- if (indexSize === 1) {
1063
- return buf[i]
1064
- } else {
1065
- return buf.readUInt16BE(i * indexSize)
1066
- }
1067
- }
1068
-
1069
- let i;
1070
- if (dir) {
1071
- let foundIndex = -1;
1072
- for (i = byteOffset; i < arrLength; i++) {
1073
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1074
- if (foundIndex === -1) foundIndex = i;
1075
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1076
- } else {
1077
- if (foundIndex !== -1) i -= i - foundIndex;
1078
- foundIndex = -1;
1079
- }
1080
- }
1081
- } else {
1082
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
1083
- for (i = byteOffset; i >= 0; i--) {
1084
- let found = true;
1085
- for (let j = 0; j < valLength; j++) {
1086
- if (read(arr, i + j) !== read(val, j)) {
1087
- found = false;
1088
- break
1089
- }
1090
- }
1091
- if (found) return i
1092
- }
1093
- }
1094
-
1095
- return -1
1096
- }
1097
-
1098
- Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1099
- return this.indexOf(val, byteOffset, encoding) !== -1
1100
- };
1101
-
1102
- Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1103
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1104
- };
1105
-
1106
- Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1107
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1108
- };
1109
-
1110
- function hexWrite (buf, string, offset, length) {
1111
- offset = Number(offset) || 0;
1112
- const remaining = buf.length - offset;
1113
- if (!length) {
1114
- length = remaining;
1115
- } else {
1116
- length = Number(length);
1117
- if (length > remaining) {
1118
- length = remaining;
1119
- }
1120
- }
1121
-
1122
- const strLen = string.length;
1123
-
1124
- if (length > strLen / 2) {
1125
- length = strLen / 2;
1126
- }
1127
- let i;
1128
- for (i = 0; i < length; ++i) {
1129
- const parsed = parseInt(string.substr(i * 2, 2), 16);
1130
- if (numberIsNaN(parsed)) return i
1131
- buf[offset + i] = parsed;
1132
- }
1133
- return i
1134
- }
1135
-
1136
- function utf8Write (buf, string, offset, length) {
1137
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1138
- }
1139
-
1140
- function asciiWrite (buf, string, offset, length) {
1141
- return blitBuffer(asciiToBytes(string), buf, offset, length)
1142
- }
1143
-
1144
- function base64Write (buf, string, offset, length) {
1145
- return blitBuffer(base64ToBytes(string), buf, offset, length)
1146
- }
1147
-
1148
- function ucs2Write (buf, string, offset, length) {
1149
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1150
- }
1151
-
1152
- Buffer.prototype.write = function write (string, offset, length, encoding) {
1153
- // Buffer#write(string)
1154
- if (offset === undefined) {
1155
- encoding = 'utf8';
1156
- length = this.length;
1157
- offset = 0;
1158
- // Buffer#write(string, encoding)
1159
- } else if (length === undefined && typeof offset === 'string') {
1160
- encoding = offset;
1161
- length = this.length;
1162
- offset = 0;
1163
- // Buffer#write(string, offset[, length][, encoding])
1164
- } else if (isFinite(offset)) {
1165
- offset = offset >>> 0;
1166
- if (isFinite(length)) {
1167
- length = length >>> 0;
1168
- if (encoding === undefined) encoding = 'utf8';
1169
- } else {
1170
- encoding = length;
1171
- length = undefined;
1172
- }
1173
- } else {
1174
- throw new Error(
1175
- 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1176
- )
1177
- }
1178
-
1179
- const remaining = this.length - offset;
1180
- if (length === undefined || length > remaining) length = remaining;
1181
-
1182
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1183
- throw new RangeError('Attempt to write outside buffer bounds')
1184
- }
1185
-
1186
- if (!encoding) encoding = 'utf8';
1187
-
1188
- let loweredCase = false;
1189
- for (;;) {
1190
- switch (encoding) {
1191
- case 'hex':
1192
- return hexWrite(this, string, offset, length)
1193
-
1194
- case 'utf8':
1195
- case 'utf-8':
1196
- return utf8Write(this, string, offset, length)
1197
-
1198
- case 'ascii':
1199
- case 'latin1':
1200
- case 'binary':
1201
- return asciiWrite(this, string, offset, length)
1202
-
1203
- case 'base64':
1204
- // Warning: maxLength not taken into account in base64Write
1205
- return base64Write(this, string, offset, length)
1206
-
1207
- case 'ucs2':
1208
- case 'ucs-2':
1209
- case 'utf16le':
1210
- case 'utf-16le':
1211
- return ucs2Write(this, string, offset, length)
1212
-
1213
- default:
1214
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1215
- encoding = ('' + encoding).toLowerCase();
1216
- loweredCase = true;
1217
- }
1218
- }
1219
- };
1220
-
1221
- Buffer.prototype.toJSON = function toJSON () {
1222
- return {
1223
- type: 'Buffer',
1224
- data: Array.prototype.slice.call(this._arr || this, 0)
1225
- }
1226
- };
1227
-
1228
- function base64Slice (buf, start, end) {
1229
- if (start === 0 && end === buf.length) {
1230
- return base64.fromByteArray(buf)
1231
- } else {
1232
- return base64.fromByteArray(buf.slice(start, end))
1233
- }
1234
- }
1235
-
1236
- function utf8Slice (buf, start, end) {
1237
- end = Math.min(buf.length, end);
1238
- const res = [];
1239
-
1240
- let i = start;
1241
- while (i < end) {
1242
- const firstByte = buf[i];
1243
- let codePoint = null;
1244
- let bytesPerSequence = (firstByte > 0xEF)
1245
- ? 4
1246
- : (firstByte > 0xDF)
1247
- ? 3
1248
- : (firstByte > 0xBF)
1249
- ? 2
1250
- : 1;
1251
-
1252
- if (i + bytesPerSequence <= end) {
1253
- let secondByte, thirdByte, fourthByte, tempCodePoint;
1254
-
1255
- switch (bytesPerSequence) {
1256
- case 1:
1257
- if (firstByte < 0x80) {
1258
- codePoint = firstByte;
1259
- }
1260
- break
1261
- case 2:
1262
- secondByte = buf[i + 1];
1263
- if ((secondByte & 0xC0) === 0x80) {
1264
- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
1265
- if (tempCodePoint > 0x7F) {
1266
- codePoint = tempCodePoint;
1267
- }
1268
- }
1269
- break
1270
- case 3:
1271
- secondByte = buf[i + 1];
1272
- thirdByte = buf[i + 2];
1273
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1274
- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
1275
- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1276
- codePoint = tempCodePoint;
1277
- }
1278
- }
1279
- break
1280
- case 4:
1281
- secondByte = buf[i + 1];
1282
- thirdByte = buf[i + 2];
1283
- fourthByte = buf[i + 3];
1284
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1285
- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
1286
- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1287
- codePoint = tempCodePoint;
1288
- }
1289
- }
1290
- }
1291
- }
1292
-
1293
- if (codePoint === null) {
1294
- // we did not generate a valid codePoint so insert a
1295
- // replacement char (U+FFFD) and advance only 1 byte
1296
- codePoint = 0xFFFD;
1297
- bytesPerSequence = 1;
1298
- } else if (codePoint > 0xFFFF) {
1299
- // encode to utf16 (surrogate pair dance)
1300
- codePoint -= 0x10000;
1301
- res.push(codePoint >>> 10 & 0x3FF | 0xD800);
1302
- codePoint = 0xDC00 | codePoint & 0x3FF;
1303
- }
1304
-
1305
- res.push(codePoint);
1306
- i += bytesPerSequence;
1307
- }
1308
-
1309
- return decodeCodePointsArray(res)
1310
- }
1311
-
1312
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
1313
- // the lowest limit is Chrome, with 0x10000 args.
1314
- // We go 1 magnitude less, for safety
1315
- const MAX_ARGUMENTS_LENGTH = 0x1000;
1316
-
1317
- function decodeCodePointsArray (codePoints) {
1318
- const len = codePoints.length;
1319
- if (len <= MAX_ARGUMENTS_LENGTH) {
1320
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1321
- }
1322
-
1323
- // Decode in chunks to avoid "call stack size exceeded".
1324
- let res = '';
1325
- let i = 0;
1326
- while (i < len) {
1327
- res += String.fromCharCode.apply(
1328
- String,
1329
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1330
- );
1331
- }
1332
- return res
1333
- }
1334
-
1335
- function asciiSlice (buf, start, end) {
1336
- let ret = '';
1337
- end = Math.min(buf.length, end);
1338
-
1339
- for (let i = start; i < end; ++i) {
1340
- ret += String.fromCharCode(buf[i] & 0x7F);
1341
- }
1342
- return ret
1343
- }
1344
-
1345
- function latin1Slice (buf, start, end) {
1346
- let ret = '';
1347
- end = Math.min(buf.length, end);
1348
-
1349
- for (let i = start; i < end; ++i) {
1350
- ret += String.fromCharCode(buf[i]);
1351
- }
1352
- return ret
1353
- }
1354
-
1355
- function hexSlice (buf, start, end) {
1356
- const len = buf.length;
1357
-
1358
- if (!start || start < 0) start = 0;
1359
- if (!end || end < 0 || end > len) end = len;
1360
-
1361
- let out = '';
1362
- for (let i = start; i < end; ++i) {
1363
- out += hexSliceLookupTable[buf[i]];
1364
- }
1365
- return out
1366
- }
1367
-
1368
- function utf16leSlice (buf, start, end) {
1369
- const bytes = buf.slice(start, end);
1370
- let res = '';
1371
- // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
1372
- for (let i = 0; i < bytes.length - 1; i += 2) {
1373
- res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
1374
- }
1375
- return res
1376
- }
1377
-
1378
- Buffer.prototype.slice = function slice (start, end) {
1379
- const len = this.length;
1380
- start = ~~start;
1381
- end = end === undefined ? len : ~~end;
1382
-
1383
- if (start < 0) {
1384
- start += len;
1385
- if (start < 0) start = 0;
1386
- } else if (start > len) {
1387
- start = len;
1388
- }
1389
-
1390
- if (end < 0) {
1391
- end += len;
1392
- if (end < 0) end = 0;
1393
- } else if (end > len) {
1394
- end = len;
1395
- }
1396
-
1397
- if (end < start) end = start;
1398
-
1399
- const newBuf = this.subarray(start, end);
1400
- // Return an augmented `Uint8Array` instance
1401
- Object.setPrototypeOf(newBuf, Buffer.prototype);
1402
-
1403
- return newBuf
1404
- };
1405
-
1406
- /*
1407
- * Need to make sure that buffer isn't trying to write out of bounds.
1408
- */
1409
- function checkOffset (offset, ext, length) {
1410
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1411
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1412
- }
1413
-
1414
- Buffer.prototype.readUintLE =
1415
- Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1416
- offset = offset >>> 0;
1417
- byteLength = byteLength >>> 0;
1418
- if (!noAssert) checkOffset(offset, byteLength, this.length);
1419
-
1420
- let val = this[offset];
1421
- let mul = 1;
1422
- let i = 0;
1423
- while (++i < byteLength && (mul *= 0x100)) {
1424
- val += this[offset + i] * mul;
1425
- }
1426
-
1427
- return val
1428
- };
1429
-
1430
- Buffer.prototype.readUintBE =
1431
- Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1432
- offset = offset >>> 0;
1433
- byteLength = byteLength >>> 0;
1434
- if (!noAssert) {
1435
- checkOffset(offset, byteLength, this.length);
1436
- }
1437
-
1438
- let val = this[offset + --byteLength];
1439
- let mul = 1;
1440
- while (byteLength > 0 && (mul *= 0x100)) {
1441
- val += this[offset + --byteLength] * mul;
1442
- }
1443
-
1444
- return val
1445
- };
1446
-
1447
- Buffer.prototype.readUint8 =
1448
- Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1449
- offset = offset >>> 0;
1450
- if (!noAssert) checkOffset(offset, 1, this.length);
1451
- return this[offset]
1452
- };
1453
-
1454
- Buffer.prototype.readUint16LE =
1455
- Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1456
- offset = offset >>> 0;
1457
- if (!noAssert) checkOffset(offset, 2, this.length);
1458
- return this[offset] | (this[offset + 1] << 8)
1459
- };
1460
-
1461
- Buffer.prototype.readUint16BE =
1462
- Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1463
- offset = offset >>> 0;
1464
- if (!noAssert) checkOffset(offset, 2, this.length);
1465
- return (this[offset] << 8) | this[offset + 1]
1466
- };
1467
-
1468
- Buffer.prototype.readUint32LE =
1469
- Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1470
- offset = offset >>> 0;
1471
- if (!noAssert) checkOffset(offset, 4, this.length);
1472
-
1473
- return ((this[offset]) |
1474
- (this[offset + 1] << 8) |
1475
- (this[offset + 2] << 16)) +
1476
- (this[offset + 3] * 0x1000000)
1477
- };
1478
-
1479
- Buffer.prototype.readUint32BE =
1480
- Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1481
- offset = offset >>> 0;
1482
- if (!noAssert) checkOffset(offset, 4, this.length);
1483
-
1484
- return (this[offset] * 0x1000000) +
1485
- ((this[offset + 1] << 16) |
1486
- (this[offset + 2] << 8) |
1487
- this[offset + 3])
1488
- };
1489
-
1490
- Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
1491
- offset = offset >>> 0;
1492
- validateNumber(offset, 'offset');
1493
- const first = this[offset];
1494
- const last = this[offset + 7];
1495
- if (first === undefined || last === undefined) {
1496
- boundsError(offset, this.length - 8);
1497
- }
1498
-
1499
- const lo = first +
1500
- this[++offset] * 2 ** 8 +
1501
- this[++offset] * 2 ** 16 +
1502
- this[++offset] * 2 ** 24;
1503
-
1504
- const hi = this[++offset] +
1505
- this[++offset] * 2 ** 8 +
1506
- this[++offset] * 2 ** 16 +
1507
- last * 2 ** 24;
1508
-
1509
- return BigInt(lo) + (BigInt(hi) << BigInt(32))
1510
- });
1511
-
1512
- Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
1513
- offset = offset >>> 0;
1514
- validateNumber(offset, 'offset');
1515
- const first = this[offset];
1516
- const last = this[offset + 7];
1517
- if (first === undefined || last === undefined) {
1518
- boundsError(offset, this.length - 8);
1519
- }
1520
-
1521
- const hi = first * 2 ** 24 +
1522
- this[++offset] * 2 ** 16 +
1523
- this[++offset] * 2 ** 8 +
1524
- this[++offset];
1525
-
1526
- const lo = this[++offset] * 2 ** 24 +
1527
- this[++offset] * 2 ** 16 +
1528
- this[++offset] * 2 ** 8 +
1529
- last;
1530
-
1531
- return (BigInt(hi) << BigInt(32)) + BigInt(lo)
1532
- });
1533
-
1534
- Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1535
- offset = offset >>> 0;
1536
- byteLength = byteLength >>> 0;
1537
- if (!noAssert) checkOffset(offset, byteLength, this.length);
1538
-
1539
- let val = this[offset];
1540
- let mul = 1;
1541
- let i = 0;
1542
- while (++i < byteLength && (mul *= 0x100)) {
1543
- val += this[offset + i] * mul;
1544
- }
1545
- mul *= 0x80;
1546
-
1547
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
1548
-
1549
- return val
1550
- };
1551
-
1552
- Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1553
- offset = offset >>> 0;
1554
- byteLength = byteLength >>> 0;
1555
- if (!noAssert) checkOffset(offset, byteLength, this.length);
1556
-
1557
- let i = byteLength;
1558
- let mul = 1;
1559
- let val = this[offset + --i];
1560
- while (i > 0 && (mul *= 0x100)) {
1561
- val += this[offset + --i] * mul;
1562
- }
1563
- mul *= 0x80;
1564
-
1565
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
1566
-
1567
- return val
1568
- };
1569
-
1570
- Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1571
- offset = offset >>> 0;
1572
- if (!noAssert) checkOffset(offset, 1, this.length);
1573
- if (!(this[offset] & 0x80)) return (this[offset])
1574
- return ((0xff - this[offset] + 1) * -1)
1575
- };
1576
-
1577
- Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1578
- offset = offset >>> 0;
1579
- if (!noAssert) checkOffset(offset, 2, this.length);
1580
- const val = this[offset] | (this[offset + 1] << 8);
1581
- return (val & 0x8000) ? val | 0xFFFF0000 : val
1582
- };
1583
-
1584
- Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1585
- offset = offset >>> 0;
1586
- if (!noAssert) checkOffset(offset, 2, this.length);
1587
- const val = this[offset + 1] | (this[offset] << 8);
1588
- return (val & 0x8000) ? val | 0xFFFF0000 : val
1589
- };
1590
-
1591
- Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1592
- offset = offset >>> 0;
1593
- if (!noAssert) checkOffset(offset, 4, this.length);
1594
-
1595
- return (this[offset]) |
1596
- (this[offset + 1] << 8) |
1597
- (this[offset + 2] << 16) |
1598
- (this[offset + 3] << 24)
1599
- };
1600
-
1601
- Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1602
- offset = offset >>> 0;
1603
- if (!noAssert) checkOffset(offset, 4, this.length);
1604
-
1605
- return (this[offset] << 24) |
1606
- (this[offset + 1] << 16) |
1607
- (this[offset + 2] << 8) |
1608
- (this[offset + 3])
1609
- };
1610
-
1611
- Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
1612
- offset = offset >>> 0;
1613
- validateNumber(offset, 'offset');
1614
- const first = this[offset];
1615
- const last = this[offset + 7];
1616
- if (first === undefined || last === undefined) {
1617
- boundsError(offset, this.length - 8);
1618
- }
1619
-
1620
- const val = this[offset + 4] +
1621
- this[offset + 5] * 2 ** 8 +
1622
- this[offset + 6] * 2 ** 16 +
1623
- (last << 24); // Overflow
1624
-
1625
- return (BigInt(val) << BigInt(32)) +
1626
- BigInt(first +
1627
- this[++offset] * 2 ** 8 +
1628
- this[++offset] * 2 ** 16 +
1629
- this[++offset] * 2 ** 24)
1630
- });
1631
-
1632
- Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
1633
- offset = offset >>> 0;
1634
- validateNumber(offset, 'offset');
1635
- const first = this[offset];
1636
- const last = this[offset + 7];
1637
- if (first === undefined || last === undefined) {
1638
- boundsError(offset, this.length - 8);
1639
- }
1640
-
1641
- const val = (first << 24) + // Overflow
1642
- this[++offset] * 2 ** 16 +
1643
- this[++offset] * 2 ** 8 +
1644
- this[++offset];
1645
-
1646
- return (BigInt(val) << BigInt(32)) +
1647
- BigInt(this[++offset] * 2 ** 24 +
1648
- this[++offset] * 2 ** 16 +
1649
- this[++offset] * 2 ** 8 +
1650
- last)
1651
- });
1652
-
1653
- Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1654
- offset = offset >>> 0;
1655
- if (!noAssert) checkOffset(offset, 4, this.length);
1656
- return ieee754.read(this, offset, true, 23, 4)
1657
- };
1658
-
1659
- Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1660
- offset = offset >>> 0;
1661
- if (!noAssert) checkOffset(offset, 4, this.length);
1662
- return ieee754.read(this, offset, false, 23, 4)
1663
- };
1664
-
1665
- Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1666
- offset = offset >>> 0;
1667
- if (!noAssert) checkOffset(offset, 8, this.length);
1668
- return ieee754.read(this, offset, true, 52, 8)
1669
- };
1670
-
1671
- Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1672
- offset = offset >>> 0;
1673
- if (!noAssert) checkOffset(offset, 8, this.length);
1674
- return ieee754.read(this, offset, false, 52, 8)
1675
- };
1676
-
1677
- function checkInt (buf, value, offset, ext, max, min) {
1678
- if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1679
- if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1680
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
1681
- }
1682
-
1683
- Buffer.prototype.writeUintLE =
1684
- Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1685
- value = +value;
1686
- offset = offset >>> 0;
1687
- byteLength = byteLength >>> 0;
1688
- if (!noAssert) {
1689
- const maxBytes = Math.pow(2, 8 * byteLength) - 1;
1690
- checkInt(this, value, offset, byteLength, maxBytes, 0);
1691
- }
1692
-
1693
- let mul = 1;
1694
- let i = 0;
1695
- this[offset] = value & 0xFF;
1696
- while (++i < byteLength && (mul *= 0x100)) {
1697
- this[offset + i] = (value / mul) & 0xFF;
1698
- }
1699
-
1700
- return offset + byteLength
1701
- };
1702
-
1703
- Buffer.prototype.writeUintBE =
1704
- Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1705
- value = +value;
1706
- offset = offset >>> 0;
1707
- byteLength = byteLength >>> 0;
1708
- if (!noAssert) {
1709
- const maxBytes = Math.pow(2, 8 * byteLength) - 1;
1710
- checkInt(this, value, offset, byteLength, maxBytes, 0);
1711
- }
1712
-
1713
- let i = byteLength - 1;
1714
- let mul = 1;
1715
- this[offset + i] = value & 0xFF;
1716
- while (--i >= 0 && (mul *= 0x100)) {
1717
- this[offset + i] = (value / mul) & 0xFF;
1718
- }
1719
-
1720
- return offset + byteLength
1721
- };
1722
-
1723
- Buffer.prototype.writeUint8 =
1724
- Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1725
- value = +value;
1726
- offset = offset >>> 0;
1727
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
1728
- this[offset] = (value & 0xff);
1729
- return offset + 1
1730
- };
1731
-
1732
- Buffer.prototype.writeUint16LE =
1733
- Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1734
- value = +value;
1735
- offset = offset >>> 0;
1736
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
1737
- this[offset] = (value & 0xff);
1738
- this[offset + 1] = (value >>> 8);
1739
- return offset + 2
1740
- };
1741
-
1742
- Buffer.prototype.writeUint16BE =
1743
- Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1744
- value = +value;
1745
- offset = offset >>> 0;
1746
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
1747
- this[offset] = (value >>> 8);
1748
- this[offset + 1] = (value & 0xff);
1749
- return offset + 2
1750
- };
1751
-
1752
- Buffer.prototype.writeUint32LE =
1753
- Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1754
- value = +value;
1755
- offset = offset >>> 0;
1756
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
1757
- this[offset + 3] = (value >>> 24);
1758
- this[offset + 2] = (value >>> 16);
1759
- this[offset + 1] = (value >>> 8);
1760
- this[offset] = (value & 0xff);
1761
- return offset + 4
1762
- };
1763
-
1764
- Buffer.prototype.writeUint32BE =
1765
- Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1766
- value = +value;
1767
- offset = offset >>> 0;
1768
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
1769
- this[offset] = (value >>> 24);
1770
- this[offset + 1] = (value >>> 16);
1771
- this[offset + 2] = (value >>> 8);
1772
- this[offset + 3] = (value & 0xff);
1773
- return offset + 4
1774
- };
1775
-
1776
- function wrtBigUInt64LE (buf, value, offset, min, max) {
1777
- checkIntBI(value, min, max, buf, offset, 7);
1778
-
1779
- let lo = Number(value & BigInt(0xffffffff));
1780
- buf[offset++] = lo;
1781
- lo = lo >> 8;
1782
- buf[offset++] = lo;
1783
- lo = lo >> 8;
1784
- buf[offset++] = lo;
1785
- lo = lo >> 8;
1786
- buf[offset++] = lo;
1787
- let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
1788
- buf[offset++] = hi;
1789
- hi = hi >> 8;
1790
- buf[offset++] = hi;
1791
- hi = hi >> 8;
1792
- buf[offset++] = hi;
1793
- hi = hi >> 8;
1794
- buf[offset++] = hi;
1795
- return offset
1796
- }
1797
-
1798
- function wrtBigUInt64BE (buf, value, offset, min, max) {
1799
- checkIntBI(value, min, max, buf, offset, 7);
1800
-
1801
- let lo = Number(value & BigInt(0xffffffff));
1802
- buf[offset + 7] = lo;
1803
- lo = lo >> 8;
1804
- buf[offset + 6] = lo;
1805
- lo = lo >> 8;
1806
- buf[offset + 5] = lo;
1807
- lo = lo >> 8;
1808
- buf[offset + 4] = lo;
1809
- let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
1810
- buf[offset + 3] = hi;
1811
- hi = hi >> 8;
1812
- buf[offset + 2] = hi;
1813
- hi = hi >> 8;
1814
- buf[offset + 1] = hi;
1815
- hi = hi >> 8;
1816
- buf[offset] = hi;
1817
- return offset + 8
1818
- }
1819
-
1820
- Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
1821
- return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
1822
- });
1823
-
1824
- Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
1825
- return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
1826
- });
1827
-
1828
- Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1829
- value = +value;
1830
- offset = offset >>> 0;
1831
- if (!noAssert) {
1832
- const limit = Math.pow(2, (8 * byteLength) - 1);
1833
-
1834
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
1835
- }
1836
-
1837
- let i = 0;
1838
- let mul = 1;
1839
- let sub = 0;
1840
- this[offset] = value & 0xFF;
1841
- while (++i < byteLength && (mul *= 0x100)) {
1842
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1843
- sub = 1;
1844
- }
1845
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
1846
- }
1847
-
1848
- return offset + byteLength
1849
- };
1850
-
1851
- Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1852
- value = +value;
1853
- offset = offset >>> 0;
1854
- if (!noAssert) {
1855
- const limit = Math.pow(2, (8 * byteLength) - 1);
1856
-
1857
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
1858
- }
1859
-
1860
- let i = byteLength - 1;
1861
- let mul = 1;
1862
- let sub = 0;
1863
- this[offset + i] = value & 0xFF;
1864
- while (--i >= 0 && (mul *= 0x100)) {
1865
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1866
- sub = 1;
1867
- }
1868
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
1869
- }
1870
-
1871
- return offset + byteLength
1872
- };
1873
-
1874
- Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1875
- value = +value;
1876
- offset = offset >>> 0;
1877
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
1878
- if (value < 0) value = 0xff + value + 1;
1879
- this[offset] = (value & 0xff);
1880
- return offset + 1
1881
- };
1882
-
1883
- Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1884
- value = +value;
1885
- offset = offset >>> 0;
1886
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
1887
- this[offset] = (value & 0xff);
1888
- this[offset + 1] = (value >>> 8);
1889
- return offset + 2
1890
- };
1891
-
1892
- Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1893
- value = +value;
1894
- offset = offset >>> 0;
1895
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
1896
- this[offset] = (value >>> 8);
1897
- this[offset + 1] = (value & 0xff);
1898
- return offset + 2
1899
- };
1900
-
1901
- Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1902
- value = +value;
1903
- offset = offset >>> 0;
1904
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
1905
- this[offset] = (value & 0xff);
1906
- this[offset + 1] = (value >>> 8);
1907
- this[offset + 2] = (value >>> 16);
1908
- this[offset + 3] = (value >>> 24);
1909
- return offset + 4
1910
- };
1911
-
1912
- Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1913
- value = +value;
1914
- offset = offset >>> 0;
1915
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
1916
- if (value < 0) value = 0xffffffff + value + 1;
1917
- this[offset] = (value >>> 24);
1918
- this[offset + 1] = (value >>> 16);
1919
- this[offset + 2] = (value >>> 8);
1920
- this[offset + 3] = (value & 0xff);
1921
- return offset + 4
1922
- };
1923
-
1924
- Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
1925
- return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
1926
- });
1927
-
1928
- Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
1929
- return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
1930
- });
1931
-
1932
- function checkIEEE754 (buf, value, offset, ext, max, min) {
1933
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
1934
- if (offset < 0) throw new RangeError('Index out of range')
1935
- }
1936
-
1937
- function writeFloat (buf, value, offset, littleEndian, noAssert) {
1938
- value = +value;
1939
- offset = offset >>> 0;
1940
- if (!noAssert) {
1941
- checkIEEE754(buf, value, offset, 4);
1942
- }
1943
- ieee754.write(buf, value, offset, littleEndian, 23, 4);
1944
- return offset + 4
1945
- }
1946
-
1947
- Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1948
- return writeFloat(this, value, offset, true, noAssert)
1949
- };
1950
-
1951
- Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1952
- return writeFloat(this, value, offset, false, noAssert)
1953
- };
1954
-
1955
- function writeDouble (buf, value, offset, littleEndian, noAssert) {
1956
- value = +value;
1957
- offset = offset >>> 0;
1958
- if (!noAssert) {
1959
- checkIEEE754(buf, value, offset, 8);
1960
- }
1961
- ieee754.write(buf, value, offset, littleEndian, 52, 8);
1962
- return offset + 8
1963
- }
1964
-
1965
- Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1966
- return writeDouble(this, value, offset, true, noAssert)
1967
- };
1968
-
1969
- Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1970
- return writeDouble(this, value, offset, false, noAssert)
1971
- };
1972
-
1973
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1974
- Buffer.prototype.copy = function copy (target, targetStart, start, end) {
1975
- if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
1976
- if (!start) start = 0;
1977
- if (!end && end !== 0) end = this.length;
1978
- if (targetStart >= target.length) targetStart = target.length;
1979
- if (!targetStart) targetStart = 0;
1980
- if (end > 0 && end < start) end = start;
1981
-
1982
- // Copy 0 bytes; we're done
1983
- if (end === start) return 0
1984
- if (target.length === 0 || this.length === 0) return 0
1985
-
1986
- // Fatal error conditions
1987
- if (targetStart < 0) {
1988
- throw new RangeError('targetStart out of bounds')
1989
- }
1990
- if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
1991
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
1992
-
1993
- // Are we oob?
1994
- if (end > this.length) end = this.length;
1995
- if (target.length - targetStart < end - start) {
1996
- end = target.length - targetStart + start;
1997
- }
1998
-
1999
- const len = end - start;
2000
-
2001
- if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
2002
- // Use built-in when available, missing from IE11
2003
- this.copyWithin(targetStart, start, end);
2004
- } else {
2005
- Uint8Array.prototype.set.call(
2006
- target,
2007
- this.subarray(start, end),
2008
- targetStart
2009
- );
2010
- }
2011
-
2012
- return len
2013
- };
2014
-
2015
- // Usage:
2016
- // buffer.fill(number[, offset[, end]])
2017
- // buffer.fill(buffer[, offset[, end]])
2018
- // buffer.fill(string[, offset[, end]][, encoding])
2019
- Buffer.prototype.fill = function fill (val, start, end, encoding) {
2020
- // Handle string cases:
2021
- if (typeof val === 'string') {
2022
- if (typeof start === 'string') {
2023
- encoding = start;
2024
- start = 0;
2025
- end = this.length;
2026
- } else if (typeof end === 'string') {
2027
- encoding = end;
2028
- end = this.length;
2029
- }
2030
- if (encoding !== undefined && typeof encoding !== 'string') {
2031
- throw new TypeError('encoding must be a string')
2032
- }
2033
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
2034
- throw new TypeError('Unknown encoding: ' + encoding)
2035
- }
2036
- if (val.length === 1) {
2037
- const code = val.charCodeAt(0);
2038
- if ((encoding === 'utf8' && code < 128) ||
2039
- encoding === 'latin1') {
2040
- // Fast path: If `val` fits into a single byte, use that numeric value.
2041
- val = code;
2042
- }
2043
- }
2044
- } else if (typeof val === 'number') {
2045
- val = val & 255;
2046
- } else if (typeof val === 'boolean') {
2047
- val = Number(val);
2048
- }
2049
-
2050
- // Invalid ranges are not set to a default, so can range check early.
2051
- if (start < 0 || this.length < start || this.length < end) {
2052
- throw new RangeError('Out of range index')
2053
- }
2054
-
2055
- if (end <= start) {
2056
- return this
2057
- }
2058
-
2059
- start = start >>> 0;
2060
- end = end === undefined ? this.length : end >>> 0;
2061
-
2062
- if (!val) val = 0;
2063
-
2064
- let i;
2065
- if (typeof val === 'number') {
2066
- for (i = start; i < end; ++i) {
2067
- this[i] = val;
2068
- }
2069
- } else {
2070
- const bytes = Buffer.isBuffer(val)
2071
- ? val
2072
- : Buffer.from(val, encoding);
2073
- const len = bytes.length;
2074
- if (len === 0) {
2075
- throw new TypeError('The value "' + val +
2076
- '" is invalid for argument "value"')
2077
- }
2078
- for (i = 0; i < end - start; ++i) {
2079
- this[i + start] = bytes[i % len];
2080
- }
2081
- }
2082
-
2083
- return this
2084
- };
2085
-
2086
- // CUSTOM ERRORS
2087
- // =============
2088
-
2089
- // Simplified versions from Node, changed for Buffer-only usage
2090
- const errors = {};
2091
- function E (sym, getMessage, Base) {
2092
- errors[sym] = class NodeError extends Base {
2093
- constructor () {
2094
- super();
2095
-
2096
- Object.defineProperty(this, 'message', {
2097
- value: getMessage.apply(this, arguments),
2098
- writable: true,
2099
- configurable: true
2100
- });
2101
-
2102
- // Add the error code to the name to include it in the stack trace.
2103
- this.name = `${this.name} [${sym}]`;
2104
- // Access the stack to generate the error message including the error code
2105
- // from the name.
2106
- this.stack; // eslint-disable-line no-unused-expressions
2107
- // Reset the name to the actual name.
2108
- delete this.name;
2109
- }
2110
-
2111
- get code () {
2112
- return sym
2113
- }
2114
-
2115
- set code (value) {
2116
- Object.defineProperty(this, 'code', {
2117
- configurable: true,
2118
- enumerable: true,
2119
- value,
2120
- writable: true
2121
- });
2122
- }
2123
-
2124
- toString () {
2125
- return `${this.name} [${sym}]: ${this.message}`
2126
- }
2127
- };
2128
- }
2129
-
2130
- E('ERR_BUFFER_OUT_OF_BOUNDS',
2131
- function (name) {
2132
- if (name) {
2133
- return `${name} is outside of buffer bounds`
2134
- }
2135
-
2136
- return 'Attempt to access memory outside buffer bounds'
2137
- }, RangeError);
2138
- E('ERR_INVALID_ARG_TYPE',
2139
- function (name, actual) {
2140
- return `The "${name}" argument must be of type number. Received type ${typeof actual}`
2141
- }, TypeError);
2142
- E('ERR_OUT_OF_RANGE',
2143
- function (str, range, input) {
2144
- let msg = `The value of "${str}" is out of range.`;
2145
- let received = input;
2146
- if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
2147
- received = addNumericalSeparator(String(input));
2148
- } else if (typeof input === 'bigint') {
2149
- received = String(input);
2150
- if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
2151
- received = addNumericalSeparator(received);
2152
- }
2153
- received += 'n';
2154
- }
2155
- msg += ` It must be ${range}. Received ${received}`;
2156
- return msg
2157
- }, RangeError);
2158
-
2159
- function addNumericalSeparator (val) {
2160
- let res = '';
2161
- let i = val.length;
2162
- const start = val[0] === '-' ? 1 : 0;
2163
- for (; i >= start + 4; i -= 3) {
2164
- res = `_${val.slice(i - 3, i)}${res}`;
2165
- }
2166
- return `${val.slice(0, i)}${res}`
2167
- }
2168
-
2169
- // CHECK FUNCTIONS
2170
- // ===============
2171
-
2172
- function checkBounds (buf, offset, byteLength) {
2173
- validateNumber(offset, 'offset');
2174
- if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
2175
- boundsError(offset, buf.length - (byteLength + 1));
2176
- }
2177
- }
2178
-
2179
- function checkIntBI (value, min, max, buf, offset, byteLength) {
2180
- if (value > max || value < min) {
2181
- const n = typeof min === 'bigint' ? 'n' : '';
2182
- let range;
2183
- {
2184
- if (min === 0 || min === BigInt(0)) {
2185
- range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
2186
- } else {
2187
- range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
2188
- `${(byteLength + 1) * 8 - 1}${n}`;
2189
- }
2190
- }
2191
- throw new errors.ERR_OUT_OF_RANGE('value', range, value)
2192
- }
2193
- checkBounds(buf, offset, byteLength);
2194
- }
2195
-
2196
- function validateNumber (value, name) {
2197
- if (typeof value !== 'number') {
2198
- throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
2199
- }
2200
- }
2201
-
2202
- function boundsError (value, length, type) {
2203
- if (Math.floor(value) !== value) {
2204
- validateNumber(value, type);
2205
- throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
2206
- }
2207
-
2208
- if (length < 0) {
2209
- throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
2210
- }
2211
-
2212
- throw new errors.ERR_OUT_OF_RANGE('offset',
2213
- `>= ${0} and <= ${length}`,
2214
- value)
2215
- }
2216
-
2217
- // HELPER FUNCTIONS
2218
- // ================
2219
-
2220
- const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
2221
-
2222
- function base64clean (str) {
2223
- // Node takes equal signs as end of the Base64 encoding
2224
- str = str.split('=')[0];
2225
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
2226
- str = str.trim().replace(INVALID_BASE64_RE, '');
2227
- // Node converts strings with length < 2 to ''
2228
- if (str.length < 2) return ''
2229
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2230
- while (str.length % 4 !== 0) {
2231
- str = str + '=';
2232
- }
2233
- return str
2234
- }
2235
-
2236
- function utf8ToBytes (string, units) {
2237
- units = units || Infinity;
2238
- let codePoint;
2239
- const length = string.length;
2240
- let leadSurrogate = null;
2241
- const bytes = [];
2242
-
2243
- for (let i = 0; i < length; ++i) {
2244
- codePoint = string.charCodeAt(i);
2245
-
2246
- // is surrogate component
2247
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
2248
- // last char was a lead
2249
- if (!leadSurrogate) {
2250
- // no lead yet
2251
- if (codePoint > 0xDBFF) {
2252
- // unexpected trail
2253
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2254
- continue
2255
- } else if (i + 1 === length) {
2256
- // unpaired lead
2257
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2258
- continue
2259
- }
2260
-
2261
- // valid lead
2262
- leadSurrogate = codePoint;
2263
-
2264
- continue
2265
- }
2266
-
2267
- // 2 leads in a row
2268
- if (codePoint < 0xDC00) {
2269
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2270
- leadSurrogate = codePoint;
2271
- continue
2272
- }
2273
-
2274
- // valid surrogate pair
2275
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
2276
- } else if (leadSurrogate) {
2277
- // valid bmp char, but last char was a lead
2278
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
2279
- }
2280
-
2281
- leadSurrogate = null;
2282
-
2283
- // encode utf8
2284
- if (codePoint < 0x80) {
2285
- if ((units -= 1) < 0) break
2286
- bytes.push(codePoint);
2287
- } else if (codePoint < 0x800) {
2288
- if ((units -= 2) < 0) break
2289
- bytes.push(
2290
- codePoint >> 0x6 | 0xC0,
2291
- codePoint & 0x3F | 0x80
2292
- );
2293
- } else if (codePoint < 0x10000) {
2294
- if ((units -= 3) < 0) break
2295
- bytes.push(
2296
- codePoint >> 0xC | 0xE0,
2297
- codePoint >> 0x6 & 0x3F | 0x80,
2298
- codePoint & 0x3F | 0x80
2299
- );
2300
- } else if (codePoint < 0x110000) {
2301
- if ((units -= 4) < 0) break
2302
- bytes.push(
2303
- codePoint >> 0x12 | 0xF0,
2304
- codePoint >> 0xC & 0x3F | 0x80,
2305
- codePoint >> 0x6 & 0x3F | 0x80,
2306
- codePoint & 0x3F | 0x80
2307
- );
2308
- } else {
2309
- throw new Error('Invalid code point')
2310
- }
2311
- }
2312
-
2313
- return bytes
2314
- }
2315
-
2316
- function asciiToBytes (str) {
2317
- const byteArray = [];
2318
- for (let i = 0; i < str.length; ++i) {
2319
- // Node's code seems to be doing this and not & 0x7F..
2320
- byteArray.push(str.charCodeAt(i) & 0xFF);
2321
- }
2322
- return byteArray
2323
- }
2324
-
2325
- function utf16leToBytes (str, units) {
2326
- let c, hi, lo;
2327
- const byteArray = [];
2328
- for (let i = 0; i < str.length; ++i) {
2329
- if ((units -= 2) < 0) break
2330
-
2331
- c = str.charCodeAt(i);
2332
- hi = c >> 8;
2333
- lo = c % 256;
2334
- byteArray.push(lo);
2335
- byteArray.push(hi);
2336
- }
2337
-
2338
- return byteArray
2339
- }
2340
-
2341
- function base64ToBytes (str) {
2342
- return base64.toByteArray(base64clean(str))
2343
- }
2344
-
2345
- function blitBuffer (src, dst, offset, length) {
2346
- let i;
2347
- for (i = 0; i < length; ++i) {
2348
- if ((i + offset >= dst.length) || (i >= src.length)) break
2349
- dst[i + offset] = src[i];
2350
- }
2351
- return i
2352
- }
2353
-
2354
- // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
2355
- // the `instanceof` check but they should be treated as of that type.
2356
- // See: https://github.com/feross/buffer/issues/166
2357
- function isInstance (obj, type) {
2358
- return obj instanceof type ||
2359
- (obj != null && obj.constructor != null && obj.constructor.name != null &&
2360
- obj.constructor.name === type.name)
2361
- }
2362
- function numberIsNaN (obj) {
2363
- // For IE11 support
2364
- return obj !== obj // eslint-disable-line no-self-compare
2365
- }
2366
-
2367
- // Create lookup table for `toString('hex')`
2368
- // See: https://github.com/feross/buffer/issues/219
2369
- const hexSliceLookupTable = (function () {
2370
- const alphabet = '0123456789abcdef';
2371
- const table = new Array(256);
2372
- for (let i = 0; i < 16; ++i) {
2373
- const i16 = i * 16;
2374
- for (let j = 0; j < 16; ++j) {
2375
- table[i16 + j] = alphabet[i] + alphabet[j];
2376
- }
2377
- }
2378
- return table
2379
- })();
2380
-
2381
- // Return not function with Error if BigInt not supported
2382
- function defineBigIntMethod (fn) {
2383
- return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
2384
- }
2385
-
2386
- function BufferBigIntNotDefined () {
2387
- throw new Error('BigInt not supported')
2388
- }
2389
- } (buffer));
2390
- return buffer;
2391
- }
2392
-
2393
- var bufferExports = requireBuffer();
2394
-
2395
- const encoder$3 = new TextEncoder();
2396
- const decoder$5 = new TextDecoder();
2397
-
2398
-
2399
- const NB = numberBuffer;
2400
- /**
2401
- * Create a typed buffer with a specific type and initial value
2402
- * @param {string} type - Buffer type (8, 16, 32, F, N)
2403
- * @param {number} [initValue=0] - Initial value for the buffer
2404
- * @returns {Buffer} Typed buffer
2405
- * @throws {TypeError} If invalid type or initValue is provided
2406
- */
2407
- function numberBuffer(type, initValue = 0) {
2408
- let buffer;
2409
- if (type === undefined || typeof type !== 'string' || typeof initValue !== 'number') {
2410
- throw TypeError('invlaid init variablie type name. ')
2411
- }
2412
- type = type.toUpperCase();
2413
-
2414
- if (type.includes('8')) {
2415
- buffer = bufferExports.Buffer.alloc(1);
2416
- if (type.includes('I')) buffer.writeInt8(initValue);
2417
- else buffer.writeUint8(initValue);
2418
- } else if (type.includes('16')) {
2419
- buffer = bufferExports.Buffer.alloc(2);
2420
- if (type.includes('I')) {
2421
- if (type.includes('L')) buffer.writeInt16LE(initValue);
2422
- else buffer.writeInt16BE(initValue);
2423
- } else {
2424
- if (type.includes('L')) buffer.writeUint16LE(initValue);
2425
- else buffer.writeUint16BE(initValue);
2426
- }
2427
- } else if (type.includes('32')) {
2428
- buffer = bufferExports.Buffer.alloc(4);
2429
- if (type.includes('I')) {
2430
- if (type.includes('L')) buffer.writeInt32LE(initValue);
2431
- else buffer.writeInt32BE(initValue);
2432
- } else {
2433
- if (type.includes('L')) buffer.writeUint32LE(initValue);
2434
- else buffer.writeUint32BE(initValue);
2435
- }
2436
- } else if (type.includes('F')) {
2437
- buffer = bufferExports.Buffer.alloc(4);
2438
- if (type.includes('L')) {
2439
- buffer.writeFloatLE(initValue);
2440
- } else {
2441
- buffer.writeFloatBE(initValue);
2442
- }
2443
- } else if (type.includes('N')) { // number as string
2444
- buffer = bufferExports.Buffer.from(String(initValue));
2445
- } else {
2446
- console.log(`invalid type: ${type} or initvalue: ${initValue}`);
2447
- }
2448
- return buffer
2449
- }
2450
-
2451
-
2452
- const MB$1 = metaBuffer;
2453
- /**
2454
- * Create a meta buffer with name, type, and initial value
2455
- * @param {number|string} name - Name of the buffer
2456
- * @param {number|string|Uint8Array|ArrayBuffer|Object|boolean} typeOrData - Data type or value
2457
- * @param {number|string|undefined} [initValue] - Initial value for numeric types
2458
- * @returns {[string, string, Buffer]} metaBufferTuple containing name, buffer type, and buffer
2459
- * @throws {TypeError} If invalid meta buffer type is provided
2460
- */
2461
- function metaBuffer(name, typeOrData, initValue) {
2462
- let buffer;
2463
- let bufferType = 'B';
2464
- if (typeof typeOrData === 'number') {
2465
- if (typeof initValue === 'number') { // initValue 0 should be passed.
2466
- buffer = bufferExports.Buffer.alloc(typeOrData);
2467
- if (initValue !== 0) buffer.fill(initValue);
2468
- bufferType = 'B';
2469
- } else {
2470
- buffer = bufferExports.Buffer.from(String(typeOrData));
2471
- bufferType = 'N';
2472
- }
2473
- } else if (typeof typeOrData === 'string' && typeof initValue === 'number') { // number with type.
2474
- bufferType = typeOrData.toUpperCase(); // use explicit type name
2475
- buffer = numberBuffer(typeOrData, initValue); // notice. two categories. n: number string. 8, 16, 32: typed number.
2476
- } else if (typeof typeOrData === 'string' && initValue === undefined) { // string buffer
2477
- buffer = bufferExports.Buffer.from(typeOrData);
2478
- bufferType = 'S';
2479
- } else if (typeOrData instanceof Uint8Array && initValue === undefined) { // buffer | Uint8Array
2480
- // Buffer.from: Copies the passed buffer data onto a new Buffer instance.
2481
- // typecasting Uint8Array to Buffer.
2482
- buffer = (typeOrData instanceof bufferExports.Buffer) ? typeOrData : bufferExports.Buffer.from(typeOrData);
2483
- } else if (typeOrData instanceof ArrayBuffer && initValue === undefined) { // arrayBuffer
2484
- // Notice. typedArray is recommended instead of arrayBuffer
2485
- buffer = bufferExports.Buffer.from(typeOrData);
2486
- } else if (ArrayBuffer.isView(typeOrData)) { // typedarray buffer
2487
- buffer = bufferExports.Buffer.from(typeOrData.buffer, typeOrData.byteOffset, typeOrData.byteLength);
2488
- } else if (typeof typeOrData === 'object' && initValue === undefined) { // object. like array. stringify
2489
- buffer = bufferExports.Buffer.from(JSON.stringify(typeOrData));
2490
- bufferType = 'O';
2491
- } else if (typeof typeOrData === 'boolean' && initValue === undefined) { // object. like array. stringify
2492
- const v = typeOrData ? 1 : 0;
2493
- buffer = bufferExports.Buffer.from([v]);
2494
- bufferType = '!';
2495
- } else {
2496
- throw TypeError('invalid meta buffer type')
2497
- }
2498
-
2499
- if (typeof name === 'string' && name.includes('#')) name = ''; //
2500
-
2501
- return [name, bufferType, buffer]
2502
- }
2503
-
2504
- const MBA = metaBufferArguments;
2505
- /**
2506
- * Create meta buffers from arguments
2507
- * @param {...any} args - Arguments to create meta buffers
2508
- * @returns {Array<[string, string, Buffer]>} Array of meta buffer tuples
2509
- */
2510
- function metaBufferArguments(...args) {
2511
- let i = 0;
2512
- const mba = args.map(
2513
- data => {
2514
- const argsIndex = i++;
2515
- // tip. MBA use index number as metabuffer's property name.
2516
- if (typeof data === 'number') {
2517
- // * JS's primitive Number stored as string.
2518
- return MB$1(argsIndex, 'N', data)
2519
- } else {
2520
- // typedarray, dataview, array, object, boolean
2521
- return MB$1(argsIndex, data)
2522
- }
2523
- });
2524
-
2525
- return mba
2526
- }
2527
-
2528
- function parseTypeName(type) {
2529
- type = type.toUpperCase();
2530
-
2531
- if (type.includes('8')) {
2532
- if (type.includes('I')) {
2533
- return 'int8'
2534
- } else {
2535
- return 'uint8'
2536
- }
2537
- } else if (type.includes('16')) {
2538
- if (type.includes('I')) {
2539
- if (type.includes('L')) {
2540
- return 'int16_le'
2541
- } else {
2542
- return 'int16_be'
2543
- }
2544
- } else {
2545
- if (type.includes('L')) {
2546
- return 'uint16_le'
2547
- } else {
2548
- return 'uint16_be'
2549
- }
2550
- }
2551
- } else if (type.includes('32')) {
2552
- if (type.includes('I')) {
2553
- if (type.includes('L')) {
2554
- return 'int32_le'
2555
- } else {
2556
- return 'int32_be'
2557
- }
2558
- } else {
2559
- if (type.includes('L')) {
2560
- return 'uint32_le'
2561
- } else {
2562
- return 'uint32_be'
2563
- }
2564
- }
2565
- } else if (type.includes('F')) {
2566
- if (type.includes('L')) {
2567
- return 'float_le'
2568
- } else {
2569
- return 'float_be'
2570
- }
2571
- } else if (type === 'B') {
2572
- return 'buffer'
2573
- } else if (type === 'S') { // string or arguments
2574
- return 'string'
2575
- } else if (type === 'N') { // number encoded as string
2576
- return 'number'
2577
- } else if (type === 'O') { // object encoded string
2578
- return 'object'
2579
- } else if (type === '!') { // boolean 1:true 0:false
2580
- return 'boolean'
2581
- } else {
2582
- throw TypeError('invalid data type')
2583
- }
2584
-
2585
- }
2586
-
2587
- function readTypedBuffer(simpleType, buffer, offset, length) {
2588
- try {
2589
- const type = parseTypeName(simpleType);
2590
- if (type == 'int8') return buffer.readInt8(offset)
2591
- else if (type === 'uint8') return buffer.readUint8(offset)
2592
- else if (type === 'int16_le') return buffer.readInt16LE(offset)
2593
- else if (type === 'int16_be') return buffer.readInt16BE(offset)
2594
- else if (type === 'uint16_le') return buffer.readUint16LE(offset)
2595
- else if (type === 'uint16_be') return buffer.readUint16BE(offset)
2596
- else if (type === 'int32_le') return buffer.readInt32LE(offset)
2597
- else if (type === 'int32_be') return buffer.readInt32BE(offset)
2598
- else if (type === 'uint32_le') return buffer.readUint32LE(offset)
2599
- else if (type === 'uint32_be') return buffer.readUint32BE(offset)
2600
- else if (type === 'float_le') return buffer.readFloatLE(offset)
2601
- else if (type === 'float_be') return buffer.readFloatBE(offset)
2602
-
2603
- else if (type === 'buffer') {
2604
- return buffer.subarray(offset, offset + length)
2605
- } else if (type === 'string') {
2606
- const strBuffer = buffer.subarray(offset, offset + length);
2607
- return decoder$5.decode(strBuffer)
2608
- } else if (type === 'number') {
2609
- const strNumber = buffer.subarray(offset, offset + length);
2610
- return Number(decoder$5.decode(strNumber))
2611
- } else if (type === 'object') {
2612
- const objEncoded = buffer.subarray(offset, offset + length);
2613
- return JSON.parse(decoder$5.decode(objEncoded))
2614
- } else if (type === 'boolean') {
2615
- const v = buffer.readInt8(offset);
2616
- return v === 1
2617
- } else {
2618
- return
2619
- }
2620
- } catch (error) {
2621
- // console.log('MBP:readTypedBuffer obj decoding error.', error)
2622
- }
2623
- // any error and invalid data return undefined
2624
- return
2625
- }
2626
-
2627
- // to join MBA or MB meta list.
2628
- function flatArray(args) {
2629
- let subArr = [];
2630
- const mainArr = args.filter(item => {
2631
- if (Array.isArray(item[0])) subArr = subArr.concat(item);
2632
- else return item
2633
- });
2634
- return mainArr.concat(subArr)
2635
- }
2636
-
2637
- /**
2638
- * Pack data with metadata
2639
- * @param {...any} args - Data to pack
2640
- * @returns {Buffer} Packed buffer with metadata
2641
- */
2642
- function pack$1(...args) {
2643
- const bufArr = flatArray(args);
2644
- // console.log('MBP.pack: flat MB or MBA list', bufArr)
2645
- let size = 0;
2646
- const info = [];
2647
- let offset = 0;
2648
-
2649
- bufArr.forEach(bufPack => {
2650
- const [name, type, data] = bufPack;
2651
- size += data.byteLength;
2652
-
2653
- if (typeof name === 'number' || name.length > 0) {
2654
- // if the item has property name then add meta JSON info.
2655
- // type of name is Number in MBA.(index number)
2656
- // type of name is String in MB. except null string.
2657
- // add additional informative meta info.
2658
- info.push([name, type, offset, data.byteLength]);
2659
- }
2660
- offset = size;
2661
- });
2662
-
2663
-
2664
- // console.log('MBP.pack meta:', info )
2665
- let infoEncoded;
2666
- let infoSize;
2667
-
2668
- if (info.length > 0) {
2669
- let infoStr = JSON.stringify(info);
2670
- // console.log('pack infoStr , size:', infoStr , infoStr.length )
2671
- infoEncoded = encoder$3.encode(infoStr);
2672
- infoSize = infoEncoded.byteLength;
2673
- size = size + infoSize + 2;
2674
- }
2675
-
2676
- const buffer = bufferExports.Buffer.alloc(size);
2677
- offset = 0;
2678
- bufArr.forEach(bufPack => {
2679
- const buf = bufPack[2];
2680
- buffer.set(buf, offset);
2681
- offset += buf.byteLength;
2682
- });
2683
-
2684
- if (info.length > 0) {
2685
- buffer.set(infoEncoded, offset);
2686
- const infoSizeBuff = NB('16', infoSize);
2687
- buffer.set(infoSizeBuff, offset + infoSize);
2688
- return buffer
2689
- } else {
2690
- return buffer
2691
- }
2692
- }
2693
-
2694
-
2695
- /**
2696
- * unpack() will use embeded meta info from the binary pack.
2697
- * You can specify (optional) meta obejct.
2698
- * (It's useful to read pure buffer data.)
2699
- *
2700
- * You can get the meta object from: meta()
2701
- * @param {Buffer|Uint8Array} binPack binaryData
2702
- * @param {Object} meta *OPTION*
2703
- * @returns {Object|undefined} success: return Object (include buffer data). fail: return undefined
2704
- */
2705
- /**
2706
- * Unpack data from buffer using metadata
2707
- * @param {Buffer|Uint8Array} binPack - Binary data to unpack
2708
- * @param {Object} [meta] - Optional metadata object
2709
- * @returns {Object|undefined} Unpacked data or undefined if failed
2710
- */
2711
- function unpack(binPack, meta) {
2712
-
2713
- const infoArr = meta || getMeta(binPack);
2714
- if (!infoArr) return
2715
-
2716
- const buffer = bufferExports.Buffer.from(binPack);
2717
- const binObj = {};
2718
- let readCounter = 0;
2719
- infoArr.forEach(bufPack => {
2720
- const [name, type, offset, length] = bufPack;
2721
- let result = readTypedBuffer(type, buffer, offset, length);
2722
- if (result == undefined) return
2723
- binObj[name] = result;
2724
- if (length) readCounter += length;
2725
- });
2726
-
2727
- // Can not define meta for variable size buffer
2728
- // unpacker support automatic property to read left(did't read) buffers.
2729
- // console.log("######, unpack: buffer " , readCounter, buffer ,buffer.byteLength)
2730
- if (meta && buffer.byteLength !== readCounter) {
2731
- let leftSize = buffer.byteLength - readCounter;
2732
- // console.log('total,left buffer size', buffer.byteLength, leftSize )
2733
- let result = readTypedBuffer('b', buffer, readCounter, leftSize);
2734
- if (result == undefined) return
2735
- binObj["$OTHERS"] = result;
2736
- }
2737
-
2738
- // set args with values if exist.
2739
- let mbaIndex = 0;
2740
- let args = [];
2741
- while (binObj[mbaIndex]) {
2742
- args.push(binObj[mbaIndex++]);
2743
- }
2744
-
2745
- if (args.length > 0) {
2746
- binObj.args = args;
2747
- binObj.$ = binObj.args;
2748
- }
2749
- return binObj
2750
- }
2751
-
2752
-
2753
- const U8 = parseUint8Array; //alias
2754
- /**
2755
- *
2756
- * @param {any} data
2757
- * @param {Boolean} shareArrayBuffer false(default): return new( or copied) ArrayBuffer. true: share the input data's arrayBuffer.
2758
- * @returns {Uint8Array}
2759
- */
2760
- /**
2761
- * Parse data into Uint8Array
2762
- * @param {any} data - Data to parse
2763
- * @param {boolean} [shareArrayBuffer=false] - Whether to share the input data's array buffer
2764
- * @returns {Uint8Array} Parsed Uint8Array
2765
- */
2766
- function parseUint8Array(data, shareArrayBuffer = false) {
2767
- if (data === undefined) throw TypeError('Invalid data type: Undefined')
2768
- if (typeof data === 'string') {
2769
- return encoder$3.encode(data)
2770
- } else if (typeof data === 'number') { // number -> 1 byte uint8array(number)
2771
- return Uint8Array.from([data])
2772
- } else if (data instanceof ArrayBuffer) { // arraybuffer -> wrap uint8array(ab)
2773
- if (shareArrayBuffer) {
2774
- return new Uint8Array(data)
2775
- } else {
2776
- const originData = new Uint8Array(data);
2777
- const dataCopy = new Uint8Array(data.byteLength);
2778
- dataCopy.set(originData);
2779
- return dataCopy
2780
- }
2781
- } else if (ArrayBuffer.isView(data)) { // accept Buffer too.
2782
- if (shareArrayBuffer) {
2783
- return new Uint8Array(data.buffer, data.byteOffset, data.byteLength) // DataView, TypedArray > uint8array( use offset, length )
2784
- } else {
2785
- // new memory to protect origin arraybuffer.
2786
- const originData = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
2787
- const dataCopy = new Uint8Array(data.byteLength);
2788
- dataCopy.set(originData);
2789
- return dataCopy
2790
- }
2791
- } else { // array, object
2792
- return encoder$3.encode(JSON.stringify(data)) // object(array.. ) > JSON.str > encode > unint8array
2793
- }
2794
- }
2795
-
2796
- const B8 = parseBuffer;
2797
- /**
2798
- * Parse data into Buffer
2799
- * @param {any} data - Data to parse
2800
- * @param {boolean} [shareArrayBuffer=false] - Whether to share the input data's array buffer
2801
- * @returns {Buffer} Parsed Buffer
2802
- */
2803
- function parseBuffer(data, shareArrayBuffer = false) {
2804
-
2805
- const u8 = parseUint8Array(data, shareArrayBuffer);
2806
- if (shareArrayBuffer) {
2807
- return bufferExports.Buffer.from(u8.buffer, u8.byteOffset, u8.byteLength)
2808
- } else {
2809
- return bufferExports.Buffer.from(u8)
2810
- }
2811
- }
2812
-
2813
- const B8pack = parseBufferThenConcat;
2814
- function parseBufferThenConcat(...dataArray) {
2815
- const buffers = dataArray.map(data => parseBuffer(data));
2816
- return bufferExports.Buffer.concat(buffers)
2817
- }
2818
-
2819
-
2820
- const U8pack = parseUint8ThenConcat; // alias
2821
- /**
2822
- * 1. parse list of data into U8 list
2823
- * 2. return new Uint8Array merged.
2824
- * @param {...any} dataArray
2825
- * @returns
2826
- */
2827
- function parseUint8ThenConcat(...dataArray) {
2828
- try {
2829
- let bufferSize = 0;
2830
- let offset = 0;
2831
- const buffers = dataArray.map(data => parseUint8Array(data));
2832
- buffers.forEach(buf => { bufferSize += buf.byteLength; });
2833
- const buffer = new Uint8Array(bufferSize);
2834
- buffers.forEach(buf => {
2835
- buffer.set(buf, offset);
2836
- offset += buf.byteLength;
2837
- });
2838
- return buffer
2839
- } catch (error) {
2840
- console.log(error);
2841
- }
2842
- }
2843
-
2844
- function hex(buffer) {
2845
- return Array.prototype.map.call(new Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2)).join('')
2846
- }
2847
-
2848
- function equal(buf1, buf2) {
2849
- if (buf1.byteLength !== buf2.byteLength) return false
2850
- for (let i = 0; i < buf1.byteLength; i++) {
2851
- if (buf1[i] !== buf2[i]) return false
2852
- }
2853
- return true
2854
- }
2855
-
2856
-
2857
- function getBufferSize(binPack) {
2858
- if (getMetaSize(binPack) === 0) {
2859
- return binPack.byteLength
2860
- } else {
2861
- return binPack.byteLength - getMetaSize(binPack) - TAIL_LEN
2862
- }
2863
- }
2864
-
2865
- // MB and MBA
2866
- function parseMetaInfo(binPack, infoSize) {
2867
- try {
2868
- const buffer = new Uint8Array(binPack.buffer, binPack.byteOffset, binPack.byteLength);
2869
- const infoFrom = buffer.byteLength - infoSize - 2;
2870
- const infoEncoded = buffer.subarray(infoFrom, buffer.byteLength - 2);
2871
- const decoded = decoder$5.decode(infoEncoded);
2872
- const info = JSON.parse(decoded);
2873
-
2874
- if (!Array.isArray(info) || !Array.isArray(info[0])) return
2875
-
2876
- let firstItem = info[0];
2877
- if (!firstItem) return
2878
-
2879
- if (firstItem.length < 3) return
2880
- const [name, type, offset] = firstItem;
2881
-
2882
- if (typeof type !== 'string' || typeof offset !== 'number') return
2883
-
2884
- return info
2885
- } catch (error) {
2886
- // return undefined
2887
- }
2888
- }
2889
-
2890
-
2891
- /**
2892
- * Meta buffer pack Tail:
2893
- * binary Pack include TAIL(two bytes size) info at the end if it has JSON info.
2894
- * not include TAIL if it has not JSON.
2895
- */
2896
- const TAIL_LEN = 2;
2897
-
2898
- /**
2899
- *
2900
- * @param {Buffer|Uint8Array|ArrayBuffer} binPack
2901
- * @returns {Number} last two byte value( read Uint16 bigendian )
2902
- */
2903
- function readTail(binPack) {
2904
- if (binPack instanceof ArrayBuffer) {
2905
- binPack = bufferExports.Buffer.from(binPack); // creates a view for ArrayBuffer, without copying.
2906
- }
2907
- if (binPack instanceof Uint8Array) {
2908
- if (binPack.byteLength <= TAIL_LEN) return 0
2909
-
2910
- const dv = new DataView(binPack.buffer, binPack.byteOffset, binPack.byteLength);
2911
- const infoSize = dv.getUint16(binPack.byteLength - TAIL_LEN); // last 2 bytes for json-info-length.
2912
- return infoSize
2913
-
2914
- } else {
2915
- // throw TypeError('invalid data type.')
2916
- return 0
2917
- }
2918
-
2919
- }
2920
-
2921
-
2922
- // binay data pack is not always Buffer.
2923
- // It should accept Uint8Array binPack.
2924
- // This function don't use Buffer method.
2925
-
2926
- function getMetaSize(binPack) {
2927
- if (binPack instanceof ArrayBuffer) {
2928
- binPack = bufferExports.Buffer.from(binPack); // creates a view for ArrayBuffer, without copying.
2929
- }
2930
- if (binPack instanceof Uint8Array) {
2931
-
2932
- const size = binPack.byteLength;
2933
- if (size <= TAIL_LEN) return 0
2934
-
2935
- //1. tail size check
2936
- const infoSize = readTail(binPack);
2937
- if (infoSize === 0 || infoSize > size) return 0
2938
- //2. try parse JSON
2939
- const success = parseMetaInfo(binPack, infoSize);
2940
- //3. return success: jsonInfoSize, fail: 0
2941
- if (success) return infoSize
2942
- else return 0
2943
- } else {
2944
- return 0
2945
- }
2946
- }
2947
-
2948
-
2949
- /**
2950
- *
2951
- * @param {Buffer|Uint8Array} binPack
2952
- * @returns {Buffer}
2953
- */
2954
- function getBuffer(binPack) {
2955
- const rawBufferSize = getBufferSize(binPack);
2956
- return binPack.subarray(0, rawBufferSize)
2957
- }
2958
-
2959
-
2960
-
2961
- /**
2962
- * extract Meta info object if it has.
2963
- *
2964
- * @param {Buffer|Uint8Array|ArrayBuffer} binPack
2965
- * @param {Boolean} showDetail add additional item info: full data type name and bytelength.
2966
- * @returns {Object|undefined} success: return MetaInfo Object. fail: return undefined.(No valid JSON included.)
2967
- */
2968
- /**
2969
- * Extract metadata from buffer
2970
- * @param {Buffer|Uint8Array|ArrayBuffer} binPack - Binary data to extract metadata from
2971
- * @param {boolean} [showDetail=false] - Whether to show detailed information
2972
- * @returns {Object|undefined} Metadata object or undefined if no valid JSON included
2973
- */
2974
- function getMeta(binPack, showDetail = false) {
2975
- if (binPack instanceof ArrayBuffer) {
2976
- binPack = bufferExports.Buffer.from(binPack); // creates a view for ArrayBuffer, without copying.
2977
- }
2978
- const infoSize = readTail(binPack);
2979
- if (infoSize === 0) return
2980
-
2981
- // check valid Meta
2982
- let metaInfo = parseMetaInfo(binPack, infoSize);
2983
- if (!metaInfo) return
2984
-
2985
- if (!showDetail) {
2986
- return metaInfo
2987
- } else {
2988
- // add additional info
2989
- metaInfo.forEach(bufPack => {
2990
- const len = bufPack[3];
2991
- if (len == undefined) { // add size info.
2992
- if (bufPack[1].includes('8')) bufPack[3] = 1;
2993
- else if (bufPack[1].includes('16')) bufPack[3] = 2;
2994
- else if (bufPack[1].includes('32')) bufPack[3] = 4;
2995
- else if (bufPack[1].includes('F')) bufPack[3] = 4;
2996
- else if (bufPack[1].includes('!')) bufPack[3] = 1;
2997
- }
2998
- bufPack[4] = parseTypeName(bufPack[1]); // add full-type-name.
2999
- });
3000
- return metaInfo
3001
- }
3002
- }
3003
-
3004
- function rawPack(...args) {
3005
- return getBuffer(pack$1(...args))
3006
- }
3007
-
3008
- function meta(...args) {
3009
- return getMeta(pack$1(...args))
3010
- }
3011
-
3012
- function metaDetail(...args) {
3013
- return getMeta(pack$1(...args), true)
3014
- }
21
+ var t$1,e$1={},r$1={};var n$1,i$1,o$1={};
22
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function f$1(){return n$1||(n$1=1,o$1.read=function(t,e,r,n,i){var o,f,u=8*i-n-1,s=(1<<u)-1,h=s>>1,a=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-a)-1,p>>=-a,a+=u;a>0;o=256*o+t[e+c],c+=l,a-=8);for(f=o&(1<<-a)-1,o>>=-a,a+=n;a>0;f=256*f+t[e+c],c+=l,a-=8);if(0===o)o=1-h;else {if(o===s)return f?NaN:1/0*(p?-1:1);f+=Math.pow(2,n),o-=h;}return (p?-1:1)*f*Math.pow(2,o-n)},o$1.write=function(t,e,r,n,i,o){var f,u,s,h=8*o-i-1,a=(1<<h)-1,c=a>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,f=a):(f=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-f))<1&&(f--,s*=2),(e+=f+c>=1?l/s:l*Math.pow(2,1-c))*s>=2&&(f++,s/=2),f+c>=a?(u=0,f=a):f+c>=1?(u=(e*s-1)*Math.pow(2,i),f+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,i),f=0));i>=8;t[r+p]=255&u,p+=y,u/=256,i-=8);for(f=f<<i|u,h+=i;h>0;t[r+p]=255&f,p+=y,f/=256,h-=8);t[r+p-y]|=128*g;}),o$1}
23
+ /*!
24
+ * The buffer module from node.js, for the browser.
25
+ *
26
+ * @author Feross Aboukhadijeh <https://feross.org>
27
+ * @license MIT
28
+ */var u$1=(i$1||(i$1=1,function(e){const n=function(){if(t$1)return r$1;t$1=1,r$1.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r$1.toByteArray=function(t){var e,r,o=u(t),f=o[0],s=o[1],h=new i(function(t,e,r){return 3*(e+r)/4-r}(0,f,s)),a=0,c=s>0?f-4:f;for(r=0;r<c;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],h[a++]=e>>16&255,h[a++]=e>>8&255,h[a++]=255&e;return 2===s&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,h[a++]=255&e),1===s&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,h[a++]=e>>8&255,h[a++]=255&e),h},r$1.fromByteArray=function(t){for(var r,n=t.length,i=n%3,o=[],f=16383,u=0,s=n-i;u<s;u+=f)o.push(h(t,u,u+f>s?s:u+f));return 1===i?(r=t[n-1],o.push(e[r>>2]+e[r<<4&63]+"==")):2===i&&(r=(t[n-2]<<8)+t[n-1],o.push(e[r>>10]+e[r>>4&63]+e[r<<2&63]+"=")),o.join("")};for(var e=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0;f<64;++f)e[f]=o[f],n[o.charCodeAt(f)]=f;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return -1===r&&(r=e),[r,r===e?0:4-r%4]}function s(t){return e[t>>18&63]+e[t>>12&63]+e[t>>6&63]+e[63&t]}function h(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(s(n));return i.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r$1}(),i=f$1(),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=h,e.SlowBuffer=function(t){return +t!=t&&(t=0),h.alloc(+t)},e.INSPECT_MAX_BYTES=50;const u=2147483647;function s(t){if(t>u)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,h.prototype),e}function h(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return a(t,e,r)}function a(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|d(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(H(t,Uint8Array)){const e=new Uint8Array(t);return y(e.buffer,e.byteOffset,e.byteLength)}return p(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return y(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(H(t,SharedArrayBuffer)||t&&H(t.buffer,SharedArrayBuffer)))return y(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return h.from(n,e,r);const i=function(t){if(h.isBuffer(t)){const e=0|g(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Z(t.length)?s(0):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return h.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return c(t),s(t<0?0:0|g(t))}function p(t){const e=t.length<0?0:0|g(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function y(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,h.prototype),n}function g(t){if(t>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return 0|t}function d(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&true===arguments[2];if(!n&&0===r)return 0;let i=false;for(;;)switch(e){case "ascii":case "latin1":case "binary":return r;case "utf8":case "utf-8":return q(t).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*r;case "hex":return r>>>1;case "base64":return W(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=true;}}function b(t,e,r){let n=false;if((void 0===e||e<0)&&(e=0),e>this.length)return "";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return "";if((r>>>=0)<=(e>>>=0))return "";for(t||(t="utf8");;)switch(t){case "hex":return S(this,e,r);case "utf8":case "utf-8":return O(this,e,r);case "ascii":return _(this,e,r);case "latin1":case "binary":return R(this,e,r);case "base64":return v(this,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return N(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=true;}}function w(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function B(t,e,r,n,i){if(0===t.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Z(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return -1;r=t.length-1;}else if(r<0){if(!i)return -1;r=0;}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,i){let o,f=1,u=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return -1;f=2,u/=2,s/=2,r/=2;}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(i){let n=-1;for(o=r;o<u;o++)if(h(t,o)===h(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===s)return n*f}else -1!==n&&(o-=o-n),n=-1;}else for(r+s>u&&(r=u-s),o=r;o>=0;o--){let r=true;for(let n=0;n<s;n++)if(h(t,o+n)!==h(e,n)){r=false;break}if(r)return o}return -1}function E(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let f;for(n>o/2&&(n=o/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(Z(n))return f;t[r+f]=n;}return f}function A(t,e,r,n){return X(q(e,t.length-r),t,r,n)}function U(t,e,r,n){return X(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function I(t,e,r,n){return X(W(e),t,r,n)}function L(t,e,r,n){return X(function(t,e){let r,n,i;const o=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function v(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function O(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,f=e>239?4:e>223?3:e>191?2:1;if(i+f<=r){let r,n,u,s;switch(f){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(s=(31&e)<<6|63&r,s>127&&(o=s));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(s=(15&e)<<12|(63&r)<<6|63&n,s>2047&&(s<55296||s>57343)&&(o=s));break;case 4:r=t[i+1],n=t[i+2],u=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&u)&&(s=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&u,s>65535&&s<1114112&&(o=s));}}null===o?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=f;}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=T));return r}(n)}e.kMaxLength=u,h.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return false}}(),h.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(h.prototype,"parent",{enumerable:true,get:function(){if(h.isBuffer(this))return this.buffer}}),Object.defineProperty(h.prototype,"offset",{enumerable:true,get:function(){if(h.isBuffer(this))return this.byteOffset}}),h.poolSize=8192,h.from=function(t,e,r){return a(t,e,r)},Object.setPrototypeOf(h.prototype,Uint8Array.prototype),Object.setPrototypeOf(h,Uint8Array),h.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},h.allocUnsafe=function(t){return l(t)},h.allocUnsafeSlow=function(t){return l(t)},h.isBuffer=function(t){return null!=t&&true===t._isBuffer&&t!==h.prototype},h.compare=function(t,e){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),H(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(t)||!h.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},h.isEncoding=function(t){switch(String(t).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return true;default:return false}},h.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return h.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=h.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(H(e,Uint8Array))i+e.length>n.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else {if(!h.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i);}i+=e.length;}return n},h.byteLength=d,h.prototype._isBuffer=true,h.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},h.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},h.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},h.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):b.apply(this,arguments)},h.prototype.toLocaleString=h.prototype.toString,h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(h.prototype[o]=h.prototype.inspect),h.prototype.compare=function(t,e,r,n,i){if(H(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return -1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const u=Math.min(o,f),s=this.slice(n,i),a=t.slice(e,r);for(let t=0;t<u;++t)if(s[t]!==a[t]){o=s[t],f=a[t];break}return o<f?-1:f<o?1:0},h.prototype.includes=function(t,e,r){return -1!==this.indexOf(t,e,r)},h.prototype.indexOf=function(t,e,r){return B(this,t,e,r,true)},h.prototype.lastIndexOf=function(t,e,r){return B(this,t,e,r,false)},h.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else {if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=false;for(;;)switch(n){case "hex":return E(this,t,e,r);case "utf8":case "utf-8":return A(this,t,e,r);case "ascii":case "latin1":case "binary":return U(this,t,e,r);case "base64":return I(this,t,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return L(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=true;}},h.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function _(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function R(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function S(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=K[t[n]];return i}function N(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function C(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,i,o){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function x(t,e,r,n,i){Y(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function $(t,e,r,n,i){Y(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function k(t,e,r,n,o){return e=+e,r>>>=0,o||P(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||P(t,0,r,8),i.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,h.prototype),n},h.prototype.readUintLE=h.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},h.prototype.readUintBE=h.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=Q(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),h.prototype.readBigUInt64BE=Q(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return (BigInt(n)<<BigInt(32))+BigInt(i)}),h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||C(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},h.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=Q(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return (BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),h.prototype.readBigInt64BE=Q(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return (BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),h.prototype.readFloatLE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,true,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,false,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,true,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,false,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||M(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},h.prototype.writeUintBE=h.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||M(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=Q(function(t,e=0){return x(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeBigUInt64BE=Q(function(t,e=0){return $(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);M(this,t,e,r,n-1,-n);}let i=0,o=1,f=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===f&&0!==this[e+i-1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);M(this,t,e,r,n-1,-n);}let i=r-1,o=1,f=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=Q(function(t,e=0){return x(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeBigInt64BE=Q(function(t,e=0){return $(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),h.prototype.writeFloatLE=function(t,e,r){return k(this,t,e,true,r)},h.prototype.writeFloatBE=function(t,e,r){return k(this,t,e,false,r)},h.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,true,r)},h.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,false,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},h.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!h.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e);}}else "number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else {const o=h.isBuffer(t)?t:h.from(t,n),f=o.length;if(0===f)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%f];}return this};const j={};function D(t,e,r){j[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:true,configurable:true}),this.name=`${this.name} [${t}]`,this.stack,delete this.name;}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:true,enumerable:true,value:t,writable:true});}toString(){return `${this.name} [${t}]: ${this.message}`}};}function z(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return `${t.slice(0,r)}${e}`}function Y(t,e,r,n,i,o){if(t>r||t<e){const r="bigint"==typeof e?"n":"";let n;throw n=0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`,new j.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||G(e,t.length-(r+1));}(n,i,o);}function V(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function G(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new j.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),D("ERR_INVALID_ARG_TYPE",function(t,e){return `The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),D("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=z(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=z(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const J=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r);}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function W(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(J,"")).length<2)return "";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Z(t){return t!=t}const K=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i];}return e}();function Q(t){return "undefined"==typeof BigInt?tt:t}function tt(){throw new Error("BigInt not supported")}}(e$1)),e$1);const s$1=new TextEncoder,h$1=new TextDecoder,a$1=c$1;function c$1(t,e=0){let r;if(void 0===t||"string"!=typeof t||"number"!=typeof e)throw TypeError("invlaid init variablie type name. ");return (t=t.toUpperCase()).includes("8")?(r=u$1.Buffer.alloc(1),t.includes("I")?r.writeInt8(e):r.writeUint8(e)):t.includes("16")?(r=u$1.Buffer.alloc(2),t.includes("I")?t.includes("L")?r.writeInt16LE(e):r.writeInt16BE(e):t.includes("L")?r.writeUint16LE(e):r.writeUint16BE(e)):t.includes("32")?(r=u$1.Buffer.alloc(4),t.includes("I")?t.includes("L")?r.writeInt32LE(e):r.writeInt32BE(e):t.includes("L")?r.writeUint32LE(e):r.writeUint32BE(e)):t.includes("F")?(r=u$1.Buffer.alloc(4),t.includes("L")?r.writeFloatLE(e):r.writeFloatBE(e)):t.includes("N")?r=u$1.Buffer.from(String(e)):console.log(`invalid type: ${t} or initvalue: ${e}`),r}const l$1=p$1;function p$1(t,e,r){let n,i="B";if("number"==typeof e)"number"==typeof r?(n=u$1.Buffer.alloc(e),0!==r&&n.fill(r),i="B"):(n=u$1.Buffer.from(String(e)),i="N");else if("string"==typeof e&&"number"==typeof r)i=e.toUpperCase(),n=c$1(e,r);else if("string"==typeof e&&void 0===r)n=u$1.Buffer.from(e),i="S";else if(e instanceof Uint8Array&&void 0===r)n=e instanceof u$1.Buffer?e:u$1.Buffer.from(e);else if(e instanceof ArrayBuffer&&void 0===r)n=u$1.Buffer.from(e);else if(ArrayBuffer.isView(e))n=u$1.Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if("object"==typeof e&&void 0===r)n=u$1.Buffer.from(JSON.stringify(e)),i="O";else {if("boolean"!=typeof e||void 0!==r)throw TypeError("invalid meta buffer type");{const t=e?1:0;n=u$1.Buffer.from([t]),i="!";}}return "string"==typeof t&&t.includes("#")&&(t=""),[t,i,n]}const y$1=g$1;function g$1(...t){let e=0;return t.map(t=>{const r=e++;return "number"==typeof t?l$1(r,"N",t):l$1(r,t)})}function d$1(t){if((t=t.toUpperCase()).includes("8"))return t.includes("I")?"int8":"uint8";if(t.includes("16"))return t.includes("I")?t.includes("L")?"int16_le":"int16_be":t.includes("L")?"uint16_le":"uint16_be";if(t.includes("32"))return t.includes("I")?t.includes("L")?"int32_le":"int32_be":t.includes("L")?"uint32_le":"uint32_be";if(t.includes("F"))return t.includes("L")?"float_le":"float_be";if("B"===t)return "buffer";if("S"===t)return "string";if("N"===t)return "number";if("O"===t)return "object";if("!"===t)return "boolean";throw TypeError("invalid data type")}function b$1(t,e,r,n){try{const i=d$1(t);if("int8"==i)return e.readInt8(r);if("uint8"===i)return e.readUint8(r);if("int16_le"===i)return e.readInt16LE(r);if("int16_be"===i)return e.readInt16BE(r);if("uint16_le"===i)return e.readUint16LE(r);if("uint16_be"===i)return e.readUint16BE(r);if("int32_le"===i)return e.readInt32LE(r);if("int32_be"===i)return e.readInt32BE(r);if("uint32_le"===i)return e.readUint32LE(r);if("uint32_be"===i)return e.readUint32BE(r);if("float_le"===i)return e.readFloatLE(r);if("float_be"===i)return e.readFloatBE(r);if("buffer"===i)return e.subarray(r,r+n);if("string"===i){const t=e.subarray(r,r+n);return h$1.decode(t)}if("number"===i){const t=e.subarray(r,r+n);return Number(h$1.decode(t))}if("object"===i){const t=e.subarray(r,r+n);return JSON.parse(h$1.decode(t))}if("boolean"===i){return 1===e.readInt8(r)}return}catch(t){}}function w$1(...t){const e=function(t){let e=[];return t.filter(t=>{if(!Array.isArray(t[0]))return t;e=e.concat(t);}).concat(e)}(t);let r=0;const n=[];let i,o,f=0;if(e.forEach(t=>{const[e,i,o]=t;r+=o.byteLength,("number"==typeof e||e.length>0)&&n.push([e,i,f,o.byteLength]),f=r;}),n.length>0){let t=JSON.stringify(n);i=s$1.encode(t),o=i.byteLength,r=r+o+2;}const h=u$1.Buffer.alloc(r);if(f=0,e.forEach(t=>{const e=t[2];h.set(e,f),f+=e.byteLength;}),n.length>0){h.set(i,f);const t=a$1("16",o);return h.set(t,f+o),h}return h}const B$1=m$1;function m$1(t,e=false){if(void 0===t)throw TypeError("Invalid data type: Undefined");if("string"==typeof t)return s$1.encode(t);if("number"==typeof t)return Uint8Array.from([t]);if(t instanceof ArrayBuffer){if(e)return new Uint8Array(t);{const e=new Uint8Array(t),r=new Uint8Array(t.byteLength);return r.set(e),r}}if(ArrayBuffer.isView(t)){if(e)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);{const e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r=new Uint8Array(t.byteLength);return r.set(e),r}}return s$1.encode(JSON.stringify(t))}const E$1=A$1;function A$1(t,e=false){const r=m$1(t,e);return e?u$1.Buffer.from(r.buffer,r.byteOffset,r.byteLength):u$1.Buffer.from(r)}const U$1=I$1;function I$1(...t){const e=t.map(t=>A$1(t));return u$1.Buffer.concat(e)}const L$1=v$1;function v$1(...t){try{let e=0,r=0;const n=t.map(t=>m$1(t));n.forEach(t=>{e+=t.byteLength;});const i=new Uint8Array(e);return n.forEach(t=>{i.set(t,r),r+=t.byteLength;}),i}catch(t){console.log(t);}}function O$1(t){return 0===S$1(t)?t.byteLength:t.byteLength-S$1(t)-_$1}function T$1(t,e){try{const r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n=r.byteLength-e-2,i=r.subarray(n,r.byteLength-2),o=h$1.decode(i),f=JSON.parse(o);if(!Array.isArray(f)||!Array.isArray(f[0]))return;let u=f[0];if(!u)return;if(u.length<3)return;const[s,a,c]=u;if("string"!=typeof a||"number"!=typeof c)return;return f}catch(t){}}const _$1=2;function R$1(t){if(t instanceof ArrayBuffer&&(t=u$1.Buffer.from(t)),t instanceof Uint8Array){if(t.byteLength<=_$1)return 0;return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint16(t.byteLength-_$1)}return 0}function S$1(t){if(t instanceof ArrayBuffer&&(t=u$1.Buffer.from(t)),t instanceof Uint8Array){const e=t.byteLength;if(e<=_$1)return 0;const r=R$1(t);if(0===r||r>e)return 0;return T$1(t,r)?r:0}return 0}function N$1(t){const e=O$1(t);return t.subarray(0,e)}function C$1(t,e=false){t instanceof ArrayBuffer&&(t=u$1.Buffer.from(t));const r=R$1(t);if(0===r)return;let n=T$1(t,r);return n?e?(n.forEach(t=>{null==t[3]&&(t[1].includes("8")?t[3]=1:t[1].includes("16")?t[3]=2:t[1].includes("32")||t[1].includes("F")?t[3]=4:t[1].includes("!")&&(t[3]=1)),t[4]=d$1(t[1]);}),n):n:void 0}var M$1=Object.freeze({__proto__:null,B8:E$1,B8pack:U$1,Buffer:u$1.Buffer,MB:l$1,MBA:y$1,NB:a$1,TAIL_LEN:_$1,U8:B$1,U8pack:L$1,equal:function(t,e){if(t.byteLength!==e.byteLength)return false;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return false;return true},getBuffer:N$1,getBufferSize:O$1,getMeta:C$1,getMetaDetail:function(t){return C$1(t,true)},getMetaSize:S$1,hex:function(t){return Array.prototype.map.call(new Uint8Array(t),t=>("00"+t.toString(16)).slice(-2)).join("")},meta:function(...t){return C$1(w$1(...t))},metaBuffer:p$1,metaBufferArguments:g$1,metaDetail:function(...t){return C$1(w$1(...t),true)},numberBuffer:c$1,pack:w$1,parseBuffer:A$1,parseBufferThenConcat:I$1,parseMetaInfo:T$1,parseTypeName:d$1,parseUint8Array:m$1,parseUint8ThenConcat:v$1,rawPack:function(...t){return N$1(w$1(...t))},readTail:R$1,readTypedBuffer:b$1,unpack:function(t,e){const r=e||C$1(t);if(!r)return;const n=u$1.Buffer.from(t),i={};let o=0;if(r.forEach(t=>{const[e,r,f,u]=t;let s=b$1(r,n,f,u);null!=s&&(i[e]=s,u&&(o+=u));}),e&&n.byteLength!==o){let t=n.byteLength-o,e=b$1("b",n,o,t);if(null==e)return;i.$OTHERS=e;}let f=0,s=[];for(;i[f];)s.push(i[f++]);return s.length>0&&(i.args=s,i.$=i.args),i}});
3015
29
 
3016
- function getMetaDetail(binPack) {
3017
- return getMeta(binPack, true)
30
+ function getDefaultExportFromCjs (x) {
31
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
3018
32
  }
3019
33
 
3020
- var mbp = /*#__PURE__*/Object.freeze({
3021
- __proto__: null,
3022
- B8: B8,
3023
- B8pack: B8pack,
3024
- Buffer: bufferExports.Buffer,
3025
- MB: MB$1,
3026
- MBA: MBA,
3027
- NB: NB,
3028
- TAIL_LEN: TAIL_LEN,
3029
- U8: U8,
3030
- U8pack: U8pack,
3031
- equal: equal,
3032
- getBuffer: getBuffer,
3033
- getBufferSize: getBufferSize,
3034
- getMeta: getMeta,
3035
- getMetaDetail: getMetaDetail,
3036
- getMetaSize: getMetaSize,
3037
- hex: hex,
3038
- meta: meta,
3039
- metaBuffer: metaBuffer,
3040
- metaBufferArguments: metaBufferArguments,
3041
- metaDetail: metaDetail,
3042
- numberBuffer: numberBuffer,
3043
- pack: pack$1,
3044
- parseBuffer: parseBuffer,
3045
- parseBufferThenConcat: parseBufferThenConcat,
3046
- parseMetaInfo: parseMetaInfo,
3047
- parseTypeName: parseTypeName,
3048
- parseUint8Array: parseUint8Array,
3049
- parseUint8ThenConcat: parseUint8ThenConcat,
3050
- rawPack: rawPack,
3051
- readTail: readTail,
3052
- readTypedBuffer: readTypedBuffer,
3053
- unpack: unpack
3054
- });
3055
-
3056
34
  var eventemitter3 = {exports: {}};
3057
35
 
3058
36
  var hasRequiredEventemitter3;
@@ -3691,28 +669,28 @@ function getSignalPack(tag, ...args) {
3691
669
 
3692
670
  let sigPack;
3693
671
  if (payload.type == PAYLOAD_TYPE.EMPTY) {
3694
- sigPack = mbp.pack(
3695
- mbp.MB('#MsgType', '8', IOMsg.SIGNAL),
3696
- mbp.MB('#tagLen', '8', tagEncoded.byteLength),
3697
- mbp.MB('#tag', tagEncoded),
3698
- mbp.MB('#payloadType', '8', payload.type)
672
+ sigPack = M$1.pack(
673
+ M$1.MB('#MsgType', '8', IOMsg.SIGNAL),
674
+ M$1.MB('#tagLen', '8', tagEncoded.byteLength),
675
+ M$1.MB('#tag', tagEncoded),
676
+ M$1.MB('#payloadType', '8', payload.type)
3699
677
  );
3700
678
  } else if (payload.type == PAYLOAD_TYPE.MBA) {
3701
- let mbaBuffer = mbp.pack(mbp.MBA(...args));
3702
- sigPack = mbp.pack(
3703
- mbp.MB('#MsgType', '8', IOMsg.SIGNAL),
3704
- mbp.MB('#tagLen', '8', tagEncoded.byteLength),
3705
- mbp.MB('#tag', tagEncoded),
3706
- mbp.MB('#payloadType', '8', payload.type),
3707
- mbp.MB('#mbaBuffer', mbaBuffer)
679
+ let mbaBuffer = M$1.pack(M$1.MBA(...args));
680
+ sigPack = M$1.pack(
681
+ M$1.MB('#MsgType', '8', IOMsg.SIGNAL),
682
+ M$1.MB('#tagLen', '8', tagEncoded.byteLength),
683
+ M$1.MB('#tag', tagEncoded),
684
+ M$1.MB('#payloadType', '8', payload.type),
685
+ M$1.MB('#mbaBuffer', mbaBuffer)
3708
686
  );
3709
687
  } else {
3710
- sigPack = mbp.pack(
3711
- mbp.MB('#MsgType', '8', IOMsg.SIGNAL),
3712
- mbp.MB('#tagLen', '8', tagEncoded.byteLength),
3713
- mbp.MB('#tag', tagEncoded),
3714
- mbp.MB('#payloadType', '8', payload.type),
3715
- mbp.MB('#payload', payload.buffer)
688
+ sigPack = M$1.pack(
689
+ M$1.MB('#MsgType', '8', IOMsg.SIGNAL),
690
+ M$1.MB('#tagLen', '8', tagEncoded.byteLength),
691
+ M$1.MB('#tag', tagEncoded),
692
+ M$1.MB('#payloadType', '8', payload.type),
693
+ M$1.MB('#payload', payload.buffer)
3716
694
  );
3717
695
  }
3718
696
  return sigPack
@@ -3732,7 +710,7 @@ function parsePayload(args) {
3732
710
 
3733
711
  } else if (ArrayBuffer.isView(args[0]) || args[0] instanceof ArrayBuffer) {
3734
712
  type = PAYLOAD_TYPE.BINARY;
3735
- pack = mbp.B8(args[0]);
713
+ pack = M$1.B8(args[0]);
3736
714
  } else if (typeof args[0] === 'object') {
3737
715
  type = PAYLOAD_TYPE.OBJECT;
3738
716
  pack = encoder$2.encode(JSON.stringify(args[0]));
@@ -3762,14 +740,21 @@ function getPayloadFromSignalPack(signalPack) {
3762
740
  return signalPack.subarray(3 + tagLen)
3763
741
  }
3764
742
 
3765
- const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function e(e,r,n,i,o){let f,s,u,h,a,c,l,p,y,g,d,b,B;for(;o>=64;){for(f=r[0],s=r[1],u=r[2],h=r[3],a=r[4],c=r[5],l=r[6],p=r[7],g=0;g<16;g++)d=i+4*g,e[g]=(255&n[d])<<24|(255&n[d+1])<<16|(255&n[d+2])<<8|255&n[d+3];for(g=16;g<64;g++)y=e[g-2],b=(y>>>17|y<<15)^(y>>>19|y<<13)^y>>>10,y=e[g-15],B=(y>>>7|y<<25)^(y>>>18|y<<14)^y>>>3,e[g]=(b+e[g-7]|0)+(B+e[g-16]|0);for(g=0;g<64;g++)b=(((a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7))+(a&c^~a&l)|0)+(p+(t[g]+e[g]|0)|0)|0,B=((f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10))+(f&s^f&u^s&u)|0,p=l,l=c,c=a,a=h+b|0,h=u,u=s,s=f,f=b+B|0;r[0]+=f,r[1]+=s,r[2]+=u,r[3]+=h,r[4]+=a,r[5]+=c,r[6]+=l,r[7]+=p,i+=64,o-=64;}return i}const r=function(){function t(){this.digestLength=32,this.blockSize=64,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=false,this.reset();}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=false,this},t.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset();},t.prototype.update=function(t,r){if(void 0===r&&(r=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");let n=0;if(this.bytesHashed+=r,this.bufferLength>0){for(;this.bufferLength<64&&r>0;)this.buffer[this.bufferLength++]=t[n++],r--;64===this.bufferLength&&(e(this.temp,this.state,this.buffer,0,64),this.bufferLength=0);}for(r>=64&&(n=e(this.temp,this.state,t,n,r),r%=64);r>0;)this.buffer[this.bufferLength++]=t[n++],r--;return this},t.prototype.finish=function(t){if(!this.finished){const t=this.bytesHashed,n=this.bufferLength,i=t/536870912|0,o=t<<3,f=t%64<56?64:128;this.buffer[n]=128;for(var r=n+1;r<f-8;r++)this.buffer[r]=0;this.buffer[f-8]=i>>>24&255,this.buffer[f-7]=i>>>16&255,this.buffer[f-6]=i>>>8&255,this.buffer[f-5]=i>>>0&255,this.buffer[f-4]=o>>>24&255,this.buffer[f-3]=o>>>16&255,this.buffer[f-2]=o>>>8&255,this.buffer[f-1]=o>>>0&255,e(this.temp,this.state,this.buffer,0,f),this.finished=true;}for(r=0;r<8;r++)t[4*r+0]=this.state[r]>>>24&255,t[4*r+1]=this.state[r]>>>16&255,t[4*r+2]=this.state[r]>>>8&255,t[4*r+3]=this.state[r]>>>0&255;return this},t.prototype.digest=function(){const t=new Uint8Array(this.digestLength);return this.finish(t),t},t.prototype._saveState=function(t){for(let e=0;e<this.state.length;e++)t[e]=this.state[e];},t.prototype._restoreState=function(t,e){for(let e=0;e<this.state.length;e++)this.state[e]=t[e];this.bytesHashed=e,this.finished=false,this.bufferLength=0;},t}(),n=function(){function t(t){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;const e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new r).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;this.inner.update(e);for(n=0;n<e.length;n++)e[n]^=106;this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(n=0;n<e.length;n++)e[n]=0;}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(let t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean();},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){const t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function i(t){const e=(new r).update(t),n=e.digest();return e.clean(),n}var o,f={},s={};var u,h,a={};
3766
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function c(){return u||(u=1,a.read=function(t,e,r,n,i){var o,f,s=8*i-n-1,u=(1<<s)-1,h=u>>1,a=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-a)-1,p>>=-a,a+=s;a>0;o=256*o+t[e+c],c+=l,a-=8);for(f=o&(1<<-a)-1,o>>=-a,a+=n;a>0;f=256*f+t[e+c],c+=l,a-=8);if(0===o)o=1-h;else {if(o===u)return f?NaN:1/0*(p?-1:1);f+=Math.pow(2,n),o-=h;}return (p?-1:1)*f*Math.pow(2,o-n)},a.write=function(t,e,r,n,i,o){var f,s,u,h=8*o-i-1,a=(1<<h)-1,c=a>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,f=a):(f=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-f))<1&&(f--,u*=2),(e+=f+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(f++,u/=2),f+c>=a?(s=0,f=a):f+c>=1?(s=(e*u-1)*Math.pow(2,i),f+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,i),f=0));i>=8;t[r+p]=255&s,p+=y,s/=256,i-=8);for(f=f<<i|s,h+=i;h>0;t[r+p]=255&f,p+=y,f/=256,h-=8);t[r+p-y]|=128*g;}),a}
743
+ const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function e(e,r,n,i,o){let f,s,u,h,a,c,l,p,y,g,d,b,w;for(;o>=64;){for(f=r[0],s=r[1],u=r[2],h=r[3],a=r[4],c=r[5],l=r[6],p=r[7],g=0;g<16;g++)d=i+4*g,e[g]=(255&n[d])<<24|(255&n[d+1])<<16|(255&n[d+2])<<8|255&n[d+3];for(g=16;g<64;g++)y=e[g-2],b=(y>>>17|y<<15)^(y>>>19|y<<13)^y>>>10,y=e[g-15],w=(y>>>7|y<<25)^(y>>>18|y<<14)^y>>>3,e[g]=(b+e[g-7]|0)+(w+e[g-16]|0);for(g=0;g<64;g++)b=(((a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7))+(a&c^~a&l)|0)+(p+(t[g]+e[g]|0)|0)|0,w=((f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10))+(f&s^f&u^s&u)|0,p=l,l=c,c=a,a=h+b|0,h=u,u=s,s=f,f=b+w|0;r[0]+=f,r[1]+=s,r[2]+=u,r[3]+=h,r[4]+=a,r[5]+=c,r[6]+=l,r[7]+=p,i+=64,o-=64;}return i}const r=function(){function t(){this.digestLength=32,this.blockSize=64,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=false,this.reset();}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=false,this},t.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset();},t.prototype.update=function(t,r){if(void 0===r&&(r=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");let n=0;if(this.bytesHashed+=r,this.bufferLength>0){for(;this.bufferLength<64&&r>0;)this.buffer[this.bufferLength++]=t[n++],r--;64===this.bufferLength&&(e(this.temp,this.state,this.buffer,0,64),this.bufferLength=0);}for(r>=64&&(n=e(this.temp,this.state,t,n,r),r%=64);r>0;)this.buffer[this.bufferLength++]=t[n++],r--;return this},t.prototype.finish=function(t){if(!this.finished){const t=this.bytesHashed,n=this.bufferLength,i=t/536870912|0,o=t<<3,f=t%64<56?64:128;this.buffer[n]=128;for(var r=n+1;r<f-8;r++)this.buffer[r]=0;this.buffer[f-8]=i>>>24&255,this.buffer[f-7]=i>>>16&255,this.buffer[f-6]=i>>>8&255,this.buffer[f-5]=i>>>0&255,this.buffer[f-4]=o>>>24&255,this.buffer[f-3]=o>>>16&255,this.buffer[f-2]=o>>>8&255,this.buffer[f-1]=o>>>0&255,e(this.temp,this.state,this.buffer,0,f),this.finished=true;}for(r=0;r<8;r++)t[4*r+0]=this.state[r]>>>24&255,t[4*r+1]=this.state[r]>>>16&255,t[4*r+2]=this.state[r]>>>8&255,t[4*r+3]=this.state[r]>>>0&255;return this},t.prototype.digest=function(){const t=new Uint8Array(this.digestLength);return this.finish(t),t},t.prototype._saveState=function(t){for(let e=0;e<this.state.length;e++)t[e]=this.state[e];},t.prototype._restoreState=function(t,e){for(let e=0;e<this.state.length;e++)this.state[e]=t[e];this.bytesHashed=e,this.finished=false,this.bufferLength=0;},t}(),n=function(){function t(t){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;const e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new r).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;this.inner.update(e);for(n=0;n<e.length;n++)e[n]^=106;this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(n=0;n<e.length;n++)e[n]=0;}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(let t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean();},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){const t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function i(t){const e=(new r).update(t),n=e.digest();return e.clean(),n}var o,f,s,u={},h={},a={};
744
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function c(){return f||(f=1,a.read=function(t,e,r,n,i){var o,f,s=8*i-n-1,u=(1<<s)-1,h=u>>1,a=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-a)-1,p>>=-a,a+=s;a>0;o=256*o+t[e+c],c+=l,a-=8);for(f=o&(1<<-a)-1,o>>=-a,a+=n;a>0;f=256*f+t[e+c],c+=l,a-=8);if(0===o)o=1-h;else {if(o===u)return f?NaN:1/0*(p?-1:1);f+=Math.pow(2,n),o-=h;}return (p?-1:1)*f*Math.pow(2,o-n)},a.write=function(t,e,r,n,i,o){var f,s,u,h=8*o-i-1,a=(1<<h)-1,c=a>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,f=a):(f=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-f))<1&&(f--,u*=2),(e+=f+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(f++,u/=2),f+c>=a?(s=0,f=a):f+c>=1?(s=(e*u-1)*Math.pow(2,i),f+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,i),f=0));i>=8;t[r+p]=255&s,p+=y,s/=256,i-=8);for(f=f<<i|s,h+=i;h>0;t[r+p]=255&f,p+=y,f/=256,h-=8);t[r+p-y]|=128*g;}),a}
745
+ /*!
746
+ * The buffer module from node.js, for the browser.
747
+ *
748
+ * @author Feross Aboukhadijeh <https://feross.org>
749
+ * @license MIT
750
+ */var l=(s||(s=1,function(t){const e=function(){if(o)return h;o=1,h.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},h.toByteArray=function(t){var n,i,o=f(t),s=o[0],u=o[1],h=new r(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),a=0,c=u>0?s-4:s;for(i=0;i<c;i+=4)n=e[t.charCodeAt(i)]<<18|e[t.charCodeAt(i+1)]<<12|e[t.charCodeAt(i+2)]<<6|e[t.charCodeAt(i+3)],h[a++]=n>>16&255,h[a++]=n>>8&255,h[a++]=255&n;return 2===u&&(n=e[t.charCodeAt(i)]<<2|e[t.charCodeAt(i+1)]>>4,h[a++]=255&n),1===u&&(n=e[t.charCodeAt(i)]<<10|e[t.charCodeAt(i+1)]<<4|e[t.charCodeAt(i+2)]>>2,h[a++]=n>>8&255,h[a++]=255&n),h},h.fromByteArray=function(e){for(var r,n=e.length,i=n%3,o=[],f=16383,s=0,h=n-i;s<h;s+=f)o.push(u(e,s,s+f>h?h:s+f));return 1===i?(r=e[n-1],o.push(t[r>>2]+t[r<<4&63]+"==")):2===i&&(r=(e[n-2]<<8)+e[n-1],o.push(t[r>>10]+t[r>>4&63]+t[r<<2&63]+"=")),o.join("")};for(var t=[],e=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0;i<64;++i)t[i]=n[i],e[n.charCodeAt(i)]=i;function f(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return -1===r&&(r=e),[r,r===e?0:4-r%4]}function s(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[63&e]}function u(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(s(n));return i.join("")}return e["-".charCodeAt(0)]=62,e["_".charCodeAt(0)]=63,h}(),r=c(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=s,t.SlowBuffer=function(t){return +t!=t&&(t=0),s.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function f(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|d(t,e);let n=f(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Q(t,Uint8Array)){const e=new Uint8Array(t);return y(e.buffer,e.byteOffset,e.byteLength)}return p(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Q(t,ArrayBuffer)||t&&Q(t.buffer,ArrayBuffer))return y(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Q(t,SharedArrayBuffer)||t&&Q(t.buffer,SharedArrayBuffer)))return y(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return s.from(n,e,r);const i=function(t){if(s.isBuffer(t)){const e=0|g(t.length),r=f(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||W(t.length)?f(0):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return s.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return a(t),f(t<0?0:0|g(t))}function p(t){const e=t.length<0?0:0|g(t.length),r=f(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function y(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,s.prototype),n}function g(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&true===arguments[2];if(!n&&0===r)return 0;let i=false;for(;;)switch(e){case "ascii":case "latin1":case "binary":return r;case "utf8":case "utf-8":return G(t).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*r;case "hex":return r>>>1;case "base64":return K(t).length;default:if(i)return n?-1:G(t).length;e=(""+e).toLowerCase(),i=true;}}function b(t,e,r){let n=false;if((void 0===e||e<0)&&(e=0),e>this.length)return "";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return "";if((r>>>=0)<=(e>>>=0))return "";for(t||(t="utf8");;)switch(t){case "hex":return O(this,e,r);case "utf8":case "utf-8":return v(this,e,r);case "ascii":return T(this,e,r);case "latin1":case "binary":return S(this,e,r);case "base64":return L(this,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return N(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=true;}}function w(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function B(t,e,r,n,i){if(0===t.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return -1;r=t.length-1;}else if(r<0){if(!i)return -1;r=0;}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:E(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):E(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function E(t,e,r,n,i){let o,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return -1;f=2,s/=2,u/=2,r/=2;}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(i){let n=-1;for(o=r;o<s;o++)if(h(t,o)===h(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*f}else -1!==n&&(o-=o-n),n=-1;}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=true;for(let n=0;n<u;n++)if(h(t,o+n)!==h(e,n)){r=false;break}if(r)return o}return -1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let f;for(n>o/2&&(n=o/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(W(n))return f;t[r+f]=n;}return f}function A(t,e,r,n){return J(G(e,t.length-r),t,r,n)}function _(t,e,r,n){return J(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function U(t,e,r,n){return J(K(e),t,r,n)}function I(t,e,r,n){return J(function(t,e){let r,n,i;const o=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function L(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function v(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,f=e>239?4:e>223?3:e>191?2:1;if(i+f<=r){let r,n,s,u;switch(f){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u));}}null===o?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=f;}return function(t){const e=t.length;if(e<=R)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=R));return r}(n)}t.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return false}}(),s.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:true,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:true,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(t,e,r){return function(t,e,r){return a(t),t<=0?f(t):void 0!==e?"string"==typeof r?f(t).fill(e,r):f(t).fill(e):f(t)}(t,e,r)},s.allocUnsafe=function(t){return l(t)},s.allocUnsafeSlow=function(t){return l(t)},s.isBuffer=function(t){return null!=t&&true===t._isBuffer&&t!==s.prototype},s.compare=function(t,e){if(Q(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),Q(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},s.isEncoding=function(t){switch(String(t).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return true;default:return false}},s.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=s.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(Q(e,Uint8Array))i+e.length>n.length?(s.isBuffer(e)||(e=s.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else {if(!s.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i);}i+=e.length;}return n},s.byteLength=d,s.prototype._isBuffer=true,s.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},s.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},s.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},s.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?v(this,0,t):b.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(s.prototype[n]=s.prototype.inspect),s.prototype.compare=function(t,e,r,n,i){if(Q(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return -1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const u=Math.min(o,f),h=this.slice(n,i),a=t.slice(e,r);for(let t=0;t<u;++t)if(h[t]!==a[t]){o=h[t],f=a[t];break}return o<f?-1:f<o?1:0},s.prototype.includes=function(t,e,r){return -1!==this.indexOf(t,e,r)},s.prototype.indexOf=function(t,e,r){return B(this,t,e,r,true)},s.prototype.lastIndexOf=function(t,e,r){return B(this,t,e,r,false)},s.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else {if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=false;for(;;)switch(n){case "hex":return m(this,t,e,r);case "utf8":case "utf-8":return A(this,t,e,r);case "ascii":case "latin1":case "binary":return _(this,t,e,r);case "base64":return U(this,t,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return I(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=true;}},s.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const R=4096;function T(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function S(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function O(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=X[t[n]];return i}function N(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function M(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function x(t,e,r,n,i){D(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function k(t,e,r,n,i){D(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function $(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function F(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,8),r.write(t,e,n,i,52,8),n+8}s.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,s.prototype),n},s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readBigUInt64LE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),s.prototype.readBigUInt64BE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return (BigInt(n)<<BigInt(32))+BigInt(i)}),s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||M(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||M(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readBigInt64LE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return (BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),s.prototype.readBigInt64BE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return (BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),s.prototype.readFloatLE=function(t,e){return t>>>=0,e||M(t,4,this.length),r.read(this,t,true,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||M(t,4,this.length),r.read(this,t,false,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||M(t,8,this.length),r.read(this,t,true,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||M(t,8,this.length),r.read(this,t,false,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigUInt64LE=Z(function(t,e=0){return x(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=Z(function(t,e=0){return k(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n);}let i=0,o=1,f=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===f&&0!==this[e+i-1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n);}let i=r-1,o=1,f=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigInt64LE=Z(function(t,e=0){return x(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=Z(function(t,e=0){return k(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeFloatLE=function(t,e,r){return $(this,t,e,true,r)},s.prototype.writeFloatBE=function(t,e,r){return $(this,t,e,false,r)},s.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,true,r)},s.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,false,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e);}}else "number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else {const o=s.isBuffer(t)?t:s.from(t,n),f=o.length;if(0===f)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%f];}return this};const j={};function z(t,e,r){j[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:true,configurable:true}),this.name=`${this.name} [${t}]`,this.stack,delete this.name;}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:true,enumerable:true,value:t,writable:true});}toString(){return `${this.name} [${t}]: ${this.message}`}};}function H(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return `${t.slice(0,r)}${e}`}function D(t,e,r,n,i,o){if(t>r||t<e){const r="bigint"==typeof e?"n":"";let n;throw n=0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`,new j.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||q(e,t.length-(r+1));}(n,i,o);}function V(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function q(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new j.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}z("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),z("ERR_INVALID_ARG_TYPE",function(t,e){return `The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),z("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=H(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=H(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const Y=/[^+/0-9A-Za-z-_]/g;function G(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r);}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function K(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(Y,"")).length<2)return "";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function W(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i];}return e}();function Z(t){return "undefined"==typeof BigInt?tt:t}function tt(){throw new Error("BigInt not supported")}}(u)),u);const p=new TextEncoder,y=new TextDecoder,g=d;function d(t,e=0){let r;if(void 0===t||"string"!=typeof t||"number"!=typeof e)throw TypeError("invlaid init variablie type name. ");return (t=t.toUpperCase()).includes("8")?(r=l.Buffer.alloc(1),t.includes("I")?r.writeInt8(e):r.writeUint8(e)):t.includes("16")?(r=l.Buffer.alloc(2),t.includes("I")?t.includes("L")?r.writeInt16LE(e):r.writeInt16BE(e):t.includes("L")?r.writeUint16LE(e):r.writeUint16BE(e)):t.includes("32")?(r=l.Buffer.alloc(4),t.includes("I")?t.includes("L")?r.writeInt32LE(e):r.writeInt32BE(e):t.includes("L")?r.writeUint32LE(e):r.writeUint32BE(e)):t.includes("F")?(r=l.Buffer.alloc(4),t.includes("L")?r.writeFloatLE(e):r.writeFloatBE(e)):t.includes("N")?r=l.Buffer.from(String(e)):console.log(`invalid type: ${t} or initvalue: ${e}`),r}const b=w;function w(t,e,r){let n,i="B";if("number"==typeof e)"number"==typeof r?(n=l.Buffer.alloc(e),0!==r&&n.fill(r),i="B"):(n=l.Buffer.from(String(e)),i="N");else if("string"==typeof e&&"number"==typeof r)i=e.toUpperCase(),n=d(e,r);else if("string"==typeof e&&void 0===r)n=l.Buffer.from(e),i="S";else if(e instanceof Uint8Array&&void 0===r)n=e instanceof l.Buffer?e:l.Buffer.from(e);else if(e instanceof ArrayBuffer&&void 0===r)n=l.Buffer.from(e);else if(ArrayBuffer.isView(e))n=l.Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if("object"==typeof e&&void 0===r)n=l.Buffer.from(JSON.stringify(e)),i="O";else {if("boolean"!=typeof e||void 0!==r)throw TypeError("invalid meta buffer type");{const t=e?1:0;n=l.Buffer.from([t]),i="!";}}return "string"==typeof t&&t.includes("#")&&(t=""),[t,i,n]}const B=E;function E(...t){let e=0;return t.map(t=>{const r=e++;return "number"==typeof t?b(r,"N",t):b(r,t)})}function m(t){if((t=t.toUpperCase()).includes("8"))return t.includes("I")?"int8":"uint8";if(t.includes("16"))return t.includes("I")?t.includes("L")?"int16_le":"int16_be":t.includes("L")?"uint16_le":"uint16_be";if(t.includes("32"))return t.includes("I")?t.includes("L")?"int32_le":"int32_be":t.includes("L")?"uint32_le":"uint32_be";if(t.includes("F"))return t.includes("L")?"float_le":"float_be";if("B"===t)return "buffer";if("S"===t)return "string";if("N"===t)return "number";if("O"===t)return "object";if("!"===t)return "boolean";throw TypeError("invalid data type")}function A(t,e,r,n){try{const i=m(t);if("int8"==i)return e.readInt8(r);if("uint8"===i)return e.readUint8(r);if("int16_le"===i)return e.readInt16LE(r);if("int16_be"===i)return e.readInt16BE(r);if("uint16_le"===i)return e.readUint16LE(r);if("uint16_be"===i)return e.readUint16BE(r);if("int32_le"===i)return e.readInt32LE(r);if("int32_be"===i)return e.readInt32BE(r);if("uint32_le"===i)return e.readUint32LE(r);if("uint32_be"===i)return e.readUint32BE(r);if("float_le"===i)return e.readFloatLE(r);if("float_be"===i)return e.readFloatBE(r);if("buffer"===i)return e.subarray(r,r+n);if("string"===i){const t=e.subarray(r,r+n);return y.decode(t)}if("number"===i){const t=e.subarray(r,r+n);return Number(y.decode(t))}if("object"===i){const t=e.subarray(r,r+n);return JSON.parse(y.decode(t))}return "boolean"===i?1===e.readInt8(r):void 0}catch(t){}}function _(...t){const e=function(t){let e=[];return t.filter(t=>{if(!Array.isArray(t[0]))return t;e=e.concat(t);}).concat(e)}(t);let r=0;const n=[];let i,o,f=0;if(e.forEach(t=>{const[e,i,o]=t;r+=o.byteLength,("number"==typeof e||e.length>0)&&n.push([e,i,f,o.byteLength]),f=r;}),n.length>0){let t=JSON.stringify(n);i=p.encode(t),o=i.byteLength,r=r+o+2;}const s=l.Buffer.alloc(r);if(f=0,e.forEach(t=>{const e=t[2];s.set(e,f),f+=e.byteLength;}),n.length>0){s.set(i,f);const t=g("16",o);return s.set(t,f+o),s}return s}const U=I;function I(t,e=false){if(void 0===t)throw TypeError("Invalid data type: Undefined");if("string"==typeof t)return p.encode(t);if("number"==typeof t)return Uint8Array.from([t]);if(t instanceof ArrayBuffer){if(e)return new Uint8Array(t);{const e=new Uint8Array(t),r=new Uint8Array(t.byteLength);return r.set(e),r}}if(ArrayBuffer.isView(t)){if(e)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);{const e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r=new Uint8Array(t.byteLength);return r.set(e),r}}return p.encode(JSON.stringify(t))}const L=v;function v(t,e=false){const r=I(t,e);return e?l.Buffer.from(r.buffer,r.byteOffset,r.byteLength):l.Buffer.from(r)}const R=T;function T(...t){const e=t.map(t=>v(t));return l.Buffer.concat(e)}const S=O;function O(...t){try{let e=0,r=0;const n=t.map(t=>I(t));n.forEach(t=>{e+=t.byteLength;});const i=new Uint8Array(e);return n.forEach(t=>{i.set(t,r),r+=t.byteLength;}),i}catch(t){console.log(t);}}function N(t){return 0===k(t)?t.byteLength:t.byteLength-k(t)-C}function M(t,e){try{const r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n=r.byteLength-e-2,i=r.subarray(n,r.byteLength-2),o=y.decode(i),f=JSON.parse(o);if(!Array.isArray(f)||!Array.isArray(f[0]))return;let s=f[0];if(!s)return;if(s.length<3)return;const[u,h,a]=s;if("string"!=typeof h||"number"!=typeof a)return;return f}catch(t){}}const C=2;function x(t){return t instanceof ArrayBuffer&&(t=l.Buffer.from(t)),t instanceof Uint8Array?t.byteLength<=C?0:new DataView(t.buffer,t.byteOffset,t.byteLength).getUint16(t.byteLength-C):0}function k(t){if(t instanceof ArrayBuffer&&(t=l.Buffer.from(t)),t instanceof Uint8Array){const e=t.byteLength;if(e<=C)return 0;const r=x(t);return 0===r||r>e?0:M(t,r)?r:0}return 0}function P(t){const e=N(t);return t.subarray(0,e)}function $(t,e=false){t instanceof ArrayBuffer&&(t=l.Buffer.from(t));const r=x(t);if(0===r)return;let n=M(t,r);return n?e?(n.forEach(t=>{null==t[3]&&(t[1].includes("8")?t[3]=1:t[1].includes("16")?t[3]=2:t[1].includes("32")||t[1].includes("F")?t[3]=4:t[1].includes("!")&&(t[3]=1)),t[4]=m(t[1]);}),n):n:void 0}var F=Object.freeze({__proto__:null,B8:L,B8pack:R,Buffer:l.Buffer,MB:b,MBA:B,NB:g,TAIL_LEN:C,U8:U,U8pack:S,equal:function(t,e){if(t.byteLength!==e.byteLength)return false;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return false;return true},getBuffer:P,getBufferSize:N,getMeta:$,getMetaDetail:function(t){return $(t,true)},getMetaSize:k,hex:function(t){return Array.prototype.map.call(new Uint8Array(t),t=>("00"+t.toString(16)).slice(-2)).join("")},meta:function(...t){return $(_(...t))},metaBuffer:w,metaBufferArguments:E,metaDetail:function(...t){return $(_(...t),true)},numberBuffer:d,pack:_,parseBuffer:v,parseBufferThenConcat:T,parseMetaInfo:M,parseTypeName:m,parseUint8Array:I,parseUint8ThenConcat:O,rawPack:function(...t){return P(_(...t))},readTail:x,readTypedBuffer:A,unpack:function(t,e){const r=e||$(t);if(!r)return;const n=l.Buffer.from(t),i={};let o=0;if(r.forEach(t=>{const[e,r,f,s]=t;let u=A(r,n,f,s);null!=u&&(i[e]=u,s&&(o+=s));}),e&&n.byteLength!==o){let t=n.byteLength-o,e=A("b",n,o,t);if(null==e)return;i.$OTHERS=e;}let f=0,s=[];for(;i[f];)s.push(i[f++]);return s.length>0&&(i.args=s,i.$=i.args),i}});const j={hash:function(t){return i(F.U8(t))},hex:function(t){return F.B8(i(F.U8(t))).toString("hex")},base64:function(t){return F.B8(i(F.U8(t))).toString("base64")}};j.hmac=function(t,e){return function(t,e){const r=new n(t).update(e),i=r.digest();return r.clean(),i}(F.U8(t),F.U8(e))};var z,H={},D={};var V,q,Y={};
751
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function G(){return V||(V=1,Y.read=function(t,e,r,n,i){var o,f,s=8*i-n-1,u=(1<<s)-1,h=u>>1,a=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-a)-1,p>>=-a,a+=s;a>0;o=256*o+t[e+c],c+=l,a-=8);for(f=o&(1<<-a)-1,o>>=-a,a+=n;a>0;f=256*f+t[e+c],c+=l,a-=8);if(0===o)o=1-h;else {if(o===u)return f?NaN:1/0*(p?-1:1);f+=Math.pow(2,n),o-=h;}return (p?-1:1)*f*Math.pow(2,o-n)},Y.write=function(t,e,r,n,i,o){var f,s,u,h=8*o-i-1,a=(1<<h)-1,c=a>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,f=a):(f=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-f))<1&&(f--,u*=2),(e+=f+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(f++,u/=2),f+c>=a?(s=0,f=a):f+c>=1?(s=(e*u-1)*Math.pow(2,i),f+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,i),f=0));i>=8;t[r+p]=255&s,p+=y,s/=256,i-=8);for(f=f<<i|s,h+=i;h>0;t[r+p]=255&f,p+=y,f/=256,h-=8);t[r+p-y]|=128*g;}),Y}
3767
752
  /*!
3768
753
  * The buffer module from node.js, for the browser.
3769
754
  *
3770
755
  * @author Feross Aboukhadijeh <https://feross.org>
3771
756
  * @license MIT
3772
- */var l=(h||(h=1,function(t){const e=function(){if(o)return s;o=1,s.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},s.toByteArray=function(t){var n,i,o=f(t),s=o[0],u=o[1],h=new r(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),a=0,c=u>0?s-4:s;for(i=0;i<c;i+=4)n=e[t.charCodeAt(i)]<<18|e[t.charCodeAt(i+1)]<<12|e[t.charCodeAt(i+2)]<<6|e[t.charCodeAt(i+3)],h[a++]=n>>16&255,h[a++]=n>>8&255,h[a++]=255&n;return 2===u&&(n=e[t.charCodeAt(i)]<<2|e[t.charCodeAt(i+1)]>>4,h[a++]=255&n),1===u&&(n=e[t.charCodeAt(i)]<<10|e[t.charCodeAt(i+1)]<<4|e[t.charCodeAt(i+2)]>>2,h[a++]=n>>8&255,h[a++]=255&n),h},s.fromByteArray=function(e){for(var r,n=e.length,i=n%3,o=[],f=16383,s=0,u=n-i;s<u;s+=f)o.push(h(e,s,s+f>u?u:s+f));return 1===i?(r=e[n-1],o.push(t[r>>2]+t[r<<4&63]+"==")):2===i&&(r=(e[n-2]<<8)+e[n-1],o.push(t[r>>10]+t[r>>4&63]+t[r<<2&63]+"=")),o.join("")};for(var t=[],e=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0;i<64;++i)t[i]=n[i],e[n.charCodeAt(i)]=i;function f(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return -1===r&&(r=e),[r,r===e?0:4-r%4]}function u(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[63&e]}function h(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(u(n));return i.join("")}return e["-".charCodeAt(0)]=62,e["_".charCodeAt(0)]=63,s}(),r=c(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=u,t.SlowBuffer=function(t){return +t!=t&&(t=0),u.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function f(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return h(t,e,r)}function h(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|d(t,e);let n=f(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Q(t,Uint8Array)){const e=new Uint8Array(t);return y(e.buffer,e.byteOffset,e.byteLength)}return p(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Q(t,ArrayBuffer)||t&&Q(t.buffer,ArrayBuffer))return y(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Q(t,SharedArrayBuffer)||t&&Q(t.buffer,SharedArrayBuffer)))return y(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|g(t.length),r=f(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||W(t.length)?f(0):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return a(t),f(t<0?0:0|g(t))}function p(t){const e=t.length<0?0:0|g(t.length),r=f(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function y(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function g(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function d(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&true===arguments[2];if(!n&&0===r)return 0;let i=false;for(;;)switch(e){case "ascii":case "latin1":case "binary":return r;case "utf8":case "utf-8":return Y(t).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*r;case "hex":return r>>>1;case "base64":return G(t).length;default:if(i)return n?-1:Y(t).length;e=(""+e).toLowerCase(),i=true;}}function b(t,e,r){let n=false;if((void 0===e||e<0)&&(e=0),e>this.length)return "";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return "";if((r>>>=0)<=(e>>>=0))return "";for(t||(t="utf8");;)switch(t){case "hex":return M(this,e,r);case "utf8":case "utf-8":return v(this,e,r);case "ascii":return N(this,e,r);case "latin1":case "binary":return T(this,e,r);case "base64":return I(this,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return R(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=true;}}function B(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function w(t,e,r,n,i){if(0===t.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return -1;r=t.length-1;}else if(r<0){if(!i)return -1;r=0;}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:E(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):E(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function E(t,e,r,n,i){let o,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return -1;f=2,s/=2,u/=2,r/=2;}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(i){let n=-1;for(o=r;o<s;o++)if(h(t,o)===h(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*f}else -1!==n&&(o-=o-n),n=-1;}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=true;for(let n=0;n<u;n++)if(h(t,o+n)!==h(e,n)){r=false;break}if(r)return o}return -1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let f;for(n>o/2&&(n=o/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(W(n))return f;t[r+f]=n;}return f}function _(t,e,r,n){return J(Y(e,t.length-r),t,r,n)}function A(t,e,r,n){return J(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function U(t,e,r,n){return J(G(e),t,r,n)}function L(t,e,r,n){return J(function(t,e){let r,n,i;const o=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function I(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function v(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,f=e>239?4:e>223?3:e>191?2:1;if(i+f<=r){let r,n,s,u;switch(f){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u));}}null===o?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=f;}return function(t){const e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=S));return r}(n)}t.kMaxLength=i,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return false}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:true,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:true,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return h(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return a(t),t<=0?f(t):void 0!==e?"string"==typeof r?f(t).fill(e,r):f(t).fill(e):f(t)}(t,e,r)},u.allocUnsafe=function(t){return l(t)},u.allocUnsafeSlow=function(t){return l(t)},u.isBuffer=function(t){return null!=t&&true===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(Q(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),Q(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return true;default:return false}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(Q(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else {if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i);}i+=e.length;}return n},u.byteLength=d,u.prototype._isBuffer=true,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)B(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)B(this,e,e+3),B(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)B(this,e,e+7),B(this,e+1,e+6),B(this,e+2,e+5),B(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?v(this,0,t):b.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(Q(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return -1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const s=Math.min(o,f),h=this.slice(n,i),a=t.slice(e,r);for(let t=0;t<s;++t)if(h[t]!==a[t]){o=h[t],f=a[t];break}return o<f?-1:f<o?1:0},u.prototype.includes=function(t,e,r){return -1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return w(this,t,e,r,true)},u.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,false)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else {if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=false;for(;;)switch(n){case "hex":return m(this,t,e,r);case "utf8":case "utf-8":return _(this,t,e,r);case "ascii":case "latin1":case "binary":return A(this,t,e,r);case "base64":return U(this,t,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return L(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=true;}},u.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const S=4096;function N(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function T(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function M(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=X[t[n]];return i}function R(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function O(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function k(t,e,r,n,i){D(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function x(t,e,r,n,i){D(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function H(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function $(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,8),r.write(t,e,n,i,52,8),n+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return (BigInt(n)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return (BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),u.prototype.readBigInt64BE=Z(function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return (BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),r.read(this,t,true,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),r.read(this,t,false,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),r.read(this,t,true,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),r.read(this,t,false,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z(function(t,e=0){return k(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Z(function(t,e=0){return x(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n);}let i=0,o=1,f=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===f&&0!==this[e+i-1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n);}let i=r-1,o=1,f=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z(function(t,e=0){return k(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Z(function(t,e=0){return x(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(t,e,r){return H(this,t,e,true,r)},u.prototype.writeFloatBE=function(t,e,r){return H(this,t,e,false,r)},u.prototype.writeDoubleLE=function(t,e,r){return $(this,t,e,true,r)},u.prototype.writeDoubleBE=function(t,e,r){return $(this,t,e,false,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e);}}else "number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else {const o=u.isBuffer(t)?t:u.from(t,n),f=o.length;if(0===f)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%f];}return this};const z={};function F(t,e,r){z[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:true,configurable:true}),this.name=`${this.name} [${t}]`,this.stack,delete this.name;}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:true,enumerable:true,value:t,writable:true});}toString(){return `${this.name} [${t}]: ${this.message}`}};}function j(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return `${t.slice(0,r)}${e}`}function D(t,e,r,n,i,o){if(t>r||t<e){const r="bigint"==typeof e?"n":"";let n;throw n=0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`,new z.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||q(e,t.length-(r+1));}(n,i,o);}function V(t,e){if("number"!=typeof t)throw new z.ERR_INVALID_ARG_TYPE(e,"number",t)}function q(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new z.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new z.ERR_BUFFER_OUT_OF_BOUNDS;throw new z.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}F("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),F("ERR_INVALID_ARG_TYPE",function(t,e){return `The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),F("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=j(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=j(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const K=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r);}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function G(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return "";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function W(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i];}return e}();function Z(t){return "undefined"==typeof BigInt?tt:t}function tt(){throw new Error("BigInt not supported")}}(f)),f);const p=new TextEncoder,y=new TextDecoder,g=d;function d(t,e=0){let r;if(void 0===t||"string"!=typeof t||"number"!=typeof e)throw TypeError("invlaid init variablie type name. ");return (t=t.toUpperCase()).includes("8")?(r=l.Buffer.alloc(1),t.includes("I")?r.writeInt8(e):r.writeUint8(e)):t.includes("16")?(r=l.Buffer.alloc(2),t.includes("I")?t.includes("L")?r.writeInt16LE(e):r.writeInt16BE(e):t.includes("L")?r.writeUint16LE(e):r.writeUint16BE(e)):t.includes("32")?(r=l.Buffer.alloc(4),t.includes("I")?t.includes("L")?r.writeInt32LE(e):r.writeInt32BE(e):t.includes("L")?r.writeUint32LE(e):r.writeUint32BE(e)):t.includes("F")?(r=l.Buffer.alloc(4),t.includes("L")?r.writeFloatLE(e):r.writeFloatBE(e)):t.includes("N")?r=l.Buffer.from(String(e)):console.log(`invalid type: ${t} or initvalue: ${e}`),r}const b=B;function B(t,e,r){let n,i="B";if("number"==typeof e)"number"==typeof r?(n=l.Buffer.alloc(e),0!==r&&n.fill(r),i="B"):(n=l.Buffer.from(String(e)),i="N");else if("string"==typeof e&&"number"==typeof r)i=e.toUpperCase(),n=d(e,r);else if("string"==typeof e&&void 0===r)n=l.Buffer.from(e),i="S";else if(e instanceof Uint8Array&&void 0===r)n=e instanceof l.Buffer?e:l.Buffer.from(e);else if(e instanceof ArrayBuffer&&void 0===r)n=l.Buffer.from(e);else if(ArrayBuffer.isView(e))n=l.Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if("object"==typeof e&&void 0===r)n=l.Buffer.from(JSON.stringify(e)),i="O";else {if("boolean"!=typeof e||void 0!==r)throw TypeError("invalid meta buffer type");{const t=e?1:0;n=l.Buffer.from([t]),i="!";}}return "string"==typeof t&&t.includes("#")&&(t=""),[t,i,n]}const w=E;function E(...t){let e=0;return t.map(t=>{const r=e++;return "number"==typeof t?b(r,"N",t):b(r,t)})}function m(t){if((t=t.toUpperCase()).includes("8"))return t.includes("I")?"int8":"uint8";if(t.includes("16"))return t.includes("I")?t.includes("L")?"int16_le":"int16_be":t.includes("L")?"uint16_le":"uint16_be";if(t.includes("32"))return t.includes("I")?t.includes("L")?"int32_le":"int32_be":t.includes("L")?"uint32_le":"uint32_be";if(t.includes("F"))return t.includes("L")?"float_le":"float_be";if("B"===t)return "buffer";if("S"===t)return "string";if("N"===t)return "number";if("O"===t)return "object";if("!"===t)return "boolean";throw TypeError("invalid data type")}function _(t,e,r,n){try{const i=m(t);if("int8"==i)return e.readInt8(r);if("uint8"===i)return e.readUint8(r);if("int16_le"===i)return e.readInt16LE(r);if("int16_be"===i)return e.readInt16BE(r);if("uint16_le"===i)return e.readUint16LE(r);if("uint16_be"===i)return e.readUint16BE(r);if("int32_le"===i)return e.readInt32LE(r);if("int32_be"===i)return e.readInt32BE(r);if("uint32_le"===i)return e.readUint32LE(r);if("uint32_be"===i)return e.readUint32BE(r);if("float_le"===i)return e.readFloatLE(r);if("float_be"===i)return e.readFloatBE(r);if("buffer"===i)return e.subarray(r,r+n);if("string"===i){const t=e.subarray(r,r+n);return y.decode(t)}if("number"===i){const t=e.subarray(r,r+n);return Number(y.decode(t))}if("object"===i){const t=e.subarray(r,r+n);return JSON.parse(y.decode(t))}if("boolean"===i){return 1===e.readInt8(r)}return}catch(t){}}function A(...t){const e=function(t){let e=[];return t.filter(t=>{if(!Array.isArray(t[0]))return t;e=e.concat(t);}).concat(e)}(t);let r=0;const n=[];let i,o,f=0;if(e.forEach(t=>{const[e,i,o]=t;r+=o.byteLength,("number"==typeof e||e.length>0)&&n.push([e,i,f,o.byteLength]),f=r;}),n.length>0){let t=JSON.stringify(n);i=p.encode(t),o=i.byteLength,r=r+o+2;}const s=l.Buffer.alloc(r);if(f=0,e.forEach(t=>{const e=t[2];s.set(e,f),f+=e.byteLength;}),n.length>0){s.set(i,f);const t=g("16",o);return s.set(t,f+o),s}return s}const U=L;function L(t,e=false){if(void 0===t)throw TypeError("Invalid data type: Undefined");if("string"==typeof t)return p.encode(t);if("number"==typeof t)return Uint8Array.from([t]);if(t instanceof ArrayBuffer){if(e)return new Uint8Array(t);{const e=new Uint8Array(t),r=new Uint8Array(t.byteLength);return r.set(e),r}}if(ArrayBuffer.isView(t)){if(e)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);{const e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r=new Uint8Array(t.byteLength);return r.set(e),r}}return p.encode(JSON.stringify(t))}const I=v;function v(t,e=false){const r=L(t,e);return e?l.Buffer.from(r.buffer,r.byteOffset,r.byteLength):l.Buffer.from(r)}const S=N;function N(...t){const e=t.map(t=>v(t));return l.Buffer.concat(e)}const T=M;function M(...t){try{let e=0,r=0;const n=t.map(t=>L(t));n.forEach(t=>{e+=t.byteLength;});const i=new Uint8Array(e);return n.forEach(t=>{i.set(t,r),r+=t.byteLength;}),i}catch(t){console.log(t);}}function R(t){return 0===x(t)?t.byteLength:t.byteLength-x(t)-C}function O(t,e){try{const r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n=r.byteLength-e-2,i=r.subarray(n,r.byteLength-2),o=y.decode(i),f=JSON.parse(o);if(!Array.isArray(f)||!Array.isArray(f[0]))return;let s=f[0];if(!s)return;if(s.length<3)return;const[u,h,a]=s;if("string"!=typeof h||"number"!=typeof a)return;return f}catch(t){}}const C=2;function k(t){if(t instanceof ArrayBuffer&&(t=l.Buffer.from(t)),t instanceof Uint8Array){if(t.byteLength<=C)return 0;return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint16(t.byteLength-C)}return 0}function x(t){if(t instanceof ArrayBuffer&&(t=l.Buffer.from(t)),t instanceof Uint8Array){const e=t.byteLength;if(e<=C)return 0;const r=k(t);if(0===r||r>e)return 0;return O(t,r)?r:0}return 0}function P(t){const e=R(t);return t.subarray(0,e)}function H(t,e=false){t instanceof ArrayBuffer&&(t=l.Buffer.from(t));const r=k(t);if(0===r)return;let n=O(t,r);return n?e?(n.forEach(t=>{null==t[3]&&(t[1].includes("8")?t[3]=1:t[1].includes("16")?t[3]=2:t[1].includes("32")||t[1].includes("F")?t[3]=4:t[1].includes("!")&&(t[3]=1)),t[4]=m(t[1]);}),n):n:void 0}var $=Object.freeze({__proto__:null,B8:I,B8pack:S,Buffer:l.Buffer,MB:b,MBA:w,NB:g,TAIL_LEN:C,U8:U,U8pack:T,equal:function(t,e){if(t.byteLength!==e.byteLength)return false;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return false;return true},getBuffer:P,getBufferSize:R,getMeta:H,getMetaDetail:function(t){return H(t,true)},getMetaSize:x,hex:function(t){return Array.prototype.map.call(new Uint8Array(t),t=>("00"+t.toString(16)).slice(-2)).join("")},meta:function(...t){return H(A(...t))},metaBuffer:B,metaBufferArguments:E,metaDetail:function(...t){return H(A(...t),true)},numberBuffer:d,pack:A,parseBuffer:v,parseBufferThenConcat:N,parseMetaInfo:O,parseTypeName:m,parseUint8Array:L,parseUint8ThenConcat:M,rawPack:function(...t){return P(A(...t))},readTail:k,readTypedBuffer:_,unpack:function(t,e){const r=e||H(t);if(!r)return;const n=l.Buffer.from(t),i={};let o=0;if(r.forEach(t=>{const[e,r,f,s]=t;let u=_(r,n,f,s);null!=u&&(i[e]=u,s&&(o+=s));}),e&&n.byteLength!==o){let t=n.byteLength-o,e=_("b",n,o,t);if(null==e)return;i.$OTHERS=e;}let f=0,s=[];for(;i[f];)s.push(i[f++]);return s.length>0&&(i.args=s,i.$=i.args),i}});const z={hash:function(t){return i($.U8(t))},hex:function(t){return $.B8(i($.U8(t))).toString("hex")},base64:function(t){return $.B8(i($.U8(t))).toString("base64")}};z.hmac=function(t,e){return function(t,e){const r=new n(t).update(e),i=r.digest();return r.clean(),i}($.U8(t),$.U8(e))};let F={SERVER_TIME_NONCE:176,AUTH_REQ:177,AUTH_RES:178,AUTH_FAIL:179,ENC_PACK:182,ENC_E2E:183,ENC_488:184};for(let t in F)F[F[t]]=t;const j={SERVER_TIME_NONCE:$.meta($.MB("header","8",0),$.MB("unixTime","32L",0),$.MB("milTime","16L",0),$.MB("counter","16L",0),$.MB("nonce",l.Buffer.alloc(4))),AUTH_REQ:$.meta($.MB("header","8",0),$.MB("id8",l.Buffer.alloc(8)),$.MB("nonce",l.Buffer.alloc(4)),$.MB("hmac32",l.Buffer.alloc(32))),AUTH_RES:$.meta($.MB("header","8",0),$.MB("hmac32",l.Buffer.alloc(32))),ENC_PACK:$.meta($.MB("type","8",0),$.MB("len","32L",0),$.MB("salt12",l.Buffer.alloc(12)),$.MB("hmac",8,0)),ENC_488:$.meta($.MB("type","8",0),$.MB("len","32L",0),$.MB("otpSrc8",l.Buffer.alloc(8)),$.MB("hmac8",l.Buffer.alloc(8)))};function D(t){let e=t[t.length-1];return e[2]+e[3]}const V={SERVER_TIME_NONCE:D(j.SERVER_TIME_NONCE),AUTH_REQ:D(j.AUTH_REQ),AUTH_RES:D(j.AUTH_RES),ENC_PACK:D(j.ENC_PACK),ENC_488:D(j.ENC_488)};function q(t){return globalThis.crypto.getRandomValues(l.Buffer.alloc(t))}class K{constructor(){this._id8=l.Buffer.alloc(8),this._otpSrc44=l.Buffer.alloc(44),this._otp36=l.Buffer.alloc(36),this._hmac=l.Buffer.alloc(32),this.auth_salt12=l.Buffer.alloc(12),this.localNonce=l.Buffer.alloc(4),this.remoteNonce=l.Buffer.alloc(4),this.isAuthorized=false,this.counter=0;}clearAuth(){this._id8.fill(0),this._otpSrc44.fill(0),this._otp36.fill(0),this._hmac.fill(0),this.auth_salt12.fill(0),this.localNonce.fill(0),this.remoteNonce.fill(0),this.isAuthorized=false,this.counter=0;}set_hash_id8(t){$.B8(z.hash(t)).copy(this._id8,0,0,8);}set_id8(t){let e=$.B8(t);this._id8.fill(0),e.copy(this._id8,0,0,8);}set_key(t){$.B8(z.hash(t)).copy(this._otpSrc44,0,0,32);}set_id_key(t){let e=t.indexOf(".");if(-1==e)return;let r=t.substring(0,e),n=t.substring(e+1);this.set_id8(r),this.set_key(n);}copy_id8(t){t.copy(this._id8,0,0,8);}copy_key(t){t.copy(this._otpSrc44,0,0,32);}sha256_n(t,e){let r=z.hash(t);for(let t=0;t<e;t++)r=z.hash(r);return r}set_clock_rand(){const t=Date.now(),e=parseInt(t/1e3),r=t%1e3;++this.counter>65535&&(this.counter=0);l.Buffer.concat([$.NB("32L",e),$.NB("16L",r),$.NB("16L",this.counter),q(4)]).copy(this._otpSrc44,32);}set_clock_nonce(t){const e=Date.now(),r=parseInt(e/1e3),n=e%1e3;++this.counter>65535&&(this.counter=0);l.Buffer.concat([$.NB("32L",r),$.NB("16L",n),$.NB("16L",this.counter),t]).copy(this._otpSrc44,32);}set_salt12(t,e){if(12!=t.byteLength)throw TypeError("set_salt12: Invalid salt12 byteLength.");t.copy(this._otpSrc44,32);}resetOTP(){$.B8(z.hash(this._otpSrc44)).copy(this._otp36,0,0,32);}getIndexOTP(t){return this._otp36.writeUInt32LE(t,32),z.hash(this._otp36)}generateHMAC(t){let e=l.Buffer.concat([this._otpSrc44,t]);this._hmac=$.B8(z.hash(e));}getHMAC8(t){let e=l.Buffer.concat([this._otpSrc44,t]);return this._hmac=$.B8(z.hash(e)),this._hmac.subarray(0,8)}xotp(t,e=0,r=false){let n=(t=$.B8(t,r)).byteLength,i=e,o=0,f=0;for(;n>0;){f=n<32?n:32;let e=this.getIndexOTP(++i);for(let r=0;r<f;r++)t[o++]^=e[r];n-=32;}return t}server_time_nonce(){const t=Date.now(),e=Math.floor(t/1e3),r=t%1e3;return this.localNonce=q(4),this.auth_salt12=l.Buffer.concat([$.NB("32L",e),$.NB("16L",r),q(2),this.localNonce]),l.Buffer.concat([$.NB("8",F.SERVER_TIME_NONCE),this.auth_salt12])}auth_req(t){let e=$.unpack(t,j.SERVER_TIME_NONCE);if(e){let t=l.Buffer.concat([$.NB("32L",e.unixTime),$.NB("16L",e.milTime),$.NB("16L",e.counter),e.nonce]);return this.set_salt12(t,"auth_req"),this.localNonce=q(4),this.generateHMAC(this.localNonce),this.remoteNonce=e.nonce,$.pack($.MB("#header","8",F.AUTH_REQ),$.MB("#id8",this._id8),$.MB("#nonce",this.localNonce),$.MB("#hmac32",this._hmac))}return false}verify_auth_req(t){let e;if(t instanceof Uint8Array){if(e=$.unpack(t,j.AUTH_REQ),!e)return}else e=t;this.set_salt12(this.auth_salt12,"verify_auth_req 1/2"),this.generateHMAC(e.nonce);let r=this._hmac;if($.equal(e.hmac32,r)){this.remoteNonce=e.nonce;let t=l.Buffer.concat([this.localNonce,this.remoteNonce,this.localNonce]);this.set_salt12(t,"verify_auth_req 2/2"),this.generateHMAC(e.nonce);let r=this._hmac,n=$.rawPack($.MB("header","8",F.AUTH_RES),$.MB("hmac32",r));return this.isAuthorized=true,n}return false}verify_auth_res(t){let e=$.unpack(t,j.AUTH_RES);if(e){let t=l.Buffer.concat([this.remoteNonce,this.localNonce,this.remoteNonce]);this.set_salt12(t,"verify_auth_res"),this.generateHMAC(this.localNonce);let r=this._hmac;if($.equal(r,e.hmac32))return this.isAuthorized=true,true}}encrypt_488(t){if(!this.isAuthorized)return;t=$.B8(t),this.set_clock_nonce(this.remoteNonce),this.resetOTP();let e=this.getHMAC8(t),r=this.xotp(t);return $.pack($.MB("#type","8",F.ENC_488),$.MB("#len","32L",t.byteLength),$.MB("#otpSrc8",this._otpSrc44.subarray(32,40)),$.MB("#hmac8",e),$.MB("#xdata",r))}decrypt_488(t){t=$.B8(t);let e=$.unpack(t,j.ENC_488);if(e){let t=l.Buffer.concat([e.otpSrc8,this.localNonce]);this.set_salt12(t,"decrypt_488"),this.resetOTP();let r=e.$OTHERS.subarray(0,e.len),n=this.xotp(r),i=this.getHMAC8(n);if($.equal(i,e.hmac8))return n}}encryptPack(t){t=$.B8(t),this.set_clock_rand(),this.resetOTP();let e=this.getHMAC8(t),r=this.xotp(t);return $.pack($.MB("#type","8",F.ENC_PACK),$.MB("#len","32L",t.byteLength),$.MB("#salt12",this._otpSrc44.subarray(32)),$.MB("#hmac8",e),$.MB("#xdata",r))}decryptPack(t){if(t[0]!==F.ENC_PACK)return;if(t.readUint32LE(1)==t.byteLength-V.ENC_PACK)try{let e=$.unpack(t,j.ENC_PACK);if(!e)return;this.set_salt12(e.salt12,"decryptPack"),this.resetOTP();let r=e.$OTHERS,n=this.xotp(r),i=this.getHMAC8(n);if($.equal(e.hmac,i))return e.data=n,e}catch(t){}}encrypt_e2e(t,e){let r=l.Buffer.alloc(32);r.set(this._otpSrc44.subarray(0,32)),this.set_key(e);let n=this.encryptPack(t);return this._otpSrc44.set(r),n}decrypt_e2e(t,e){let r=l.Buffer.alloc(32);r.set(this._otpSrc44.subarray(0,32)),this.set_key(e);let n=this.decryptPack(t);return this._otpSrc44.set(r),n}}K.RAND=q,K.BohoMsg=F,K.Meta=j,K.MetaSize=V,K.sha256=z,K.MBP=$,K.Buffer=l.Buffer;
757
+ */var K=(q||(q=1,function(t){const e=function(){if(z)return D;z=1,D.byteLength=function(t){var e=o(t),r=e[0],n=e[1];return 3*(r+n)/4-n},D.toByteArray=function(t){var n,i,f=o(t),s=f[0],u=f[1],h=new r(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),a=0,c=u>0?s-4:s;for(i=0;i<c;i+=4)n=e[t.charCodeAt(i)]<<18|e[t.charCodeAt(i+1)]<<12|e[t.charCodeAt(i+2)]<<6|e[t.charCodeAt(i+3)],h[a++]=n>>16&255,h[a++]=n>>8&255,h[a++]=255&n;return 2===u&&(n=e[t.charCodeAt(i)]<<2|e[t.charCodeAt(i+1)]>>4,h[a++]=255&n),1===u&&(n=e[t.charCodeAt(i)]<<10|e[t.charCodeAt(i+1)]<<4|e[t.charCodeAt(i+2)]>>2,h[a++]=n>>8&255,h[a++]=255&n),h},D.fromByteArray=function(e){for(var r,n=e.length,i=n%3,o=[],f=16383,u=0,h=n-i;u<h;u+=f)o.push(s(e,u,u+f>h?h:u+f));return 1===i?(r=e[n-1],o.push(t[r>>2]+t[r<<4&63]+"==")):2===i&&(r=(e[n-2]<<8)+e[n-1],o.push(t[r>>10]+t[r>>4&63]+t[r<<2&63]+"=")),o.join("")};for(var t=[],e=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0;i<64;++i)t[i]=n[i],e[n.charCodeAt(i)]=i;function o(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return -1===r&&(r=e),[r,r===e?0:4-r%4]}function f(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[63&e]}function s(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(f(n));return i.join("")}return e["-".charCodeAt(0)]=62,e["_".charCodeAt(0)]=63,D}(),r=G(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=f,t.SlowBuffer=function(t){return +t!=t&&(t=0),f.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function o(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,f.prototype),e}function f(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|p(t,e);let n=o(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Q(t,Uint8Array)){const e=new Uint8Array(t);return c(e.buffer,e.byteOffset,e.byteLength)}return a(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Q(t,ArrayBuffer)||t&&Q(t.buffer,ArrayBuffer))return c(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Q(t,SharedArrayBuffer)||t&&Q(t.buffer,SharedArrayBuffer)))return c(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return f.from(n,e,r);const i=function(t){if(f.isBuffer(t)){const e=0|l(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||W(t.length)?o(0):a(t):"Buffer"===t.type&&Array.isArray(t.data)?a(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return f.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return u(t),o(t<0?0:0|l(t))}function a(t){const e=t.length<0?0:0|l(t.length),r=o(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function c(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,f.prototype),n}function l(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(f.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&true===arguments[2];if(!n&&0===r)return 0;let i=false;for(;;)switch(e){case "ascii":case "latin1":case "binary":return r;case "utf8":case "utf-8":return Y(t).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*r;case "hex":return r>>>1;case "base64":return K(t).length;default:if(i)return n?-1:Y(t).length;e=(""+e).toLowerCase(),i=true;}}function y(t,e,r){let n=false;if((void 0===e||e<0)&&(e=0),e>this.length)return "";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return "";if((r>>>=0)<=(e>>>=0))return "";for(t||(t="utf8");;)switch(t){case "hex":return R(this,e,r);case "utf8":case "utf-8":return U(this,e,r);case "ascii":return L(this,e,r);case "latin1":case "binary":return v(this,e,r);case "base64":return _(this,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=true;}}function g(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function d(t,e,r,n,i){if(0===t.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return -1;r=t.length-1;}else if(r<0){if(!i)return -1;r=0;}if("string"==typeof e&&(e=f.from(e,n)),f.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){let o,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return -1;f=2,s/=2,u/=2,r/=2;}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(i){let n=-1;for(o=r;o<s;o++)if(h(t,o)===h(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*f}else -1!==n&&(o-=o-n),n=-1;}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=true;for(let n=0;n<u;n++)if(h(t,o+n)!==h(e,n)){r=false;break}if(r)return o}return -1}function w(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let f;for(n>o/2&&(n=o/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(W(n))return f;t[r+f]=n;}return f}function B(t,e,r,n){return J(Y(e,t.length-r),t,r,n)}function E(t,e,r,n){return J(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function m(t,e,r,n){return J(K(e),t,r,n)}function A(t,e,r,n){return J(function(t,e){let r,n,i;const o=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function U(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,f=e>239?4:e>223?3:e>191?2:1;if(i+f<=r){let r,n,s,u;switch(f){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u));}}null===o?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=f;}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=I));return r}(n)}t.kMaxLength=i,f.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return false}}(),f.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(f.prototype,"parent",{enumerable:true,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:true,get:function(){if(f.isBuffer(this))return this.byteOffset}}),f.poolSize=8192,f.from=function(t,e,r){return s(t,e,r)},Object.setPrototypeOf(f.prototype,Uint8Array.prototype),Object.setPrototypeOf(f,Uint8Array),f.alloc=function(t,e,r){return function(t,e,r){return u(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},f.allocUnsafe=function(t){return h(t)},f.allocUnsafeSlow=function(t){return h(t)},f.isBuffer=function(t){return null!=t&&true===t._isBuffer&&t!==f.prototype},f.compare=function(t,e){if(Q(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),Q(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(t)||!f.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return true;default:return false}},f.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=f.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(Q(e,Uint8Array))i+e.length>n.length?(f.isBuffer(e)||(e=f.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else {if(!f.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i);}i+=e.length;}return n},f.byteLength=p,f.prototype._isBuffer=true,f.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},f.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},f.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},f.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?U(this,0,t):y.apply(this,arguments)},f.prototype.toLocaleString=f.prototype.toString,f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(f.prototype[n]=f.prototype.inspect),f.prototype.compare=function(t,e,r,n,i){if(Q(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return -1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const u=Math.min(o,s),h=this.slice(n,i),a=t.slice(e,r);for(let t=0;t<u;++t)if(h[t]!==a[t]){o=h[t],s=a[t];break}return o<s?-1:s<o?1:0},f.prototype.includes=function(t,e,r){return -1!==this.indexOf(t,e,r)},f.prototype.indexOf=function(t,e,r){return d(this,t,e,r,true)},f.prototype.lastIndexOf=function(t,e,r){return d(this,t,e,r,false)},f.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else {if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=false;for(;;)switch(n){case "hex":return w(this,t,e,r);case "utf8":case "utf-8":return B(this,t,e,r);case "ascii":case "latin1":case "binary":return E(this,t,e,r);case "base64":return m(this,t,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=true;}},f.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function L(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function v(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function R(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=X[t[n]];return i}function T(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function S(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!f.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function N(t,e,r,n,i){j(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function M(t,e,r,n,i){j(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function k(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,8),r.write(t,e,n,i,52,8),n+8}f.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,f.prototype),n},f.prototype.readUintLE=f.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUintBE=f.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},f.prototype.readUint8=f.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},f.prototype.readUint16LE=f.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUint16BE=f.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUint32LE=f.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUint32BE=f.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readBigUInt64LE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),f.prototype.readBigUInt64BE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return (BigInt(n)<<BigInt(32))+BigInt(i)}),f.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},f.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},f.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readBigInt64LE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return (BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),f.prototype.readBigInt64BE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return (BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),f.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),r.read(this,t,true,23,4)},f.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),r.read(this,t,false,23,4)},f.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),r.read(this,t,true,52,8)},f.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),r.read(this,t,false,52,8)},f.prototype.writeUintLE=f.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||O(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},f.prototype.writeUintBE=f.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||O(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},f.prototype.writeUint8=f.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeBigUInt64LE=Z(function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),f.prototype.writeBigUInt64BE=Z(function(t,e=0){return M(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),f.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);O(this,t,e,r,n-1,-n);}let i=0,o=1,f=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===f&&0!==this[e+i-1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},f.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);O(this,t,e,r,n-1,-n);}let i=r-1,o=1,f=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},f.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},f.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},f.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeBigInt64LE=Z(function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),f.prototype.writeBigInt64BE=Z(function(t,e=0){return M(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),f.prototype.writeFloatLE=function(t,e,r){return x(this,t,e,true,r)},f.prototype.writeFloatBE=function(t,e,r){return x(this,t,e,false,r)},f.prototype.writeDoubleLE=function(t,e,r){return k(this,t,e,true,r)},f.prototype.writeDoubleBE=function(t,e,r){return k(this,t,e,false,r)},f.prototype.copy=function(t,e,r,n){if(!f.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},f.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e);}}else "number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else {const o=f.isBuffer(t)?t:f.from(t,n),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%s];}return this};const P={};function $(t,e,r){P[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:true,configurable:true}),this.name=`${this.name} [${t}]`,this.stack,delete this.name;}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:true,enumerable:true,value:t,writable:true});}toString(){return `${this.name} [${t}]: ${this.message}`}};}function F(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return `${t.slice(0,r)}${e}`}function j(t,e,r,n,i,o){if(t>r||t<e){const r="bigint"==typeof e?"n":"";let n;throw n=0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`,new P.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){H(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1));}(n,i,o);}function H(t,e){if("number"!=typeof t)throw new P.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,r){if(Math.floor(t)!==t)throw H(t,r),new P.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new P.ERR_BUFFER_OUT_OF_BOUNDS;throw new P.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}$("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),$("ERR_INVALID_ARG_TYPE",function(t,e){return `The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),$("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=F(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=F(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const q=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r);}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function K(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(q,"")).length<2)return "";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function W(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i];}return e}();function Z(t){return "undefined"==typeof BigInt?tt:t}function tt(){throw new Error("BigInt not supported")}}(H)),H);let J={SERVER_TIME_NONCE:176,AUTH_REQ:177,AUTH_RES:178,AUTH_FAIL:179,ENC_PACK:182,ENC_E2E:183,ENC_488:184};for(let t in J)J[J[t]]=t;const Q={SERVER_TIME_NONCE:F.meta(F.MB("header","8",0),F.MB("unixTime","32L",0),F.MB("milTime","16L",0),F.MB("counter","16L",0),F.MB("nonce",K.Buffer.alloc(4))),AUTH_REQ:F.meta(F.MB("header","8",0),F.MB("id8",K.Buffer.alloc(8)),F.MB("nonce",K.Buffer.alloc(4)),F.MB("hmac32",K.Buffer.alloc(32))),AUTH_RES:F.meta(F.MB("header","8",0),F.MB("hmac32",K.Buffer.alloc(32))),ENC_PACK:F.meta(F.MB("type","8",0),F.MB("len","32L",0),F.MB("salt12",K.Buffer.alloc(12)),F.MB("hmac",8,0)),ENC_488:F.meta(F.MB("type","8",0),F.MB("len","32L",0),F.MB("otpSrc8",K.Buffer.alloc(8)),F.MB("hmac8",K.Buffer.alloc(8)))};function W(t){let e=t[t.length-1];return e[2]+e[3]}const X={SERVER_TIME_NONCE:W(Q.SERVER_TIME_NONCE),AUTH_REQ:W(Q.AUTH_REQ),AUTH_RES:W(Q.AUTH_RES),ENC_PACK:W(Q.ENC_PACK),ENC_488:W(Q.ENC_488)};function Z(t){return globalThis.crypto.getRandomValues(K.Buffer.alloc(t))}class tt{constructor(){this._id8=K.Buffer.alloc(8),this._otpSrc44=K.Buffer.alloc(44),this._otp36=K.Buffer.alloc(36),this._hmac=K.Buffer.alloc(32),this.auth_salt12=K.Buffer.alloc(12),this.localNonce=K.Buffer.alloc(4),this.remoteNonce=K.Buffer.alloc(4),this.isAuthorized=false,this.counter=0;}clearAuth(){this._id8.fill(0),this._otpSrc44.fill(0),this._otp36.fill(0),this._hmac.fill(0),this.auth_salt12.fill(0),this.localNonce.fill(0),this.remoteNonce.fill(0),this.isAuthorized=false,this.counter=0;}set_hash_id8(t){F.B8(j.hash(t)).copy(this._id8,0,0,8);}set_id8(t){let e=F.B8(t);this._id8.fill(0),e.copy(this._id8,0,0,8);}set_key(t){F.B8(j.hash(t)).copy(this._otpSrc44,0,0,32);}set_id_key(t){let e=t.indexOf(".");if(-1==e)return;let r=t.substring(0,e),n=t.substring(e+1);this.set_id8(r),this.set_key(n);}copy_id8(t){t.copy(this._id8,0,0,8);}copy_key(t){t.copy(this._otpSrc44,0,0,32);}sha256_n(t,e){let r=j.hash(t);for(let t=0;t<e;t++)r=j.hash(r);return r}set_clock_rand(){const t=Date.now(),e=parseInt(t/1e3),r=t%1e3;++this.counter>65535&&(this.counter=0);K.Buffer.concat([F.NB("32L",e),F.NB("16L",r),F.NB("16L",this.counter),Z(4)]).copy(this._otpSrc44,32);}set_clock_nonce(t){const e=Date.now(),r=parseInt(e/1e3),n=e%1e3;++this.counter>65535&&(this.counter=0);K.Buffer.concat([F.NB("32L",r),F.NB("16L",n),F.NB("16L",this.counter),t]).copy(this._otpSrc44,32);}set_salt12(t,e){if(12!=t.byteLength)throw TypeError("set_salt12: Invalid salt12 byteLength.");t.copy(this._otpSrc44,32);}resetOTP(){F.B8(j.hash(this._otpSrc44)).copy(this._otp36,0,0,32);}getIndexOTP(t){return this._otp36.writeUInt32LE(t,32),j.hash(this._otp36)}generateHMAC(t){let e=K.Buffer.concat([this._otpSrc44,t]);this._hmac=F.B8(j.hash(e));}getHMAC8(t){let e=K.Buffer.concat([this._otpSrc44,t]);return this._hmac=F.B8(j.hash(e)),this._hmac.subarray(0,8)}xotp(t,e=0,r=false){let n=(t=F.B8(t,r)).byteLength,i=e,o=0,f=0;for(;n>0;){f=n<32?n:32;let e=this.getIndexOTP(++i);for(let r=0;r<f;r++)t[o++]^=e[r];n-=32;}return t}server_time_nonce(){const t=Date.now(),e=Math.floor(t/1e3),r=t%1e3;return this.localNonce=Z(4),this.auth_salt12=K.Buffer.concat([F.NB("32L",e),F.NB("16L",r),Z(2),this.localNonce]),K.Buffer.concat([F.NB("8",J.SERVER_TIME_NONCE),this.auth_salt12])}auth_req(t){let e=F.unpack(t,Q.SERVER_TIME_NONCE);if(e){let t=K.Buffer.concat([F.NB("32L",e.unixTime),F.NB("16L",e.milTime),F.NB("16L",e.counter),e.nonce]);return this.set_salt12(t,"auth_req"),this.localNonce=Z(4),this.generateHMAC(this.localNonce),this.remoteNonce=e.nonce,F.pack(F.MB("#header","8",J.AUTH_REQ),F.MB("#id8",this._id8),F.MB("#nonce",this.localNonce),F.MB("#hmac32",this._hmac))}return false}verify_auth_req(t){let e;if(t instanceof Uint8Array){if(e=F.unpack(t,Q.AUTH_REQ),!e)return}else e=t;this.set_salt12(this.auth_salt12,"verify_auth_req 1/2"),this.generateHMAC(e.nonce);let r=this._hmac;if(F.equal(e.hmac32,r)){this.remoteNonce=e.nonce;let t=K.Buffer.concat([this.localNonce,this.remoteNonce,this.localNonce]);this.set_salt12(t,"verify_auth_req 2/2"),this.generateHMAC(e.nonce);let r=this._hmac,n=F.rawPack(F.MB("header","8",J.AUTH_RES),F.MB("hmac32",r));return this.isAuthorized=true,n}return false}verify_auth_res(t){let e=F.unpack(t,Q.AUTH_RES);if(e){let t=K.Buffer.concat([this.remoteNonce,this.localNonce,this.remoteNonce]);this.set_salt12(t,"verify_auth_res"),this.generateHMAC(this.localNonce);let r=this._hmac;if(F.equal(r,e.hmac32))return this.isAuthorized=true,true}}encrypt_488(t){if(!this.isAuthorized)return;t=F.B8(t),this.set_clock_nonce(this.remoteNonce),this.resetOTP();let e=this.getHMAC8(t),r=this.xotp(t);return F.pack(F.MB("#type","8",J.ENC_488),F.MB("#len","32L",t.byteLength),F.MB("#otpSrc8",this._otpSrc44.subarray(32,40)),F.MB("#hmac8",e),F.MB("#xdata",r))}decrypt_488(t){t=F.B8(t);let e=F.unpack(t,Q.ENC_488);if(e){let t=K.Buffer.concat([e.otpSrc8,this.localNonce]);this.set_salt12(t,"decrypt_488"),this.resetOTP();let r=e.$OTHERS.subarray(0,e.len),n=this.xotp(r),i=this.getHMAC8(n);if(F.equal(i,e.hmac8))return n}}encryptPack(t){t=F.B8(t),this.set_clock_rand(),this.resetOTP();let e=this.getHMAC8(t),r=this.xotp(t);return F.pack(F.MB("#type","8",J.ENC_PACK),F.MB("#len","32L",t.byteLength),F.MB("#salt12",this._otpSrc44.subarray(32)),F.MB("#hmac8",e),F.MB("#xdata",r))}decryptPack(t){if(t[0]!==J.ENC_PACK)return;if(t.readUint32LE(1)==t.byteLength-X.ENC_PACK)try{let e=F.unpack(t,Q.ENC_PACK);if(!e)return;this.set_salt12(e.salt12,"decryptPack"),this.resetOTP();let r=e.$OTHERS,n=this.xotp(r),i=this.getHMAC8(n);if(F.equal(e.hmac,i))return e.data=n,e}catch(t){}}encrypt_e2e(t,e){let r=K.Buffer.alloc(32);r.set(this._otpSrc44.subarray(0,32)),this.set_key(e);let n=this.encryptPack(t);return this._otpSrc44.set(r),n}decrypt_e2e(t,e){let r=K.Buffer.alloc(32);r.set(this._otpSrc44.subarray(0,32)),this.set_key(e);let n=this.decryptPack(t);return this._otpSrc44.set(r),n}}tt.RAND=Z,tt.BohoMsg=J,tt.Meta=Q,tt.MetaSize=X,tt.sha256=j,tt.MBP=F,tt.Buffer=K.Buffer;
3773
758
 
3774
759
  /**
3775
760
  * @typedef {import('meta-buffer-pack').MBP} MBP
@@ -3784,7 +769,7 @@ const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1
3784
769
  * @typedef {import('boho').Buffer} Buffer
3785
770
  */
3786
771
 
3787
- const Buffer$1 = mbp.Buffer;
772
+ const Buffer$1 = M$1.Buffer;
3788
773
  const encoder$1 = new TextEncoder();
3789
774
  const decoder$4 = new TextDecoder();
3790
775
 
@@ -3879,9 +864,9 @@ class IOCore extends EventEmitter {
3879
864
  * Boho instance for encryption/decryption.
3880
865
  * @type {Boho}
3881
866
  */
3882
- this.boho = new K();
867
+ this.boho = new tt();
3883
868
 
3884
- this.serverTimeNonce = Buffer$1.alloc( K.MetaSize.SERVER_TIME_NONCE );
869
+ this.serverTimeNonce = Buffer$1.alloc( tt.MetaSize.SERVER_TIME_NONCE );
3885
870
  /**
3886
871
  * Indicates if the connection is TLS (wss).
3887
872
  * @type {boolean}
@@ -4154,13 +1139,13 @@ class IOCore extends EventEmitter {
4154
1139
  let msgType = buffer[0];
4155
1140
  let decoded;
4156
1141
 
4157
- if (msgType === K.BohoMsg.ENC_488) {
1142
+ if (msgType === tt.BohoMsg.ENC_488) {
4158
1143
  decoded = this.boho.decrypt_488(buffer);
4159
1144
  if (decoded) {
4160
1145
  msgType = decoded[0];
4161
1146
  buffer = decoded;
4162
1147
  }
4163
- } else if (msgType === K.BohoMsg.ENC_E2E) {
1148
+ } else if (msgType === tt.BohoMsg.ENC_E2E) {
4164
1149
 
4165
1150
  try {
4166
1151
  decoded = this.boho.decrypt_488(buffer);
@@ -4168,8 +1153,8 @@ class IOCore extends EventEmitter {
4168
1153
  // console.log( 'ENC_E2E decoded ', decoded )
4169
1154
  msgType = decoded[0];
4170
1155
  // decoded has msg_header only.
4171
- buffer.set(decoded, K.MetaSize.ENC_488); // set decoded signal_e2e headaer.
4172
- buffer = buffer.subarray(K.MetaSize.ENC_488); // reset offset.
1156
+ buffer.set(decoded, tt.MetaSize.ENC_488); // set decoded signal_e2e headaer.
1157
+ buffer = buffer.subarray(tt.MetaSize.ENC_488); // reset offset.
4173
1158
  // console.log('DECODED MsgType:', IOMsg[ msgType ] )
4174
1159
  } else {
4175
1160
  // console.log('488 DEC_FAIL', buffer)
@@ -4184,7 +1169,7 @@ class IOCore extends EventEmitter {
4184
1169
  }
4185
1170
 
4186
1171
  let type = IOMsg[msgType];
4187
- if (!type) type = K.BohoMsg[msgType];
1172
+ if (!type) type = tt.BohoMsg[msgType];
4188
1173
 
4189
1174
  // console.log( "MsgType: ", type , " LEN ", buffer.byteLength)
4190
1175
 
@@ -4263,7 +1248,7 @@ class IOCore extends EventEmitter {
4263
1248
  this.redirect(url);
4264
1249
  break;
4265
1250
 
4266
- case K.BohoMsg.SERVER_TIME_NONCE: // SERVER_READY
1251
+ case tt.BohoMsg.SERVER_TIME_NONCE: // SERVER_READY
4267
1252
  this.stateChange('server_ready', 'server_ready');
4268
1253
  if (this.useAuth) {
4269
1254
  this.send(this.boho.auth_req(buffer));
@@ -4294,7 +1279,7 @@ class IOCore extends EventEmitter {
4294
1279
 
4295
1280
  case IOMsg.SET:
4296
1281
  try {
4297
- let setPack = mbp.unpack(buffer);
1282
+ let setPack = M$1.unpack(buffer);
4298
1283
  if (setPack) {
4299
1284
  this.emit(setPack.topic, ...setPack.args);
4300
1285
  }
@@ -4373,7 +1358,7 @@ class IOCore extends EventEmitter {
4373
1358
  break;
4374
1359
 
4375
1360
  case PAYLOAD_TYPE.MBA:
4376
- let mbaObject = mbp.unpack(payloadBuffer);
1361
+ let mbaObject = M$1.unpack(payloadBuffer);
4377
1362
  if (tag.indexOf('@') === 0) this.emit('@', tag, ...mbaObject.args);
4378
1363
  else {
4379
1364
  this.emit(tag, tag, ...mbaObject.args);
@@ -4395,11 +1380,11 @@ class IOCore extends EventEmitter {
4395
1380
  this.testPromise(buffer);
4396
1381
  break;
4397
1382
 
4398
- case K.BohoMsg.AUTH_FAIL:
1383
+ case tt.BohoMsg.AUTH_FAIL:
4399
1384
  this.stateChange('auth_fail', 'auth_fail from server.');
4400
1385
  break;
4401
1386
 
4402
- case K.BohoMsg.AUTH_RES:
1387
+ case tt.BohoMsg.AUTH_RES:
4403
1388
  if (this.boho.verify_auth_res(buffer)) {
4404
1389
  this.stateChange('auth_res', 'server sent auth_res');
4405
1390
  this.send(Buffer$1.from([IOMsg.CID_REQ]));
@@ -4429,13 +1414,13 @@ class IOCore extends EventEmitter {
4429
1414
  iam(title) {
4430
1415
  // console.log('iam', title)
4431
1416
  if (title) {
4432
- this.send_enc_mode(mbp.pack(
4433
- mbp.MB('#MsgType', '8', IOMsg.IAM),
4434
- mbp.MB('#', title)
1417
+ this.send_enc_mode(M$1.pack(
1418
+ M$1.MB('#MsgType', '8', IOMsg.IAM),
1419
+ M$1.MB('#', title)
4435
1420
  ));
4436
1421
  } else {
4437
- this.send_enc_mode(mbp.pack(
4438
- mbp.MB('#MsgType', '8', IOMsg.IAM)
1422
+ this.send_enc_mode(M$1.pack(
1423
+ M$1.MB('#MsgType', '8', IOMsg.IAM)
4439
1424
  ));
4440
1425
  }
4441
1426
  }
@@ -4463,9 +1448,9 @@ class IOCore extends EventEmitter {
4463
1448
  echo(args) {
4464
1449
  if (args) {
4465
1450
  // console.log('send echo args:', args)
4466
- this.send_enc_mode(mbp.pack(
4467
- mbp.MB('#MsgType', '8', IOMsg.ECHO),
4468
- mbp.MB('#msg', args)
1451
+ this.send_enc_mode(M$1.pack(
1452
+ M$1.MB('#MsgType', '8', IOMsg.ECHO),
1453
+ M$1.MB('#msg', args)
4469
1454
  ));
4470
1455
  } else {
4471
1456
  // # do not encrypt blank echo #
@@ -4479,7 +1464,7 @@ class IOCore extends EventEmitter {
4479
1464
  * @param {...any} data - Data to send.
4480
1465
  */
4481
1466
  bin(...data) {
4482
- this.send(mbp.U8pack(...data));
1467
+ this.send(M$1.U8pack(...data));
4483
1468
  }
4484
1469
 
4485
1470
  /**
@@ -4529,7 +1514,7 @@ class IOCore extends EventEmitter {
4529
1514
  // encrypt signal_header area only. payload is encrypted with e2e key already.
4530
1515
  let tagLen = data[1];
4531
1516
  let encHeader = this.boho.encrypt_488(data.subarray(0, 3 + tagLen));
4532
- encHeader[0] = K.BohoMsg.ENC_E2E;
1517
+ encHeader[0] = tt.BohoMsg.ENC_E2E;
4533
1518
  this.send(Buffer$1.concat([encHeader, data.subarray(3 + tagLen)]));
4534
1519
  // console.log('<< send_enc_mode [ ENC_E2E ]')
4535
1520
 
@@ -4568,7 +1553,7 @@ class IOCore extends EventEmitter {
4568
1553
  */
4569
1554
  testPromise(buffer) {
4570
1555
 
4571
- let res = mbp.unpack(buffer);
1556
+ let res = M$1.unpack(buffer);
4572
1557
  if (!res) return
4573
1558
 
4574
1559
  if (this.promiseMap.has(res.mid)) {
@@ -4635,18 +1620,18 @@ class IOCore extends EventEmitter {
4635
1620
  if( !this.boho.isAuthorized ) return;
4636
1621
  if (typeof tag !== 'string') throw TypeError('tag should be string.')
4637
1622
  let tagEncoded = encoder$1.encode(tag);
4638
- let dataPack = mbp.B8(data);
1623
+ let dataPack = M$1.B8(data);
4639
1624
 
4640
1625
  //encrypt payload area with key
4641
1626
  let sercretPack = this.boho.encrypt_e2e(dataPack, key);
4642
1627
 
4643
1628
  //change signal MsgType header into SIGNAL_E2E
4644
- let signalPack = mbp.pack(
4645
- mbp.MB('#MsgType', '8', IOMsg.SIGNAL_E2E),
4646
- mbp.MB('#tagLen', '8', tagEncoded.byteLength),
4647
- mbp.MB('#tag', tagEncoded),
4648
- mbp.MB('#payloadType', '8', PAYLOAD_TYPE.BINARY),
4649
- mbp.MB('#payload', sercretPack)
1629
+ let signalPack = M$1.pack(
1630
+ M$1.MB('#MsgType', '8', IOMsg.SIGNAL_E2E),
1631
+ M$1.MB('#tagLen', '8', tagEncoded.byteLength),
1632
+ M$1.MB('#tag', tagEncoded),
1633
+ M$1.MB('#payloadType', '8', PAYLOAD_TYPE.BINARY),
1634
+ M$1.MB('#payload', sercretPack)
4650
1635
  );
4651
1636
 
4652
1637
  this.send_enc_mode(signalPack);
@@ -4676,7 +1661,7 @@ class IOCore extends EventEmitter {
4676
1661
  return Promise.reject(new Error('store get need storeName)'))
4677
1662
  }
4678
1663
  let pack = await this.call('store', 'get', storeName);
4679
- let { $ } = mbp.unpack(pack.body);
1664
+ let { $ } = M$1.unpack(pack.body);
4680
1665
  return $
4681
1666
  }
4682
1667
 
@@ -4693,19 +1678,19 @@ class IOCore extends EventEmitter {
4693
1678
  return Promise.reject(new Error('request need target and topic)'))
4694
1679
  let sigPack;
4695
1680
  if (args.length > 0) {
4696
- sigPack = mbp.pack(
4697
- mbp.MB('#MsgType', '8', IOMsg.CALL),
4698
- mbp.MB('mid', '16', ++this.mid),
4699
- mbp.MB('target', target),
4700
- mbp.MB('topic', topic),
4701
- mbp.MBA(...args)
1681
+ sigPack = M$1.pack(
1682
+ M$1.MB('#MsgType', '8', IOMsg.CALL),
1683
+ M$1.MB('mid', '16', ++this.mid),
1684
+ M$1.MB('target', target),
1685
+ M$1.MB('topic', topic),
1686
+ M$1.MBA(...args)
4702
1687
  );
4703
1688
  } else {
4704
- sigPack = mbp.pack(
4705
- mbp.MB('#MsgType', '8', IOMsg.CALL),
4706
- mbp.MB('mid', '16', ++this.mid),
4707
- mbp.MB('target', target),
4708
- mbp.MB('topic', topic)
1689
+ sigPack = M$1.pack(
1690
+ M$1.MB('#MsgType', '8', IOMsg.CALL),
1691
+ M$1.MB('mid', '16', ++this.mid),
1692
+ M$1.MB('target', target),
1693
+ M$1.MB('topic', topic)
4709
1694
  );
4710
1695
  }
4711
1696
  this.send_enc_mode(sigPack);
@@ -4726,8 +1711,8 @@ class IOCore extends EventEmitter {
4726
1711
  let tagEncoded = encoder$1.encode(tag);
4727
1712
  this.send_enc_mode(
4728
1713
  Buffer$1.concat([
4729
- mbp.NB('8', IOMsg.SUBSCRIBE),
4730
- mbp.NB('8', tagEncoded.byteLength),
1714
+ M$1.NB('8', IOMsg.SUBSCRIBE),
1715
+ M$1.NB('8', tagEncoded.byteLength),
4731
1716
  tagEncoded]));
4732
1717
  } catch (error) { }
4733
1718
 
@@ -4747,8 +1732,8 @@ class IOCore extends EventEmitter {
4747
1732
  let tagEncoded = encoder$1.encode(tag);
4748
1733
  this.send_enc_mode(
4749
1734
  Buffer$1.concat([
4750
- mbp.NB('8', IOMsg.SUBSCRIBE),
4751
- mbp.NB('8', tagEncoded.byteLength),
1735
+ M$1.NB('8', IOMsg.SUBSCRIBE),
1736
+ M$1.NB('8', tagEncoded.byteLength),
4752
1737
  tagEncoded]));
4753
1738
  } catch (error) { }
4754
1739
 
@@ -4775,8 +1760,8 @@ class IOCore extends EventEmitter {
4775
1760
  if (tagEncoded.byteLength > SIZE_LIMIT.TAG_LEN1) throw TypeError('please use tag string bytelength below:' + SIZE_LIMIT.TAG_LEN1)
4776
1761
 
4777
1762
  this.send_enc_mode(Buffer$1.concat([
4778
- mbp.NB('8', IOMsg.UNSUBSCRIBE),
4779
- mbp.NB('8', tagEncoded.byteLength),
1763
+ M$1.NB('8', IOMsg.UNSUBSCRIBE),
1764
+ M$1.NB('8', tagEncoded.byteLength),
4780
1765
  tagEncoded]));
4781
1766
  }
4782
1767
 
@@ -4971,34 +1956,34 @@ function pack(payload) {
4971
1956
  if( payload.byteLength == undefined ) payload = Buffer.from(payload);
4972
1957
 
4973
1958
  if (payload.byteLength < 256) { //one byte len
4974
- return mbp.pack(
4975
- mbp.MB('#type', '8', CongType.TYPE_LEN1),
4976
- mbp.MB('#payloadLen1', '8', payload.byteLength),
4977
- mbp.MB('#payload', payload)
1959
+ return M$1.pack(
1960
+ M$1.MB('#type', '8', CongType.TYPE_LEN1),
1961
+ M$1.MB('#payloadLen1', '8', payload.byteLength),
1962
+ M$1.MB('#payload', payload)
4978
1963
  )
4979
1964
 
4980
1965
  } else if (payload.byteLength < 65536) { // 2bytes len
4981
- return mbp.pack(
4982
- mbp.MB('#type', '8', CongType.TYPE_LEN2),
4983
- mbp.MB('#payloadLen2', '16L', payload.byteLength),
4984
- mbp.MB('#payload', payload)
1966
+ return M$1.pack(
1967
+ M$1.MB('#type', '8', CongType.TYPE_LEN2),
1968
+ M$1.MB('#payloadLen2', '16L', payload.byteLength),
1969
+ M$1.MB('#payload', payload)
4985
1970
  )
4986
1971
 
4987
1972
  } else if (payload.byteLength < 2 ** 24) { // 3bytes len
4988
1973
  let len4Buffer = Buffer.alloc(4);
4989
1974
  len4Buffer.writeUint32LE(payload.byteLength);
4990
1975
  let cropLen3 = len4Buffer.subarray(0, 3);
4991
- return mbp.pack(
4992
- mbp.MB('#type', '8', CongType.TYPE_LEN3),
4993
- mbp.MB('#payloadLen3', cropLen3),
4994
- mbp.MB('#payload', payload)
1976
+ return M$1.pack(
1977
+ M$1.MB('#type', '8', CongType.TYPE_LEN3),
1978
+ M$1.MB('#payloadLen3', cropLen3),
1979
+ M$1.MB('#payload', payload)
4995
1980
  )
4996
1981
 
4997
1982
  } else { //use 4 bytes.
4998
- return mbp.pack(
4999
- mbp.MB('#type', '8', CongType.TYPE_LEN4),
5000
- mbp.MB('#payloadLen4', '32L', payload.byteLength),
5001
- mbp.MB('#payload', payload)
1983
+ return M$1.pack(
1984
+ M$1.MB('#type', '8', CongType.TYPE_LEN4),
1985
+ M$1.MB('#payloadLen4', '32L', payload.byteLength),
1986
+ M$1.MB('#payload', payload)
5002
1987
  )
5003
1988
  }
5004
1989
 
@@ -5878,7 +2863,9 @@ function requirePermessageDeflate () {
5878
2863
  (typeof opts.serverMaxWindowBits === 'number' &&
5879
2864
  opts.serverMaxWindowBits > params.server_max_window_bits))) ||
5880
2865
  (typeof opts.clientMaxWindowBits === 'number' &&
5881
- !params.client_max_window_bits)
2866
+ (typeof params.client_max_window_bits === 'number'
2867
+ ? opts.clientMaxWindowBits > params.client_max_window_bits
2868
+ : !params.client_max_window_bits))
5882
2869
  ) {
5883
2870
  return false;
5884
2871
  }
@@ -6534,6 +3521,10 @@ function requireReceiver () {
6534
3521
  * extensions
6535
3522
  * @param {Boolean} [options.isServer=false] Specifies whether to operate in
6536
3523
  * client or server mode
3524
+ * @param {Number} [options.maxBufferedChunks=0] The maximum number of
3525
+ * buffered data chunks
3526
+ * @param {Number} [options.maxFragments=0] The maximum number of message
3527
+ * fragments
6537
3528
  * @param {Number} [options.maxPayload=0] The maximum allowed message length
6538
3529
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
6539
3530
  * not to skip UTF-8 validation for text and close messages
@@ -6548,6 +3539,8 @@ function requireReceiver () {
6548
3539
  this._binaryType = options.binaryType || BINARY_TYPES[0];
6549
3540
  this._extensions = options.extensions || {};
6550
3541
  this._isServer = !!options.isServer;
3542
+ this._maxBufferedChunks = options.maxBufferedChunks | 0;
3543
+ this._maxFragments = options.maxFragments | 0;
6551
3544
  this._maxPayload = options.maxPayload | 0;
6552
3545
  this._skipUTF8Validation = !!options.skipUTF8Validation;
6553
3546
  this[kWebSocket] = undefined;
@@ -6565,6 +3558,7 @@ function requireReceiver () {
6565
3558
 
6566
3559
  this._totalPayloadLength = 0;
6567
3560
  this._messageLength = 0;
3561
+ this._numFragments = 0;
6568
3562
  this._fragments = [];
6569
3563
 
6570
3564
  this._errored = false;
@@ -6583,6 +3577,22 @@ function requireReceiver () {
6583
3577
  _write(chunk, encoding, cb) {
6584
3578
  if (this._opcode === 0x08 && this._state == GET_INFO) return cb();
6585
3579
 
3580
+ if (
3581
+ this._maxBufferedChunks > 0 &&
3582
+ this._buffers.length >= this._maxBufferedChunks
3583
+ ) {
3584
+ cb(
3585
+ this.createError(
3586
+ RangeError,
3587
+ 'Too many buffered chunks',
3588
+ false,
3589
+ 1008,
3590
+ 'WS_ERR_TOO_MANY_BUFFERED_PARTS'
3591
+ )
3592
+ );
3593
+ return;
3594
+ }
3595
+
6586
3596
  this._bufferedBytes += chunk.length;
6587
3597
  this._buffers.push(chunk);
6588
3598
  this.startLoop(cb);
@@ -6972,6 +3982,19 @@ function requireReceiver () {
6972
3982
  return;
6973
3983
  }
6974
3984
 
3985
+ if (this._maxFragments > 0 && ++this._numFragments > this._maxFragments) {
3986
+ const error = this.createError(
3987
+ RangeError,
3988
+ 'Too many message fragments',
3989
+ false,
3990
+ 1008,
3991
+ 'WS_ERR_TOO_MANY_BUFFERED_PARTS'
3992
+ );
3993
+
3994
+ cb(error);
3995
+ return;
3996
+ }
3997
+
6975
3998
  if (this._compressed) {
6976
3999
  this._state = INFLATING;
6977
4000
  this.decompress(data, cb);
@@ -7044,6 +4067,7 @@ function requireReceiver () {
7044
4067
  this._totalPayloadLength = 0;
7045
4068
  this._messageLength = 0;
7046
4069
  this._fragmented = 0;
4070
+ this._numFragments = 0;
7047
4071
  this._fragments = [];
7048
4072
 
7049
4073
  if (this._opcode === 2) {
@@ -7212,6 +4236,9 @@ function requireSender () {
7212
4236
 
7213
4237
  const { Duplex } = require$$0$2;
7214
4238
  const { randomFillSync } = require$$1;
4239
+ const {
4240
+ types: { isUint8Array }
4241
+ } = require$$2$1;
7215
4242
 
7216
4243
  const PerMessageDeflate = requirePermessageDeflate();
7217
4244
  const { EMPTY_BUFFER, kWebSocket, NOOP } = requireConstants();
@@ -7408,8 +4435,10 @@ function requireSender () {
7408
4435
 
7409
4436
  if (typeof data === 'string') {
7410
4437
  buf.write(data, 2);
7411
- } else {
4438
+ } else if (isUint8Array(data)) {
7412
4439
  buf.set(data, 2);
4440
+ } else {
4441
+ throw new TypeError('Second argument must be a string or a Uint8Array');
7413
4442
  }
7414
4443
  }
7415
4444
 
@@ -8333,7 +5362,7 @@ function requireWebsocket () {
8333
5362
 
8334
5363
  const EventEmitter = require$$0$3;
8335
5364
  const https = require$$1$1;
8336
- const http = require$$2$1;
5365
+ const http = require$$2$2;
8337
5366
  const net$1 = net;
8338
5367
  const tls = require$$4;
8339
5368
  const { randomBytes, createHash } = require$$1;
@@ -8530,6 +5559,10 @@ function requireWebsocket () {
8530
5559
  * multiple times in the same tick
8531
5560
  * @param {Function} [options.generateMask] The function used to generate the
8532
5561
  * masking key
5562
+ * @param {Number} [options.maxBufferedChunks=0] The maximum number of
5563
+ * buffered data chunks
5564
+ * @param {Number} [options.maxFragments=0] The maximum number of message
5565
+ * fragments
8533
5566
  * @param {Number} [options.maxPayload=0] The maximum allowed message size
8534
5567
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
8535
5568
  * not to skip UTF-8 validation for text and close messages
@@ -8541,6 +5574,8 @@ function requireWebsocket () {
8541
5574
  binaryType: this.binaryType,
8542
5575
  extensions: this._extensions,
8543
5576
  isServer: this._isServer,
5577
+ maxBufferedChunks: options.maxBufferedChunks,
5578
+ maxFragments: options.maxFragments,
8544
5579
  maxPayload: options.maxPayload,
8545
5580
  skipUTF8Validation: options.skipUTF8Validation
8546
5581
  });
@@ -8969,6 +6004,10 @@ function requireWebsocket () {
8969
6004
  * masking key
8970
6005
  * @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the
8971
6006
  * handshake request
6007
+ * @param {Number} [options.maxBufferedChunks=262144] The maximum number of
6008
+ * buffered data chunks
6009
+ * @param {Number} [options.maxFragments=16384] The maximum number of message
6010
+ * fragments
8972
6011
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
8973
6012
  * size
8974
6013
  * @param {Number} [options.maxRedirects=10] The maximum number of redirects
@@ -8989,6 +6028,8 @@ function requireWebsocket () {
8989
6028
  autoPong: true,
8990
6029
  closeTimeout: CLOSE_TIMEOUT,
8991
6030
  protocolVersion: protocolVersions[1],
6031
+ maxBufferedChunks: 256 * 1024,
6032
+ maxFragments: 16 * 1024,
8992
6033
  maxPayload: 100 * 1024 * 1024,
8993
6034
  skipUTF8Validation: false,
8994
6035
  perMessageDeflate: true,
@@ -9346,6 +6387,8 @@ function requireWebsocket () {
9346
6387
  websocket.setSocket(socket, head, {
9347
6388
  allowSynchronousEvents: opts.allowSynchronousEvents,
9348
6389
  generateMask: opts.generateMask,
6390
+ maxBufferedChunks: opts.maxBufferedChunks,
6391
+ maxFragments: opts.maxFragments,
9349
6392
  maxPayload: opts.maxPayload,
9350
6393
  skipUTF8Validation: opts.skipUTF8Validation
9351
6394
  });
@@ -9988,7 +7031,7 @@ function requireWebsocketServer () {
9988
7031
  hasRequiredWebsocketServer = 1;
9989
7032
 
9990
7033
  const EventEmitter = require$$0$3;
9991
- const http = require$$2$1;
7034
+ const http = require$$2$2;
9992
7035
  const { Duplex } = require$$0$2;
9993
7036
  const { createHash } = require$$1;
9994
7037
 
@@ -10028,6 +7071,10 @@ function requireWebsocketServer () {
10028
7071
  * called
10029
7072
  * @param {Function} [options.handleProtocols] A hook to handle protocols
10030
7073
  * @param {String} [options.host] The hostname where to bind the server
7074
+ * @param {Number} [options.maxBufferedChunks=262144] The maximum number of
7075
+ * buffered data chunks
7076
+ * @param {Number} [options.maxFragments=16384] The maximum number of message
7077
+ * fragments
10031
7078
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
10032
7079
  * size
10033
7080
  * @param {Boolean} [options.noServer=false] Enable no server mode
@@ -10050,6 +7097,8 @@ function requireWebsocketServer () {
10050
7097
  options = {
10051
7098
  allowSynchronousEvents: true,
10052
7099
  autoPong: true,
7100
+ maxBufferedChunks: 256 * 1024,
7101
+ maxFragments: 16 * 1024,
10053
7102
  maxPayload: 100 * 1024 * 1024,
10054
7103
  skipUTF8Validation: false,
10055
7104
  perMessageDeflate: false,
@@ -10409,6 +7458,8 @@ function requireWebsocketServer () {
10409
7458
 
10410
7459
  ws.setSocket(socket, head, {
10411
7460
  allowSynchronousEvents: this.options.allowSynchronousEvents,
7461
+ maxBufferedChunks: this.options.maxBufferedChunks,
7462
+ maxFragments: this.options.maxFragments,
10412
7463
  maxPayload: this.options.maxPayload,
10413
7464
  skipUTF8Validation: this.options.skipUTF8Validation
10414
7465
  });
@@ -10668,7 +7719,9 @@ let serverOption = {
10668
7719
  };
10669
7720
 
10670
7721
  const decoder$3 = new TextDecoder();
10671
- const MB = mbp.MB;
7722
+
7723
+ M$1.NB;
7724
+ const MB = M$1.MB;
10672
7725
 
10673
7726
 
10674
7727
  class RemoteCore {
@@ -10680,7 +7733,7 @@ class RemoteCore {
10680
7733
  socket.rxCounter = 0;
10681
7734
  socket.openTime = Date.now();
10682
7735
 
10683
- this.boho = new K();
7736
+ this.boho = new tt();
10684
7737
  this.encMode = ENC_MODE.AUTO;
10685
7738
  this.channels = new Set(); // subscribed tags
10686
7739
  this.retain_signal = new Map();
@@ -10734,7 +7787,7 @@ class RemoteCore {
10734
7787
  let prnLimit = 20;
10735
7788
  if (isBinary) {
10736
7789
  let msgTypeName = IOMsg[message[0]];
10737
- if (!msgTypeName) msgTypeName = K.BohoMsg[message[0]];
7790
+ if (!msgTypeName) msgTypeName = tt.BohoMsg[message[0]];
10738
7791
 
10739
7792
  msgTypeName = '[' + msgTypeName + ']';
10740
7793
  let size = message.byteLength;
@@ -10787,7 +7840,7 @@ class RemoteCore {
10787
7840
  if (isBinary) {
10788
7841
  msgType = message[0];
10789
7842
 
10790
- if (msgType === K.BohoMsg.ENC_488) {
7843
+ if (msgType === tt.BohoMsg.ENC_488) {
10791
7844
 
10792
7845
  try {
10793
7846
  decoded = this.boho.decrypt_488(message);
@@ -10803,7 +7856,7 @@ class RemoteCore {
10803
7856
  return
10804
7857
  }
10805
7858
 
10806
- } else if (msgType === K.BohoMsg.ENC_E2E) { // symetric E2EE Signal
7859
+ } else if (msgType === tt.BohoMsg.ENC_E2E) { // symetric E2EE Signal
10807
7860
  try {
10808
7861
  decoded = this.boho.decrypt_488(message);
10809
7862
  } catch (err) {
@@ -10813,8 +7866,8 @@ class RemoteCore {
10813
7866
  // console.log('e2e unpack:', decoded )
10814
7867
  if (decoded) {
10815
7868
  msgType = decoded[0];
10816
- message.set(decoded, K.MetaSize.ENC_488); // set decoded signal_e2e headaer.
10817
- message = message.subarray(K.MetaSize.ENC_488); // reset offset.
7869
+ message.set(decoded, tt.MetaSize.ENC_488); // set decoded signal_e2e headaer.
7870
+ message = message.subarray(tt.MetaSize.ENC_488); // reset offset.
10818
7871
  } else {
10819
7872
  return
10820
7873
  }
@@ -10842,7 +7895,7 @@ class RemoteCore {
10842
7895
  }
10843
7896
 
10844
7897
  // console.log('<< SENDING CID_RES:', this.cid)
10845
- this.send_enc_mode(mbp.pack(
7898
+ this.send_enc_mode(M$1.pack(
10846
7899
  MB('#cid_ack', '8', IOMsg.CID_RES),
10847
7900
  MB('#cid', this.cid)
10848
7901
  ));
@@ -10926,7 +7979,7 @@ class RemoteCore {
10926
7979
 
10927
7980
  case IOMsg.CALL: //service request
10928
7981
  try {
10929
- let req = mbp.unpack(message);
7982
+ let req = M$1.unpack(message);
10930
7983
  if (req) {
10931
7984
  if (!req.target || !req.topic) return
10932
7985
  if (this.manager.server.serviceNames.has(req.target)) {
@@ -10951,7 +8004,7 @@ class RemoteCore {
10951
8004
 
10952
8005
 
10953
8006
  // client's auth requst
10954
- case K.BohoMsg.AUTH_REQ:
8007
+ case tt.BohoMsg.AUTH_REQ:
10955
8008
  if (!this.manager.authManager) return
10956
8009
  if (this.state < STATE.SERVER_READY) {
10957
8010
  console.log('protocol error. must called auth_req after server_ready');
@@ -10996,14 +8049,14 @@ class RemoteCore {
10996
8049
  response(msgId, statusCode, body) {
10997
8050
  // console.log('response body', body)
10998
8051
  if (body) {
10999
- this.send_enc_mode(mbp.pack(
8052
+ this.send_enc_mode(M$1.pack(
11000
8053
  MB('#type', '8', IOMsg.RESPONSE_MBP),
11001
8054
  MB('status', '8', statusCode),
11002
8055
  MB('mid', '16', msgId),
11003
8056
  MB('body', body)
11004
8057
  ));
11005
8058
  } else {
11006
- this.send_enc_mode(mbp.pack(
8059
+ this.send_enc_mode(M$1.pack(
11007
8060
  MB('#type', '8', IOMsg.RESPONSE_MBP),
11008
8061
  MB('status', '8', statusCode),
11009
8062
  MB('mid', '16', msgId)
@@ -11030,7 +8083,7 @@ class RemoteCore {
11030
8083
  // console.log('server bypass E2E signal taginfo:', tagInfo )
11031
8084
 
11032
8085
  let encHeader = this.boho.encrypt_488(data.subarray(0, 3 + tagLen));
11033
- encHeader[0] = K.BohoMsg.ENC_E2E;
8086
+ encHeader[0] = tt.BohoMsg.ENC_E2E;
11034
8087
  let newEncBuffer = Buffer.concat([encHeader, data.subarray(3 + tagLen)]);
11035
8088
  this.send(newEncBuffer);
11036
8089
 
@@ -11070,7 +8123,7 @@ class RemoteCore {
11070
8123
  }
11071
8124
 
11072
8125
  // console.log( 'iam res info', info )
11073
- let pack = mbp.pack(
8126
+ let pack = M$1.pack(
11074
8127
  MB('#MsgType', '8', IOMsg.IAM_RES),
11075
8128
  MB('#info', info)
11076
8129
  );
@@ -11648,9 +8701,9 @@ class Manager {
11648
8701
 
11649
8702
  // it's like unix wall command.
11650
8703
  serverSignal(obj) {
11651
- let sigPack = mbp.pack(
11652
- mbp.MB('#MsgType', '8', IOMsg.SERVER_SIGNAL),
11653
- mbp.MB('#signalObject', obj)
8704
+ let sigPack = M$1.pack(
8705
+ M$1.MB('#MsgType', '8', IOMsg.SERVER_SIGNAL),
8706
+ M$1.MB('#signalObject', obj)
11654
8707
  );
11655
8708
 
11656
8709
  this.remotes.forEach(remote => {
@@ -12215,7 +9268,7 @@ class BohoAuth {
12215
9268
  peer.setState(STATE.AUTH_FAIL);
12216
9269
  // add some delay time.
12217
9270
  setTimeout(e => {
12218
- peer.send(Buffer.from([K.BohoMsg.AUTH_FAIL]));
9271
+ peer.send(Buffer.from([tt.BohoMsg.AUTH_FAIL]));
12219
9272
  }, serverOption.auth.delay_auth_fail);
12220
9273
  }
12221
9274
 
@@ -12223,7 +9276,7 @@ class BohoAuth {
12223
9276
  async verify_auth_req(auth_req, peer) {
12224
9277
  try {
12225
9278
  //1. unpack
12226
- let infoPack = mbp.unpack(auth_req, K.Meta.AUTH_REQ);
9279
+ let infoPack = M$1.unpack(auth_req, tt.Meta.AUTH_REQ);
12227
9280
  if (!infoPack) {
12228
9281
  this.send_auth_fail(peer, 'unpack auth_pack fail');
12229
9282
  return
@@ -12279,9 +9332,9 @@ class BohoAuth {
12279
9332
  return
12280
9333
  }
12281
9334
 
12282
- let authClearSignal = mbp.pack(
12283
- mbp.MB('#MsgType', '8', IOMsg.AUTH_CLEAR),
12284
- mbp.MB('#reason', 'duplicate login.')
9335
+ let authClearSignal = M$1.pack(
9336
+ M$1.MB('#MsgType', '8', IOMsg.AUTH_CLEAR),
9337
+ M$1.MB('#reason', 'duplicate login.')
12285
9338
  );
12286
9339
  if (this.keepOldConnection) { // default true
12287
9340
  // keep old connection. reject new connection by sending auth_fail signal.
@@ -12431,7 +9484,7 @@ class FileKeyProvider {
12431
9484
  }
12432
9485
 
12433
9486
  addAuth(id, keyStr, cid, level = 0) {
12434
- let Base64hashKey = Buffer.from(K.sha256.hash(keyStr)).toString('base64');
9487
+ let Base64hashKey = Buffer.from(tt.sha256.hash(keyStr)).toString('base64');
12435
9488
  this.AUTH.set(id, { key: Base64hashKey, cid: cid, level: level });
12436
9489
  }
12437
9490
  }
@@ -12468,7 +9521,7 @@ class RedisKeyProvider {
12468
9521
 
12469
9522
  // add device auth info
12470
9523
  async addAuth(id, keyStr, cid = '', level = 0) {
12471
- let Base64hashKey = Buffer.from(K.sha256.hash(keyStr)).toString('base64');
9524
+ let Base64hashKey = Buffer.from(tt.sha256.hash(keyStr)).toString('base64');
12472
9525
  return this.redis.hSet(DEVICE_PREFIX + id, { 'key': Base64hashKey, 'cid': cid, 'level': level })
12473
9526
  }
12474
9527
 
@@ -12531,7 +9584,7 @@ class StringKeyProvider {
12531
9584
  }
12532
9585
 
12533
9586
  addAuth(id, keyStr, cid, level = 0) {
12534
- let Base64hashKey = Buffer.from(K.sha256.hash(keyStr)).toString('base64');
9587
+ let Base64hashKey = Buffer.from(tt.sha256.hash(keyStr)).toString('base64');
12535
9588
  this.AUTH.set(id, { key: Base64hashKey, cid: cid, level: level });
12536
9589
  }
12537
9590
  }
@@ -12718,4 +9771,4 @@ class RedisService {
12718
9771
 
12719
9772
  const version = pkg.version;
12720
9773
 
12721
- export { K as Boho, BohoAuth, CongRx, ENC_MODE, FileKeyProvider, FileLogger, IOWS as IO, IOCongSocket, IOMsg, mbp as MBP, PAYLOAD_TYPE, RedisKeyProvider, RedisService, SIZE_LIMIT, STATE, STATUS$1 as STATUS, Server, StringKeyProvider, delay, getIPv4HexString, getLocalAddress, getPayloadFromSignalPack, getSignalPack, isPrivateIP, numberWithCommas, pack, parsePayload, replyService, serverOption, sudoService, version };
9774
+ export { tt as Boho, BohoAuth, CongRx, ENC_MODE, FileKeyProvider, FileLogger, IOWS as IO, IOCongSocket, IOMsg, M$1 as MBP, PAYLOAD_TYPE, RedisKeyProvider, RedisService, SIZE_LIMIT, STATE, STATUS$1 as STATUS, Server, StringKeyProvider, delay, getIPv4HexString, getLocalAddress, getPayloadFromSignalPack, getSignalPack, isPrivateIP, numberWithCommas, pack, parsePayload, replyService, serverOption, sudoService, version };