iosignal 5.1.2 → 5.1.3

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,34 +2,3057 @@ 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 from 'http';
5
+ import require$$2$1 from 'http';
6
6
  import require$$4 from 'tls';
7
7
  import require$$1 from 'crypto';
8
8
  import require$$7 from 'url';
9
9
  import require$$0 from 'zlib';
10
- import require$$0$1 from 'buffer';
11
- import { networkInterfaces } from 'os';
12
10
  import fs, { readFileSync } from 'fs';
13
- import { memoryUsage } from 'process';
14
11
  import path from 'path';
12
+ import require$$2, { networkInterfaces } from 'os';
13
+ import require$$0$1 from 'buffer';
14
+ import { memoryUsage } from 'process';
15
+
16
+ var version$1 = "5.1.3";
17
+ var pkg = {
18
+ version: version$1};
19
+
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
+ }
15
2855
 
16
- var version$1 = "5.1.2";
17
- var pkg = {
18
- version: version$1};
19
2856
 
20
- var t$1,e$1={},r$1={};var n$1,i$1,o$1={};
21
- /*! 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}
22
- /*!
23
- * The buffer module from node.js, for the browser.
24
- *
25
- * @author Feross Aboukhadijeh <https://feross.org>
26
- * @license MIT
27
- */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}});
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
+ }
28
2864
 
29
- function getDefaultExportFromCjs (x) {
30
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
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
+ }
31
3002
  }
32
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
+ }
3015
+
3016
+ function getMetaDetail(binPack) {
3017
+ return getMeta(binPack, true)
3018
+ }
3019
+
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
+
33
3056
  var eventemitter3 = {exports: {}};
34
3057
 
35
3058
  var hasRequiredEventemitter3;
@@ -668,28 +3691,28 @@ function getSignalPack(tag, ...args) {
668
3691
 
669
3692
  let sigPack;
670
3693
  if (payload.type == PAYLOAD_TYPE.EMPTY) {
671
- sigPack = M$1.pack(
672
- M$1.MB('#MsgType', '8', IOMsg.SIGNAL),
673
- M$1.MB('#tagLen', '8', tagEncoded.byteLength),
674
- M$1.MB('#tag', tagEncoded),
675
- M$1.MB('#payloadType', '8', payload.type)
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)
676
3699
  );
677
3700
  } else if (payload.type == PAYLOAD_TYPE.MBA) {
678
- let mbaBuffer = M$1.pack(M$1.MBA(...args));
679
- sigPack = M$1.pack(
680
- M$1.MB('#MsgType', '8', IOMsg.SIGNAL),
681
- M$1.MB('#tagLen', '8', tagEncoded.byteLength),
682
- M$1.MB('#tag', tagEncoded),
683
- M$1.MB('#payloadType', '8', payload.type),
684
- M$1.MB('#mbaBuffer', mbaBuffer)
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)
685
3708
  );
686
3709
  } else {
687
- sigPack = M$1.pack(
688
- M$1.MB('#MsgType', '8', IOMsg.SIGNAL),
689
- M$1.MB('#tagLen', '8', tagEncoded.byteLength),
690
- M$1.MB('#tag', tagEncoded),
691
- M$1.MB('#payloadType', '8', payload.type),
692
- M$1.MB('#payload', payload.buffer)
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)
693
3716
  );
694
3717
  }
695
3718
  return sigPack
