@pooflabs/web 0.0.76 → 0.0.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +32 -0
  2. package/dist/{index-BilNgDSc.js → index-Bfk81d8_.js} +883 -25
  3. package/dist/index-Bfk81d8_.js.map +1 -0
  4. package/dist/{index-C5Cnn7Hq.esm.js → index-CFh1x-M0.esm.js} +353 -156
  5. package/dist/index-CFh1x-M0.esm.js.map +1 -0
  6. package/dist/index-CdOv7Nw2.esm.js +6 -0
  7. package/dist/index-CdOv7Nw2.esm.js.map +1 -0
  8. package/dist/{index-DeVykeX4.esm.js → index-CeQ8hE3s.esm.js} +881 -24
  9. package/dist/index-CeQ8hE3s.esm.js.map +1 -0
  10. package/dist/index-DDXzCx2W.js +8 -0
  11. package/dist/index-DDXzCx2W.js.map +1 -0
  12. package/dist/{index-BrlvWT1Q.js → index-DQVpAl5t.js} +353 -156
  13. package/dist/index-DQVpAl5t.js.map +1 -0
  14. package/dist/{index-COMIXUxl.js → index-KUU0aVzP.js} +882 -24
  15. package/dist/index-KUU0aVzP.js.map +1 -0
  16. package/dist/{index-Dsh0H37n.esm.js → index-R7t9pRt_.esm.js} +882 -23
  17. package/dist/index-R7t9pRt_.esm.js.map +1 -0
  18. package/dist/{index.browser-CSTWylhG.esm.js → index.browser-BE44CEaJ.esm.js} +3 -3
  19. package/dist/{index.browser-CSTWylhG.esm.js.map → index.browser-BE44CEaJ.esm.js.map} +1 -1
  20. package/dist/{index.browser-DZjyUgtx.esm.js → index.browser-C-_FEr5M.esm.js} +449 -479
  21. package/dist/index.browser-C-_FEr5M.esm.js.map +1 -0
  22. package/dist/index.browser-C9bFQZyQ.esm.js +1373 -0
  23. package/dist/index.browser-C9bFQZyQ.esm.js.map +1 -0
  24. package/dist/index.browser-Dbq5Qf1G.esm.js +242 -0
  25. package/dist/index.browser-Dbq5Qf1G.esm.js.map +1 -0
  26. package/dist/index.browser-Df7yN8D5.js +245 -0
  27. package/dist/index.browser-Df7yN8D5.js.map +1 -0
  28. package/dist/{index.browser-CMO2pjaF.js → index.browser-Di1_YZpi.js} +3 -3
  29. package/dist/{index.browser-CMO2pjaF.js.map → index.browser-Di1_YZpi.js.map} +1 -1
  30. package/dist/{index.browser-BOJRGZWX.js → index.browser-DjEZSiqI.js} +449 -479
  31. package/dist/index.browser-DjEZSiqI.js.map +1 -0
  32. package/dist/index.browser-dszs5oe5.js +1376 -0
  33. package/dist/index.browser-dszs5oe5.js.map +1 -0
  34. package/dist/index.esm.js +1 -1
  35. package/dist/index.js +2 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/{index.native-CkUXrvPQ.js → index.native-CKd2b3_F.js} +2756 -188
  38. package/dist/index.native-CKd2b3_F.js.map +1 -0
  39. package/dist/{index.native-H-fEcP_L.esm.js → index.native-DAyMVhFq.esm.js} +2755 -189
  40. package/dist/index.native-DAyMVhFq.esm.js.map +1 -0
  41. package/dist/index.native.esm.js +1 -1
  42. package/dist/index.native.js +2 -1
  43. package/dist/index.native.js.map +1 -1
  44. package/dist/{phantom-wallet-provider-DrNrxSUL.js → phantom-wallet-provider-DJ6qf2VB.js} +4 -4
  45. package/dist/{phantom-wallet-provider-DrNrxSUL.js.map → phantom-wallet-provider-DJ6qf2VB.js.map} +1 -1
  46. package/dist/{phantom-wallet-provider-5IQi4ihD.esm.js → phantom-wallet-provider-DQ0uhl2v.esm.js} +4 -4
  47. package/dist/{phantom-wallet-provider-5IQi4ihD.esm.js.map → phantom-wallet-provider-DQ0uhl2v.esm.js.map} +1 -1
  48. package/dist/{privy-wallet-provider-BtLH1dpY.esm.js → privy-wallet-provider-BhiHnphv.esm.js} +3 -3
  49. package/dist/privy-wallet-provider-BhiHnphv.esm.js.map +1 -0
  50. package/dist/{privy-wallet-provider-CrRfcONv.js → privy-wallet-provider-CMCv5g3O.js} +3 -3
  51. package/dist/privy-wallet-provider-CMCv5g3O.js.map +1 -0
  52. package/dist/{solana-mobile-wallet-provider-C3l6mxSm.esm.js → solana-mobile-wallet-provider-DSSk_6CR.esm.js} +4 -4
  53. package/dist/{solana-mobile-wallet-provider-C3l6mxSm.esm.js.map → solana-mobile-wallet-provider-DSSk_6CR.esm.js.map} +1 -1
  54. package/dist/{solana-mobile-wallet-provider-QcGazewW.js → solana-mobile-wallet-provider-DaFNesCe.js} +4 -4
  55. package/dist/{solana-mobile-wallet-provider-QcGazewW.js.map → solana-mobile-wallet-provider-DaFNesCe.js.map} +1 -1
  56. package/package.json +2 -2
  57. package/dist/index-Bdcc5821.js +0 -2375
  58. package/dist/index-Bdcc5821.js.map +0 -1
  59. package/dist/index-BilNgDSc.js.map +0 -1
  60. package/dist/index-BrlvWT1Q.js.map +0 -1
  61. package/dist/index-C5Cnn7Hq.esm.js.map +0 -1
  62. package/dist/index-COMIXUxl.js.map +0 -1
  63. package/dist/index-CrOVJFX9.esm.js +0 -2373
  64. package/dist/index-CrOVJFX9.esm.js.map +0 -1
  65. package/dist/index-DeVykeX4.esm.js.map +0 -1
  66. package/dist/index-Dsh0H37n.esm.js.map +0 -1
  67. package/dist/index.browser--rDwfvXH.esm.js +0 -307
  68. package/dist/index.browser--rDwfvXH.esm.js.map +0 -1
  69. package/dist/index.browser-BOJRGZWX.js.map +0 -1
  70. package/dist/index.browser-CLZv9v_y.js +0 -310
  71. package/dist/index.browser-CLZv9v_y.js.map +0 -1
  72. package/dist/index.browser-DQKnuR3q.esm.js +0 -1468
  73. package/dist/index.browser-DQKnuR3q.esm.js.map +0 -1
  74. package/dist/index.browser-DZjyUgtx.esm.js.map +0 -1
  75. package/dist/index.browser-DqO3G-HJ.js +0 -1471
  76. package/dist/index.browser-DqO3G-HJ.js.map +0 -1
  77. package/dist/index.native-CkUXrvPQ.js.map +0 -1
  78. package/dist/index.native-H-fEcP_L.esm.js.map +0 -1
  79. package/dist/privy-wallet-provider-BtLH1dpY.esm.js.map +0 -1
  80. package/dist/privy-wallet-provider-CrRfcONv.js.map +0 -1
@@ -22,6 +22,21 @@ function _interopNamespaceDefault(e) {
22
22
  return Object.freeze(n);
23
23
  }
24
24
 
25
+ function _mergeNamespaces(n, m) {
26
+ m.forEach(function (e) {
27
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
28
+ if (k !== 'default' && !(k in n)) {
29
+ var d = Object.getOwnPropertyDescriptor(e, k);
30
+ Object.defineProperty(n, k, d.get ? d : {
31
+ enumerable: true,
32
+ get: function () { return e[k]; }
33
+ });
34
+ }
35
+ });
36
+ });
37
+ return Object.freeze(n);
38
+ }
39
+
25
40
  var anchor__namespace = /*#__PURE__*/_interopNamespaceDefault(anchor);
26
41
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
27
42
 
@@ -6609,19 +6624,19 @@ function getDefaultExportFromCjs (x) {
6609
6624
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
6610
6625
  }
6611
6626
 
6612
- var buffer = {};
6627
+ var buffer$1 = {};
6613
6628
 
6614
- var base64Js = {};
6629
+ var base64Js$1 = {};
6615
6630
 
6616
- var hasRequiredBase64Js;
6631
+ var hasRequiredBase64Js$1;
6617
6632
 