@@ -709,7 +3732,7 @@ function parsePayload(args) {
709
3732
 
710
3733
  } else if (ArrayBuffer.isView(args[0]) || args[0] instanceof ArrayBuffer) {
711
3734
  type = PAYLOAD_TYPE.BINARY;
712
- pack = M$1.B8(args[0]);
3735
+ pack = mbp.B8(args[0]);
713
3736
  } else if (typeof args[0] === 'object') {
714
3737
  type = PAYLOAD_TYPE.OBJECT;
715
3738
  pack = encoder$2.encode(JSON.stringify(args[0]));
@@ -739,21 +3762,14 @@ function getPayloadFromSignalPack(signalPack) {
739
3762
  return signalPack.subarray(3 + tagLen)
740
3763
  }
741
3764
 
742
- 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={};
743
- /*! 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}
744
- /*!
745
- * The buffer module from node.js, for the browser.
746
- *
747
- * @author Feross Aboukhadijeh <https://feross.org>
748
- * @license MIT
749
- */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={};
750
- /*! 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}
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}
751
3767
  /*!
752
3768
  * The buffer module from node.js, for the browser.
753
3769
  *
754
3770
  * @author Feross Aboukhadijeh <https://feross.org>
755
3771
  * @license MIT
756
- */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;
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
3773
 
758
3774
  /**
759
3775
  * @typedef {import('meta-buffer-pack').MBP} MBP
@@ -768,7 +3784,7 @@ const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1
768
3784
  * @typedef {import('boho').Buffer} Buffer
769
3785
  */
770
3786
 
771
- const Buffer$1 = M$1.Buffer;
3787
+ const Buffer$1 = mbp.Buffer;
772
3788
  const encoder$1 = new TextEncoder();
773
3789
  const decoder$4 = new TextDecoder();
774
3790
 
@@ -863,9 +3879,9 @@ class IOCore extends EventEmitter {
863
3879
  * Boho instance for encryption/decryption.
864
3880
  * @type {Boho}
865
3881
  */
866
- this.boho = new tt();
3882
+ this.boho = new K();
867
3883
 
868
- this.serverTimeNonce = Buffer$1.alloc( tt.MetaSize.SERVER_TIME_NONCE );
3884
+ this.serverTimeNonce = Buffer$1.alloc( K.MetaSize.SERVER_TIME_NONCE );
869
3885
  /**
870
3886
  * Indicates if the connection is TLS (wss).
871
3887
  * @type {boolean}
@@ -1138,13 +4154,13 @@ class IOCore extends EventEmitter {
1138
4154
  let msgType = buffer[0];
1139
4155
  let decoded;
1140
4156
 
1141
- if (msgType === tt.BohoMsg.ENC_488) {
4157
+ if (msgType === K.BohoMsg.ENC_488) {
1142
4158
  decoded = this.boho.decrypt_488(buffer);
1143
4159
  if (decoded) {
1144
4160
  msgType = decoded[0];
1145
4161
  buffer = decoded;
1146
4162
  }
1147
- } else if (msgType === tt.BohoMsg.ENC_E2E) {
4163
+ } else if (msgType === K.BohoMsg.ENC_E2E) {
1148
4164
 
1149
4165
  try {
1150
4166
  decoded = this.boho.decrypt_488(buffer);
@@ -1152,8 +4168,8 @@ class IOCore extends EventEmitter {
1152
4168
  // console.log( 'ENC_E2E decoded ', decoded )
1153
4169
  msgType = decoded[0];
1154
4170
  // decoded has msg_header only.
1155
- buffer.set(decoded, tt.MetaSize.ENC_488); // set decoded signal_e2e headaer.
1156
- buffer = buffer.subarray(tt.MetaSize.ENC_488); // reset offset.
4171
+ buffer.set(decoded, K.MetaSize.ENC_488); // set decoded signal_e2e headaer.
4172
+ buffer = buffer.subarray(K.MetaSize.ENC_488); // reset offset.
1157
4173
  // console.log('DECODED MsgType:', IOMsg[ msgType ] )
1158
4174
  } else {
1159
4175
  // console.log('488 DEC_FAIL', buffer)
@@ -1168,7 +4184,7 @@ class IOCore extends EventEmitter {
1168
4184
  }
1169
4185
 
1170
4186
  let type = IOMsg[msgType];
1171
- if (!type) type = tt.BohoMsg[msgType];
4187
+ if (!type) type = K.BohoMsg[msgType];
1172
4188
 
1173
4189
  // console.log( "MsgType: ", type , " LEN ", buffer.byteLength)
1174
4190
 
@@ -1247,7 +4263,7 @@ class IOCore extends EventEmitter {
1247
4263
  this.redirect(url);
1248
4264
  break;
1249
4265
 
1250
- case tt.BohoMsg.SERVER_TIME_NONCE: // SERVER_READY
4266
+ case K.BohoMsg.SERVER_TIME_NONCE: // SERVER_READY
1251
4267
  this.stateChange('server_ready', 'server_ready');
1252
4268
  if (this.useAuth) {
1253
4269
  this.send(this.boho.auth_req(buffer));
@@ -1278,7 +4294,7 @@ class IOCore extends EventEmitter {
1278
4294
 
1279
4295
  case IOMsg.SET:
1280
4296
  try {
1281
- let setPack = M$1.unpack(buffer);
4297
+ let setPack = mbp.unpack(buffer);
1282
4298
  if (setPack) {
1283
4299
  this.emit(setPack.topic, ...setPack.args);
1284
4300
  }
@@ -1357,7 +4373,7 @@ class IOCore extends EventEmitter {
1357
4373
  break;
1358
4374
 
1359
4375
  case PAYLOAD_TYPE.MBA:
1360
- let mbaObject = M$1.unpack(payloadBuffer);
4376
+ let mbaObject = mbp.unpack(payloadBuffer);
1361
4377
  if (tag.indexOf('@') === 0) this.emit('@', tag, ...mbaObject.args);
1362
4378
  else {
1363
4379
  this.emit(tag, tag, ...mbaObject.args);
@@ -1379,11 +4395,11 @@ class IOCore extends EventEmitter {
1379
4395
  this.testPromise(buffer);
1380
4396
  break;
1381
4397
 
1382
- case tt.BohoMsg.AUTH_FAIL:
4398
+ case K.BohoMsg.AUTH_FAIL:
1383
4399
  this.stateChange('auth_fail', 'auth_fail from server.');
1384
4400
  break;
1385
4401
 
1386
- case tt.BohoMsg.AUTH_RES:
4402
+ case K.BohoMsg.AUTH_RES:
1387
4403
  if (this.boho.verify_auth_res(buffer)) {
1388
4404
  this.stateChange('auth_res', 'server sent auth_res');
1389
4405
  this.send(Buffer$1.from([IOMsg.CID_REQ]));
@@ -1413,13 +4429,13 @@ class IOCore extends EventEmitter {
1413
4429
  iam(title) {
1414
4430
  // console.log('iam', title)
1415
4431
  if (title) {
1416
- this.send_enc_mode(M$1.pack(
1417
- M$1.MB('#MsgType', '8', IOMsg.IAM),
1418
- M$1.MB('#', title)
4432
+ this.send_enc_mode(mbp.pack(
4433
+ mbp.MB('#MsgType', '8', IOMsg.IAM),
4434
+ mbp.MB('#', title)
1419
4435
  ));
1420
4436
  } else {
1421
- this.send_enc_mode(M$1.pack(
1422
- M$1.MB('#MsgType', '8', IOMsg.IAM)
4437
+ this.send_enc_mode(mbp.pack(
4438
+ mbp.MB('#MsgType', '8', IOMsg.IAM)
1423
4439
  ));
1424
4440
  }
1425
4441
  }
@@ -1447,9 +4463,9 @@ class IOCore extends EventEmitter {
1447
4463
  echo(args) {
1448
4464
  if (args) {
1449
4465
  // console.log('send echo args:', args)
1450
- this.send_enc_mode(M$1.pack(
1451
- M$1.MB('#MsgType', '8', IOMsg.ECHO),
1452
- M$1.MB('#msg', args)
4466
+ this.send_enc_mode(mbp.pack(
4467
+ mbp.MB('#MsgType', '8', IOMsg.ECHO),
4468
+ mbp.MB('#msg', args)
1453
4469
  ));
1454
4470
  } else {
1455
4471
  // # do not encrypt blank echo #
@@ -1463,7 +4479,7 @@ class IOCore extends EventEmitter {
1463
4479
  * @param {...any} data - Data to send.
1464
4480
  */
1465
4481
  bin(...data) {
1466
- this.send(M$1.U8pack(...data));
4482
+ this.send(mbp.U8pack(...data));
1467
4483
  }
1468
4484
 
1469
4485
  /**
@@ -1513,7 +4529,7 @@ class IOCore extends EventEmitter {
1513
4529
  // encrypt signal_header area only. payload is encrypted with e2e key already.
1514
4530
  let tagLen = data[1];
1515
4531
  let encHeader = this.boho.encrypt_488(data.subarray(0, 3 + tagLen));
1516
- encHeader[0] = tt.BohoMsg.ENC_E2E;
4532
+ encHeader[0] = K.BohoMsg.ENC_E2E;
1517
4533
  this.send(Buffer$1.concat([encHeader, data.subarray(3 + tagLen)]));
1518
4534
  // console.log('<< send_enc_mode [ ENC_E2E ]')
1519
4535
 
@@ -1552,7 +4568,7 @@ class IOCore extends EventEmitter {
1552
4568
  */
1553
4569
  testPromise(buffer) {
1554
4570
 
1555
- let res = M$1.unpack(buffer);
4571
+ let res = mbp.unpack(buffer);
1556
4572
  if (!res) return
1557
4573
 
1558
4574
  if (this.promiseMap.has(res.mid)) {
@@ -1619,18 +4635,18 @@ class IOCore extends EventEmitter {
1619
4635
  if( !this.boho.isAuthorized ) return;
1620
4636
  if (typeof tag !== 'string') throw TypeError('tag should be string.')
1621
4637
  let tagEncoded = encoder$1.encode(tag);
1622
- let dataPack = M$1.B8(data);
4638
+ let dataPack = mbp.B8(data);
1623
4639
 
1624
4640
  //encrypt payload area with key
1625
4641
  let sercretPack = this.boho.encrypt_e2e(dataPack, key);
1626
4642
 
1627
4643
  //change signal MsgType header into SIGNAL_E2E
1628
- let signalPack = M$1.pack(
1629
- M$1.MB('#MsgType', '8', IOMsg.SIGNAL_E2E),
1630
- M$1.MB('#tagLen', '8', tagEncoded.byteLength),
1631
- M$1.MB('#tag', tagEncoded),
1632
- M$1.MB('#payloadType', '8', PAYLOAD_TYPE.BINARY),
1633
- M$1.MB('#payload', sercretPack)
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)
1634
4650
  );
1635
4651
 
1636
4652
  this.send_enc_mode(signalPack);
@@ -1660,7 +4676,7 @@ class IOCore extends EventEmitter {
1660
4676
  return Promise.reject(new Error('store get need storeName)'))
1661
4677
  }
1662
4678
  let pack = await this.call('store', 'get', storeName);
1663
- let { $ } = M$1.unpack(pack.body);
4679
+ let { $ } = mbp.unpack(pack.body);
1664
4680
  return $
1665
4681
  }
1666
4682
 
@@ -1677,19 +4693,19 @@ class IOCore extends EventEmitter {
1677
4693
  return Promise.reject(new Error('request need target and topic)'))
1678
4694
  let sigPack;
1679
4695
  if (args.length > 0) {
1680
- sigPack = M$1.pack(
1681
- M$1.MB('#MsgType', '8', IOMsg.CALL),
1682
- M$1.MB('mid', '16', ++this.mid),
1683
- M$1.MB('target', target),
1684
- M$1.MB('topic', topic),
1685
- M$1.MBA(...args)
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)
1686
4702
  );
1687
4703
  } else {
1688
- sigPack = M$1.pack(
1689
- M$1.MB('#MsgType', '8', IOMsg.CALL),
1690
- M$1.MB('mid', '16', ++this.mid),
1691
- M$1.MB('target', target),
1692
- M$1.MB('topic', topic)
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)
1693
4709
  );
1694
4710
  }
1695
4711
  this.send_enc_mode(sigPack);
@@ -1710,8 +4726,8 @@ class IOCore extends EventEmitter {
1710
4726
  let tagEncoded = encoder$1.encode(tag);
1711
4727
  this.send_enc_mode(
1712
4728
  Buffer$1.concat([
1713
- M$1.NB('8', IOMsg.SUBSCRIBE),
1714
- M$1.NB('8', tagEncoded.byteLength),
4729
+ mbp.NB('8', IOMsg.SUBSCRIBE),
4730
+ mbp.NB('8', tagEncoded.byteLength),
1715
4731
  tagEncoded]));
1716
4732
  } catch (error) { }
1717
4733
 
@@ -1731,8 +4747,8 @@ class IOCore extends EventEmitter {
1731
4747
  let tagEncoded = encoder$1.encode(tag);
1732
4748
  this.send_enc_mode(
1733
4749
  Buffer$1.concat([
1734
- M$1.NB('8', IOMsg.SUBSCRIBE),
1735
- M$1.NB('8', tagEncoded.byteLength),
4750
+ mbp.NB('8', IOMsg.SUBSCRIBE),
4751
+ mbp.NB('8', tagEncoded.byteLength),
1736
4752
  tagEncoded]));
1737
4753
  } catch (error) { }
1738
4754
 
@@ -1759,8 +4775,8 @@ class IOCore extends EventEmitter {
1759
4775
  if (tagEncoded.byteLength > SIZE_LIMIT.TAG_LEN1) throw TypeError('please use tag string bytelength below:' + SIZE_LIMIT.TAG_LEN1)
1760
4776
 
1761
4777
  this.send_enc_mode(Buffer$1.concat([
1762
- M$1.NB('8', IOMsg.UNSUBSCRIBE),
1763
- M$1.NB('8', tagEncoded.byteLength),
4778
+ mbp.NB('8', IOMsg.UNSUBSCRIBE),
4779
+ mbp.NB('8', tagEncoded.byteLength),
1764
4780
  tagEncoded]));
1765
4781
  }
1766
4782
 
@@ -1955,34 +4971,34 @@ function pack(payload) {
1955
4971
  if( payload.byteLength == undefined ) payload = Buffer.from(payload);
1956
4972
 
1957
4973
  if (payload.byteLength < 256) { //one byte len
1958
- return M$1.pack(
1959
- M$1.MB('#type', '8', CongType.TYPE_LEN1),
1960
- M$1.MB('#payloadLen1', '8', payload.byteLength),
1961
- M$1.MB('#payload', payload)
4974
+ return mbp.pack(
4975
+ mbp.MB('#type', '8', CongType.TYPE_LEN1),
4976
+ mbp.MB('#payloadLen1', '8', payload.byteLength),
4977
+ mbp.MB('#payload', payload)
1962
4978
  )
1963
4979
 
1964
4980
  } else if (payload.byteLength < 65536) { // 2bytes len
1965
- return M$1.pack(
1966
- M$1.MB('#type', '8', CongType.TYPE_LEN2),
1967
- M$1.MB('#payloadLen2', '16L', payload.byteLength),
1968
- M$1.MB('#payload', payload)
4981
+ return mbp.pack(
4982
+ mbp.MB('#type', '8', CongType.TYPE_LEN2),
4983
+ mbp.MB('#payloadLen2', '16L', payload.byteLength),
4984
+ mbp.MB('#payload', payload)
1969
4985
  )
1970
4986
 
1971
4987
  } else if (payload.byteLength < 2 ** 24) { // 3bytes len
1972
4988
  let len4Buffer = Buffer.alloc(4);
1973
4989
  len4Buffer.writeUint32LE(payload.byteLength);
1974
4990
  let cropLen3 = len4Buffer.subarray(0, 3);
1975
- return M$1.pack(
1976
- M$1.MB('#type', '8', CongType.TYPE_LEN3),
1977
- M$1.MB('#payloadLen3', cropLen3),
1978
- M$1.MB('#payload', payload)
4991
+ return mbp.pack(
4992
+ mbp.MB('#type', '8', CongType.TYPE_LEN3),
4993
+ mbp.MB('#payloadLen3', cropLen3),
4994
+ mbp.MB('#payload', payload)
1979
4995
  )
1980
4996
 
1981
4997
  } else { //use 4 bytes.
1982
- return M$1.pack(
1983
- M$1.MB('#type', '8', CongType.TYPE_LEN4),
1984
- M$1.MB('#payloadLen4', '32L', payload.byteLength),
1985
- M$1.MB('#payload', payload)
4998
+ return mbp.pack(
4999
+ mbp.MB('#type', '8', CongType.TYPE_LEN4),
5000
+ mbp.MB('#payloadLen4', '32L', payload.byteLength),
5001
+ mbp.MB('#payload', payload)
1986
5002
  )
1987
5003
  }
1988
5004
 
@@ -2180,6 +5196,7 @@ function requireConstants () {
2180
5196
 
2181
5197
  constants = {
2182
5198
  BINARY_TYPES,
5199
+ CLOSE_TIMEOUT: 30000,
2183
5200
  EMPTY_BUFFER: Buffer.alloc(0),
2184
5201
  GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11',
2185
5202
  hasBlob,
@@ -2192,6 +5209,300 @@ function requireConstants () {
2192
5209
  return constants;
2193
5210
  }
2194
5211
 
5212
+ var bufferutil = {exports: {}};
5213
+
5214
+ function commonjsRequire(path) {
5215
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
5216
+ }
5217
+
5218
+ var nodeGypBuild$1 = {exports: {}};
5219
+
5220
+ var nodeGypBuild;
5221
+ var hasRequiredNodeGypBuild$1;
5222
+
5223
+ function requireNodeGypBuild$1 () {
5224
+ if (hasRequiredNodeGypBuild$1) return nodeGypBuild;
5225
+ hasRequiredNodeGypBuild$1 = 1;
5226
+ var fs$1 = fs;
5227
+ var path$1 = path;
5228
+ var os = require$$2;
5229
+
5230
+ // Workaround to fix webpack's build warnings: 'the request of a dependency is an expression'
5231
+ var runtimeRequire = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : commonjsRequire; // eslint-disable-line
5232
+
5233
+ var vars = (process.config && process.config.variables) || {};
5234
+ var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
5235
+ var abi = process.versions.modules; // TODO: support old node where this is undef
5236
+ var runtime = isElectron() ? 'electron' : (isNwjs() ? 'node-webkit' : 'node');
5237
+
5238
+ var arch = process.env.npm_config_arch || os.arch();
5239
+ var platform = process.env.npm_config_platform || os.platform();
5240
+ var libc = process.env.LIBC || (isAlpine(platform) ? 'musl' : 'glibc');
5241
+ var armv = process.env.ARM_VERSION || (arch === 'arm64' ? '8' : vars.arm_version) || '';
5242
+ var uv = (process.versions.uv || '').split('.')[0];
5243
+
5244
+ nodeGypBuild = load;
5245
+
5246
+ function load (dir) {
5247
+ return runtimeRequire(load.resolve(dir))
5248
+ }
5249
+
5250
+ load.resolve = load.path = function (dir) {
5251
+ dir = path$1.resolve(dir || '.');
5252
+
5253
+ try {
5254
+ var name = runtimeRequire(path$1.join(dir, 'package.json')).name.toUpperCase().replace(/-/g, '_');
5255
+ if (process.env[name + '_PREBUILD']) dir = process.env[name + '_PREBUILD'];
5256
+ } catch (err) {}
5257
+
5258
+ if (!prebuildsOnly) {
5259
+ var release = getFirst(path$1.join(dir, 'build/Release'), matchBuild);
5260
+ if (release) return release
5261
+
5262
+ var debug = getFirst(path$1.join(dir, 'build/Debug'), matchBuild);
5263
+ if (debug) return debug
5264
+ }
5265
+
5266
+ var prebuild = resolve(dir);
5267
+ if (prebuild) return prebuild
5268
+
5269
+ var nearby = resolve(path$1.dirname(process.execPath));
5270
+ if (nearby) return nearby
5271
+
5272
+ var target = [
5273
+ 'platform=' + platform,
5274
+ 'arch=' + arch,
5275
+ 'runtime=' + runtime,
5276
+ 'abi=' + abi,
5277
+ 'uv=' + uv,
5278
+ armv ? 'armv=' + armv : '',
5279
+ 'libc=' + libc,
5280
+ 'node=' + process.versions.node,
5281
+ process.versions.electron ? 'electron=' + process.versions.electron : '',
5282
+ typeof __webpack_require__ === 'function' ? 'webpack=true' : '' // eslint-disable-line
5283
+ ].filter(Boolean).join(' ');
5284
+
5285
+ throw new Error('No native build was found for ' + target + '\n loaded from: ' + dir + '\n')
5286
+
5287
+ function resolve (dir) {
5288
+ // Find matching "prebuilds/<platform>-<arch>" directory
5289
+ var tuples = readdirSync(path$1.join(dir, 'prebuilds')).map(parseTuple);
5290
+ var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
5291
+ if (!tuple) return
5292
+
5293
+ // Find most specific flavor first
5294
+ var prebuilds = path$1.join(dir, 'prebuilds', tuple.name);
5295
+ var parsed = readdirSync(prebuilds).map(parseTags);
5296
+ var candidates = parsed.filter(matchTags(runtime, abi));
5297
+ var winner = candidates.sort(compareTags(runtime))[0];
5298
+ if (winner) return path$1.join(prebuilds, winner.file)
5299
+ }
5300
+ };
5301
+
5302
+ function readdirSync (dir) {
5303
+ try {
5304
+ return fs$1.readdirSync(dir)
5305
+ } catch (err) {
5306
+ return []
5307
+ }
5308
+ }
5309
+
5310
+ function getFirst (dir, filter) {
5311
+ var files = readdirSync(dir).filter(filter);
5312
+ return files[0] && path$1.join(dir, files[0])
5313
+ }
5314
+
5315
+ function matchBuild (name) {
5316
+ return /\.node$/.test(name)
5317
+ }
5318
+
5319
+ function parseTuple (name) {
5320
+ // Example: darwin-x64+arm64
5321
+ var arr = name.split('-');
5322
+ if (arr.length !== 2) return
5323
+
5324
+ var platform = arr[0];
5325
+ var architectures = arr[1].split('+');
5326
+
5327
+ if (!platform) return
5328
+ if (!architectures.length) return
5329
+ if (!architectures.every(Boolean)) return
5330
+
5331
+ return { name, platform, architectures }
5332
+ }
5333
+
5334
+ function matchTuple (platform, arch) {
5335
+ return function (tuple) {
5336
+ if (tuple == null) return false
5337
+ if (tuple.platform !== platform) return false
5338
+ return tuple.architectures.includes(arch)
5339
+ }
5340
+ }
5341
+
5342
+ function compareTuples (a, b) {
5343
+ // Prefer single-arch prebuilds over multi-arch
5344
+ return a.architectures.length - b.architectures.length
5345
+ }
5346
+
5347
+ function parseTags (file) {
5348
+ var arr = file.split('.');
5349
+ var extension = arr.pop();
5350
+ var tags = { file: file, specificity: 0 };
5351
+
5352
+ if (extension !== 'node') return
5353
+
5354
+ for (var i = 0; i < arr.length; i++) {
5355
+ var tag = arr[i];
5356
+
5357
+ if (tag === 'node' || tag === 'electron' || tag === 'node-webkit') {
5358
+ tags.runtime = tag;
5359
+ } else if (tag === 'napi') {
5360
+ tags.napi = true;
5361
+ } else if (tag.slice(0, 3) === 'abi') {
5362
+ tags.abi = tag.slice(3);
5363
+ } else if (tag.slice(0, 2) === 'uv') {
5364
+ tags.uv = tag.slice(2);
5365
+ } else if (tag.slice(0, 4) === 'armv') {
5366
+ tags.armv = tag.slice(4);
5367
+ } else if (tag === 'glibc' || tag === 'musl') {
5368
+ tags.libc = tag;
5369
+ } else {
5370
+ continue
5371
+ }
5372
+
5373
+ tags.specificity++;
5374
+ }
5375
+
5376
+ return tags
5377
+ }
5378
+
5379
+ function matchTags (runtime, abi) {
5380
+ return function (tags) {
5381
+ if (tags == null) return false
5382
+ if (tags.runtime && tags.runtime !== runtime && !runtimeAgnostic(tags)) return false
5383
+ if (tags.abi && tags.abi !== abi && !tags.napi) return false
5384
+ if (tags.uv && tags.uv !== uv) return false
5385
+ if (tags.armv && tags.armv !== armv) return false
5386
+ if (tags.libc && tags.libc !== libc) return false
5387
+
5388
+ return true
5389
+ }
5390
+ }
5391
+
5392
+ function runtimeAgnostic (tags) {
5393
+ return tags.runtime === 'node' && tags.napi
5394
+ }
5395
+
5396
+ function compareTags (runtime) {
5397
+ // Precedence: non-agnostic runtime, abi over napi, then by specificity.
5398
+ return function (a, b) {
5399
+ if (a.runtime !== b.runtime) {
5400
+ return a.runtime === runtime ? -1 : 1
5401
+ } else if (a.abi !== b.abi) {
5402
+ return a.abi ? -1 : 1
5403
+ } else if (a.specificity !== b.specificity) {
5404
+ return a.specificity > b.specificity ? -1 : 1
5405
+ } else {
5406
+ return 0
5407
+ }
5408
+ }
5409
+ }
5410
+
5411
+ function isNwjs () {
5412
+ return !!(process.versions && process.versions.nw)
5413
+ }
5414
+
5415
+ function isElectron () {
5416
+ if (process.versions && process.versions.electron) return true
5417
+ if (process.env.ELECTRON_RUN_AS_NODE) return true
5418
+ return typeof window !== 'undefined' && window.process && window.process.type === 'renderer'
5419
+ }
5420
+
5421
+ function isAlpine (platform) {
5422
+ return platform === 'linux' && fs$1.existsSync('/etc/alpine-release')
5423
+ }
5424
+
5425
+ // Exposed for unit tests
5426
+ // TODO: move to lib
5427
+ load.parseTags = parseTags;
5428
+ load.matchTags = matchTags;
5429
+ load.compareTags = compareTags;
5430
+ load.parseTuple = parseTuple;
5431
+ load.matchTuple = matchTuple;
5432
+ load.compareTuples = compareTuples;
5433
+ return nodeGypBuild;
5434
+ }
5435
+
5436
+ var hasRequiredNodeGypBuild;
5437
+
5438
+ function requireNodeGypBuild () {
5439
+ if (hasRequiredNodeGypBuild) return nodeGypBuild$1.exports;
5440
+ hasRequiredNodeGypBuild = 1;
5441
+ const runtimeRequire = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : commonjsRequire; // eslint-disable-line
5442
+ if (typeof runtimeRequire.addon === 'function') { // if the platform supports native resolving prefer that
5443
+ nodeGypBuild$1.exports = runtimeRequire.addon.bind(runtimeRequire);
5444
+ } else { // else use the runtime version here
5445
+ nodeGypBuild$1.exports = requireNodeGypBuild$1();
5446
+ }
5447
+ return nodeGypBuild$1.exports;
5448
+ }
5449
+
5450
+ var fallback$1;
5451
+ var hasRequiredFallback$1;
5452
+
5453
+ function requireFallback$1 () {
5454
+ if (hasRequiredFallback$1) return fallback$1;
5455
+ hasRequiredFallback$1 = 1;
5456
+
5457
+ /**
5458
+ * Masks a buffer using the given mask.
5459
+ *
5460
+ * @param {Buffer} source The buffer to mask
5461
+ * @param {Buffer} mask The mask to use
5462
+ * @param {Buffer} output The buffer where to store the result
5463
+ * @param {Number} offset The offset at which to start writing
5464
+ * @param {Number} length The number of bytes to mask.
5465
+ * @public
5466
+ */
5467
+ const mask = (source, mask, output, offset, length) => {
5468
+ for (var i = 0; i < length; i++) {
5469
+ output[offset + i] = source[i] ^ mask[i & 3];
5470
+ }
5471
+ };
5472
+
5473
+ /**
5474
+ * Unmasks a buffer using the given mask.
5475
+ *
5476
+ * @param {Buffer} buffer The buffer to unmask
5477
+ * @param {Buffer} mask The mask to use
5478
+ * @public
5479
+ */
5480
+ const unmask = (buffer, mask) => {
5481
+ // Required until https://github.com/nodejs/node/issues/9006 is resolved.
5482
+ const length = buffer.length;
5483
+ for (var i = 0; i < length; i++) {
5484
+ buffer[i] ^= mask[i & 3];
5485
+ }
5486
+ };
5487
+
5488
+ fallback$1 = { mask, unmask };
5489
+ return fallback$1;
5490
+ }
5491
+
5492
+ var hasRequiredBufferutil;
5493
+
5494
+ function requireBufferutil () {
5495
+ if (hasRequiredBufferutil) return bufferutil.exports;
5496
+ hasRequiredBufferutil = 1;
5497
+
5498
+ try {
5499
+ bufferutil.exports = requireNodeGypBuild()(__dirname);
5500
+ } catch (e) {
5501
+ bufferutil.exports = requireFallback$1();
5502
+ }
5503
+ return bufferutil.exports;
5504
+ }
5505
+
2195
5506
  var hasRequiredBufferUtil;
2196
5507
 
2197
5508
  function requireBufferUtil () {
@@ -2312,7 +5623,7 @@ function requireBufferUtil () {
2312
5623
  /* istanbul ignore else */
2313
5624
  if (!process.env.WS_NO_BUFFER_UTIL) {
2314
5625
  try {
2315
- const bufferUtil$1 = require('bufferutil');
5626
+ const bufferUtil$1 = requireBufferutil();
2316
5627
 
2317
5628
  bufferUtil.exports.mask = function (source, mask, output, offset, length) {
2318
5629
  if (length < 48) _mask(source, mask, output, offset, length);
@@ -2437,6 +5748,9 @@ function requirePermessageDeflate () {
2437
5748
  * acknowledge disabling of client context takeover
2438
5749
  * @param {Number} [options.concurrencyLimit=10] The number of concurrent
2439
5750
  * calls to zlib
5751
+ * @param {Boolean} [options.isServer=false] Create the instance in either
5752
+ * server or client mode
5753
+ * @param {Number} [options.maxPayload=0] The maximum allowed message length
2440
5754
  * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
2441
5755
  * use of a custom server window size
2442
5756
  * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
@@ -2447,16 +5761,13 @@ function requirePermessageDeflate () {
2447
5761
  * deflate
2448
5762
  * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
2449
5763
  * inflate
2450
- * @param {Boolean} [isServer=false] Create the instance in either server or
2451
- * client mode
2452
- * @param {Number} [maxPayload=0] The maximum allowed message length
2453
5764
  */
2454
- constructor(options, isServer, maxPayload) {
2455
- this._maxPayload = maxPayload | 0;
5765
+ constructor(options) {
2456
5766
  this._options = options || {};
2457
5767
  this._threshold =
2458
5768
  this._options.threshold !== undefined ? this._options.threshold : 1024;
2459
- this._isServer = !!isServer;
5769
+ this._maxPayload = this._options.maxPayload | 0;
5770
+ this._isServer = !!this._options.isServer;
2460
5771
  this._deflate = null;
2461
5772
  this._inflate = null;
2462
5773
 
@@ -2931,6 +6242,92 @@ function requirePermessageDeflate () {
2931
6242
 
2932
6243
  var validation = {exports: {}};
2933
6244
 
6245
+ var utf8Validate = {exports: {}};
6246
+
6247
+ var fallback;
6248
+ var hasRequiredFallback;
6249
+
6250
+ function requireFallback () {
6251
+ if (hasRequiredFallback) return fallback;
6252
+ hasRequiredFallback = 1;
6253
+
6254
+ /**
6255
+ * Checks if a given buffer contains only correct UTF-8.
6256
+ * Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by
6257
+ * Markus Kuhn.
6258
+ *
6259
+ * @param {Buffer} buf The buffer to check
6260
+ * @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false`
6261
+ * @public
6262
+ */
6263
+ function isValidUTF8(buf) {
6264
+ const len = buf.length;
6265
+ let i = 0;
6266
+
6267
+ while (i < len) {
6268
+ if ((buf[i] & 0x80) === 0x00) { // 0xxxxxxx
6269
+ i++;
6270
+ } else if ((buf[i] & 0xe0) === 0xc0) { // 110xxxxx 10xxxxxx
6271
+ if (
6272
+ i + 1 === len ||
6273
+ (buf[i + 1] & 0xc0) !== 0x80 ||
6274
+ (buf[i] & 0xfe) === 0xc0 // overlong
6275
+ ) {
6276
+ return false;
6277
+ }
6278
+
6279
+ i += 2;
6280
+ } else if ((buf[i] & 0xf0) === 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
6281
+ if (
6282
+ i + 2 >= len ||
6283
+ (buf[i + 1] & 0xc0) !== 0x80 ||
6284
+ (buf[i + 2] & 0xc0) !== 0x80 ||
6285
+ buf[i] === 0xe0 && (buf[i + 1] & 0xe0) === 0x80 || // overlong
6286
+ buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0 // surrogate (U+D800 - U+DFFF)
6287
+ ) {
6288
+ return false;
6289
+ }
6290
+
6291
+ i += 3;
6292
+ } else if ((buf[i] & 0xf8) === 0xf0) { // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
6293
+ if (
6294
+ i + 3 >= len ||
6295
+ (buf[i + 1] & 0xc0) !== 0x80 ||
6296
+ (buf[i + 2] & 0xc0) !== 0x80 ||
6297
+ (buf[i + 3] & 0xc0) !== 0x80 ||
6298
+ buf[i] === 0xf0 && (buf[i + 1] & 0xf0) === 0x80 || // overlong
6299
+ buf[i] === 0xf4 && buf[i + 1] > 0x8f || buf[i] > 0xf4 // > U+10FFFF
6300
+ ) {
6301
+ return false;
6302
+ }
6303
+
6304
+ i += 4;
6305
+ } else {
6306
+ return false;
6307
+ }
6308
+ }
6309
+
6310
+ return true;
6311
+ }
6312
+
6313
+ fallback = isValidUTF8;
6314
+ return fallback;
6315
+ }
6316
+
6317
+ var hasRequiredUtf8Validate;
6318
+
6319
+ function requireUtf8Validate () {
6320
+ if (hasRequiredUtf8Validate) return utf8Validate.exports;
6321
+ hasRequiredUtf8Validate = 1;
6322
+
6323
+ try {
6324
+ utf8Validate.exports = requireNodeGypBuild()(__dirname);
6325
+ } catch (e) {
6326
+ utf8Validate.exports = requireFallback();
6327
+ }
6328
+ return utf8Validate.exports;
6329
+ }
6330
+
2934
6331
  var hasRequiredValidation;
2935
6332
 
2936
6333
  function requireValidation () {
@@ -3078,7 +6475,7 @@ function requireValidation () {
3078
6475
  };
3079
6476
  } /* istanbul ignore else */ else if (!process.env.WS_NO_UTF_8_VALIDATE) {
3080
6477
  try {
3081
- const isValidUTF8 = require('utf-8-validate');
6478
+ const isValidUTF8 = requireUtf8Validate();
3082
6479
 
3083
6480
  validation.exports.isValidUTF8 = function (buf) {
3084
6481
  return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
@@ -4936,7 +8333,7 @@ function requireWebsocket () {
4936
8333
 
4937
8334
  const EventEmitter = require$$0$3;
4938
8335
  const https = require$$1$1;
4939
- const http = require$$2;
8336
+ const http = require$$2$1;
4940
8337
  const net$1 = net;
4941
8338
  const tls = require$$4;
4942
8339
  const { randomBytes, createHash } = require$$1;
@@ -4950,6 +8347,7 @@ function requireWebsocket () {
4950
8347
 
4951
8348
  const {
4952
8349
  BINARY_TYPES,
8350
+ CLOSE_TIMEOUT,
4953
8351
  EMPTY_BUFFER,
4954
8352
  GUID,
4955
8353
  kForOnEventAttribute,
@@ -4964,7 +8362,6 @@ function requireWebsocket () {
4964
8362
  const { format, parse } = requireExtension();
4965
8363
  const { toBuffer } = requireBufferUtil();
4966
8364
 
4967
- const closeTimeout = 30 * 1000;
4968
8365
  const kAborted = Symbol('kAborted');
4969
8366
  const protocolVersions = [8, 13];
4970
8367
  const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
@@ -5020,6 +8417,7 @@ function requireWebsocket () {
5020
8417
  initAsClient(this, address, protocols, options);
5021
8418
  } else {
5022
8419
  this._autoPong = options.autoPong;
8420
+ this._closeTimeout = options.closeTimeout;
5023
8421
  this._isServer = true;
5024
8422
  }
5025
8423
  }
@@ -5561,6 +8959,8 @@ function requireWebsocket () {
5561
8959
  * times in the same tick
5562
8960
  * @param {Boolean} [options.autoPong=true] Specifies whether or not to
5563
8961
  * automatically send a pong in response to a ping
8962
+ * @param {Number} [options.closeTimeout=30000] Duration in milliseconds to wait
8963
+ * for the closing handshake to finish after `websocket.close()` is called
5564
8964
  * @param {Function} [options.finishRequest] A function which can be used to
5565
8965
  * customize the headers of each http request before it is sent
5566
8966
  * @param {Boolean} [options.followRedirects=false] Whether or not to follow
@@ -5587,6 +8987,7 @@ function requireWebsocket () {
5587
8987
  const opts = {
5588
8988
  allowSynchronousEvents: true,
5589
8989
  autoPong: true,
8990
+ closeTimeout: CLOSE_TIMEOUT,
5590
8991
  protocolVersion: protocolVersions[1],
5591
8992
  maxPayload: 100 * 1024 * 1024,
5592
8993
  skipUTF8Validation: false,
@@ -5605,6 +9006,7 @@ function requireWebsocket () {
5605
9006
  };
5606
9007
 
5607
9008
  websocket._autoPong = opts.autoPong;
9009
+ websocket._closeTimeout = opts.closeTimeout;
5608
9010
 
5609
9011
  if (!protocolVersions.includes(opts.protocolVersion)) {
5610
9012
  throw new RangeError(
@@ -5620,7 +9022,7 @@ function requireWebsocket () {
5620
9022
  } else {
5621
9023
  try {
5622
9024
  parsedUrl = new URL(address);
5623
- } catch (e) {
9025
+ } catch {
5624
9026
  throw new SyntaxError(`Invalid URL: ${address}`);
5625
9027
  }
5626
9028
  }
@@ -5682,11 +9084,11 @@ function requireWebsocket () {
5682
9084
  opts.timeout = opts.handshakeTimeout;
5683
9085
 
5684
9086
  if (opts.perMessageDeflate) {
5685
- perMessageDeflate = new PerMessageDeflate(
5686
- opts.perMessageDeflate !== true ? opts.perMessageDeflate : {},
5687
- false,
5688
- opts.maxPayload
5689
- );
9087
+ perMessageDeflate = new PerMessageDeflate({
9088
+ ...opts.perMessageDeflate,
9089
+ isServer: false,
9090
+ maxPayload: opts.maxPayload
9091
+ });
5690
9092
  opts.headers['Sec-WebSocket-Extensions'] = format({
5691
9093
  [PerMessageDeflate.extensionName]: perMessageDeflate.offer()
5692
9094
  });
@@ -6222,7 +9624,7 @@ function requireWebsocket () {
6222
9624
  function setCloseTimer(websocket) {
6223
9625
  websocket._closeTimer = setTimeout(
6224
9626
  websocket._socket.destroy.bind(websocket._socket),
6225
- closeTimeout
9627
+ websocket._closeTimeout
6226
9628
  );
6227
9629
  }
6228
9630
 
@@ -6240,23 +9642,23 @@ function requireWebsocket () {
6240
9642
 
6241
9643
  websocket._readyState = WebSocket.CLOSING;
6242
9644
 
6243
- let chunk;
6244
-
6245
9645
  //
6246
9646
  // The close frame might not have been received or the `'end'` event emitted,
6247
9647
  // for example, if the socket was destroyed due to an error. Ensure that the
6248
9648
  // `receiver` stream is closed after writing any remaining buffered data to
6249
9649
  // it. If the readable side of the socket is in flowing mode then there is no
6250
- // buffered data as everything has been already written and `readable.read()`
6251
- // will return `null`. If instead, the socket is paused, any possible buffered
6252
- // data will be read as a single chunk.
9650
+ // buffered data as everything has been already written. If instead, the
9651
+ // socket is paused, any possible buffered data will be read as a single
9652
+ // chunk.
6253
9653
  //
6254
9654
  if (
6255
9655
  !this._readableState.endEmitted &&
6256
9656
  !websocket._closeFrameReceived &&
6257
9657
  !websocket._receiver._writableState.errorEmitted &&
6258
- (chunk = websocket._socket.read()) !== null
9658
+ this._readableState.length !== 0
6259
9659
  ) {
9660
+ const chunk = this.read(this._readableState.length);
9661
+
6260
9662
  websocket._receiver.write(chunk);
6261
9663
  }
6262
9664
 
@@ -6493,13 +9895,14 @@ function requireStream () {
6493
9895
 
6494
9896
  requireStream();
6495
9897
 
9898
+ requireExtension();
9899
+
9900
+ requirePermessageDeflate();
9901
+
6496
9902
  requireReceiver();
6497
9903
 
6498
9904
  requireSender();
6499
9905
 
6500
- var websocketExports = requireWebsocket();
6501
- var WebSocket = /*@__PURE__*/getDefaultExportFromCjs(websocketExports);
6502
-
6503
9906
  var subprotocol;
6504
9907
  var hasRequiredSubprotocol;
6505
9908
 
@@ -6570,6 +9973,11 @@ function requireSubprotocol () {
6570
9973
  return subprotocol;
6571
9974
  }
6572
9975
 
9976
+ requireSubprotocol();
9977
+
9978
+ var websocketExports = requireWebsocket();
9979
+ var WebSocket = /*@__PURE__*/getDefaultExportFromCjs(websocketExports);
9980
+
6573
9981
  /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$", "caughtErrors": "none" }] */
6574
9982
 
6575
9983
  var websocketServer;
@@ -6580,7 +9988,7 @@ function requireWebsocketServer () {
6580
9988
  hasRequiredWebsocketServer = 1;
6581
9989
 
6582
9990
  const EventEmitter = require$$0$3;
6583
- const http = require$$2;
9991
+ const http = require$$2$1;
6584
9992
  const { Duplex } = require$$0$2;
6585
9993
  const { createHash } = require$$1;
6586
9994
 
@@ -6588,7 +9996,7 @@ function requireWebsocketServer () {
6588
9996
  const PerMessageDeflate = requirePermessageDeflate();
6589
9997
  const subprotocol = requireSubprotocol();
6590
9998
  const WebSocket = requireWebsocket();
6591
- const { GUID, kWebSocket } = requireConstants();
9999
+ const { CLOSE_TIMEOUT, GUID, kWebSocket } = requireConstants();
6592
10000
 
6593
10001
  const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
6594
10002
 
@@ -6615,6 +10023,9 @@ function requireWebsocketServer () {
6615
10023
  * pending connections
6616
10024
  * @param {Boolean} [options.clientTracking=true] Specifies whether or not to
6617
10025
  * track clients
10026
+ * @param {Number} [options.closeTimeout=30000] Duration in milliseconds to
10027
+ * wait for the closing handshake to finish after `websocket.close()` is
10028
+ * called
6618
10029
  * @param {Function} [options.handleProtocols] A hook to handle protocols
6619
10030
  * @param {String} [options.host] The hostname where to bind the server
6620
10031
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
@@ -6644,6 +10055,7 @@ function requireWebsocketServer () {
6644
10055
  perMessageDeflate: false,
6645
10056
  handleProtocols: null,
6646
10057
  clientTracking: true,
10058
+ closeTimeout: CLOSE_TIMEOUT,
6647
10059
  verifyClient: null,
6648
10060
  noServer: false,
6649
10061
  backlog: null, // use default (511 as implemented in net.js)
@@ -6866,11 +10278,11 @@ function requireWebsocketServer () {
6866
10278
  this.options.perMessageDeflate &&
6867
10279
  secWebSocketExtensions !== undefined
6868
10280
  ) {
6869
- const perMessageDeflate = new PerMessageDeflate(
6870
- this.options.perMessageDeflate,
6871
- true,
6872
- this.options.maxPayload
6873
- );
10281
+ const perMessageDeflate = new PerMessageDeflate({
10282
+ ...this.options.perMessageDeflate,
10283
+ isServer: true,
10284
+ maxPayload: this.options.maxPayload
10285
+ });
6874
10286
 
6875
10287
  try {
6876
10288
  const offers = extension.parse(secWebSocketExtensions);
@@ -7256,9 +10668,7 @@ let serverOption = {
7256
10668
  };
7257
10669
 
7258
10670
  const decoder$3 = new TextDecoder();
7259
-
7260
- M$1.NB;
7261
- const MB = M$1.MB;
10671
+ const MB = mbp.MB;
7262
10672
 
7263
10673
 
7264
10674
  class RemoteCore {
@@ -7270,7 +10680,7 @@ class RemoteCore {
7270
10680
  socket.rxCounter = 0;
7271
10681
  socket.openTime = Date.now();
7272
10682
 
7273
- this.boho = new tt();
10683
+ this.boho = new K();
7274
10684
  this.encMode = ENC_MODE.AUTO;
7275
10685
  this.channels = new Set(); // subscribed tags
7276
10686
  this.retain_signal = new Map();
@@ -7324,7 +10734,7 @@ class RemoteCore {
7324
10734
  let prnLimit = 20;
7325
10735
  if (isBinary) {
7326
10736
  let msgTypeName = IOMsg[message[0]];
7327
- if (!msgTypeName) msgTypeName = tt.BohoMsg[message[0]];
10737
+ if (!msgTypeName) msgTypeName = K.BohoMsg[message[0]];
7328
10738
 
7329
10739
  msgTypeName = '[' + msgTypeName + ']';
7330
10740
  let size = message.byteLength;
@@ -7377,7 +10787,7 @@ class RemoteCore {
7377
10787
  if (isBinary) {
7378
10788
  msgType = message[0];
7379
10789
 
7380
- if (msgType === tt.BohoMsg.ENC_488) {
10790
+ if (msgType === K.BohoMsg.ENC_488) {
7381
10791
 
7382
10792
  try {
7383
10793
  decoded = this.boho.decrypt_488(message);
@@ -7393,7 +10803,7 @@ class RemoteCore {
7393
10803
  return
7394
10804
  }
7395
10805
 
7396
- } else if (msgType === tt.BohoMsg.ENC_E2E) { // symetric E2EE Signal
10806
+ } else if (msgType === K.BohoMsg.ENC_E2E) { // symetric E2EE Signal
7397
10807
  try {
7398
10808
  decoded = this.boho.decrypt_488(message);
7399
10809
  } catch (err) {
@@ -7403,8 +10813,8 @@ class RemoteCore {
7403
10813
  // console.log('e2e unpack:', decoded )
7404
10814
  if (decoded) {
7405
10815
  msgType = decoded[0];
7406
- message.set(decoded, tt.MetaSize.ENC_488); // set decoded signal_e2e headaer.
7407
- message = message.subarray(tt.MetaSize.ENC_488); // reset offset.
10816
+ message.set(decoded, K.MetaSize.ENC_488); // set decoded signal_e2e headaer.
10817
+ message = message.subarray(K.MetaSize.ENC_488); // reset offset.
7408
10818
  } else {
7409
10819
  return
7410
10820
  }
@@ -7432,7 +10842,7 @@ class RemoteCore {
7432
10842
  }
7433
10843
 
7434
10844
  // console.log('<< SENDING CID_RES:', this.cid)
7435
- this.send_enc_mode(M$1.pack(
10845
+ this.send_enc_mode(mbp.pack(
7436
10846
  MB('#cid_ack', '8', IOMsg.CID_RES),
7437
10847
  MB('#cid', this.cid)
7438
10848
  ));
@@ -7516,7 +10926,7 @@ class RemoteCore {
7516
10926
 
7517
10927
  case IOMsg.CALL: //service request
7518
10928
  try {
7519
- let req = M$1.unpack(message);
10929
+ let req = mbp.unpack(message);
7520
10930
  if (req) {
7521
10931
  if (!req.target || !req.topic) return
7522
10932
  if (this.manager.server.serviceNames.has(req.target)) {
@@ -7541,7 +10951,7 @@ class RemoteCore {
7541
10951
 
7542
10952
 
7543
10953
  // client's auth requst
7544
- case tt.BohoMsg.AUTH_REQ:
10954
+ case K.BohoMsg.AUTH_REQ:
7545
10955
  if (!this.manager.authManager) return
7546
10956
  if (this.state < STATE.SERVER_READY) {
7547
10957
  console.log('protocol error. must called auth_req after server_ready');
@@ -7586,14 +10996,14 @@ class RemoteCore {
7586
10996
  response(msgId, statusCode, body) {
7587
10997
  // console.log('response body', body)
7588
10998
  if (body) {
7589
- this.send_enc_mode(M$1.pack(
10999
+ this.send_enc_mode(mbp.pack(
7590
11000
  MB('#type', '8', IOMsg.RESPONSE_MBP),
7591
11001
  MB('status', '8', statusCode),
7592
11002
  MB('mid', '16', msgId),
7593
11003
  MB('body', body)
7594
11004
  ));
7595
11005
  } else {
7596
- this.send_enc_mode(M$1.pack(
11006
+ this.send_enc_mode(mbp.pack(
7597
11007
  MB('#type', '8', IOMsg.RESPONSE_MBP),
7598
11008
  MB('status', '8', statusCode),
7599
11009
  MB('mid', '16', msgId)
@@ -7620,7 +11030,7 @@ class RemoteCore {
7620
11030
  // console.log('server bypass E2E signal taginfo:', tagInfo )
7621
11031
 
7622
11032
  let encHeader = this.boho.encrypt_488(data.subarray(0, 3 + tagLen));
7623
- encHeader[0] = tt.BohoMsg.ENC_E2E;
11033
+ encHeader[0] = K.BohoMsg.ENC_E2E;
7624
11034
  let newEncBuffer = Buffer.concat([encHeader, data.subarray(3 + tagLen)]);
7625
11035
  this.send(newEncBuffer);
7626
11036
 
@@ -7660,7 +11070,7 @@ class RemoteCore {
7660
11070
  }
7661
11071
 
7662
11072
  // console.log( 'iam res info', info )
7663
- let pack = M$1.pack(
11073
+ let pack = mbp.pack(
7664
11074
  MB('#MsgType', '8', IOMsg.IAM_RES),
7665
11075
  MB('#info', info)
7666
11076
  );
@@ -8238,9 +11648,9 @@ class Manager {
8238
11648
 
8239
11649
  // it's like unix wall command.
8240
11650
  serverSignal(obj) {
8241
- let sigPack = M$1.pack(
8242
- M$1.MB('#MsgType', '8', IOMsg.SERVER_SIGNAL),
8243
- M$1.MB('#signalObject', obj)
11651
+ let sigPack = mbp.pack(
11652
+ mbp.MB('#MsgType', '8', IOMsg.SERVER_SIGNAL),
11653
+ mbp.MB('#signalObject', obj)
8244
11654
  );
8245
11655
 
8246
11656
  this.remotes.forEach(remote => {
@@ -8805,7 +12215,7 @@ class BohoAuth {
8805
12215
  peer.setState(STATE.AUTH_FAIL);
8806
12216
  // add some delay time.
8807
12217
  setTimeout(e => {
8808
- peer.send(Buffer.from([tt.BohoMsg.AUTH_FAIL]));
12218
+ peer.send(Buffer.from([K.BohoMsg.AUTH_FAIL]));
8809
12219
  }, serverOption.auth.delay_auth_fail);
8810
12220
  }
8811
12221
 
@@ -8813,7 +12223,7 @@ class BohoAuth {
8813
12223
  async verify_auth_req(auth_req, peer) {
8814
12224
  try {
8815
12225
  //1. unpack
8816
- let infoPack = M$1.unpack(auth_req, tt.Meta.AUTH_REQ);
12226
+ let infoPack = mbp.unpack(auth_req, K.Meta.AUTH_REQ);
8817
12227
  if (!infoPack) {
8818
12228
  this.send_auth_fail(peer, 'unpack auth_pack fail');
8819
12229
  return
@@ -8869,9 +12279,9 @@ class BohoAuth {
8869
12279
  return
8870
12280
  }
8871
12281
 
8872
- let authClearSignal = M$1.pack(
8873
- M$1.MB('#MsgType', '8', IOMsg.AUTH_CLEAR),
8874
- M$1.MB('#reason', 'duplicate login.')
12282
+ let authClearSignal = mbp.pack(
12283
+ mbp.MB('#MsgType', '8', IOMsg.AUTH_CLEAR),
12284
+ mbp.MB('#reason', 'duplicate login.')
8875
12285
  );
8876
12286
  if (this.keepOldConnection) { // default true
8877
12287
  // keep old connection. reject new connection by sending auth_fail signal.
@@ -9021,7 +12431,7 @@ class FileKeyProvider {
9021
12431
  }
9022
12432
 
9023
12433
  addAuth(id, keyStr, cid, level = 0) {
9024
- let Base64hashKey = Buffer.from(tt.sha256.hash(keyStr)).toString('base64');
12434
+ let Base64hashKey = Buffer.from(K.sha256.hash(keyStr)).toString('base64');
9025
12435
  this.AUTH.set(id, { key: Base64hashKey, cid: cid, level: level });
9026
12436
  }
9027
12437
  }
@@ -9058,7 +12468,7 @@ class RedisKeyProvider {
9058
12468
 
9059
12469
  // add device auth info
9060
12470
  async addAuth(id, keyStr, cid = '', level = 0) {
9061
- let Base64hashKey = Buffer.from(tt.sha256.hash(keyStr)).toString('base64');
12471
+ let Base64hashKey = Buffer.from(K.sha256.hash(keyStr)).toString('base64');
9062
12472
  return this.redis.hSet(DEVICE_PREFIX + id, { 'key': Base64hashKey, 'cid': cid, 'level': level })
9063
12473
  }
9064
12474
 
@@ -9121,7 +12531,7 @@ class StringKeyProvider {
9121
12531
  }
9122
12532
 
9123
12533
  addAuth(id, keyStr, cid, level = 0) {
9124
- let Base64hashKey = Buffer.from(tt.sha256.hash(keyStr)).toString('base64');
12534
+ let Base64hashKey = Buffer.from(K.sha256.hash(keyStr)).toString('base64');
9125
12535
  this.AUTH.set(id, { key: Base64hashKey, cid: cid, level: level });
9126
12536
  }
9127
12537
  }
@@ -9308,4 +12718,4 @@ class RedisService {
9308
12718
 
9309
12719
  const version = pkg.version;
9310
12720
 
9311
- 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 };
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 };