6618
- function requireBase64Js () {
6619
- if (hasRequiredBase64Js) return base64Js;
6620
- hasRequiredBase64Js = 1;
6633
+ function requireBase64Js$1 () {
6634
+ if (hasRequiredBase64Js$1) return base64Js$1;
6635
+ hasRequiredBase64Js$1 = 1;
6621
6636
 
6622
- base64Js.byteLength = byteLength;
6623
- base64Js.toByteArray = toByteArray;
6624
- base64Js.fromByteArray = fromByteArray;
6637
+ base64Js$1.byteLength = byteLength;
6638
+ base64Js$1.toByteArray = toByteArray;
6639
+ base64Js$1.fromByteArray = fromByteArray;
6625
6640
 
6626
6641
  var lookup = [];
6627
6642
  var revLookup = [];
@@ -6767,19 +6782,19 @@ function requireBase64Js () {
6767
6782
 
6768
6783
  return parts.join('')
6769
6784
  }
6770
- return base64Js;
6785
+ return base64Js$1;
6771
6786
  }
6772
6787
 
6773
- var ieee754 = {};
6788
+ var ieee754$1 = {};
6774
6789
 
6775
6790
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
6776
6791
 
6777
- var hasRequiredIeee754;
6792
+ var hasRequiredIeee754$1;
6778
6793
 
6779
- function requireIeee754 () {
6780
- if (hasRequiredIeee754) return ieee754;
6781
- hasRequiredIeee754 = 1;
6782
- ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
6794
+ function requireIeee754$1 () {
6795
+ if (hasRequiredIeee754$1) return ieee754$1;
6796
+ hasRequiredIeee754$1 = 1;
6797
+ ieee754$1.read = function (buffer, offset, isLE, mLen, nBytes) {
6783
6798
  var e, m;
6784
6799
  var eLen = (nBytes * 8) - mLen - 1;
6785
6800
  var eMax = (1 << eLen) - 1;
@@ -6812,7 +6827,7 @@ function requireIeee754 () {
6812
6827
  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
6813
6828
  };
6814
6829
 
6815
- ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
6830
+ ieee754$1.write = function (buffer, value, offset, isLE, mLen, nBytes) {
6816
6831
  var e, m, c;
6817
6832
  var eLen = (nBytes * 8) - mLen - 1;
6818
6833
  var eMax = (1 << eLen) - 1;
@@ -6863,7 +6878,7 @@ function requireIeee754 () {
6863
6878
 
6864
6879
  buffer[offset + i - d] |= s * 128;
6865
6880
  };
6866
- return ieee754;
6881
+ return ieee754$1;
6867
6882
  }
6868
6883
 
6869
6884
  /*!
@@ -6873,15 +6888,15 @@ function requireIeee754 () {
6873
6888
  * @license MIT
6874
6889
  */
6875
6890
 
6876
- var hasRequiredBuffer;
6891
+ var hasRequiredBuffer$1;
6877
6892
 
6878
- function requireBuffer () {
6879
- if (hasRequiredBuffer) return buffer;
6880
- hasRequiredBuffer = 1;
6893
+ function requireBuffer$1 () {
6894
+ if (hasRequiredBuffer$1) return buffer$1;
6895
+ hasRequiredBuffer$1 = 1;
6881
6896
  (function (exports$1) {
6882
6897
 
6883
- const base64 = requireBase64Js();
6884
- const ieee754 = requireIeee754();
6898
+ const base64 = requireBase64Js$1();
6899
+ const ieee754 = requireIeee754$1();
6885
6900
  const customInspectSymbol =
6886
6901
  (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
6887
6902
  ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
@@ -8974,24 +8989,24 @@ function requireBuffer () {
8974
8989
  function BufferBigIntNotDefined () {
8975
8990
  throw new Error('BigInt not supported')
8976
8991
  }
8977
- } (buffer));
8978
- return buffer;
8992
+ } (buffer$1));
8993
+ return buffer$1;
8979
8994
  }
8980
8995
 
8981
- var bufferExports = requireBuffer();
8996
+ var bufferExports = requireBuffer$1();
8982
8997
 
8983
- var safeBuffer = {exports: {}};
8998
+ var safeBuffer$1 = {exports: {}};
8984
8999
 
8985
9000
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
8986
9001
 
8987
- var hasRequiredSafeBuffer;
9002
+ var hasRequiredSafeBuffer$1;
8988
9003
 
8989
- function requireSafeBuffer () {
8990
- if (hasRequiredSafeBuffer) return safeBuffer.exports;
8991
- hasRequiredSafeBuffer = 1;
9004
+ function requireSafeBuffer$1 () {
9005
+ if (hasRequiredSafeBuffer$1) return safeBuffer$1.exports;
9006
+ hasRequiredSafeBuffer$1 = 1;
8992
9007
  (function (module, exports$1) {
8993
9008
  /* eslint-disable node/no-deprecated-api */
8994
- var buffer = requireBuffer();
9009
+ var buffer = requireBuffer$1();
8995
9010
  var Buffer = buffer.Buffer;
8996
9011
 
8997
9012
  // alternative to using Object.keys for old browsers
@@ -9054,23 +9069,23 @@ function requireSafeBuffer () {
9054
9069
  }
9055
9070
  return buffer.SlowBuffer(size)
9056
9071
  };
9057
- } (safeBuffer, safeBuffer.exports));
9058
- return safeBuffer.exports;
9072
+ } (safeBuffer$1, safeBuffer$1.exports));
9073
+ return safeBuffer$1.exports;
9059
9074
  }
9060
9075
 
9061
- var src;
9062
- var hasRequiredSrc;
9076
+ var src$1;
9077
+ var hasRequiredSrc$1;
9063
9078
 
9064
- function requireSrc () {
9065
- if (hasRequiredSrc) return src;
9066
- hasRequiredSrc = 1;
9079
+ function requireSrc$1 () {
9080
+ if (hasRequiredSrc$1) return src$1;
9081
+ hasRequiredSrc$1 = 1;
9067
9082
  // base-x encoding / decoding
9068
9083
  // Copyright (c) 2018 base-x contributors
9069
9084
  // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
9070
9085
  // Distributed under the MIT software license, see the accompanying
9071
9086
  // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
9072
9087
  // @ts-ignore
9073
- var _Buffer = requireSafeBuffer().Buffer;
9088
+ var _Buffer = requireSafeBuffer$1().Buffer;
9074
9089
  function base (ALPHABET) {
9075
9090
  if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
9076
9091
  var BASE_MAP = new Uint8Array(256);
@@ -9185,25 +9200,25 @@ function requireSrc () {
9185
9200
  decode: decode
9186
9201
  }
9187
9202
  }
9188
- src = base;
9189
- return src;
9203
+ src$1 = base;
9204
+ return src$1;
9190
9205
  }
9191
9206
 
9192
- var bs58$1;
9193
- var hasRequiredBs58;
9207
+ var bs58$1$1;
9208
+ var hasRequiredBs58$1;
9194
9209
 
9195
- function requireBs58 () {
9196
- if (hasRequiredBs58) return bs58$1;
9197
- hasRequiredBs58 = 1;
9198
- var basex = requireSrc();
9210
+ function requireBs58$1 () {
9211
+ if (hasRequiredBs58$1) return bs58$1$1;
9212
+ hasRequiredBs58$1 = 1;
9213
+ var basex = requireSrc$1();
9199
9214
  var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
9200
9215
 
9201
- bs58$1 = basex(ALPHABET);
9202
- return bs58$1;
9216
+ bs58$1$1 = basex(ALPHABET);
9217
+ return bs58$1$1;
9203
9218
  }
9204
9219
 
9205
- var bs58Exports = requireBs58();
9206
- var bs58$2 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports);
9220
+ var bs58Exports$1 = requireBs58$1();
9221
+ var bs58$2 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports$1);
9207
9222
 
9208
9223
  // ─────────────────────────────────────────────────────────────
9209
9224
  // Local implementation of getSimulationComputeUnits
@@ -10122,6 +10137,90 @@ function cleanupExpiredCache() {
10122
10137
  });
10123
10138
  lastCacheCleanup = now;
10124
10139
  }
10140
+ async function getMany(paths, opts = {}) {
10141
+ if (paths.length === 0) {
10142
+ return [];
10143
+ }
10144
+ if (paths.length > 30) {
10145
+ throw new Error('Cannot fetch more than 30 documents at once');
10146
+ }
10147
+ const normalizedPaths = [];
10148
+ for (const path of paths) {
10149
+ let normalizedPath = path.startsWith("/") ? path.slice(1) : path;
10150
+ if (normalizedPath.endsWith("*") && normalizedPath.length > 1) {
10151
+ normalizedPath = normalizedPath.slice(0, -1);
10152
+ }
10153
+ if (!normalizedPath || normalizedPath.length === 0) {
10154
+ throw new Error(`Invalid path provided: ${path}`);
10155
+ }
10156
+ const pathIsDocument = normalizedPath.split("/").length % 2 === 0;
10157
+ if (!pathIsDocument) {
10158
+ throw new Error(`Path must point to a document (even number of segments): ${path}`);
10159
+ }
10160
+ normalizedPaths.push(normalizedPath);
10161
+ }
10162
+ const now = Date.now();
10163
+ const results = new Array(paths.length);
10164
+ const uncachedIndices = [];
10165
+ const uncachedPaths = [];
10166
+ for (let i = 0; i < normalizedPaths.length; i++) {
10167
+ const normalizedPath = normalizedPaths[i];
10168
+ const cacheKey = `${normalizedPath}:`;
10169
+ if (!opts.bypassCache && getCache[cacheKey] && now < getCache[cacheKey].expiresAt) {
10170
+ results[i] = { path: normalizedPath, data: getCache[cacheKey].data };
10171
+ }
10172
+ else {
10173
+ uncachedIndices.push(i);
10174
+ uncachedPaths.push(normalizedPath);
10175
+ }
10176
+ }
10177
+ if (uncachedPaths.length > 0) {
10178
+ try {
10179
+ const response = await makeApiRequest('POST', 'items/batch', { paths: uncachedPaths }, opts._overrides);
10180
+ const serverResults = response.data.results;
10181
+ const serverResultsMap = new Map();
10182
+ for (const result of serverResults) {
10183
+ serverResultsMap.set(result.path, result);
10184
+ }
10185
+ for (let i = 0; i < uncachedIndices.length; i++) {
10186
+ const originalIndex = uncachedIndices[i];
10187
+ const normalizedPath = uncachedPaths[i];
10188
+ const serverResult = serverResultsMap.get(normalizedPath);
10189
+ if (serverResult) {
10190
+ results[originalIndex] = serverResult;
10191
+ if (!serverResult.error && !opts.bypassCache) {
10192
+ const cacheKey = `${normalizedPath}:`;
10193
+ getCache[cacheKey] = {
10194
+ data: serverResult.data,
10195
+ expiresAt: now + GET_CACHE_TTL
10196
+ };
10197
+ }
10198
+ }
10199
+ else {
10200
+ results[originalIndex] = {
10201
+ path: normalizedPath,
10202
+ data: null,
10203
+ error: { code: 'NOT_FOUND', message: `No result returned for path ${normalizedPath}` }
10204
+ };
10205
+ }
10206
+ }
10207
+ if (now - lastCacheCleanup > 5000) {
10208
+ cleanupExpiredCache();
10209
+ lastCacheCleanup = now;
10210
+ }
10211
+ }
10212
+ catch (error) {
10213
+ for (const originalIndex of uncachedIndices) {
10214
+ results[originalIndex] = {
10215
+ path: normalizedPaths[originalIndex],
10216
+ data: null,
10217
+ error: { code: 'NOT_FOUND', message: error instanceof Error ? error.message : 'Unknown error' }
10218
+ };
10219
+ }
10220
+ }
10221
+ }
10222
+ return results;
10223
+ }
10125
10224
  async function runQuery(absolutePath, queryName, queryArgs, opts) {
10126
10225
  const result = await runQueryMany([{ absolutePath, queryName, queryArgs }], opts);
10127
10226
  return result[0];
@@ -12407,15 +12506,15 @@ function clearIncompatibleSession() {
12407
12506
  // Lazy loaders for web-only providers.
12408
12507
  // Using dynamic import() ensures Metro (RN) never resolves these modules.
12409
12508
  async function loadPrivyWalletProvider() {
12410
- const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-CrRfcONv.js'); });
12509
+ const mod = await Promise.resolve().then(function () { return require('./privy-wallet-provider-CMCv5g3O.js'); });
12411
12510
  return mod.PrivyWalletProvider;
12412
12511
  }
12413
12512
  async function loadPhantomWalletProvider() {
12414
- const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-DrNrxSUL.js'); });
12513
+ const mod = await Promise.resolve().then(function () { return require('./phantom-wallet-provider-DJ6qf2VB.js'); });
12415
12514
  return { PhantomWalletProvider: mod.PhantomWalletProvider };
12416
12515
  }
12417
12516
  async function loadSolanaMobileWalletProvider() {
12418
- const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-QcGazewW.js'); });
12517
+ const mod = await Promise.resolve().then(function () { return require('./solana-mobile-wallet-provider-DaFNesCe.js'); });
12419
12518
  return mod.SolanaMobileWalletProvider;
12420
12519
  }
12421
12520
  async function hotSwapToPrivyProvider(config) {
@@ -12825,137 +12924,2604 @@ async function confirmAndCheckTransaction(connection, signature) {
12825
12924
  throw new Error('Transaction confirmation timeout');
12826
12925
  }
12827
12926
 
12828
- // base-x encoding / decoding
12829
- // Copyright (c) 2018 base-x contributors
12830
- // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
12831
- // Distributed under the MIT software license, see the accompanying
12832
- // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
12833
- function base (ALPHABET) {
12834
- if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
12835
- const BASE_MAP = new Uint8Array(256);
12836
- for (let j = 0; j < BASE_MAP.length; j++) {
12837
- BASE_MAP[j] = 255;
12838
- }
12839
- for (let i = 0; i < ALPHABET.length; i++) {
12840
- const x = ALPHABET.charAt(i);
12841
- const xc = x.charCodeAt(0);
12842
- if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
12843
- BASE_MAP[xc] = i;
12844
- }
12845
- const BASE = ALPHABET.length;
12846
- const LEADER = ALPHABET.charAt(0);
12847
- const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
12848
- const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
12849
- function encode (source) {
12850
- // eslint-disable-next-line no-empty
12851
- if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
12852
- source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
12853
- } else if (Array.isArray(source)) {
12854
- source = Uint8Array.from(source);
12855
- }
12856
- if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
12857
- if (source.length === 0) { return '' }
12858
- // Skip & count leading zeroes.
12859
- let zeroes = 0;
12860
- let length = 0;
12861
- let pbegin = 0;
12862
- const pend = source.length;
12863
- while (pbegin !== pend && source[pbegin] === 0) {
12864
- pbegin++;
12865
- zeroes++;
12866
- }
12867
- // Allocate enough space in big-endian base58 representation.
12868
- const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
12869
- const b58 = new Uint8Array(size);
12870
- // Process the bytes.
12871
- while (pbegin !== pend) {
12872
- let carry = source[pbegin];
12873
- // Apply "b58 = b58 * 256 + ch".
12874
- let i = 0;
12875
- for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
12876
- carry += (256 * b58[it1]) >>> 0;
12877
- b58[it1] = (carry % BASE) >>> 0;
12878
- carry = (carry / BASE) >>> 0;
12879
- }
12880
- if (carry !== 0) { throw new Error('Non-zero carry') }
12881
- length = i;
12882
- pbegin++;
12883
- }
12884
- // Skip leading zeroes in base58 result.
12885
- let it2 = size - length;
12886
- while (it2 !== size && b58[it2] === 0) {
12887
- it2++;
12888
- }
12889
- // Translate the result into a string.
12890
- let str = LEADER.repeat(zeroes);
12891
- for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
12892
- return str
12893
- }
12894
- function decodeUnsafe (source) {
12895
- if (typeof source !== 'string') { throw new TypeError('Expected String') }
12896
- if (source.length === 0) { return new Uint8Array() }
12897
- let psz = 0;
12898
- // Skip and count leading '1's.
12899
- let zeroes = 0;
12900
- let length = 0;
12901
- while (source[psz] === LEADER) {
12902
- zeroes++;
12903
- psz++;
12904
- }
12905
- // Allocate enough space in big-endian base256 representation.
12906
- const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
12907
- const b256 = new Uint8Array(size);
12908
- // Process the characters.
12909
- while (psz < source.length) {
12910
- // Find code of next character
12911
- const charCode = source.charCodeAt(psz);
12912
- // Base map can not be indexed using char code
12913
- if (charCode > 255) { return }
12914
- // Decode character
12915
- let carry = BASE_MAP[charCode];
12916
- // Invalid character
12917
- if (carry === 255) { return }
12918
- let i = 0;
12919
- for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
12920
- carry += (BASE * b256[it3]) >>> 0;
12921
- b256[it3] = (carry % 256) >>> 0;
12922
- carry = (carry / 256) >>> 0;
12923
- }
12924
- if (carry !== 0) { throw new Error('Non-zero carry') }
12925
- length = i;
12926
- psz++;
12927
- }
12928
- // Skip leading zeroes in b256.
12929
- let it4 = size - length;
12930
- while (it4 !== size && b256[it4] === 0) {
12931
- it4++;
12932
- }
12933
- const vch = new Uint8Array(zeroes + (size - it4));
12934
- let j = zeroes;
12935
- while (it4 !== size) {
12936
- vch[j++] = b256[it4++];
12937
- }
12938
- return vch
12939
- }
12940
- function decode (string) {
12941
- const buffer = decodeUnsafe(string);
12942
- if (buffer) { return buffer }
12943
- throw new Error('Non-base' + BASE + ' character')
12944
- }
12945
- return {
12946
- encode,
12947
- decodeUnsafe,
12948
- decode
12949
- }
12950
- }
12951
-
12952
- var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
12953
- var bs58 = base(ALPHABET);
12954
-
12955
- var index = /*#__PURE__*/Object.freeze({
12956
- __proto__: null,
12957
- default: bs58
12958
- });
12927
+ var safeBuffer = {exports: {}};
12928
+
12929
+ var buffer = {};
12930
+
12931
+ var base64Js = {};
12932
+
12933
+ var hasRequiredBase64Js;
12934
+
12935
+ function requireBase64Js () {
12936
+ if (hasRequiredBase64Js) return base64Js;
12937
+ hasRequiredBase64Js = 1;
12938
+
12939
+ base64Js.byteLength = byteLength;
12940
+ base64Js.toByteArray = toByteArray;
12941
+ base64Js.fromByteArray = fromByteArray;
12942
+
12943
+ var lookup = [];
12944
+ var revLookup = [];
12945
+ var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
12946
+
12947
+ var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
12948
+ for (var i = 0, len = code.length; i < len; ++i) {
12949
+ lookup[i] = code[i];
12950
+ revLookup[code.charCodeAt(i)] = i;
12951
+ }
12952
+
12953
+ // Support decoding URL-safe base64 strings, as Node.js does.
12954
+ // See: https://en.wikipedia.org/wiki/Base64#URL_applications
12955
+ revLookup['-'.charCodeAt(0)] = 62;
12956
+ revLookup['_'.charCodeAt(0)] = 63;
12957
+
12958
+ function getLens (b64) {
12959
+ var len = b64.length;
12960
+
12961
+ if (len % 4 > 0) {
12962
+ throw new Error('Invalid string. Length must be a multiple of 4')
12963
+ }
12964
+
12965
+ // Trim off extra bytes after placeholder bytes are found
12966
+ // See: https://github.com/beatgammit/base64-js/issues/42
12967
+ var validLen = b64.indexOf('=');
12968
+ if (validLen === -1) validLen = len;
12969
+
12970
+ var placeHoldersLen = validLen === len
12971
+ ? 0
12972
+ : 4 - (validLen % 4);
12973
+
12974
+ return [validLen, placeHoldersLen]
12975
+ }
12976
+
12977
+ // base64 is 4/3 + up to two characters of the original data
12978
+ function byteLength (b64) {
12979
+ var lens = getLens(b64);
12980
+ var validLen = lens[0];
12981
+ var placeHoldersLen = lens[1];
12982
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
12983
+ }
12984
+
12985
+ function _byteLength (b64, validLen, placeHoldersLen) {
12986
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
12987
+ }
12988
+
12989
+ function toByteArray (b64) {
12990
+ var tmp;
12991
+ var lens = getLens(b64);
12992
+ var validLen = lens[0];
12993
+ var placeHoldersLen = lens[1];
12994
+
12995
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
12996
+
12997
+ var curByte = 0;
12998
+
12999
+ // if there are placeholders, only get up to the last complete 4 chars
13000
+ var len = placeHoldersLen > 0
13001
+ ? validLen - 4
13002
+ : validLen;
13003
+
13004
+ var i;
13005
+ for (i = 0; i < len; i += 4) {
13006
+ tmp =
13007
+ (revLookup[b64.charCodeAt(i)] << 18) |
13008
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
13009
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
13010
+ revLookup[b64.charCodeAt(i + 3)];
13011
+ arr[curByte++] = (tmp >> 16) & 0xFF;
13012
+ arr[curByte++] = (tmp >> 8) & 0xFF;
13013
+ arr[curByte++] = tmp & 0xFF;
13014
+ }
13015
+
13016
+ if (placeHoldersLen === 2) {
13017
+ tmp =
13018
+ (revLookup[b64.charCodeAt(i)] << 2) |
13019
+ (revLookup[b64.charCodeAt(i + 1)] >> 4);
13020
+ arr[curByte++] = tmp & 0xFF;
13021
+ }
13022
+
13023
+ if (placeHoldersLen === 1) {
13024
+ tmp =
13025
+ (revLookup[b64.charCodeAt(i)] << 10) |
13026
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
13027
+ (revLookup[b64.charCodeAt(i + 2)] >> 2);
13028
+ arr[curByte++] = (tmp >> 8) & 0xFF;
13029
+ arr[curByte++] = tmp & 0xFF;
13030
+ }
13031
+
13032
+ return arr
13033
+ }
13034
+
13035
+ function tripletToBase64 (num) {
13036
+ return lookup[num >> 18 & 0x3F] +
13037
+ lookup[num >> 12 & 0x3F] +
13038
+ lookup[num >> 6 & 0x3F] +
13039
+ lookup[num & 0x3F]
13040
+ }
13041
+
13042
+ function encodeChunk (uint8, start, end) {
13043
+ var tmp;
13044
+ var output = [];
13045
+ for (var i = start; i < end; i += 3) {
13046
+ tmp =
13047
+ ((uint8[i] << 16) & 0xFF0000) +
13048
+ ((uint8[i + 1] << 8) & 0xFF00) +
13049
+ (uint8[i + 2] & 0xFF);
13050
+ output.push(tripletToBase64(tmp));
13051
+ }
13052
+ return output.join('')
13053
+ }
13054
+
13055
+ function fromByteArray (uint8) {
13056
+ var tmp;
13057
+ var len = uint8.length;
13058
+ var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
13059
+ var parts = [];
13060
+ var maxChunkLength = 16383; // must be multiple of 3
13061
+
13062
+ // go through the array every three bytes, we'll deal with trailing stuff later
13063
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
13064
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
13065
+ }
13066
+
13067
+ // pad the end with zeros, but make sure to not forget the extra bytes
13068
+ if (extraBytes === 1) {
13069
+ tmp = uint8[len - 1];
13070
+ parts.push(
13071
+ lookup[tmp >> 2] +
13072
+ lookup[(tmp << 4) & 0x3F] +
13073
+ '=='
13074
+ );
13075
+ } else if (extraBytes === 2) {
13076
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1];
13077
+ parts.push(
13078
+ lookup[tmp >> 10] +
13079
+ lookup[(tmp >> 4) & 0x3F] +
13080
+ lookup[(tmp << 2) & 0x3F] +
13081
+ '='
13082
+ );
13083
+ }
13084
+
13085
+ return parts.join('')
13086
+ }
13087
+ return base64Js;
13088
+ }
13089
+
13090
+ var ieee754 = {};
13091
+
13092
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
13093
+
13094
+ var hasRequiredIeee754;
13095
+
13096
+ function requireIeee754 () {
13097
+ if (hasRequiredIeee754) return ieee754;
13098
+ hasRequiredIeee754 = 1;
13099
+ ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
13100
+ var e, m;
13101
+ var eLen = (nBytes * 8) - mLen - 1;
13102
+ var eMax = (1 << eLen) - 1;
13103
+ var eBias = eMax >> 1;
13104
+ var nBits = -7;
13105
+ var i = isLE ? (nBytes - 1) : 0;
13106
+ var d = isLE ? -1 : 1;
13107
+ var s = buffer[offset + i];
13108
+
13109
+ i += d;
13110
+
13111
+ e = s & ((1 << (-nBits)) - 1);
13112
+ s >>= (-nBits);
13113
+ nBits += eLen;
13114
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13115
+
13116
+ m = e & ((1 << (-nBits)) - 1);
13117
+ e >>= (-nBits);
13118
+ nBits += mLen;
13119
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13120
+
13121
+ if (e === 0) {
13122
+ e = 1 - eBias;
13123
+ } else if (e === eMax) {
13124
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
13125
+ } else {
13126
+ m = m + Math.pow(2, mLen);
13127
+ e = e - eBias;
13128
+ }
13129
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
13130
+ };
13131
+
13132
+ ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
13133
+ var e, m, c;
13134
+ var eLen = (nBytes * 8) - mLen - 1;
13135
+ var eMax = (1 << eLen) - 1;
13136
+ var eBias = eMax >> 1;
13137
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
13138
+ var i = isLE ? 0 : (nBytes - 1);
13139
+ var d = isLE ? 1 : -1;
13140
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
13141
+
13142
+ value = Math.abs(value);
13143
+
13144
+ if (isNaN(value) || value === Infinity) {
13145
+ m = isNaN(value) ? 1 : 0;
13146
+ e = eMax;
13147
+ } else {
13148
+ e = Math.floor(Math.log(value) / Math.LN2);
13149
+ if (value * (c = Math.pow(2, -e)) < 1) {
13150
+ e--;
13151
+ c *= 2;
13152
+ }
13153
+ if (e + eBias >= 1) {
13154
+ value += rt / c;
13155
+ } else {
13156
+ value += rt * Math.pow(2, 1 - eBias);
13157
+ }
13158
+ if (value * c >= 2) {
13159
+ e++;
13160
+ c /= 2;
13161
+ }
13162
+
13163
+ if (e + eBias >= eMax) {
13164
+ m = 0;
13165
+ e = eMax;
13166
+ } else if (e + eBias >= 1) {
13167
+ m = ((value * c) - 1) * Math.pow(2, mLen);
13168
+ e = e + eBias;
13169
+ } else {
13170
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
13171
+ e = 0;
13172
+ }
13173
+ }
13174
+
13175
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
13176
+
13177
+ e = (e << mLen) | m;
13178
+ eLen += mLen;
13179
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
13180
+
13181
+ buffer[offset + i - d] |= s * 128;
13182
+ };
13183
+ return ieee754;
13184
+ }
13185
+
13186
+ /*!
13187
+ * The buffer module from node.js, for the browser.
13188
+ *
13189
+ * @author Feross Aboukhadijeh <https://feross.org>
13190
+ * @license MIT
13191
+ */
13192
+
13193
+ var hasRequiredBuffer;
13194
+
13195
+ function requireBuffer () {
13196
+ if (hasRequiredBuffer) return buffer;
13197
+ hasRequiredBuffer = 1;
13198
+ (function (exports$1) {
13199
+
13200
+ const base64 = requireBase64Js();
13201
+ const ieee754 = requireIeee754();
13202
+ const customInspectSymbol =
13203
+ (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
13204
+ ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
13205
+ : null;
13206
+
13207
+ exports$1.Buffer = Buffer;
13208
+ exports$1.SlowBuffer = SlowBuffer;
13209
+ exports$1.INSPECT_MAX_BYTES = 50;
13210
+
13211
+ const K_MAX_LENGTH = 0x7fffffff;
13212
+ exports$1.kMaxLength = K_MAX_LENGTH;
13213
+
13214
+ /**
13215
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
13216
+ * === true Use Uint8Array implementation (fastest)
13217
+ * === false Print warning and recommend using `buffer` v4.x which has an Object
13218
+ * implementation (most compatible, even IE6)
13219
+ *
13220
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
13221
+ * Opera 11.6+, iOS 4.2+.
13222
+ *
13223
+ * We report that the browser does not support typed arrays if the are not subclassable
13224
+ * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
13225
+ * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
13226
+ * for __proto__ and has a buggy typed array implementation.
13227
+ */
13228
+ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
13229
+
13230
+ if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
13231
+ typeof console.error === 'function') {
13232
+ console.error(
13233
+ 'This browser lacks typed array (Uint8Array) support which is required by ' +
13234
+ '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
13235
+ );
13236
+ }
13237
+
13238
+ function typedArraySupport () {
13239
+ // Can typed array instances can be augmented?
13240
+ try {
13241
+ const arr = new Uint8Array(1);
13242
+ const proto = { foo: function () { return 42 } };
13243
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
13244
+ Object.setPrototypeOf(arr, proto);
13245
+ return arr.foo() === 42
13246
+ } catch (e) {
13247
+ return false
13248
+ }
13249
+ }
13250
+
13251
+ Object.defineProperty(Buffer.prototype, 'parent', {
13252
+ enumerable: true,
13253
+ get: function () {
13254
+ if (!Buffer.isBuffer(this)) return undefined
13255
+ return this.buffer
13256
+ }
13257
+ });
13258
+
13259
+ Object.defineProperty(Buffer.prototype, 'offset', {
13260
+ enumerable: true,
13261
+ get: function () {
13262
+ if (!Buffer.isBuffer(this)) return undefined
13263
+ return this.byteOffset
13264
+ }
13265
+ });
13266
+
13267
+ function createBuffer (length) {
13268
+ if (length > K_MAX_LENGTH) {
13269
+ throw new RangeError('The value "' + length + '" is invalid for option "size"')
13270
+ }
13271
+ // Return an augmented `Uint8Array` instance
13272
+ const buf = new Uint8Array(length);
13273
+ Object.setPrototypeOf(buf, Buffer.prototype);
13274
+ return buf
13275
+ }
13276
+
13277
+ /**
13278
+ * The Buffer constructor returns instances of `Uint8Array` that have their
13279
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
13280
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
13281
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
13282
+ * returns a single octet.
13283
+ *
13284
+ * The `Uint8Array` prototype remains unmodified.
13285
+ */
13286
+
13287
+ function Buffer (arg, encodingOrOffset, length) {
13288
+ // Common case.
13289
+ if (typeof arg === 'number') {
13290
+ if (typeof encodingOrOffset === 'string') {
13291
+ throw new TypeError(
13292
+ 'The "string" argument must be of type string. Received type number'
13293
+ )
13294
+ }
13295
+ return allocUnsafe(arg)
13296
+ }
13297
+ return from(arg, encodingOrOffset, length)
13298
+ }
13299
+
13300
+ Buffer.poolSize = 8192; // not used by this implementation
13301
+
13302
+ function from (value, encodingOrOffset, length) {
13303
+ if (typeof value === 'string') {
13304
+ return fromString(value, encodingOrOffset)
13305
+ }
13306
+
13307
+ if (ArrayBuffer.isView(value)) {
13308
+ return fromArrayView(value)
13309
+ }
13310
+
13311
+ if (value == null) {
13312
+ throw new TypeError(
13313
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
13314
+ 'or Array-like Object. Received type ' + (typeof value)
13315
+ )
13316
+ }
13317
+
13318
+ if (isInstance(value, ArrayBuffer) ||
13319
+ (value && isInstance(value.buffer, ArrayBuffer))) {
13320
+ return fromArrayBuffer(value, encodingOrOffset, length)
13321
+ }
13322
+
13323
+ if (typeof SharedArrayBuffer !== 'undefined' &&
13324
+ (isInstance(value, SharedArrayBuffer) ||
13325
+ (value && isInstance(value.buffer, SharedArrayBuffer)))) {
13326
+ return fromArrayBuffer(value, encodingOrOffset, length)
13327
+ }
13328
+
13329
+ if (typeof value === 'number') {
13330
+ throw new TypeError(
13331
+ 'The "value" argument must not be of type number. Received type number'
13332
+ )
13333
+ }
13334
+
13335
+ const valueOf = value.valueOf && value.valueOf();
13336
+ if (valueOf != null && valueOf !== value) {
13337
+ return Buffer.from(valueOf, encodingOrOffset, length)
13338
+ }
13339
+
13340
+ const b = fromObject(value);
13341
+ if (b) return b
13342
+
13343
+ if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
13344
+ typeof value[Symbol.toPrimitive] === 'function') {
13345
+ return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
13346
+ }
13347
+
13348
+ throw new TypeError(
13349
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
13350
+ 'or Array-like Object. Received type ' + (typeof value)
13351
+ )
13352
+ }
13353
+
13354
+ /**
13355
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
13356
+ * if value is a number.
13357
+ * Buffer.from(str[, encoding])
13358
+ * Buffer.from(array)
13359
+ * Buffer.from(buffer)
13360
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
13361
+ **/
13362
+ Buffer.from = function (value, encodingOrOffset, length) {
13363
+ return from(value, encodingOrOffset, length)
13364
+ };
13365
+
13366
+ // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
13367
+ // https://github.com/feross/buffer/pull/148
13368
+ Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
13369
+ Object.setPrototypeOf(Buffer, Uint8Array);
13370
+
13371
+ function assertSize (size) {
13372
+ if (typeof size !== 'number') {
13373
+ throw new TypeError('"size" argument must be of type number')
13374
+ } else if (size < 0) {
13375
+ throw new RangeError('The value "' + size + '" is invalid for option "size"')
13376
+ }
13377
+ }
13378
+
13379
+ function alloc (size, fill, encoding) {
13380
+ assertSize(size);
13381
+ if (size <= 0) {
13382
+ return createBuffer(size)
13383
+ }
13384
+ if (fill !== undefined) {
13385
+ // Only pay attention to encoding if it's a string. This
13386
+ // prevents accidentally sending in a number that would
13387
+ // be interpreted as a start offset.
13388
+ return typeof encoding === 'string'
13389
+ ? createBuffer(size).fill(fill, encoding)
13390
+ : createBuffer(size).fill(fill)
13391
+ }
13392
+ return createBuffer(size)
13393
+ }
13394
+
13395
+ /**
13396
+ * Creates a new filled Buffer instance.
13397
+ * alloc(size[, fill[, encoding]])
13398
+ **/
13399
+ Buffer.alloc = function (size, fill, encoding) {
13400
+ return alloc(size, fill, encoding)
13401
+ };
13402
+
13403
+ function allocUnsafe (size) {
13404
+ assertSize(size);
13405
+ return createBuffer(size < 0 ? 0 : checked(size) | 0)
13406
+ }
13407
+
13408
+ /**
13409
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
13410
+ * */
13411
+ Buffer.allocUnsafe = function (size) {
13412
+ return allocUnsafe(size)
13413
+ };
13414
+ /**
13415
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
13416
+ */
13417
+ Buffer.allocUnsafeSlow = function (size) {
13418
+ return allocUnsafe(size)
13419
+ };
13420
+
13421
+ function fromString (string, encoding) {
13422
+ if (typeof encoding !== 'string' || encoding === '') {
13423
+ encoding = 'utf8';
13424
+ }
13425
+
13426
+ if (!Buffer.isEncoding(encoding)) {
13427
+ throw new TypeError('Unknown encoding: ' + encoding)
13428
+ }
13429
+
13430
+ const length = byteLength(string, encoding) | 0;
13431
+ let buf = createBuffer(length);
13432
+
13433
+ const actual = buf.write(string, encoding);
13434
+
13435
+ if (actual !== length) {
13436
+ // Writing a hex string, for example, that contains invalid characters will
13437
+ // cause everything after the first invalid character to be ignored. (e.g.
13438
+ // 'abxxcd' will be treated as 'ab')
13439
+ buf = buf.slice(0, actual);
13440
+ }
13441
+
13442
+ return buf
13443
+ }
13444
+
13445
+ function fromArrayLike (array) {
13446
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
13447
+ const buf = createBuffer(length);
13448
+ for (let i = 0; i < length; i += 1) {
13449
+ buf[i] = array[i] & 255;
13450
+ }
13451
+ return buf
13452
+ }
13453
+
13454
+ function fromArrayView (arrayView) {
13455
+ if (isInstance(arrayView, Uint8Array)) {
13456
+ const copy = new Uint8Array(arrayView);
13457
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
13458
+ }
13459
+ return fromArrayLike(arrayView)
13460
+ }
13461
+
13462
+ function fromArrayBuffer (array, byteOffset, length) {
13463
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
13464
+ throw new RangeError('"offset" is outside of buffer bounds')
13465
+ }
13466
+
13467
+ if (array.byteLength < byteOffset + (length || 0)) {
13468
+ throw new RangeError('"length" is outside of buffer bounds')
13469
+ }
13470
+
13471
+ let buf;
13472
+ if (byteOffset === undefined && length === undefined) {
13473
+ buf = new Uint8Array(array);
13474
+ } else if (length === undefined) {
13475
+ buf = new Uint8Array(array, byteOffset);
13476
+ } else {
13477
+ buf = new Uint8Array(array, byteOffset, length);
13478
+ }
13479
+
13480
+ // Return an augmented `Uint8Array` instance
13481
+ Object.setPrototypeOf(buf, Buffer.prototype);
13482
+
13483
+ return buf
13484
+ }
13485
+
13486
+ function fromObject (obj) {
13487
+ if (Buffer.isBuffer(obj)) {
13488
+ const len = checked(obj.length) | 0;
13489
+ const buf = createBuffer(len);
13490
+
13491
+ if (buf.length === 0) {
13492
+ return buf
13493
+ }
13494
+
13495
+ obj.copy(buf, 0, 0, len);
13496
+ return buf
13497
+ }
13498
+
13499
+ if (obj.length !== undefined) {
13500
+ if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
13501
+ return createBuffer(0)
13502
+ }
13503
+ return fromArrayLike(obj)
13504
+ }
13505
+
13506
+ if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
13507
+ return fromArrayLike(obj.data)
13508
+ }
13509
+ }
13510
+
13511
+ function checked (length) {
13512
+ // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
13513
+ // length is NaN (which is otherwise coerced to zero.)
13514
+ if (length >= K_MAX_LENGTH) {
13515
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
13516
+ 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
13517
+ }
13518
+ return length | 0
13519
+ }
13520
+
13521
+ function SlowBuffer (length) {
13522
+ if (+length != length) { // eslint-disable-line eqeqeq
13523
+ length = 0;
13524
+ }
13525
+ return Buffer.alloc(+length)
13526
+ }
13527
+
13528
+ Buffer.isBuffer = function isBuffer (b) {
13529
+ return b != null && b._isBuffer === true &&
13530
+ b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
13531
+ };
13532
+
13533
+ Buffer.compare = function compare (a, b) {
13534
+ if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
13535
+ if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
13536
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
13537
+ throw new TypeError(
13538
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
13539
+ )
13540
+ }
13541
+
13542
+ if (a === b) return 0
13543
+
13544
+ let x = a.length;
13545
+ let y = b.length;
13546
+
13547
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
13548
+ if (a[i] !== b[i]) {
13549
+ x = a[i];
13550
+ y = b[i];
13551
+ break
13552
+ }
13553
+ }
13554
+
13555
+ if (x < y) return -1
13556
+ if (y < x) return 1
13557
+ return 0
13558
+ };
13559
+
13560
+ Buffer.isEncoding = function isEncoding (encoding) {
13561
+ switch (String(encoding).toLowerCase()) {
13562
+ case 'hex':
13563
+ case 'utf8':
13564
+ case 'utf-8':
13565
+ case 'ascii':
13566
+ case 'latin1':
13567
+ case 'binary':
13568
+ case 'base64':
13569
+ case 'ucs2':
13570
+ case 'ucs-2':
13571
+ case 'utf16le':
13572
+ case 'utf-16le':
13573
+ return true
13574
+ default:
13575
+ return false
13576
+ }
13577
+ };
13578
+
13579
+ Buffer.concat = function concat (list, length) {
13580
+ if (!Array.isArray(list)) {
13581
+ throw new TypeError('"list" argument must be an Array of Buffers')
13582
+ }
13583
+
13584
+ if (list.length === 0) {
13585
+ return Buffer.alloc(0)
13586
+ }
13587
+
13588
+ let i;
13589
+ if (length === undefined) {
13590
+ length = 0;
13591
+ for (i = 0; i < list.length; ++i) {
13592
+ length += list[i].length;
13593
+ }
13594
+ }
13595
+
13596
+ const buffer = Buffer.allocUnsafe(length);
13597
+ let pos = 0;
13598
+ for (i = 0; i < list.length; ++i) {
13599
+ let buf = list[i];
13600
+ if (isInstance(buf, Uint8Array)) {
13601
+ if (pos + buf.length > buffer.length) {
13602
+ if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
13603
+ buf.copy(buffer, pos);
13604
+ } else {
13605
+ Uint8Array.prototype.set.call(
13606
+ buffer,
13607
+ buf,
13608
+ pos
13609
+ );
13610
+ }
13611
+ } else if (!Buffer.isBuffer(buf)) {
13612
+ throw new TypeError('"list" argument must be an Array of Buffers')
13613
+ } else {
13614
+ buf.copy(buffer, pos);
13615
+ }
13616
+ pos += buf.length;
13617
+ }
13618
+ return buffer
13619
+ };
13620
+
13621
+ function byteLength (string, encoding) {
13622
+ if (Buffer.isBuffer(string)) {
13623
+ return string.length
13624
+ }
13625
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
13626
+ return string.byteLength
13627
+ }
13628
+ if (typeof string !== 'string') {
13629
+ throw new TypeError(
13630
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
13631
+ 'Received type ' + typeof string
13632
+ )
13633
+ }
13634
+
13635
+ const len = string.length;
13636
+ const mustMatch = (arguments.length > 2 && arguments[2] === true);
13637
+ if (!mustMatch && len === 0) return 0
13638
+
13639
+ // Use a for loop to avoid recursion
13640
+ let loweredCase = false;
13641
+ for (;;) {
13642
+ switch (encoding) {
13643
+ case 'ascii':
13644
+ case 'latin1':
13645
+ case 'binary':
13646
+ return len
13647
+ case 'utf8':
13648
+ case 'utf-8':
13649
+ return utf8ToBytes(string).length
13650
+ case 'ucs2':
13651
+ case 'ucs-2':
13652
+ case 'utf16le':
13653
+ case 'utf-16le':
13654
+ return len * 2
13655
+ case 'hex':
13656
+ return len >>> 1
13657
+ case 'base64':
13658
+ return base64ToBytes(string).length
13659
+ default:
13660
+ if (loweredCase) {
13661
+ return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
13662
+ }
13663
+ encoding = ('' + encoding).toLowerCase();
13664
+ loweredCase = true;
13665
+ }
13666
+ }
13667
+ }
13668
+ Buffer.byteLength = byteLength;
13669
+
13670
+ function slowToString (encoding, start, end) {
13671
+ let loweredCase = false;
13672
+
13673
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
13674
+ // property of a typed array.
13675
+
13676
+ // This behaves neither like String nor Uint8Array in that we set start/end
13677
+ // to their upper/lower bounds if the value passed is out of range.
13678
+ // undefined is handled specially as per ECMA-262 6th Edition,
13679
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
13680
+ if (start === undefined || start < 0) {
13681
+ start = 0;
13682
+ }
13683
+ // Return early if start > this.length. Done here to prevent potential uint32
13684
+ // coercion fail below.
13685
+ if (start > this.length) {
13686
+ return ''
13687
+ }
13688
+
13689
+ if (end === undefined || end > this.length) {
13690
+ end = this.length;
13691
+ }
13692
+
13693
+ if (end <= 0) {
13694
+ return ''
13695
+ }
13696
+
13697
+ // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
13698
+ end >>>= 0;
13699
+ start >>>= 0;
13700
+
13701
+ if (end <= start) {
13702
+ return ''
13703
+ }
13704
+
13705
+ if (!encoding) encoding = 'utf8';
13706
+
13707
+ while (true) {
13708
+ switch (encoding) {
13709
+ case 'hex':
13710
+ return hexSlice(this, start, end)
13711
+
13712
+ case 'utf8':
13713
+ case 'utf-8':
13714
+ return utf8Slice(this, start, end)
13715
+
13716
+ case 'ascii':
13717
+ return asciiSlice(this, start, end)
13718
+
13719
+ case 'latin1':
13720
+ case 'binary':
13721
+ return latin1Slice(this, start, end)
13722
+
13723
+ case 'base64':
13724
+ return base64Slice(this, start, end)
13725
+
13726
+ case 'ucs2':
13727
+ case 'ucs-2':
13728
+ case 'utf16le':
13729
+ case 'utf-16le':
13730
+ return utf16leSlice(this, start, end)
13731
+
13732
+ default:
13733
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
13734
+ encoding = (encoding + '').toLowerCase();
13735
+ loweredCase = true;
13736
+ }
13737
+ }
13738
+ }
13739
+
13740
+ // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
13741
+ // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
13742
+ // reliably in a browserify context because there could be multiple different
13743
+ // copies of the 'buffer' package in use. This method works even for Buffer
13744
+ // instances that were created from another copy of the `buffer` package.
13745
+ // See: https://github.com/feross/buffer/issues/154
13746
+ Buffer.prototype._isBuffer = true;
13747
+
13748
+ function swap (b, n, m) {
13749
+ const i = b[n];
13750
+ b[n] = b[m];
13751
+ b[m] = i;
13752
+ }
13753
+
13754
+ Buffer.prototype.swap16 = function swap16 () {
13755
+ const len = this.length;
13756
+ if (len % 2 !== 0) {
13757
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
13758
+ }
13759
+ for (let i = 0; i < len; i += 2) {
13760
+ swap(this, i, i + 1);
13761
+ }
13762
+ return this
13763
+ };
13764
+
13765
+ Buffer.prototype.swap32 = function swap32 () {
13766
+ const len = this.length;
13767
+ if (len % 4 !== 0) {
13768
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
13769
+ }
13770
+ for (let i = 0; i < len; i += 4) {
13771
+ swap(this, i, i + 3);
13772
+ swap(this, i + 1, i + 2);
13773
+ }
13774
+ return this
13775
+ };
13776
+
13777
+ Buffer.prototype.swap64 = function swap64 () {
13778
+ const len = this.length;
13779
+ if (len % 8 !== 0) {
13780
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
13781
+ }
13782
+ for (let i = 0; i < len; i += 8) {
13783
+ swap(this, i, i + 7);
13784
+ swap(this, i + 1, i + 6);
13785
+ swap(this, i + 2, i + 5);
13786
+ swap(this, i + 3, i + 4);
13787
+ }
13788
+ return this
13789
+ };
13790
+
13791
+ Buffer.prototype.toString = function toString () {
13792
+ const length = this.length;
13793
+ if (length === 0) return ''
13794
+ if (arguments.length === 0) return utf8Slice(this, 0, length)
13795
+ return slowToString.apply(this, arguments)
13796
+ };
13797
+
13798
+ Buffer.prototype.toLocaleString = Buffer.prototype.toString;
13799
+
13800
+ Buffer.prototype.equals = function equals (b) {
13801
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
13802
+ if (this === b) return true
13803
+ return Buffer.compare(this, b) === 0
13804
+ };
13805
+
13806
+ Buffer.prototype.inspect = function inspect () {
13807
+ let str = '';
13808
+ const max = exports$1.INSPECT_MAX_BYTES;
13809
+ str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
13810
+ if (this.length > max) str += ' ... ';
13811
+ return '<Buffer ' + str + '>'
13812
+ };
13813
+ if (customInspectSymbol) {
13814
+ Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
13815
+ }
13816
+
13817
+ Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
13818
+ if (isInstance(target, Uint8Array)) {
13819
+ target = Buffer.from(target, target.offset, target.byteLength);
13820
+ }
13821
+ if (!Buffer.isBuffer(target)) {
13822
+ throw new TypeError(
13823
+ 'The "target" argument must be one of type Buffer or Uint8Array. ' +
13824
+ 'Received type ' + (typeof target)
13825
+ )
13826
+ }
13827
+
13828
+ if (start === undefined) {
13829
+ start = 0;
13830
+ }
13831
+ if (end === undefined) {
13832
+ end = target ? target.length : 0;
13833
+ }
13834
+ if (thisStart === undefined) {
13835
+ thisStart = 0;
13836
+ }
13837
+ if (thisEnd === undefined) {
13838
+ thisEnd = this.length;
13839
+ }
13840
+
13841
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
13842
+ throw new RangeError('out of range index')
13843
+ }
13844
+
13845
+ if (thisStart >= thisEnd && start >= end) {
13846
+ return 0
13847
+ }
13848
+ if (thisStart >= thisEnd) {
13849
+ return -1
13850
+ }
13851
+ if (start >= end) {
13852
+ return 1
13853
+ }
13854
+
13855
+ start >>>= 0;
13856
+ end >>>= 0;
13857
+ thisStart >>>= 0;
13858
+ thisEnd >>>= 0;
13859
+
13860
+ if (this === target) return 0
13861
+
13862
+ let x = thisEnd - thisStart;
13863
+ let y = end - start;
13864
+ const len = Math.min(x, y);
13865
+
13866
+ const thisCopy = this.slice(thisStart, thisEnd);
13867
+ const targetCopy = target.slice(start, end);
13868
+
13869
+ for (let i = 0; i < len; ++i) {
13870
+ if (thisCopy[i] !== targetCopy[i]) {
13871
+ x = thisCopy[i];
13872
+ y = targetCopy[i];
13873
+ break
13874
+ }
13875
+ }
13876
+
13877
+ if (x < y) return -1
13878
+ if (y < x) return 1
13879
+ return 0
13880
+ };
13881
+
13882
+ // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
13883
+ // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
13884
+ //
13885
+ // Arguments:
13886
+ // - buffer - a Buffer to search
13887
+ // - val - a string, Buffer, or number
13888
+ // - byteOffset - an index into `buffer`; will be clamped to an int32
13889
+ // - encoding - an optional encoding, relevant is val is a string
13890
+ // - dir - true for indexOf, false for lastIndexOf
13891
+ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
13892
+ // Empty buffer means no match
13893
+ if (buffer.length === 0) return -1
13894
+
13895
+ // Normalize byteOffset
13896
+ if (typeof byteOffset === 'string') {
13897
+ encoding = byteOffset;
13898
+ byteOffset = 0;
13899
+ } else if (byteOffset > 0x7fffffff) {
13900
+ byteOffset = 0x7fffffff;
13901
+ } else if (byteOffset < -2147483648) {
13902
+ byteOffset = -2147483648;
13903
+ }
13904
+ byteOffset = +byteOffset; // Coerce to Number.
13905
+ if (numberIsNaN(byteOffset)) {
13906
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
13907
+ byteOffset = dir ? 0 : (buffer.length - 1);
13908
+ }
13909
+
13910
+ // Normalize byteOffset: negative offsets start from the end of the buffer
13911
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
13912
+ if (byteOffset >= buffer.length) {
13913
+ if (dir) return -1
13914
+ else byteOffset = buffer.length - 1;
13915
+ } else if (byteOffset < 0) {
13916
+ if (dir) byteOffset = 0;
13917
+ else return -1
13918
+ }
13919
+
13920
+ // Normalize val
13921
+ if (typeof val === 'string') {
13922
+ val = Buffer.from(val, encoding);
13923
+ }
13924
+
13925
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
13926
+ if (Buffer.isBuffer(val)) {
13927
+ // Special case: looking for empty string/buffer always fails
13928
+ if (val.length === 0) {
13929
+ return -1
13930
+ }
13931
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
13932
+ } else if (typeof val === 'number') {
13933
+ val = val & 0xFF; // Search for a byte value [0-255]
13934
+ if (typeof Uint8Array.prototype.indexOf === 'function') {
13935
+ if (dir) {
13936
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
13937
+ } else {
13938
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
13939
+ }
13940
+ }
13941
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
13942
+ }
13943
+
13944
+ throw new TypeError('val must be string, number or Buffer')
13945
+ }
13946
+
13947
+ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
13948
+ let indexSize = 1;
13949
+ let arrLength = arr.length;
13950
+ let valLength = val.length;
13951
+
13952
+ if (encoding !== undefined) {
13953
+ encoding = String(encoding).toLowerCase();
13954
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
13955
+ encoding === 'utf16le' || encoding === 'utf-16le') {
13956
+ if (arr.length < 2 || val.length < 2) {
13957
+ return -1
13958
+ }
13959
+ indexSize = 2;
13960
+ arrLength /= 2;
13961
+ valLength /= 2;
13962
+ byteOffset /= 2;
13963
+ }
13964
+ }
13965
+
13966
+ function read (buf, i) {
13967
+ if (indexSize === 1) {
13968
+ return buf[i]
13969
+ } else {
13970
+ return buf.readUInt16BE(i * indexSize)
13971
+ }
13972
+ }
13973
+
13974
+ let i;
13975
+ if (dir) {
13976
+ let foundIndex = -1;
13977
+ for (i = byteOffset; i < arrLength; i++) {
13978
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
13979
+ if (foundIndex === -1) foundIndex = i;
13980
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
13981
+ } else {
13982
+ if (foundIndex !== -1) i -= i - foundIndex;
13983
+ foundIndex = -1;
13984
+ }
13985
+ }
13986
+ } else {
13987
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
13988
+ for (i = byteOffset; i >= 0; i--) {
13989
+ let found = true;
13990
+ for (let j = 0; j < valLength; j++) {
13991
+ if (read(arr, i + j) !== read(val, j)) {
13992
+ found = false;
13993
+ break
13994
+ }
13995
+ }
13996
+ if (found) return i
13997
+ }
13998
+ }
13999
+
14000
+ return -1
14001
+ }
14002
+
14003
+ Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
14004
+ return this.indexOf(val, byteOffset, encoding) !== -1
14005
+ };
14006
+
14007
+ Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
14008
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
14009
+ };
14010
+
14011
+ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
14012
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
14013
+ };
14014
+
14015
+ function hexWrite (buf, string, offset, length) {
14016
+ offset = Number(offset) || 0;
14017
+ const remaining = buf.length - offset;
14018
+ if (!length) {
14019
+ length = remaining;
14020
+ } else {
14021
+ length = Number(length);
14022
+ if (length > remaining) {
14023
+ length = remaining;
14024
+ }
14025
+ }
14026
+
14027
+ const strLen = string.length;
14028
+
14029
+ if (length > strLen / 2) {
14030
+ length = strLen / 2;
14031
+ }
14032
+ let i;
14033
+ for (i = 0; i < length; ++i) {
14034
+ const parsed = parseInt(string.substr(i * 2, 2), 16);
14035
+ if (numberIsNaN(parsed)) return i
14036
+ buf[offset + i] = parsed;
14037
+ }
14038
+ return i
14039
+ }
14040
+
14041
+ function utf8Write (buf, string, offset, length) {
14042
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
14043
+ }
14044
+
14045
+ function asciiWrite (buf, string, offset, length) {
14046
+ return blitBuffer(asciiToBytes(string), buf, offset, length)
14047
+ }
14048
+
14049
+ function base64Write (buf, string, offset, length) {
14050
+ return blitBuffer(base64ToBytes(string), buf, offset, length)
14051
+ }
14052
+
14053
+ function ucs2Write (buf, string, offset, length) {
14054
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
14055
+ }
14056
+
14057
+ Buffer.prototype.write = function write (string, offset, length, encoding) {
14058
+ // Buffer#write(string)
14059
+ if (offset === undefined) {
14060
+ encoding = 'utf8';
14061
+ length = this.length;
14062
+ offset = 0;
14063
+ // Buffer#write(string, encoding)
14064
+ } else if (length === undefined && typeof offset === 'string') {
14065
+ encoding = offset;
14066
+ length = this.length;
14067
+ offset = 0;
14068
+ // Buffer#write(string, offset[, length][, encoding])
14069
+ } else if (isFinite(offset)) {
14070
+ offset = offset >>> 0;
14071
+ if (isFinite(length)) {
14072
+ length = length >>> 0;
14073
+ if (encoding === undefined) encoding = 'utf8';
14074
+ } else {
14075
+ encoding = length;
14076
+ length = undefined;
14077
+ }
14078
+ } else {
14079
+ throw new Error(
14080
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
14081
+ )
14082
+ }
14083
+
14084
+ const remaining = this.length - offset;
14085
+ if (length === undefined || length > remaining) length = remaining;
14086
+
14087
+ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
14088
+ throw new RangeError('Attempt to write outside buffer bounds')
14089
+ }
14090
+
14091
+ if (!encoding) encoding = 'utf8';
14092
+
14093
+ let loweredCase = false;
14094
+ for (;;) {
14095
+ switch (encoding) {
14096
+ case 'hex':
14097
+ return hexWrite(this, string, offset, length)
14098
+
14099
+ case 'utf8':
14100
+ case 'utf-8':
14101
+ return utf8Write(this, string, offset, length)
14102
+
14103
+ case 'ascii':
14104
+ case 'latin1':
14105
+ case 'binary':
14106
+ return asciiWrite(this, string, offset, length)
14107
+
14108
+ case 'base64':
14109
+ // Warning: maxLength not taken into account in base64Write
14110
+ return base64Write(this, string, offset, length)
14111
+
14112
+ case 'ucs2':
14113
+ case 'ucs-2':
14114
+ case 'utf16le':
14115
+ case 'utf-16le':
14116
+ return ucs2Write(this, string, offset, length)
14117
+
14118
+ default:
14119
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
14120
+ encoding = ('' + encoding).toLowerCase();
14121
+ loweredCase = true;
14122
+ }
14123
+ }
14124
+ };
14125
+
14126
+ Buffer.prototype.toJSON = function toJSON () {
14127
+ return {
14128
+ type: 'Buffer',
14129
+ data: Array.prototype.slice.call(this._arr || this, 0)
14130
+ }
14131
+ };
14132
+
14133
+ function base64Slice (buf, start, end) {
14134
+ if (start === 0 && end === buf.length) {
14135
+ return base64.fromByteArray(buf)
14136
+ } else {
14137
+ return base64.fromByteArray(buf.slice(start, end))
14138
+ }
14139
+ }
14140
+
14141
+ function utf8Slice (buf, start, end) {
14142
+ end = Math.min(buf.length, end);
14143
+ const res = [];
14144
+
14145
+ let i = start;
14146
+ while (i < end) {
14147
+ const firstByte = buf[i];
14148
+ let codePoint = null;
14149
+ let bytesPerSequence = (firstByte > 0xEF)
14150
+ ? 4
14151
+ : (firstByte > 0xDF)
14152
+ ? 3
14153
+ : (firstByte > 0xBF)
14154
+ ? 2
14155
+ : 1;
14156
+
14157
+ if (i + bytesPerSequence <= end) {
14158
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
14159
+
14160
+ switch (bytesPerSequence) {
14161
+ case 1:
14162
+ if (firstByte < 0x80) {
14163
+ codePoint = firstByte;
14164
+ }
14165
+ break
14166
+ case 2:
14167
+ secondByte = buf[i + 1];
14168
+ if ((secondByte & 0xC0) === 0x80) {
14169
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
14170
+ if (tempCodePoint > 0x7F) {
14171
+ codePoint = tempCodePoint;
14172
+ }
14173
+ }
14174
+ break
14175
+ case 3:
14176
+ secondByte = buf[i + 1];
14177
+ thirdByte = buf[i + 2];
14178
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
14179
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
14180
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
14181
+ codePoint = tempCodePoint;
14182
+ }
14183
+ }
14184
+ break
14185
+ case 4:
14186
+ secondByte = buf[i + 1];
14187
+ thirdByte = buf[i + 2];
14188
+ fourthByte = buf[i + 3];
14189
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
14190
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
14191
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
14192
+ codePoint = tempCodePoint;
14193
+ }
14194
+ }
14195
+ }
14196
+ }
14197
+
14198
+ if (codePoint === null) {
14199
+ // we did not generate a valid codePoint so insert a
14200
+ // replacement char (U+FFFD) and advance only 1 byte
14201
+ codePoint = 0xFFFD;
14202
+ bytesPerSequence = 1;
14203
+ } else if (codePoint > 0xFFFF) {
14204
+ // encode to utf16 (surrogate pair dance)
14205
+ codePoint -= 0x10000;
14206
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800);
14207
+ codePoint = 0xDC00 | codePoint & 0x3FF;
14208
+ }
14209
+
14210
+ res.push(codePoint);
14211
+ i += bytesPerSequence;
14212
+ }
14213
+
14214
+ return decodeCodePointsArray(res)
14215
+ }
14216
+
14217
+ // Based on http://stackoverflow.com/a/22747272/680742, the browser with
14218
+ // the lowest limit is Chrome, with 0x10000 args.
14219
+ // We go 1 magnitude less, for safety
14220
+ const MAX_ARGUMENTS_LENGTH = 0x1000;
14221
+
14222
+ function decodeCodePointsArray (codePoints) {
14223
+ const len = codePoints.length;
14224
+ if (len <= MAX_ARGUMENTS_LENGTH) {
14225
+ return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
14226
+ }
14227
+
14228
+ // Decode in chunks to avoid "call stack size exceeded".
14229
+ let res = '';
14230
+ let i = 0;
14231
+ while (i < len) {
14232
+ res += String.fromCharCode.apply(
14233
+ String,
14234
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
14235
+ );
14236
+ }
14237
+ return res
14238
+ }
14239
+
14240
+ function asciiSlice (buf, start, end) {
14241
+ let ret = '';
14242
+ end = Math.min(buf.length, end);
14243
+
14244
+ for (let i = start; i < end; ++i) {
14245
+ ret += String.fromCharCode(buf[i] & 0x7F);
14246
+ }
14247
+ return ret
14248
+ }
14249
+
14250
+ function latin1Slice (buf, start, end) {
14251
+ let ret = '';
14252
+ end = Math.min(buf.length, end);
14253
+
14254
+ for (let i = start; i < end; ++i) {
14255
+ ret += String.fromCharCode(buf[i]);
14256
+ }
14257
+ return ret
14258
+ }
14259
+
14260
+ function hexSlice (buf, start, end) {
14261
+ const len = buf.length;
14262
+
14263
+ if (!start || start < 0) start = 0;
14264
+ if (!end || end < 0 || end > len) end = len;
14265
+
14266
+ let out = '';
14267
+ for (let i = start; i < end; ++i) {
14268
+ out += hexSliceLookupTable[buf[i]];
14269
+ }
14270
+ return out
14271
+ }
14272
+
14273
+ function utf16leSlice (buf, start, end) {
14274
+ const bytes = buf.slice(start, end);
14275
+ let res = '';
14276
+ // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
14277
+ for (let i = 0; i < bytes.length - 1; i += 2) {
14278
+ res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
14279
+ }
14280
+ return res
14281
+ }
14282
+
14283
+ Buffer.prototype.slice = function slice (start, end) {
14284
+ const len = this.length;
14285
+ start = ~~start;
14286
+ end = end === undefined ? len : ~~end;
14287
+
14288
+ if (start < 0) {
14289
+ start += len;
14290
+ if (start < 0) start = 0;
14291
+ } else if (start > len) {
14292
+ start = len;
14293
+ }
14294
+
14295
+ if (end < 0) {
14296
+ end += len;
14297
+ if (end < 0) end = 0;
14298
+ } else if (end > len) {
14299
+ end = len;
14300
+ }
14301
+
14302
+ if (end < start) end = start;
14303
+
14304
+ const newBuf = this.subarray(start, end);
14305
+ // Return an augmented `Uint8Array` instance
14306
+ Object.setPrototypeOf(newBuf, Buffer.prototype);
14307
+
14308
+ return newBuf
14309
+ };
14310
+
14311
+ /*
14312
+ * Need to make sure that buffer isn't trying to write out of bounds.
14313
+ */
14314
+ function checkOffset (offset, ext, length) {
14315
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
14316
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
14317
+ }
14318
+
14319
+ Buffer.prototype.readUintLE =
14320
+ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
14321
+ offset = offset >>> 0;
14322
+ byteLength = byteLength >>> 0;
14323
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
14324
+
14325
+ let val = this[offset];
14326
+ let mul = 1;
14327
+ let i = 0;
14328
+ while (++i < byteLength && (mul *= 0x100)) {
14329
+ val += this[offset + i] * mul;
14330
+ }
14331
+
14332
+ return val
14333
+ };
14334
+
14335
+ Buffer.prototype.readUintBE =
14336
+ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
14337
+ offset = offset >>> 0;
14338
+ byteLength = byteLength >>> 0;
14339
+ if (!noAssert) {
14340
+ checkOffset(offset, byteLength, this.length);
14341
+ }
14342
+
14343
+ let val = this[offset + --byteLength];
14344
+ let mul = 1;
14345
+ while (byteLength > 0 && (mul *= 0x100)) {
14346
+ val += this[offset + --byteLength] * mul;
14347
+ }
14348
+
14349
+ return val
14350
+ };
14351
+
14352
+ Buffer.prototype.readUint8 =
14353
+ Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
14354
+ offset = offset >>> 0;
14355
+ if (!noAssert) checkOffset(offset, 1, this.length);
14356
+ return this[offset]
14357
+ };
14358
+
14359
+ Buffer.prototype.readUint16LE =
14360
+ Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
14361
+ offset = offset >>> 0;
14362
+ if (!noAssert) checkOffset(offset, 2, this.length);
14363
+ return this[offset] | (this[offset + 1] << 8)
14364
+ };
14365
+
14366
+ Buffer.prototype.readUint16BE =
14367
+ Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
14368
+ offset = offset >>> 0;
14369
+ if (!noAssert) checkOffset(offset, 2, this.length);
14370
+ return (this[offset] << 8) | this[offset + 1]
14371
+ };
14372
+
14373
+ Buffer.prototype.readUint32LE =
14374
+ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
14375
+ offset = offset >>> 0;
14376
+ if (!noAssert) checkOffset(offset, 4, this.length);
14377
+
14378
+ return ((this[offset]) |
14379
+ (this[offset + 1] << 8) |
14380
+ (this[offset + 2] << 16)) +
14381
+ (this[offset + 3] * 0x1000000)
14382
+ };
14383
+
14384
+ Buffer.prototype.readUint32BE =
14385
+ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
14386
+ offset = offset >>> 0;
14387
+ if (!noAssert) checkOffset(offset, 4, this.length);
14388
+
14389
+ return (this[offset] * 0x1000000) +
14390
+ ((this[offset + 1] << 16) |
14391
+ (this[offset + 2] << 8) |
14392
+ this[offset + 3])
14393
+ };
14394
+
14395
+ Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
14396
+ offset = offset >>> 0;
14397
+ validateNumber(offset, 'offset');
14398
+ const first = this[offset];
14399
+ const last = this[offset + 7];
14400
+ if (first === undefined || last === undefined) {
14401
+ boundsError(offset, this.length - 8);
14402
+ }
14403
+
14404
+ const lo = first +
14405
+ this[++offset] * 2 ** 8 +
14406
+ this[++offset] * 2 ** 16 +
14407
+ this[++offset] * 2 ** 24;
14408
+
14409
+ const hi = this[++offset] +
14410
+ this[++offset] * 2 ** 8 +
14411
+ this[++offset] * 2 ** 16 +
14412
+ last * 2 ** 24;
14413
+
14414
+ return BigInt(lo) + (BigInt(hi) << BigInt(32))
14415
+ });
14416
+
14417
+ Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
14418
+ offset = offset >>> 0;
14419
+ validateNumber(offset, 'offset');
14420
+ const first = this[offset];
14421
+ const last = this[offset + 7];
14422
+ if (first === undefined || last === undefined) {
14423
+ boundsError(offset, this.length - 8);
14424
+ }
14425
+
14426
+ const hi = first * 2 ** 24 +
14427
+ this[++offset] * 2 ** 16 +
14428
+ this[++offset] * 2 ** 8 +
14429
+ this[++offset];
14430
+
14431
+ const lo = this[++offset] * 2 ** 24 +
14432
+ this[++offset] * 2 ** 16 +
14433
+ this[++offset] * 2 ** 8 +
14434
+ last;
14435
+
14436
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo)
14437
+ });
14438
+
14439
+ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
14440
+ offset = offset >>> 0;
14441
+ byteLength = byteLength >>> 0;
14442
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
14443
+
14444
+ let val = this[offset];
14445
+ let mul = 1;
14446
+ let i = 0;
14447
+ while (++i < byteLength && (mul *= 0x100)) {
14448
+ val += this[offset + i] * mul;
14449
+ }
14450
+ mul *= 0x80;
14451
+
14452
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
14453
+
14454
+ return val
14455
+ };
14456
+
14457
+ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
14458
+ offset = offset >>> 0;
14459
+ byteLength = byteLength >>> 0;
14460
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
14461
+
14462
+ let i = byteLength;
14463
+ let mul = 1;
14464
+ let val = this[offset + --i];
14465
+ while (i > 0 && (mul *= 0x100)) {
14466
+ val += this[offset + --i] * mul;
14467
+ }
14468
+ mul *= 0x80;
14469
+
14470
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
14471
+
14472
+ return val
14473
+ };
14474
+
14475
+ Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
14476
+ offset = offset >>> 0;
14477
+ if (!noAssert) checkOffset(offset, 1, this.length);
14478
+ if (!(this[offset] & 0x80)) return (this[offset])
14479
+ return ((0xff - this[offset] + 1) * -1)
14480
+ };
14481
+
14482
+ Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
14483
+ offset = offset >>> 0;
14484
+ if (!noAssert) checkOffset(offset, 2, this.length);
14485
+ const val = this[offset] | (this[offset + 1] << 8);
14486
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
14487
+ };
14488
+
14489
+ Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
14490
+ offset = offset >>> 0;
14491
+ if (!noAssert) checkOffset(offset, 2, this.length);
14492
+ const val = this[offset + 1] | (this[offset] << 8);
14493
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
14494
+ };
14495
+
14496
+ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
14497
+ offset = offset >>> 0;
14498
+ if (!noAssert) checkOffset(offset, 4, this.length);
14499
+
14500
+ return (this[offset]) |
14501
+ (this[offset + 1] << 8) |
14502
+ (this[offset + 2] << 16) |
14503
+ (this[offset + 3] << 24)
14504
+ };
14505
+
14506
+ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
14507
+ offset = offset >>> 0;
14508
+ if (!noAssert) checkOffset(offset, 4, this.length);
14509
+
14510
+ return (this[offset] << 24) |
14511
+ (this[offset + 1] << 16) |
14512
+ (this[offset + 2] << 8) |
14513
+ (this[offset + 3])
14514
+ };
14515
+
14516
+ Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
14517
+ offset = offset >>> 0;
14518
+ validateNumber(offset, 'offset');
14519
+ const first = this[offset];
14520
+ const last = this[offset + 7];
14521
+ if (first === undefined || last === undefined) {
14522
+ boundsError(offset, this.length - 8);
14523
+ }
14524
+
14525
+ const val = this[offset + 4] +
14526
+ this[offset + 5] * 2 ** 8 +
14527
+ this[offset + 6] * 2 ** 16 +
14528
+ (last << 24); // Overflow
14529
+
14530
+ return (BigInt(val) << BigInt(32)) +
14531
+ BigInt(first +
14532
+ this[++offset] * 2 ** 8 +
14533
+ this[++offset] * 2 ** 16 +
14534
+ this[++offset] * 2 ** 24)
14535
+ });
14536
+
14537
+ Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
14538
+ offset = offset >>> 0;
14539
+ validateNumber(offset, 'offset');
14540
+ const first = this[offset];
14541
+ const last = this[offset + 7];
14542
+ if (first === undefined || last === undefined) {
14543
+ boundsError(offset, this.length - 8);
14544
+ }
14545
+
14546
+ const val = (first << 24) + // Overflow
14547
+ this[++offset] * 2 ** 16 +
14548
+ this[++offset] * 2 ** 8 +
14549
+ this[++offset];
14550
+
14551
+ return (BigInt(val) << BigInt(32)) +
14552
+ BigInt(this[++offset] * 2 ** 24 +
14553
+ this[++offset] * 2 ** 16 +
14554
+ this[++offset] * 2 ** 8 +
14555
+ last)
14556
+ });
14557
+
14558
+ Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
14559
+ offset = offset >>> 0;
14560
+ if (!noAssert) checkOffset(offset, 4, this.length);
14561
+ return ieee754.read(this, offset, true, 23, 4)
14562
+ };
14563
+
14564
+ Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
14565
+ offset = offset >>> 0;
14566
+ if (!noAssert) checkOffset(offset, 4, this.length);
14567
+ return ieee754.read(this, offset, false, 23, 4)
14568
+ };
14569
+
14570
+ Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
14571
+ offset = offset >>> 0;
14572
+ if (!noAssert) checkOffset(offset, 8, this.length);
14573
+ return ieee754.read(this, offset, true, 52, 8)
14574
+ };
14575
+
14576
+ Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
14577
+ offset = offset >>> 0;
14578
+ if (!noAssert) checkOffset(offset, 8, this.length);
14579
+ return ieee754.read(this, offset, false, 52, 8)
14580
+ };
14581
+
14582
+ function checkInt (buf, value, offset, ext, max, min) {
14583
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
14584
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
14585
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
14586
+ }
14587
+
14588
+ Buffer.prototype.writeUintLE =
14589
+ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
14590
+ value = +value;
14591
+ offset = offset >>> 0;
14592
+ byteLength = byteLength >>> 0;
14593
+ if (!noAssert) {
14594
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1;
14595
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
14596
+ }
14597
+
14598
+ let mul = 1;
14599
+ let i = 0;
14600
+ this[offset] = value & 0xFF;
14601
+ while (++i < byteLength && (mul *= 0x100)) {
14602
+ this[offset + i] = (value / mul) & 0xFF;
14603
+ }
14604
+
14605
+ return offset + byteLength
14606
+ };
14607
+
14608
+ Buffer.prototype.writeUintBE =
14609
+ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
14610
+ value = +value;
14611
+ offset = offset >>> 0;
14612
+ byteLength = byteLength >>> 0;
14613
+ if (!noAssert) {
14614
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1;
14615
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
14616
+ }
14617
+
14618
+ let i = byteLength - 1;
14619
+ let mul = 1;
14620
+ this[offset + i] = value & 0xFF;
14621
+ while (--i >= 0 && (mul *= 0x100)) {
14622
+ this[offset + i] = (value / mul) & 0xFF;
14623
+ }
14624
+
14625
+ return offset + byteLength
14626
+ };
14627
+
14628
+ Buffer.prototype.writeUint8 =
14629
+ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
14630
+ value = +value;
14631
+ offset = offset >>> 0;
14632
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
14633
+ this[offset] = (value & 0xff);
14634
+ return offset + 1
14635
+ };
14636
+
14637
+ Buffer.prototype.writeUint16LE =
14638
+ Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
14639
+ value = +value;
14640
+ offset = offset >>> 0;
14641
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
14642
+ this[offset] = (value & 0xff);
14643
+ this[offset + 1] = (value >>> 8);
14644
+ return offset + 2
14645
+ };
14646
+
14647
+ Buffer.prototype.writeUint16BE =
14648
+ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
14649
+ value = +value;
14650
+ offset = offset >>> 0;
14651
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
14652
+ this[offset] = (value >>> 8);
14653
+ this[offset + 1] = (value & 0xff);
14654
+ return offset + 2
14655
+ };
14656
+
14657
+ Buffer.prototype.writeUint32LE =
14658
+ Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
14659
+ value = +value;
14660
+ offset = offset >>> 0;
14661
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
14662
+ this[offset + 3] = (value >>> 24);
14663
+ this[offset + 2] = (value >>> 16);
14664
+ this[offset + 1] = (value >>> 8);
14665
+ this[offset] = (value & 0xff);
14666
+ return offset + 4
14667
+ };
14668
+
14669
+ Buffer.prototype.writeUint32BE =
14670
+ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
14671
+ value = +value;
14672
+ offset = offset >>> 0;
14673
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
14674
+ this[offset] = (value >>> 24);
14675
+ this[offset + 1] = (value >>> 16);
14676
+ this[offset + 2] = (value >>> 8);
14677
+ this[offset + 3] = (value & 0xff);
14678
+ return offset + 4
14679
+ };
14680
+
14681
+ function wrtBigUInt64LE (buf, value, offset, min, max) {
14682
+ checkIntBI(value, min, max, buf, offset, 7);
14683
+
14684
+ let lo = Number(value & BigInt(0xffffffff));
14685
+ buf[offset++] = lo;
14686
+ lo = lo >> 8;
14687
+ buf[offset++] = lo;
14688
+ lo = lo >> 8;
14689
+ buf[offset++] = lo;
14690
+ lo = lo >> 8;
14691
+ buf[offset++] = lo;
14692
+ let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
14693
+ buf[offset++] = hi;
14694
+ hi = hi >> 8;
14695
+ buf[offset++] = hi;
14696
+ hi = hi >> 8;
14697
+ buf[offset++] = hi;
14698
+ hi = hi >> 8;
14699
+ buf[offset++] = hi;
14700
+ return offset
14701
+ }
14702
+
14703
+ function wrtBigUInt64BE (buf, value, offset, min, max) {
14704
+ checkIntBI(value, min, max, buf, offset, 7);
14705
+
14706
+ let lo = Number(value & BigInt(0xffffffff));
14707
+ buf[offset + 7] = lo;
14708
+ lo = lo >> 8;
14709
+ buf[offset + 6] = lo;
14710
+ lo = lo >> 8;
14711
+ buf[offset + 5] = lo;
14712
+ lo = lo >> 8;
14713
+ buf[offset + 4] = lo;
14714
+ let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
14715
+ buf[offset + 3] = hi;
14716
+ hi = hi >> 8;
14717
+ buf[offset + 2] = hi;
14718
+ hi = hi >> 8;
14719
+ buf[offset + 1] = hi;
14720
+ hi = hi >> 8;
14721
+ buf[offset] = hi;
14722
+ return offset + 8
14723
+ }
14724
+
14725
+ Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
14726
+ return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
14727
+ });
14728
+
14729
+ Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
14730
+ return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
14731
+ });
14732
+
14733
+ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
14734
+ value = +value;
14735
+ offset = offset >>> 0;
14736
+ if (!noAssert) {
14737
+ const limit = Math.pow(2, (8 * byteLength) - 1);
14738
+
14739
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
14740
+ }
14741
+
14742
+ let i = 0;
14743
+ let mul = 1;
14744
+ let sub = 0;
14745
+ this[offset] = value & 0xFF;
14746
+ while (++i < byteLength && (mul *= 0x100)) {
14747
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
14748
+ sub = 1;
14749
+ }
14750
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
14751
+ }
14752
+
14753
+ return offset + byteLength
14754
+ };
14755
+
14756
+ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
14757
+ value = +value;
14758
+ offset = offset >>> 0;
14759
+ if (!noAssert) {
14760
+ const limit = Math.pow(2, (8 * byteLength) - 1);
14761
+
14762
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
14763
+ }
14764
+
14765
+ let i = byteLength - 1;
14766
+ let mul = 1;
14767
+ let sub = 0;
14768
+ this[offset + i] = value & 0xFF;
14769
+ while (--i >= 0 && (mul *= 0x100)) {
14770
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
14771
+ sub = 1;
14772
+ }
14773
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
14774
+ }
14775
+
14776
+ return offset + byteLength
14777
+ };
14778
+
14779
+ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
14780
+ value = +value;
14781
+ offset = offset >>> 0;
14782
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
14783
+ if (value < 0) value = 0xff + value + 1;
14784
+ this[offset] = (value & 0xff);
14785
+ return offset + 1
14786
+ };
14787
+
14788
+ Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
14789
+ value = +value;
14790
+ offset = offset >>> 0;
14791
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
14792
+ this[offset] = (value & 0xff);
14793
+ this[offset + 1] = (value >>> 8);
14794
+ return offset + 2
14795
+ };
14796
+
14797
+ Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
14798
+ value = +value;
14799
+ offset = offset >>> 0;
14800
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
14801
+ this[offset] = (value >>> 8);
14802
+ this[offset + 1] = (value & 0xff);
14803
+ return offset + 2
14804
+ };
14805
+
14806
+ Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
14807
+ value = +value;
14808
+ offset = offset >>> 0;
14809
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
14810
+ this[offset] = (value & 0xff);
14811
+ this[offset + 1] = (value >>> 8);
14812
+ this[offset + 2] = (value >>> 16);
14813
+ this[offset + 3] = (value >>> 24);
14814
+ return offset + 4
14815
+ };
14816
+
14817
+ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
14818
+ value = +value;
14819
+ offset = offset >>> 0;
14820
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
14821
+ if (value < 0) value = 0xffffffff + value + 1;
14822
+ this[offset] = (value >>> 24);
14823
+ this[offset + 1] = (value >>> 16);
14824
+ this[offset + 2] = (value >>> 8);
14825
+ this[offset + 3] = (value & 0xff);
14826
+ return offset + 4
14827
+ };
14828
+
14829
+ Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
14830
+ return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
14831
+ });
14832
+
14833
+ Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
14834
+ return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
14835
+ });
14836
+
14837
+ function checkIEEE754 (buf, value, offset, ext, max, min) {
14838
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
14839
+ if (offset < 0) throw new RangeError('Index out of range')
14840
+ }
14841
+
14842
+ function writeFloat (buf, value, offset, littleEndian, noAssert) {
14843
+ value = +value;
14844
+ offset = offset >>> 0;
14845
+ if (!noAssert) {
14846
+ checkIEEE754(buf, value, offset, 4);
14847
+ }
14848
+ ieee754.write(buf, value, offset, littleEndian, 23, 4);
14849
+ return offset + 4
14850
+ }
14851
+
14852
+ Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
14853
+ return writeFloat(this, value, offset, true, noAssert)
14854
+ };
14855
+
14856
+ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
14857
+ return writeFloat(this, value, offset, false, noAssert)
14858
+ };
14859
+
14860
+ function writeDouble (buf, value, offset, littleEndian, noAssert) {
14861
+ value = +value;
14862
+ offset = offset >>> 0;
14863
+ if (!noAssert) {
14864
+ checkIEEE754(buf, value, offset, 8);
14865
+ }
14866
+ ieee754.write(buf, value, offset, littleEndian, 52, 8);
14867
+ return offset + 8
14868
+ }
14869
+
14870
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
14871
+ return writeDouble(this, value, offset, true, noAssert)
14872
+ };
14873
+
14874
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
14875
+ return writeDouble(this, value, offset, false, noAssert)
14876
+ };
14877
+
14878
+ // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
14879
+ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
14880
+ if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
14881
+ if (!start) start = 0;
14882
+ if (!end && end !== 0) end = this.length;
14883
+ if (targetStart >= target.length) targetStart = target.length;
14884
+ if (!targetStart) targetStart = 0;
14885
+ if (end > 0 && end < start) end = start;
14886
+
14887
+ // Copy 0 bytes; we're done
14888
+ if (end === start) return 0
14889
+ if (target.length === 0 || this.length === 0) return 0
14890
+
14891
+ // Fatal error conditions
14892
+ if (targetStart < 0) {
14893
+ throw new RangeError('targetStart out of bounds')
14894
+ }
14895
+ if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
14896
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
14897
+
14898
+ // Are we oob?
14899
+ if (end > this.length) end = this.length;
14900
+ if (target.length - targetStart < end - start) {
14901
+ end = target.length - targetStart + start;
14902
+ }
14903
+
14904
+ const len = end - start;
14905
+
14906
+ if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
14907
+ // Use built-in when available, missing from IE11
14908
+ this.copyWithin(targetStart, start, end);
14909
+ } else {
14910
+ Uint8Array.prototype.set.call(
14911
+ target,
14912
+ this.subarray(start, end),
14913
+ targetStart
14914
+ );
14915
+ }
14916
+
14917
+ return len
14918
+ };
14919
+
14920
+ // Usage:
14921
+ // buffer.fill(number[, offset[, end]])
14922
+ // buffer.fill(buffer[, offset[, end]])
14923
+ // buffer.fill(string[, offset[, end]][, encoding])
14924
+ Buffer.prototype.fill = function fill (val, start, end, encoding) {
14925
+ // Handle string cases:
14926
+ if (typeof val === 'string') {
14927
+ if (typeof start === 'string') {
14928
+ encoding = start;
14929
+ start = 0;
14930
+ end = this.length;
14931
+ } else if (typeof end === 'string') {
14932
+ encoding = end;
14933
+ end = this.length;
14934
+ }
14935
+ if (encoding !== undefined && typeof encoding !== 'string') {
14936
+ throw new TypeError('encoding must be a string')
14937
+ }
14938
+ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
14939
+ throw new TypeError('Unknown encoding: ' + encoding)
14940
+ }
14941
+ if (val.length === 1) {
14942
+ const code = val.charCodeAt(0);
14943
+ if ((encoding === 'utf8' && code < 128) ||
14944
+ encoding === 'latin1') {
14945
+ // Fast path: If `val` fits into a single byte, use that numeric value.
14946
+ val = code;
14947
+ }
14948
+ }
14949
+ } else if (typeof val === 'number') {
14950
+ val = val & 255;
14951
+ } else if (typeof val === 'boolean') {
14952
+ val = Number(val);
14953
+ }
14954
+
14955
+ // Invalid ranges are not set to a default, so can range check early.
14956
+ if (start < 0 || this.length < start || this.length < end) {
14957
+ throw new RangeError('Out of range index')
14958
+ }
14959
+
14960
+ if (end <= start) {
14961
+ return this
14962
+ }
14963
+
14964
+ start = start >>> 0;
14965
+ end = end === undefined ? this.length : end >>> 0;
14966
+
14967
+ if (!val) val = 0;
14968
+
14969
+ let i;
14970
+ if (typeof val === 'number') {
14971
+ for (i = start; i < end; ++i) {
14972
+ this[i] = val;
14973
+ }
14974
+ } else {
14975
+ const bytes = Buffer.isBuffer(val)
14976
+ ? val
14977
+ : Buffer.from(val, encoding);
14978
+ const len = bytes.length;
14979
+ if (len === 0) {
14980
+ throw new TypeError('The value "' + val +
14981
+ '" is invalid for argument "value"')
14982
+ }
14983
+ for (i = 0; i < end - start; ++i) {
14984
+ this[i + start] = bytes[i % len];
14985
+ }
14986
+ }
14987
+
14988
+ return this
14989
+ };
14990
+
14991
+ // CUSTOM ERRORS
14992
+ // =============
14993
+
14994
+ // Simplified versions from Node, changed for Buffer-only usage
14995
+ const errors = {};
14996
+ function E (sym, getMessage, Base) {
14997
+ errors[sym] = class NodeError extends Base {
14998
+ constructor () {
14999
+ super();
15000
+
15001
+ Object.defineProperty(this, 'message', {
15002
+ value: getMessage.apply(this, arguments),
15003
+ writable: true,
15004
+ configurable: true
15005
+ });
15006
+
15007
+ // Add the error code to the name to include it in the stack trace.
15008
+ this.name = `${this.name} [${sym}]`;
15009
+ // Access the stack to generate the error message including the error code
15010
+ // from the name.
15011
+ this.stack; // eslint-disable-line no-unused-expressions
15012
+ // Reset the name to the actual name.
15013
+ delete this.name;
15014
+ }
15015
+
15016
+ get code () {
15017
+ return sym
15018
+ }
15019
+
15020
+ set code (value) {
15021
+ Object.defineProperty(this, 'code', {
15022
+ configurable: true,
15023
+ enumerable: true,
15024
+ value,
15025
+ writable: true
15026
+ });
15027
+ }
15028
+
15029
+ toString () {
15030
+ return `${this.name} [${sym}]: ${this.message}`
15031
+ }
15032
+ };
15033
+ }
15034
+
15035
+ E('ERR_BUFFER_OUT_OF_BOUNDS',
15036
+ function (name) {
15037
+ if (name) {
15038
+ return `${name} is outside of buffer bounds`
15039
+ }
15040
+
15041
+ return 'Attempt to access memory outside buffer bounds'
15042
+ }, RangeError);
15043
+ E('ERR_INVALID_ARG_TYPE',
15044
+ function (name, actual) {
15045
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`
15046
+ }, TypeError);
15047
+ E('ERR_OUT_OF_RANGE',
15048
+ function (str, range, input) {
15049
+ let msg = `The value of "${str}" is out of range.`;
15050
+ let received = input;
15051
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
15052
+ received = addNumericalSeparator(String(input));
15053
+ } else if (typeof input === 'bigint') {
15054
+ received = String(input);
15055
+ if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
15056
+ received = addNumericalSeparator(received);
15057
+ }
15058
+ received += 'n';
15059
+ }
15060
+ msg += ` It must be ${range}. Received ${received}`;
15061
+ return msg
15062
+ }, RangeError);
15063
+
15064
+ function addNumericalSeparator (val) {
15065
+ let res = '';
15066
+ let i = val.length;
15067
+ const start = val[0] === '-' ? 1 : 0;
15068
+ for (; i >= start + 4; i -= 3) {
15069
+ res = `_${val.slice(i - 3, i)}${res}`;
15070
+ }
15071
+ return `${val.slice(0, i)}${res}`
15072
+ }
15073
+
15074
+ // CHECK FUNCTIONS
15075
+ // ===============
15076
+
15077
+ function checkBounds (buf, offset, byteLength) {
15078
+ validateNumber(offset, 'offset');
15079
+ if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
15080
+ boundsError(offset, buf.length - (byteLength + 1));
15081
+ }
15082
+ }
15083
+
15084
+ function checkIntBI (value, min, max, buf, offset, byteLength) {
15085
+ if (value > max || value < min) {
15086
+ const n = typeof min === 'bigint' ? 'n' : '';
15087
+ let range;
15088
+ {
15089
+ if (min === 0 || min === BigInt(0)) {
15090
+ range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
15091
+ } else {
15092
+ range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
15093
+ `${(byteLength + 1) * 8 - 1}${n}`;
15094
+ }
15095
+ }
15096
+ throw new errors.ERR_OUT_OF_RANGE('value', range, value)
15097
+ }
15098
+ checkBounds(buf, offset, byteLength);
15099
+ }
15100
+
15101
+ function validateNumber (value, name) {
15102
+ if (typeof value !== 'number') {
15103
+ throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
15104
+ }
15105
+ }
15106
+
15107
+ function boundsError (value, length, type) {
15108
+ if (Math.floor(value) !== value) {
15109
+ validateNumber(value, type);
15110
+ throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
15111
+ }
15112
+
15113
+ if (length < 0) {
15114
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
15115
+ }
15116
+
15117
+ throw new errors.ERR_OUT_OF_RANGE('offset',
15118
+ `>= ${0} and <= ${length}`,
15119
+ value)
15120
+ }
15121
+
15122
+ // HELPER FUNCTIONS
15123
+ // ================
15124
+
15125
+ const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
15126
+
15127
+ function base64clean (str) {
15128
+ // Node takes equal signs as end of the Base64 encoding
15129
+ str = str.split('=')[0];
15130
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
15131
+ str = str.trim().replace(INVALID_BASE64_RE, '');
15132
+ // Node converts strings with length < 2 to ''
15133
+ if (str.length < 2) return ''
15134
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
15135
+ while (str.length % 4 !== 0) {
15136
+ str = str + '=';
15137
+ }
15138
+ return str
15139
+ }
15140
+
15141
+ function utf8ToBytes (string, units) {
15142
+ units = units || Infinity;
15143
+ let codePoint;
15144
+ const length = string.length;
15145
+ let leadSurrogate = null;
15146
+ const bytes = [];
15147
+
15148
+ for (let i = 0; i < length; ++i) {
15149
+ codePoint = string.charCodeAt(i);
15150
+
15151
+ // is surrogate component
15152
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
15153
+ // last char was a lead
15154
+ if (!leadSurrogate) {
15155
+ // no lead yet
15156
+ if (codePoint > 0xDBFF) {
15157
+ // unexpected trail
15158
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
15159
+ continue
15160
+ } else if (i + 1 === length) {
15161
+ // unpaired lead
15162
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
15163
+ continue
15164
+ }
15165
+
15166
+ // valid lead
15167
+ leadSurrogate = codePoint;
15168
+
15169
+ continue
15170
+ }
15171
+
15172
+ // 2 leads in a row
15173
+ if (codePoint < 0xDC00) {
15174
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
15175
+ leadSurrogate = codePoint;
15176
+ continue
15177
+ }
15178
+
15179
+ // valid surrogate pair
15180
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
15181
+ } else if (leadSurrogate) {
15182
+ // valid bmp char, but last char was a lead
15183
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
15184
+ }
15185
+
15186
+ leadSurrogate = null;
15187
+
15188
+ // encode utf8
15189
+ if (codePoint < 0x80) {
15190
+ if ((units -= 1) < 0) break
15191
+ bytes.push(codePoint);
15192
+ } else if (codePoint < 0x800) {
15193
+ if ((units -= 2) < 0) break
15194
+ bytes.push(
15195
+ codePoint >> 0x6 | 0xC0,
15196
+ codePoint & 0x3F | 0x80
15197
+ );
15198
+ } else if (codePoint < 0x10000) {
15199
+ if ((units -= 3) < 0) break
15200
+ bytes.push(
15201
+ codePoint >> 0xC | 0xE0,
15202
+ codePoint >> 0x6 & 0x3F | 0x80,
15203
+ codePoint & 0x3F | 0x80
15204
+ );
15205
+ } else if (codePoint < 0x110000) {
15206
+ if ((units -= 4) < 0) break
15207
+ bytes.push(
15208
+ codePoint >> 0x12 | 0xF0,
15209
+ codePoint >> 0xC & 0x3F | 0x80,
15210
+ codePoint >> 0x6 & 0x3F | 0x80,
15211
+ codePoint & 0x3F | 0x80
15212
+ );
15213
+ } else {
15214
+ throw new Error('Invalid code point')
15215
+ }
15216
+ }
15217
+
15218
+ return bytes
15219
+ }
15220
+
15221
+ function asciiToBytes (str) {
15222
+ const byteArray = [];
15223
+ for (let i = 0; i < str.length; ++i) {
15224
+ // Node's code seems to be doing this and not & 0x7F..
15225
+ byteArray.push(str.charCodeAt(i) & 0xFF);
15226
+ }
15227
+ return byteArray
15228
+ }
15229
+
15230
+ function utf16leToBytes (str, units) {
15231
+ let c, hi, lo;
15232
+ const byteArray = [];
15233
+ for (let i = 0; i < str.length; ++i) {
15234
+ if ((units -= 2) < 0) break
15235
+
15236
+ c = str.charCodeAt(i);
15237
+ hi = c >> 8;
15238
+ lo = c % 256;
15239
+ byteArray.push(lo);
15240
+ byteArray.push(hi);
15241
+ }
15242
+
15243
+ return byteArray
15244
+ }
15245
+
15246
+ function base64ToBytes (str) {
15247
+ return base64.toByteArray(base64clean(str))
15248
+ }
15249
+
15250
+ function blitBuffer (src, dst, offset, length) {
15251
+ let i;
15252
+ for (i = 0; i < length; ++i) {
15253
+ if ((i + offset >= dst.length) || (i >= src.length)) break
15254
+ dst[i + offset] = src[i];
15255
+ }
15256
+ return i
15257
+ }
15258
+
15259
+ // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
15260
+ // the `instanceof` check but they should be treated as of that type.
15261
+ // See: https://github.com/feross/buffer/issues/166
15262
+ function isInstance (obj, type) {
15263
+ return obj instanceof type ||
15264
+ (obj != null && obj.constructor != null && obj.constructor.name != null &&
15265
+ obj.constructor.name === type.name)
15266
+ }
15267
+ function numberIsNaN (obj) {
15268
+ // For IE11 support
15269
+ return obj !== obj // eslint-disable-line no-self-compare
15270
+ }
15271
+
15272
+ // Create lookup table for `toString('hex')`
15273
+ // See: https://github.com/feross/buffer/issues/219
15274
+ const hexSliceLookupTable = (function () {
15275
+ const alphabet = '0123456789abcdef';
15276
+ const table = new Array(256);
15277
+ for (let i = 0; i < 16; ++i) {
15278
+ const i16 = i * 16;
15279
+ for (let j = 0; j < 16; ++j) {
15280
+ table[i16 + j] = alphabet[i] + alphabet[j];
15281
+ }
15282
+ }
15283
+ return table
15284
+ })();
15285
+
15286
+ // Return not function with Error if BigInt not supported
15287
+ function defineBigIntMethod (fn) {
15288
+ return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
15289
+ }
15290
+
15291
+ function BufferBigIntNotDefined () {
15292
+ throw new Error('BigInt not supported')
15293
+ }
15294
+ } (buffer));
15295
+ return buffer;
15296
+ }
15297
+
15298
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
15299
+
15300
+ var hasRequiredSafeBuffer;
15301
+
15302
+ function requireSafeBuffer () {
15303
+ if (hasRequiredSafeBuffer) return safeBuffer.exports;
15304
+ hasRequiredSafeBuffer = 1;
15305
+ (function (module, exports$1) {
15306
+ /* eslint-disable node/no-deprecated-api */
15307
+ var buffer = requireBuffer();
15308
+ var Buffer = buffer.Buffer;
15309
+
15310
+ // alternative to using Object.keys for old browsers
15311
+ function copyProps (src, dst) {
15312
+ for (var key in src) {
15313
+ dst[key] = src[key];
15314
+ }
15315
+ }
15316
+ if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
15317
+ module.exports = buffer;
15318
+ } else {
15319
+ // Copy properties from require('buffer')
15320
+ copyProps(buffer, exports$1);
15321
+ exports$1.Buffer = SafeBuffer;
15322
+ }
15323
+
15324
+ function SafeBuffer (arg, encodingOrOffset, length) {
15325
+ return Buffer(arg, encodingOrOffset, length)
15326
+ }
15327
+
15328
+ SafeBuffer.prototype = Object.create(Buffer.prototype);
15329
+
15330
+ // Copy static methods from Buffer
15331
+ copyProps(Buffer, SafeBuffer);
15332
+
15333
+ SafeBuffer.from = function (arg, encodingOrOffset, length) {
15334
+ if (typeof arg === 'number') {
15335
+ throw new TypeError('Argument must not be a number')
15336
+ }
15337
+ return Buffer(arg, encodingOrOffset, length)
15338
+ };
15339
+
15340
+ SafeBuffer.alloc = function (size, fill, encoding) {
15341
+ if (typeof size !== 'number') {
15342
+ throw new TypeError('Argument must be a number')
15343
+ }
15344
+ var buf = Buffer(size);
15345
+ if (fill !== undefined) {
15346
+ if (typeof encoding === 'string') {
15347
+ buf.fill(fill, encoding);
15348
+ } else {
15349
+ buf.fill(fill);
15350
+ }
15351
+ } else {
15352
+ buf.fill(0);
15353
+ }
15354
+ return buf
15355
+ };
15356
+
15357
+ SafeBuffer.allocUnsafe = function (size) {
15358
+ if (typeof size !== 'number') {
15359
+ throw new TypeError('Argument must be a number')
15360
+ }
15361
+ return Buffer(size)
15362
+ };
15363
+
15364
+ SafeBuffer.allocUnsafeSlow = function (size) {
15365
+ if (typeof size !== 'number') {
15366
+ throw new TypeError('Argument must be a number')
15367
+ }
15368
+ return buffer.SlowBuffer(size)
15369
+ };
15370
+ } (safeBuffer, safeBuffer.exports));
15371
+ return safeBuffer.exports;
15372
+ }
15373
+
15374
+ var src;
15375
+ var hasRequiredSrc;
15376
+
15377
+ function requireSrc () {
15378
+ if (hasRequiredSrc) return src;
15379
+ hasRequiredSrc = 1;
15380
+ // base-x encoding / decoding
15381
+ // Copyright (c) 2018 base-x contributors
15382
+ // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
15383
+ // Distributed under the MIT software license, see the accompanying
15384
+ // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
15385
+ // @ts-ignore
15386
+ var _Buffer = requireSafeBuffer().Buffer;
15387
+ function base (ALPHABET) {
15388
+ if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
15389
+ var BASE_MAP = new Uint8Array(256);
15390
+ for (var j = 0; j < BASE_MAP.length; j++) {
15391
+ BASE_MAP[j] = 255;
15392
+ }
15393
+ for (var i = 0; i < ALPHABET.length; i++) {
15394
+ var x = ALPHABET.charAt(i);
15395
+ var xc = x.charCodeAt(0);
15396
+ if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
15397
+ BASE_MAP[xc] = i;
15398
+ }
15399
+ var BASE = ALPHABET.length;
15400
+ var LEADER = ALPHABET.charAt(0);
15401
+ var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
15402
+ var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
15403
+ function encode (source) {
15404
+ if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source); }
15405
+ if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }
15406
+ if (source.length === 0) { return '' }
15407
+ // Skip & count leading zeroes.
15408
+ var zeroes = 0;
15409
+ var length = 0;
15410
+ var pbegin = 0;
15411
+ var pend = source.length;
15412
+ while (pbegin !== pend && source[pbegin] === 0) {
15413
+ pbegin++;
15414
+ zeroes++;
15415
+ }
15416
+ // Allocate enough space in big-endian base58 representation.
15417
+ var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
15418
+ var b58 = new Uint8Array(size);
15419
+ // Process the bytes.
15420
+ while (pbegin !== pend) {
15421
+ var carry = source[pbegin];
15422
+ // Apply "b58 = b58 * 256 + ch".
15423
+ var i = 0;
15424
+ for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
15425
+ carry += (256 * b58[it1]) >>> 0;
15426
+ b58[it1] = (carry % BASE) >>> 0;
15427
+ carry = (carry / BASE) >>> 0;
15428
+ }
15429
+ if (carry !== 0) { throw new Error('Non-zero carry') }
15430
+ length = i;
15431
+ pbegin++;
15432
+ }
15433
+ // Skip leading zeroes in base58 result.
15434
+ var it2 = size - length;
15435
+ while (it2 !== size && b58[it2] === 0) {
15436
+ it2++;
15437
+ }
15438
+ // Translate the result into a string.
15439
+ var str = LEADER.repeat(zeroes);
15440
+ for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
15441
+ return str
15442
+ }
15443
+ function decodeUnsafe (source) {
15444
+ if (typeof source !== 'string') { throw new TypeError('Expected String') }
15445
+ if (source.length === 0) { return _Buffer.alloc(0) }
15446
+ var psz = 0;
15447
+ // Skip and count leading '1's.
15448
+ var zeroes = 0;
15449
+ var length = 0;
15450
+ while (source[psz] === LEADER) {
15451
+ zeroes++;
15452
+ psz++;
15453
+ }
15454
+ // Allocate enough space in big-endian base256 representation.
15455
+ var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
15456
+ var b256 = new Uint8Array(size);
15457
+ // Process the characters.
15458
+ while (psz < source.length) {
15459
+ // Find code of next character
15460
+ var charCode = source.charCodeAt(psz);
15461
+ // Base map can not be indexed using char code
15462
+ if (charCode > 255) { return }
15463
+ // Decode character
15464
+ var carry = BASE_MAP[charCode];
15465
+ // Invalid character
15466
+ if (carry === 255) { return }
15467
+ var i = 0;
15468
+ for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
15469
+ carry += (BASE * b256[it3]) >>> 0;
15470
+ b256[it3] = (carry % 256) >>> 0;
15471
+ carry = (carry / 256) >>> 0;
15472
+ }
15473
+ if (carry !== 0) { throw new Error('Non-zero carry') }
15474
+ length = i;
15475
+ psz++;
15476
+ }
15477
+ // Skip leading zeroes in b256.
15478
+ var it4 = size - length;
15479
+ while (it4 !== size && b256[it4] === 0) {
15480
+ it4++;
15481
+ }
15482
+ var vch = _Buffer.allocUnsafe(zeroes + (size - it4));
15483
+ vch.fill(0x00, 0, zeroes);
15484
+ var j = zeroes;
15485
+ while (it4 !== size) {
15486
+ vch[j++] = b256[it4++];
15487
+ }
15488
+ return vch
15489
+ }
15490
+ function decode (string) {
15491
+ var buffer = decodeUnsafe(string);
15492
+ if (buffer) { return buffer }
15493
+ throw new Error('Non-base' + BASE + ' character')
15494
+ }
15495
+ return {
15496
+ encode: encode,
15497
+ decodeUnsafe: decodeUnsafe,
15498
+ decode: decode
15499
+ }
15500
+ }
15501
+ src = base;
15502
+ return src;
15503
+ }
15504
+
15505
+ var bs58$1;
15506
+ var hasRequiredBs58;
15507
+
15508
+ function requireBs58 () {
15509
+ if (hasRequiredBs58) return bs58$1;
15510
+ hasRequiredBs58 = 1;
15511
+ var basex = requireSrc();
15512
+ var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
15513
+
15514
+ bs58$1 = basex(ALPHABET);
15515
+ return bs58$1;
15516
+ }
15517
+
15518
+ var bs58Exports = requireBs58();
15519
+ var bs58 = /*@__PURE__*/getDefaultExportFromCjs$1(bs58Exports);
15520
+
15521
+ var index = /*#__PURE__*/_mergeNamespaces({
15522
+ __proto__: null,
15523
+ default: bs58
15524
+ }, [bs58Exports]);
12959
15525
 
12960
15526
  /**
12961
15527
  * Privy Expo Auth Provider — React Native implementation of AuthProvider.
@@ -13331,6 +15897,7 @@ exports.getCurrentUser = getCurrentUser;
13331
15897
  exports.getDefaultExportFromCjs = getDefaultExportFromCjs$1;
13332
15898
  exports.getFiles = getFiles;
13333
15899
  exports.getIdToken = getIdToken;
15900
+ exports.getMany = getMany;
13334
15901
  exports.getPlatform = getPlatform;
13335
15902
  exports.index = index;
13336
15903
  exports.init = init;
@@ -13340,6 +15907,7 @@ exports.onAuthLoadingChanged = onAuthLoadingChanged;
13340
15907
  exports.onAuthStateChanged = onAuthStateChanged;
13341
15908
  exports.reconnectWithNewAuth = reconnectWithNewAuth;
13342
15909
  exports.refreshSession = refreshSession;
15910
+ exports.requireBuffer = requireBuffer;
13343
15911
  exports.runExpression = runExpression;
13344
15912
  exports.runExpressionMany = runExpressionMany;
13345
15913
  exports.runQuery = runQuery;
@@ -13356,4 +15924,4 @@ exports.signSessionCreateMessage = signSessionCreateMessage;
13356
15924
  exports.signTransaction = signTransaction;
13357
15925
  exports.subscribe = subscribe;
13358
15926
  exports.useAuth = useAuth;
13359
- //# sourceMappingURL=index.native-CkUXrvPQ.js.map
15927
+ //# sourceMappingURL=index.native-CKd2b3_F.js.map