@hashgraphonline/standards-sdk 0.0.38 → 0.0.40

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.
@@ -857,9 +857,9 @@ class WasmBridge {
857
857
  const mem = this.getUint8Memory();
858
858
  let offset = 0;
859
859
  for (; offset < len; offset++) {
860
- const code2 = arg.charCodeAt(offset);
861
- if (code2 > 127) break;
862
- mem[ptr + offset] = code2;
860
+ const code = arg.charCodeAt(offset);
861
+ if (code > 127) break;
862
+ mem[ptr + offset] = code;
863
863
  }
864
864
  if (offset !== len) {
865
865
  if (offset !== 0) {
@@ -1054,10 +1054,10 @@ function stringify(value) {
1054
1054
  }
1055
1055
  return `[ COULD NOT SERIALIZE ]`;
1056
1056
  }
1057
- function isError(error, code2) {
1058
- return error && error.code === code2;
1057
+ function isError(error, code) {
1058
+ return error && error.code === code;
1059
1059
  }
1060
- function makeError(message, code2, info) {
1060
+ function makeError(message, code, info) {
1061
1061
  let shortMessage = message;
1062
1062
  {
1063
1063
  const details = [];
@@ -1073,14 +1073,14 @@ function makeError(message, code2, info) {
1073
1073
  details.push(key + "=" + stringify(value));
1074
1074
  }
1075
1075
  }
1076
- details.push(`code=${code2}`);
1076
+ details.push(`code=${code}`);
1077
1077
  details.push(`version=${version}`);
1078
1078
  if (details.length) {
1079
1079
  message += " (" + details.join(", ") + ")";
1080
1080
  }
1081
1081
  }
1082
1082
  let error;
1083
- switch (code2) {
1083
+ switch (code) {
1084
1084
  case "INVALID_ARGUMENT":
1085
1085
  error = new TypeError(message);
1086
1086
  break;
@@ -1091,7 +1091,7 @@ function makeError(message, code2, info) {
1091
1091
  default:
1092
1092
  error = new Error(message);
1093
1093
  }
1094
- defineProperties(error, { code: code2 });
1094
+ defineProperties(error, { code });
1095
1095
  if (info) {
1096
1096
  Object.assign(error, info);
1097
1097
  }
@@ -1100,9 +1100,9 @@ function makeError(message, code2, info) {
1100
1100
  }
1101
1101
  return error;
1102
1102
  }
1103
- function assert(check, message, code2, info) {
1103
+ function assert(check, message, code, info) {
1104
1104
  if (!check) {
1105
- throw makeError(message, code2, info);
1105
+ throw makeError(message, code, info);
1106
1106
  }
1107
1107
  }
1108
1108
  function assertArgument(check, message, name, value) {
@@ -4713,13 +4713,13 @@ function getBuiltinCallException(action, tx, data, abiCoder) {
4713
4713
  }
4714
4714
  } else if (hexlify(bytes2.slice(0, 4)) === "0x4e487b71") {
4715
4715
  try {
4716
- const code2 = Number(abiCoder.decode(["uint256"], bytes2.slice(4))[0]);
4716
+ const code = Number(abiCoder.decode(["uint256"], bytes2.slice(4))[0]);
4717
4717
  revert = {
4718
4718
  signature: "Panic(uint256)",
4719
4719
  name: "Panic",
4720
- args: [code2]
4720
+ args: [code]
4721
4721
  };
4722
- reason = `Panic due to ${PanicReasons$1.get(code2) || "UNKNOWN"}(${code2})`;
4722
+ reason = `Panic due to ${PanicReasons$1.get(code) || "UNKNOWN"}(${code})`;
4723
4723
  message += `: ${reason}`;
4724
4724
  } catch (error) {
4725
4725
  message += " (could not decode panic code)";
@@ -5002,12 +5002,12 @@ const BuiltinErrors = {
5002
5002
  signature: "Panic(uint256)",
5003
5003
  name: "Panic",
5004
5004
  inputs: ["uint256"],
5005
- reason: (code2) => {
5005
+ reason: (code) => {
5006
5006
  let reason = "unknown panic code";
5007
- if (code2 >= 0 && code2 <= 255 && PanicReasons[code2.toString()]) {
5008
- reason = PanicReasons[code2.toString()];
5007
+ if (code >= 0 && code <= 255 && PanicReasons[code.toString()]) {
5008
+ reason = PanicReasons[code.toString()];
5009
5009
  }
5010
- return `reverted with panic code 0x${code2.toString(16)} (${reason})`;
5010
+ return `reverted with panic code 0x${code.toString(16)} (${reason})`;
5011
5011
  }
5012
5012
  }
5013
5013
  };
@@ -6048,1938 +6048,9 @@ class ConnectionConfirmationError extends Error {
6048
6048
  this.name = "ConnectionConfirmationError";
6049
6049
  }
6050
6050
  }
6051
- function getDefaultExportFromCjs$2(x) {
6052
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
6053
- }
6054
- var browser$2 = { exports: {} };
6055
- var process$1 = browser$2.exports = {};
6056
- var cachedSetTimeout;
6057
- var cachedClearTimeout;
6058
- function defaultSetTimout() {
6059
- throw new Error("setTimeout has not been defined");
6060
- }
6061
- function defaultClearTimeout() {
6062
- throw new Error("clearTimeout has not been defined");
6063
- }
6064
- (function() {
6065
- try {
6066
- if (typeof setTimeout === "function") {
6067
- cachedSetTimeout = setTimeout;
6068
- } else {
6069
- cachedSetTimeout = defaultSetTimout;
6070
- }
6071
- } catch (e) {
6072
- cachedSetTimeout = defaultSetTimout;
6073
- }
6074
- try {
6075
- if (typeof clearTimeout === "function") {
6076
- cachedClearTimeout = clearTimeout;
6077
- } else {
6078
- cachedClearTimeout = defaultClearTimeout;
6079
- }
6080
- } catch (e) {
6081
- cachedClearTimeout = defaultClearTimeout;
6082
- }
6083
- })();
6084
- function runTimeout(fun) {
6085
- if (cachedSetTimeout === setTimeout) {
6086
- return setTimeout(fun, 0);
6087
- }
6088
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
6089
- cachedSetTimeout = setTimeout;
6090
- return setTimeout(fun, 0);
6091
- }
6092
- try {
6093
- return cachedSetTimeout(fun, 0);
6094
- } catch (e) {
6095
- try {
6096
- return cachedSetTimeout.call(null, fun, 0);
6097
- } catch (e2) {
6098
- return cachedSetTimeout.call(this, fun, 0);
6099
- }
6100
- }
6101
- }
6102
- function runClearTimeout(marker) {
6103
- if (cachedClearTimeout === clearTimeout) {
6104
- return clearTimeout(marker);
6105
- }
6106
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
6107
- cachedClearTimeout = clearTimeout;
6108
- return clearTimeout(marker);
6109
- }
6110
- try {
6111
- return cachedClearTimeout(marker);
6112
- } catch (e) {
6113
- try {
6114
- return cachedClearTimeout.call(null, marker);
6115
- } catch (e2) {
6116
- return cachedClearTimeout.call(this, marker);
6117
- }
6118
- }
6119
- }
6120
- var queue = [];
6121
- var draining = false;
6122
- var currentQueue;
6123
- var queueIndex = -1;
6124
- function cleanUpNextTick() {
6125
- if (!draining || !currentQueue) {
6126
- return;
6127
- }
6128
- draining = false;
6129
- if (currentQueue.length) {
6130
- queue = currentQueue.concat(queue);
6131
- } else {
6132
- queueIndex = -1;
6133
- }
6134
- if (queue.length) {
6135
- drainQueue();
6136
- }
6137
- }
6138
- function drainQueue() {
6139
- if (draining) {
6140
- return;
6141
- }
6142
- var timeout = runTimeout(cleanUpNextTick);
6143
- draining = true;
6144
- var len = queue.length;
6145
- while (len) {
6146
- currentQueue = queue;
6147
- queue = [];
6148
- while (++queueIndex < len) {
6149
- if (currentQueue) {
6150
- currentQueue[queueIndex].run();
6151
- }
6152
- }
6153
- queueIndex = -1;
6154
- len = queue.length;
6155
- }
6156
- currentQueue = null;
6157
- draining = false;
6158
- runClearTimeout(timeout);
6159
- }
6160
- process$1.nextTick = function(fun) {
6161
- var args = new Array(arguments.length - 1);
6162
- if (arguments.length > 1) {
6163
- for (var i = 1; i < arguments.length; i++) {
6164
- args[i - 1] = arguments[i];
6165
- }
6166
- }
6167
- queue.push(new Item(fun, args));
6168
- if (queue.length === 1 && !draining) {
6169
- runTimeout(drainQueue);
6170
- }
6171
- };
6172
- function Item(fun, array) {
6173
- this.fun = fun;
6174
- this.array = array;
6175
- }
6176
- Item.prototype.run = function() {
6177
- this.fun.apply(null, this.array);
6178
- };
6179
- process$1.title = "browser";
6180
- process$1.browser = true;
6181
- process$1.env = {};
6182
- process$1.argv = [];
6183
- process$1.version = "";
6184
- process$1.versions = {};
6185
- function noop$2() {
6186
- }
6187
- process$1.on = noop$2;
6188
- process$1.addListener = noop$2;
6189
- process$1.once = noop$2;
6190
- process$1.off = noop$2;
6191
- process$1.removeListener = noop$2;
6192
- process$1.removeAllListeners = noop$2;
6193
- process$1.emit = noop$2;
6194
- process$1.prependListener = noop$2;
6195
- process$1.prependOnceListener = noop$2;
6196
- process$1.listeners = function(name) {
6197
- return [];
6198
- };
6199
- process$1.binding = function(name) {
6200
- throw new Error("process.binding is not supported");
6201
- };
6202
- process$1.cwd = function() {
6203
- return "/";
6204
- };
6205
- process$1.chdir = function(dir) {
6206
- throw new Error("process.chdir is not supported");
6207
- };
6208
- process$1.umask = function() {
6209
- return 0;
6210
- };
6211
- var browserExports$2 = browser$2.exports;
6212
- const process$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$2(browserExports$2);
6213
6051
  var __defProp2 = Object.defineProperty;
6214
6052
  var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6215
6053
  var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
6216
- var buffer = {};
6217
- var base64Js = {};
6218
- base64Js.byteLength = byteLength;
6219
- base64Js.toByteArray = toByteArray;
6220
- base64Js.fromByteArray = fromByteArray;
6221
- var lookup = [];
6222
- var revLookup = [];
6223
- var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
6224
- var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
6225
- for (var i$1 = 0, len = code.length; i$1 < len; ++i$1) {
6226
- lookup[i$1] = code[i$1];
6227
- revLookup[code.charCodeAt(i$1)] = i$1;
6228
- }
6229
- revLookup["-".charCodeAt(0)] = 62;
6230
- revLookup["_".charCodeAt(0)] = 63;
6231
- function getLens(b64) {
6232
- var len = b64.length;
6233
- if (len % 4 > 0) {
6234
- throw new Error("Invalid string. Length must be a multiple of 4");
6235
- }
6236
- var validLen = b64.indexOf("=");
6237
- if (validLen === -1) validLen = len;
6238
- var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
6239
- return [validLen, placeHoldersLen];
6240
- }
6241
- function byteLength(b64) {
6242
- var lens = getLens(b64);
6243
- var validLen = lens[0];
6244
- var placeHoldersLen = lens[1];
6245
- return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
6246
- }
6247
- function _byteLength(b64, validLen, placeHoldersLen) {
6248
- return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
6249
- }
6250
- function toByteArray(b64) {
6251
- var tmp;
6252
- var lens = getLens(b64);
6253
- var validLen = lens[0];
6254
- var placeHoldersLen = lens[1];
6255
- var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
6256
- var curByte = 0;
6257
- var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
6258
- var i;
6259
- for (i = 0; i < len; i += 4) {
6260
- tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
6261
- arr[curByte++] = tmp >> 16 & 255;
6262
- arr[curByte++] = tmp >> 8 & 255;
6263
- arr[curByte++] = tmp & 255;
6264
- }
6265
- if (placeHoldersLen === 2) {
6266
- tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
6267
- arr[curByte++] = tmp & 255;
6268
- }
6269
- if (placeHoldersLen === 1) {
6270
- tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
6271
- arr[curByte++] = tmp >> 8 & 255;
6272
- arr[curByte++] = tmp & 255;
6273
- }
6274
- return arr;
6275
- }
6276
- function tripletToBase64(num) {
6277
- return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
6278
- }
6279
- function encodeChunk(uint8, start, end) {
6280
- var tmp;
6281
- var output2 = [];
6282
- for (var i = start; i < end; i += 3) {
6283
- tmp = (uint8[i] << 16 & 16711680) + (uint8[i + 1] << 8 & 65280) + (uint8[i + 2] & 255);
6284
- output2.push(tripletToBase64(tmp));
6285
- }
6286
- return output2.join("");
6287
- }
6288
- function fromByteArray(uint8) {
6289
- var tmp;
6290
- var len = uint8.length;
6291
- var extraBytes = len % 3;
6292
- var parts = [];
6293
- var maxChunkLength = 16383;
6294
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
6295
- parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
6296
- }
6297
- if (extraBytes === 1) {
6298
- tmp = uint8[len - 1];
6299
- parts.push(
6300
- lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
6301
- );
6302
- } else if (extraBytes === 2) {
6303
- tmp = (uint8[len - 2] << 8) + uint8[len - 1];
6304
- parts.push(
6305
- lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
6306
- );
6307
- }
6308
- return parts.join("");
6309
- }
6310
- var ieee754$1 = {};
6311
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
6312
- ieee754$1.read = function(buffer2, offset, isLE2, mLen, nBytes) {
6313
- var e, m;
6314
- var eLen = nBytes * 8 - mLen - 1;
6315
- var eMax = (1 << eLen) - 1;
6316
- var eBias = eMax >> 1;
6317
- var nBits = -7;
6318
- var i = isLE2 ? nBytes - 1 : 0;
6319
- var d = isLE2 ? -1 : 1;
6320
- var s = buffer2[offset + i];
6321
- i += d;
6322
- e = s & (1 << -nBits) - 1;
6323
- s >>= -nBits;
6324
- nBits += eLen;
6325
- for (; nBits > 0; e = e * 256 + buffer2[offset + i], i += d, nBits -= 8) {
6326
- }
6327
- m = e & (1 << -nBits) - 1;
6328
- e >>= -nBits;
6329
- nBits += mLen;
6330
- for (; nBits > 0; m = m * 256 + buffer2[offset + i], i += d, nBits -= 8) {
6331
- }
6332
- if (e === 0) {
6333
- e = 1 - eBias;
6334
- } else if (e === eMax) {
6335
- return m ? NaN : (s ? -1 : 1) * Infinity;
6336
- } else {
6337
- m = m + Math.pow(2, mLen);
6338
- e = e - eBias;
6339
- }
6340
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
6341
- };
6342
- ieee754$1.write = function(buffer2, value, offset, isLE2, mLen, nBytes) {
6343
- var e, m, c;
6344
- var eLen = nBytes * 8 - mLen - 1;
6345
- var eMax = (1 << eLen) - 1;
6346
- var eBias = eMax >> 1;
6347
- var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
6348
- var i = isLE2 ? 0 : nBytes - 1;
6349
- var d = isLE2 ? 1 : -1;
6350
- var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
6351
- value = Math.abs(value);
6352
- if (isNaN(value) || value === Infinity) {
6353
- m = isNaN(value) ? 1 : 0;
6354
- e = eMax;
6355
- } else {
6356
- e = Math.floor(Math.log(value) / Math.LN2);
6357
- if (value * (c = Math.pow(2, -e)) < 1) {
6358
- e--;
6359
- c *= 2;
6360
- }
6361
- if (e + eBias >= 1) {
6362
- value += rt / c;
6363
- } else {
6364
- value += rt * Math.pow(2, 1 - eBias);
6365
- }
6366
- if (value * c >= 2) {
6367
- e++;
6368
- c /= 2;
6369
- }
6370
- if (e + eBias >= eMax) {
6371
- m = 0;
6372
- e = eMax;
6373
- } else if (e + eBias >= 1) {
6374
- m = (value * c - 1) * Math.pow(2, mLen);
6375
- e = e + eBias;
6376
- } else {
6377
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
6378
- e = 0;
6379
- }
6380
- }
6381
- for (; mLen >= 8; buffer2[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
6382
- }
6383
- e = e << mLen | m;
6384
- eLen += mLen;
6385
- for (; eLen > 0; buffer2[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
6386
- }
6387
- buffer2[offset + i - d] |= s * 128;
6388
- };
6389
- /*!
6390
- * The buffer module from node.js, for the browser.
6391
- *
6392
- * @author Feross Aboukhadijeh <https://feross.org>
6393
- * @license MIT
6394
- */
6395
- (function(exports) {
6396
- const base64 = base64Js;
6397
- const ieee754$1$1 = ieee754$1;
6398
- const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
6399
- exports.Buffer = Buffer3;
6400
- exports.SlowBuffer = SlowBuffer;
6401
- exports.INSPECT_MAX_BYTES = 50;
6402
- const K_MAX_LENGTH = 2147483647;
6403
- exports.kMaxLength = K_MAX_LENGTH;
6404
- const { Uint8Array: GlobalUint8Array, ArrayBuffer: GlobalArrayBuffer, SharedArrayBuffer: GlobalSharedArrayBuffer } = globalThis;
6405
- Buffer3.TYPED_ARRAY_SUPPORT = typedArraySupport();
6406
- if (!Buffer3.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
6407
- console.error(
6408
- "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
6409
- );
6410
- }
6411
- function typedArraySupport() {
6412
- try {
6413
- const arr = new GlobalUint8Array(1);
6414
- const proto2 = { foo: function() {
6415
- return 42;
6416
- } };
6417
- Object.setPrototypeOf(proto2, GlobalUint8Array.prototype);
6418
- Object.setPrototypeOf(arr, proto2);
6419
- return arr.foo() === 42;
6420
- } catch (e) {
6421
- return false;
6422
- }
6423
- }
6424
- Object.defineProperty(Buffer3.prototype, "parent", {
6425
- enumerable: true,
6426
- get: function() {
6427
- if (!Buffer3.isBuffer(this)) return void 0;
6428
- return this.buffer;
6429
- }
6430
- });
6431
- Object.defineProperty(Buffer3.prototype, "offset", {
6432
- enumerable: true,
6433
- get: function() {
6434
- if (!Buffer3.isBuffer(this)) return void 0;
6435
- return this.byteOffset;
6436
- }
6437
- });
6438
- function createBuffer(length) {
6439
- if (length > K_MAX_LENGTH) {
6440
- throw new RangeError('The value "' + length + '" is invalid for option "size"');
6441
- }
6442
- const buf = new GlobalUint8Array(length);
6443
- Object.setPrototypeOf(buf, Buffer3.prototype);
6444
- return buf;
6445
- }
6446
- function Buffer3(arg, encodingOrOffset, length) {
6447
- if (typeof arg === "number") {
6448
- if (typeof encodingOrOffset === "string") {
6449
- throw new TypeError(
6450
- 'The "string" argument must be of type string. Received type number'
6451
- );
6452
- }
6453
- return allocUnsafe(arg);
6454
- }
6455
- return from(arg, encodingOrOffset, length);
6456
- }
6457
- Buffer3.poolSize = 8192;
6458
- function from(value, encodingOrOffset, length) {
6459
- if (typeof value === "string") {
6460
- return fromString(value, encodingOrOffset);
6461
- }
6462
- if (GlobalArrayBuffer.isView(value)) {
6463
- return fromArrayView(value);
6464
- }
6465
- if (value == null) {
6466
- throw new TypeError(
6467
- "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
6468
- );
6469
- }
6470
- if (isInstance(value, GlobalArrayBuffer) || value && isInstance(value.buffer, GlobalArrayBuffer)) {
6471
- return fromArrayBuffer(value, encodingOrOffset, length);
6472
- }
6473
- if (typeof GlobalSharedArrayBuffer !== "undefined" && (isInstance(value, GlobalSharedArrayBuffer) || value && isInstance(value.buffer, GlobalSharedArrayBuffer))) {
6474
- return fromArrayBuffer(value, encodingOrOffset, length);
6475
- }
6476
- if (typeof value === "number") {
6477
- throw new TypeError(
6478
- 'The "value" argument must not be of type number. Received type number'
6479
- );
6480
- }
6481
- const valueOf = value.valueOf && value.valueOf();
6482
- if (valueOf != null && valueOf !== value) {
6483
- return Buffer3.from(valueOf, encodingOrOffset, length);
6484
- }
6485
- const b2 = fromObject(value);
6486
- if (b2) return b2;
6487
- if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
6488
- return Buffer3.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
6489
- }
6490
- throw new TypeError(
6491
- "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
6492
- );
6493
- }
6494
- Buffer3.from = function(value, encodingOrOffset, length) {
6495
- return from(value, encodingOrOffset, length);
6496
- };
6497
- Object.setPrototypeOf(Buffer3.prototype, GlobalUint8Array.prototype);
6498
- Object.setPrototypeOf(Buffer3, GlobalUint8Array);
6499
- function assertSize(size) {
6500
- if (typeof size !== "number") {
6501
- throw new TypeError('"size" argument must be of type number');
6502
- } else if (size < 0) {
6503
- throw new RangeError('The value "' + size + '" is invalid for option "size"');
6504
- }
6505
- }
6506
- function alloc(size, fill, encoding) {
6507
- assertSize(size);
6508
- if (size <= 0) {
6509
- return createBuffer(size);
6510
- }
6511
- if (fill !== void 0) {
6512
- return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
6513
- }
6514
- return createBuffer(size);
6515
- }
6516
- Buffer3.alloc = function(size, fill, encoding) {
6517
- return alloc(size, fill, encoding);
6518
- };
6519
- function allocUnsafe(size) {
6520
- assertSize(size);
6521
- return createBuffer(size < 0 ? 0 : checked(size) | 0);
6522
- }
6523
- Buffer3.allocUnsafe = function(size) {
6524
- return allocUnsafe(size);
6525
- };
6526
- Buffer3.allocUnsafeSlow = function(size) {
6527
- return allocUnsafe(size);
6528
- };
6529
- function fromString(string, encoding) {
6530
- if (typeof encoding !== "string" || encoding === "") {
6531
- encoding = "utf8";
6532
- }
6533
- if (!Buffer3.isEncoding(encoding)) {
6534
- throw new TypeError("Unknown encoding: " + encoding);
6535
- }
6536
- const length = byteLength2(string, encoding) | 0;
6537
- let buf = createBuffer(length);
6538
- const actual = buf.write(string, encoding);
6539
- if (actual !== length) {
6540
- buf = buf.slice(0, actual);
6541
- }
6542
- return buf;
6543
- }
6544
- function fromArrayLike(array) {
6545
- const length = array.length < 0 ? 0 : checked(array.length) | 0;
6546
- const buf = createBuffer(length);
6547
- for (let i = 0; i < length; i += 1) {
6548
- buf[i] = array[i] & 255;
6549
- }
6550
- return buf;
6551
- }
6552
- function fromArrayView(arrayView) {
6553
- if (isInstance(arrayView, GlobalUint8Array)) {
6554
- const copy = new GlobalUint8Array(arrayView);
6555
- return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
6556
- }
6557
- return fromArrayLike(arrayView);
6558
- }
6559
- function fromArrayBuffer(array, byteOffset, length) {
6560
- if (byteOffset < 0 || array.byteLength < byteOffset) {
6561
- throw new RangeError('"offset" is outside of buffer bounds');
6562
- }
6563
- if (array.byteLength < byteOffset + (length || 0)) {
6564
- throw new RangeError('"length" is outside of buffer bounds');
6565
- }
6566
- let buf;
6567
- if (byteOffset === void 0 && length === void 0) {
6568
- buf = new GlobalUint8Array(array);
6569
- } else if (length === void 0) {
6570
- buf = new GlobalUint8Array(array, byteOffset);
6571
- } else {
6572
- buf = new GlobalUint8Array(array, byteOffset, length);
6573
- }
6574
- Object.setPrototypeOf(buf, Buffer3.prototype);
6575
- return buf;
6576
- }
6577
- function fromObject(obj) {
6578
- if (Buffer3.isBuffer(obj)) {
6579
- const len = checked(obj.length) | 0;
6580
- const buf = createBuffer(len);
6581
- if (buf.length === 0) {
6582
- return buf;
6583
- }
6584
- obj.copy(buf, 0, 0, len);
6585
- return buf;
6586
- }
6587
- if (obj.length !== void 0) {
6588
- if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
6589
- return createBuffer(0);
6590
- }
6591
- return fromArrayLike(obj);
6592
- }
6593
- if (obj.type === "Buffer" && Array.isArray(obj.data)) {
6594
- return fromArrayLike(obj.data);
6595
- }
6596
- }
6597
- function checked(length) {
6598
- if (length >= K_MAX_LENGTH) {
6599
- throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
6600
- }
6601
- return length | 0;
6602
- }
6603
- function SlowBuffer(length) {
6604
- if (+length != length) {
6605
- length = 0;
6606
- }
6607
- return Buffer3.alloc(+length);
6608
- }
6609
- Buffer3.isBuffer = function isBuffer2(b2) {
6610
- return b2 != null && b2._isBuffer === true && b2 !== Buffer3.prototype;
6611
- };
6612
- Buffer3.compare = function compare(a, b2) {
6613
- if (isInstance(a, GlobalUint8Array)) a = Buffer3.from(a, a.offset, a.byteLength);
6614
- if (isInstance(b2, GlobalUint8Array)) b2 = Buffer3.from(b2, b2.offset, b2.byteLength);
6615
- if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b2)) {
6616
- throw new TypeError(
6617
- 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
6618
- );
6619
- }
6620
- if (a === b2) return 0;
6621
- let x = a.length;
6622
- let y = b2.length;
6623
- for (let i = 0, len = Math.min(x, y); i < len; ++i) {
6624
- if (a[i] !== b2[i]) {
6625
- x = a[i];
6626
- y = b2[i];
6627
- break;
6628
- }
6629
- }
6630
- if (x < y) return -1;
6631
- if (y < x) return 1;
6632
- return 0;
6633
- };
6634
- Buffer3.isEncoding = function isEncoding(encoding) {
6635
- switch (String(encoding).toLowerCase()) {
6636
- case "hex":
6637
- case "utf8":
6638
- case "utf-8":
6639
- case "ascii":
6640
- case "latin1":
6641
- case "binary":
6642
- case "base64":
6643
- case "ucs2":
6644
- case "ucs-2":
6645
- case "utf16le":
6646
- case "utf-16le":
6647
- return true;
6648
- default:
6649
- return false;
6650
- }
6651
- };
6652
- Buffer3.concat = function concat2(list, length) {
6653
- if (!Array.isArray(list)) {
6654
- throw new TypeError('"list" argument must be an Array of Buffers');
6655
- }
6656
- if (list.length === 0) {
6657
- return Buffer3.alloc(0);
6658
- }
6659
- let i;
6660
- if (length === void 0) {
6661
- length = 0;
6662
- for (i = 0; i < list.length; ++i) {
6663
- length += list[i].length;
6664
- }
6665
- }
6666
- const buffer2 = Buffer3.allocUnsafe(length);
6667
- let pos = 0;
6668
- for (i = 0; i < list.length; ++i) {
6669
- let buf = list[i];
6670
- if (isInstance(buf, GlobalUint8Array)) {
6671
- if (pos + buf.length > buffer2.length) {
6672
- if (!Buffer3.isBuffer(buf)) buf = Buffer3.from(buf);
6673
- buf.copy(buffer2, pos);
6674
- } else {
6675
- GlobalUint8Array.prototype.set.call(
6676
- buffer2,
6677
- buf,
6678
- pos
6679
- );
6680
- }
6681
- } else if (!Buffer3.isBuffer(buf)) {
6682
- throw new TypeError('"list" argument must be an Array of Buffers');
6683
- } else {
6684
- buf.copy(buffer2, pos);
6685
- }
6686
- pos += buf.length;
6687
- }
6688
- return buffer2;
6689
- };
6690
- function byteLength2(string, encoding) {
6691
- if (Buffer3.isBuffer(string)) {
6692
- return string.length;
6693
- }
6694
- if (GlobalArrayBuffer.isView(string) || isInstance(string, GlobalArrayBuffer)) {
6695
- return string.byteLength;
6696
- }
6697
- if (typeof string !== "string") {
6698
- throw new TypeError(
6699
- 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string
6700
- );
6701
- }
6702
- const len = string.length;
6703
- const mustMatch = arguments.length > 2 && arguments[2] === true;
6704
- if (!mustMatch && len === 0) return 0;
6705
- let loweredCase = false;
6706
- for (; ; ) {
6707
- switch (encoding) {
6708
- case "ascii":
6709
- case "latin1":
6710
- case "binary":
6711
- return len;
6712
- case "utf8":
6713
- case "utf-8":
6714
- return utf8ToBytes2(string).length;
6715
- case "ucs2":
6716
- case "ucs-2":
6717
- case "utf16le":
6718
- case "utf-16le":
6719
- return len * 2;
6720
- case "hex":
6721
- return len >>> 1;
6722
- case "base64":
6723
- return base64ToBytes(string).length;
6724
- default:
6725
- if (loweredCase) {
6726
- return mustMatch ? -1 : utf8ToBytes2(string).length;
6727
- }
6728
- encoding = ("" + encoding).toLowerCase();
6729
- loweredCase = true;
6730
- }
6731
- }
6732
- }
6733
- Buffer3.byteLength = byteLength2;
6734
- function slowToString(encoding, start, end) {
6735
- let loweredCase = false;
6736
- if (start === void 0 || start < 0) {
6737
- start = 0;
6738
- }
6739
- if (start > this.length) {
6740
- return "";
6741
- }
6742
- if (end === void 0 || end > this.length) {
6743
- end = this.length;
6744
- }
6745
- if (end <= 0) {
6746
- return "";
6747
- }
6748
- end >>>= 0;
6749
- start >>>= 0;
6750
- if (end <= start) {
6751
- return "";
6752
- }
6753
- if (!encoding) encoding = "utf8";
6754
- while (true) {
6755
- switch (encoding) {
6756
- case "hex":
6757
- return hexSlice(this, start, end);
6758
- case "utf8":
6759
- case "utf-8":
6760
- return utf8Slice(this, start, end);
6761
- case "ascii":
6762
- return asciiSlice(this, start, end);
6763
- case "latin1":
6764
- case "binary":
6765
- return latin1Slice(this, start, end);
6766
- case "base64":
6767
- return base64Slice(this, start, end);
6768
- case "ucs2":
6769
- case "ucs-2":
6770
- case "utf16le":
6771
- case "utf-16le":
6772
- return utf16leSlice(this, start, end);
6773
- default:
6774
- if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
6775
- encoding = (encoding + "").toLowerCase();
6776
- loweredCase = true;
6777
- }
6778
- }
6779
- }
6780
- Buffer3.prototype._isBuffer = true;
6781
- function swap(b2, n2, m) {
6782
- const i = b2[n2];
6783
- b2[n2] = b2[m];
6784
- b2[m] = i;
6785
- }
6786
- Buffer3.prototype.swap16 = function swap16() {
6787
- const len = this.length;
6788
- if (len % 2 !== 0) {
6789
- throw new RangeError("Buffer size must be a multiple of 16-bits");
6790
- }
6791
- for (let i = 0; i < len; i += 2) {
6792
- swap(this, i, i + 1);
6793
- }
6794
- return this;
6795
- };
6796
- Buffer3.prototype.swap32 = function swap32() {
6797
- const len = this.length;
6798
- if (len % 4 !== 0) {
6799
- throw new RangeError("Buffer size must be a multiple of 32-bits");
6800
- }
6801
- for (let i = 0; i < len; i += 4) {
6802
- swap(this, i, i + 3);
6803
- swap(this, i + 1, i + 2);
6804
- }
6805
- return this;
6806
- };
6807
- Buffer3.prototype.swap64 = function swap64() {
6808
- const len = this.length;
6809
- if (len % 8 !== 0) {
6810
- throw new RangeError("Buffer size must be a multiple of 64-bits");
6811
- }
6812
- for (let i = 0; i < len; i += 8) {
6813
- swap(this, i, i + 7);
6814
- swap(this, i + 1, i + 6);
6815
- swap(this, i + 2, i + 5);
6816
- swap(this, i + 3, i + 4);
6817
- }
6818
- return this;
6819
- };
6820
- Buffer3.prototype.toString = function toString32() {
6821
- const length = this.length;
6822
- if (length === 0) return "";
6823
- if (arguments.length === 0) return utf8Slice(this, 0, length);
6824
- return slowToString.apply(this, arguments);
6825
- };
6826
- Buffer3.prototype.toLocaleString = Buffer3.prototype.toString;
6827
- Buffer3.prototype.equals = function equals(b2) {
6828
- if (!Buffer3.isBuffer(b2)) throw new TypeError("Argument must be a Buffer");
6829
- if (this === b2) return true;
6830
- return Buffer3.compare(this, b2) === 0;
6831
- };
6832
- Buffer3.prototype.inspect = function inspect() {
6833
- let str = "";
6834
- const max2 = exports.INSPECT_MAX_BYTES;
6835
- str = this.toString("hex", 0, max2).replace(/(.{2})/g, "$1 ").trim();
6836
- if (this.length > max2) str += " ... ";
6837
- return "<Buffer " + str + ">";
6838
- };
6839
- if (customInspectSymbol) {
6840
- Buffer3.prototype[customInspectSymbol] = Buffer3.prototype.inspect;
6841
- }
6842
- Buffer3.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
6843
- if (isInstance(target, GlobalUint8Array)) {
6844
- target = Buffer3.from(target, target.offset, target.byteLength);
6845
- }
6846
- if (!Buffer3.isBuffer(target)) {
6847
- throw new TypeError(
6848
- 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
6849
- );
6850
- }
6851
- if (start === void 0) {
6852
- start = 0;
6853
- }
6854
- if (end === void 0) {
6855
- end = target ? target.length : 0;
6856
- }
6857
- if (thisStart === void 0) {
6858
- thisStart = 0;
6859
- }
6860
- if (thisEnd === void 0) {
6861
- thisEnd = this.length;
6862
- }
6863
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
6864
- throw new RangeError("out of range index");
6865
- }
6866
- if (thisStart >= thisEnd && start >= end) {
6867
- return 0;
6868
- }
6869
- if (thisStart >= thisEnd) {
6870
- return -1;
6871
- }
6872
- if (start >= end) {
6873
- return 1;
6874
- }
6875
- start >>>= 0;
6876
- end >>>= 0;
6877
- thisStart >>>= 0;
6878
- thisEnd >>>= 0;
6879
- if (this === target) return 0;
6880
- let x = thisEnd - thisStart;
6881
- let y = end - start;
6882
- const len = Math.min(x, y);
6883
- const thisCopy = this.slice(thisStart, thisEnd);
6884
- const targetCopy = target.slice(start, end);
6885
- for (let i = 0; i < len; ++i) {
6886
- if (thisCopy[i] !== targetCopy[i]) {
6887
- x = thisCopy[i];
6888
- y = targetCopy[i];
6889
- break;
6890
- }
6891
- }
6892
- if (x < y) return -1;
6893
- if (y < x) return 1;
6894
- return 0;
6895
- };
6896
- function bidirectionalIndexOf(buffer2, val, byteOffset, encoding, dir) {
6897
- if (buffer2.length === 0) return -1;
6898
- if (typeof byteOffset === "string") {
6899
- encoding = byteOffset;
6900
- byteOffset = 0;
6901
- } else if (byteOffset > 2147483647) {
6902
- byteOffset = 2147483647;
6903
- } else if (byteOffset < -2147483648) {
6904
- byteOffset = -2147483648;
6905
- }
6906
- byteOffset = +byteOffset;
6907
- if (numberIsNaN(byteOffset)) {
6908
- byteOffset = dir ? 0 : buffer2.length - 1;
6909
- }
6910
- if (byteOffset < 0) byteOffset = buffer2.length + byteOffset;
6911
- if (byteOffset >= buffer2.length) {
6912
- if (dir) return -1;
6913
- else byteOffset = buffer2.length - 1;
6914
- } else if (byteOffset < 0) {
6915
- if (dir) byteOffset = 0;
6916
- else return -1;
6917
- }
6918
- if (typeof val === "string") {
6919
- val = Buffer3.from(val, encoding);
6920
- }
6921
- if (Buffer3.isBuffer(val)) {
6922
- if (val.length === 0) {
6923
- return -1;
6924
- }
6925
- return arrayIndexOf(buffer2, val, byteOffset, encoding, dir);
6926
- } else if (typeof val === "number") {
6927
- val = val & 255;
6928
- if (typeof GlobalUint8Array.prototype.indexOf === "function") {
6929
- if (dir) {
6930
- return GlobalUint8Array.prototype.indexOf.call(buffer2, val, byteOffset);
6931
- } else {
6932
- return GlobalUint8Array.prototype.lastIndexOf.call(buffer2, val, byteOffset);
6933
- }
6934
- }
6935
- return arrayIndexOf(buffer2, [val], byteOffset, encoding, dir);
6936
- }
6937
- throw new TypeError("val must be string, number or Buffer");
6938
- }
6939
- function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
6940
- let indexSize = 1;
6941
- let arrLength = arr.length;
6942
- let valLength = val.length;
6943
- if (encoding !== void 0) {
6944
- encoding = String(encoding).toLowerCase();
6945
- if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
6946
- if (arr.length < 2 || val.length < 2) {
6947
- return -1;
6948
- }
6949
- indexSize = 2;
6950
- arrLength /= 2;
6951
- valLength /= 2;
6952
- byteOffset /= 2;
6953
- }
6954
- }
6955
- function read(buf, i2) {
6956
- if (indexSize === 1) {
6957
- return buf[i2];
6958
- } else {
6959
- return buf.readUInt16BE(i2 * indexSize);
6960
- }
6961
- }
6962
- let i;
6963
- if (dir) {
6964
- let foundIndex = -1;
6965
- for (i = byteOffset; i < arrLength; i++) {
6966
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
6967
- if (foundIndex === -1) foundIndex = i;
6968
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
6969
- } else {
6970
- if (foundIndex !== -1) i -= i - foundIndex;
6971
- foundIndex = -1;
6972
- }
6973
- }
6974
- } else {
6975
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
6976
- for (i = byteOffset; i >= 0; i--) {
6977
- let found = true;
6978
- for (let j = 0; j < valLength; j++) {
6979
- if (read(arr, i + j) !== read(val, j)) {
6980
- found = false;
6981
- break;
6982
- }
6983
- }
6984
- if (found) return i;
6985
- }
6986
- }
6987
- return -1;
6988
- }
6989
- Buffer3.prototype.includes = function includes2(val, byteOffset, encoding) {
6990
- return this.indexOf(val, byteOffset, encoding) !== -1;
6991
- };
6992
- Buffer3.prototype.indexOf = function indexOf2(val, byteOffset, encoding) {
6993
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
6994
- };
6995
- Buffer3.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
6996
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
6997
- };
6998
- function hexWrite(buf, string, offset, length) {
6999
- offset = Number(offset) || 0;
7000
- const remaining = buf.length - offset;
7001
- if (!length) {
7002
- length = remaining;
7003
- } else {
7004
- length = Number(length);
7005
- if (length > remaining) {
7006
- length = remaining;
7007
- }
7008
- }
7009
- const strLen = string.length;
7010
- if (length > strLen / 2) {
7011
- length = strLen / 2;
7012
- }
7013
- let i;
7014
- for (i = 0; i < length; ++i) {
7015
- const parsed = parseInt(string.substr(i * 2, 2), 16);
7016
- if (numberIsNaN(parsed)) return i;
7017
- buf[offset + i] = parsed;
7018
- }
7019
- return i;
7020
- }
7021
- function utf8Write(buf, string, offset, length) {
7022
- return blitBuffer(utf8ToBytes2(string, buf.length - offset), buf, offset, length);
7023
- }
7024
- function asciiWrite(buf, string, offset, length) {
7025
- return blitBuffer(asciiToBytes(string), buf, offset, length);
7026
- }
7027
- function base64Write(buf, string, offset, length) {
7028
- return blitBuffer(base64ToBytes(string), buf, offset, length);
7029
- }
7030
- function ucs2Write(buf, string, offset, length) {
7031
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
7032
- }
7033
- Buffer3.prototype.write = function write(string, offset, length, encoding) {
7034
- if (offset === void 0) {
7035
- encoding = "utf8";
7036
- length = this.length;
7037
- offset = 0;
7038
- } else if (length === void 0 && typeof offset === "string") {
7039
- encoding = offset;
7040
- length = this.length;
7041
- offset = 0;
7042
- } else if (isFinite(offset)) {
7043
- offset = offset >>> 0;
7044
- if (isFinite(length)) {
7045
- length = length >>> 0;
7046
- if (encoding === void 0) encoding = "utf8";
7047
- } else {
7048
- encoding = length;
7049
- length = void 0;
7050
- }
7051
- } else {
7052
- throw new Error(
7053
- "Buffer.write(string, encoding, offset[, length]) is no longer supported"
7054
- );
7055
- }
7056
- const remaining = this.length - offset;
7057
- if (length === void 0 || length > remaining) length = remaining;
7058
- if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
7059
- throw new RangeError("Attempt to write outside buffer bounds");
7060
- }
7061
- if (!encoding) encoding = "utf8";
7062
- let loweredCase = false;
7063
- for (; ; ) {
7064
- switch (encoding) {
7065
- case "hex":
7066
- return hexWrite(this, string, offset, length);
7067
- case "utf8":
7068
- case "utf-8":
7069
- return utf8Write(this, string, offset, length);
7070
- case "ascii":
7071
- case "latin1":
7072
- case "binary":
7073
- return asciiWrite(this, string, offset, length);
7074
- case "base64":
7075
- return base64Write(this, string, offset, length);
7076
- case "ucs2":
7077
- case "ucs-2":
7078
- case "utf16le":
7079
- case "utf-16le":
7080
- return ucs2Write(this, string, offset, length);
7081
- default:
7082
- if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
7083
- encoding = ("" + encoding).toLowerCase();
7084
- loweredCase = true;
7085
- }
7086
- }
7087
- };
7088
- Buffer3.prototype.toJSON = function toJSON22() {
7089
- return {
7090
- type: "Buffer",
7091
- data: Array.prototype.slice.call(this._arr || this, 0)
7092
- };
7093
- };
7094
- function base64Slice(buf, start, end) {
7095
- if (start === 0 && end === buf.length) {
7096
- return base64.fromByteArray(buf);
7097
- } else {
7098
- return base64.fromByteArray(buf.slice(start, end));
7099
- }
7100
- }
7101
- function utf8Slice(buf, start, end) {
7102
- end = Math.min(buf.length, end);
7103
- const res = [];
7104
- let i = start;
7105
- while (i < end) {
7106
- const firstByte = buf[i];
7107
- let codePoint = null;
7108
- let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
7109
- if (i + bytesPerSequence <= end) {
7110
- let secondByte, thirdByte, fourthByte, tempCodePoint;
7111
- switch (bytesPerSequence) {
7112
- case 1:
7113
- if (firstByte < 128) {
7114
- codePoint = firstByte;
7115
- }
7116
- break;
7117
- case 2:
7118
- secondByte = buf[i + 1];
7119
- if ((secondByte & 192) === 128) {
7120
- tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
7121
- if (tempCodePoint > 127) {
7122
- codePoint = tempCodePoint;
7123
- }
7124
- }
7125
- break;
7126
- case 3:
7127
- secondByte = buf[i + 1];
7128
- thirdByte = buf[i + 2];
7129
- if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
7130
- tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
7131
- if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
7132
- codePoint = tempCodePoint;
7133
- }
7134
- }
7135
- break;
7136
- case 4:
7137
- secondByte = buf[i + 1];
7138
- thirdByte = buf[i + 2];
7139
- fourthByte = buf[i + 3];
7140
- if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
7141
- tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
7142
- if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
7143
- codePoint = tempCodePoint;
7144
- }
7145
- }
7146
- }
7147
- }
7148
- if (codePoint === null) {
7149
- codePoint = 65533;
7150
- bytesPerSequence = 1;
7151
- } else if (codePoint > 65535) {
7152
- codePoint -= 65536;
7153
- res.push(codePoint >>> 10 & 1023 | 55296);
7154
- codePoint = 56320 | codePoint & 1023;
7155
- }
7156
- res.push(codePoint);
7157
- i += bytesPerSequence;
7158
- }
7159
- return decodeCodePointsArray(res);
7160
- }
7161
- const MAX_ARGUMENTS_LENGTH = 4096;
7162
- function decodeCodePointsArray(codePoints) {
7163
- const len = codePoints.length;
7164
- if (len <= MAX_ARGUMENTS_LENGTH) {
7165
- return String.fromCharCode.apply(String, codePoints);
7166
- }
7167
- let res = "";
7168
- let i = 0;
7169
- while (i < len) {
7170
- res += String.fromCharCode.apply(
7171
- String,
7172
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
7173
- );
7174
- }
7175
- return res;
7176
- }
7177
- function asciiSlice(buf, start, end) {
7178
- let ret = "";
7179
- end = Math.min(buf.length, end);
7180
- for (let i = start; i < end; ++i) {
7181
- ret += String.fromCharCode(buf[i] & 127);
7182
- }
7183
- return ret;
7184
- }
7185
- function latin1Slice(buf, start, end) {
7186
- let ret = "";
7187
- end = Math.min(buf.length, end);
7188
- for (let i = start; i < end; ++i) {
7189
- ret += String.fromCharCode(buf[i]);
7190
- }
7191
- return ret;
7192
- }
7193
- function hexSlice(buf, start, end) {
7194
- const len = buf.length;
7195
- if (!start || start < 0) start = 0;
7196
- if (!end || end < 0 || end > len) end = len;
7197
- let out = "";
7198
- for (let i = start; i < end; ++i) {
7199
- out += hexSliceLookupTable[buf[i]];
7200
- }
7201
- return out;
7202
- }
7203
- function utf16leSlice(buf, start, end) {
7204
- const bytes2 = buf.slice(start, end);
7205
- let res = "";
7206
- for (let i = 0; i < bytes2.length - 1; i += 2) {
7207
- res += String.fromCharCode(bytes2[i] + bytes2[i + 1] * 256);
7208
- }
7209
- return res;
7210
- }
7211
- Buffer3.prototype.slice = function slice(start, end) {
7212
- const len = this.length;
7213
- start = ~~start;
7214
- end = end === void 0 ? len : ~~end;
7215
- if (start < 0) {
7216
- start += len;
7217
- if (start < 0) start = 0;
7218
- } else if (start > len) {
7219
- start = len;
7220
- }
7221
- if (end < 0) {
7222
- end += len;
7223
- if (end < 0) end = 0;
7224
- } else if (end > len) {
7225
- end = len;
7226
- }
7227
- if (end < start) end = start;
7228
- const newBuf = this.subarray(start, end);
7229
- Object.setPrototypeOf(newBuf, Buffer3.prototype);
7230
- return newBuf;
7231
- };
7232
- function checkOffset(offset, ext, length) {
7233
- if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
7234
- if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
7235
- }
7236
- Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = function readUIntLE(offset, byteLength3, noAssert) {
7237
- offset = offset >>> 0;
7238
- byteLength3 = byteLength3 >>> 0;
7239
- if (!noAssert) checkOffset(offset, byteLength3, this.length);
7240
- let val = this[offset];
7241
- let mul = 1;
7242
- let i = 0;
7243
- while (++i < byteLength3 && (mul *= 256)) {
7244
- val += this[offset + i] * mul;
7245
- }
7246
- return val;
7247
- };
7248
- Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = function readUIntBE(offset, byteLength3, noAssert) {
7249
- offset = offset >>> 0;
7250
- byteLength3 = byteLength3 >>> 0;
7251
- if (!noAssert) {
7252
- checkOffset(offset, byteLength3, this.length);
7253
- }
7254
- let val = this[offset + --byteLength3];
7255
- let mul = 1;
7256
- while (byteLength3 > 0 && (mul *= 256)) {
7257
- val += this[offset + --byteLength3] * mul;
7258
- }
7259
- return val;
7260
- };
7261
- Buffer3.prototype.readUint8 = Buffer3.prototype.readUInt8 = function readUInt8(offset, noAssert) {
7262
- offset = offset >>> 0;
7263
- if (!noAssert) checkOffset(offset, 1, this.length);
7264
- return this[offset];
7265
- };
7266
- Buffer3.prototype.readUint16LE = Buffer3.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
7267
- offset = offset >>> 0;
7268
- if (!noAssert) checkOffset(offset, 2, this.length);
7269
- return this[offset] | this[offset + 1] << 8;
7270
- };
7271
- Buffer3.prototype.readUint16BE = Buffer3.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
7272
- offset = offset >>> 0;
7273
- if (!noAssert) checkOffset(offset, 2, this.length);
7274
- return this[offset] << 8 | this[offset + 1];
7275
- };
7276
- Buffer3.prototype.readUint32LE = Buffer3.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
7277
- offset = offset >>> 0;
7278
- if (!noAssert) checkOffset(offset, 4, this.length);
7279
- return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
7280
- };
7281
- Buffer3.prototype.readUint32BE = Buffer3.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
7282
- offset = offset >>> 0;
7283
- if (!noAssert) checkOffset(offset, 4, this.length);
7284
- return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
7285
- };
7286
- Buffer3.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
7287
- offset = offset >>> 0;
7288
- validateNumber(offset, "offset");
7289
- const first = this[offset];
7290
- const last = this[offset + 7];
7291
- if (first === void 0 || last === void 0) {
7292
- boundsError(offset, this.length - 8);
7293
- }
7294
- const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
7295
- const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
7296
- return BigInt(lo) + (BigInt(hi) << BigInt(32));
7297
- });
7298
- Buffer3.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
7299
- offset = offset >>> 0;
7300
- validateNumber(offset, "offset");
7301
- const first = this[offset];
7302
- const last = this[offset + 7];
7303
- if (first === void 0 || last === void 0) {
7304
- boundsError(offset, this.length - 8);
7305
- }
7306
- const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
7307
- const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
7308
- return (BigInt(hi) << BigInt(32)) + BigInt(lo);
7309
- });
7310
- Buffer3.prototype.readIntLE = function readIntLE(offset, byteLength3, noAssert) {
7311
- offset = offset >>> 0;
7312
- byteLength3 = byteLength3 >>> 0;
7313
- if (!noAssert) checkOffset(offset, byteLength3, this.length);
7314
- let val = this[offset];
7315
- let mul = 1;
7316
- let i = 0;
7317
- while (++i < byteLength3 && (mul *= 256)) {
7318
- val += this[offset + i] * mul;
7319
- }
7320
- mul *= 128;
7321
- if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
7322
- return val;
7323
- };
7324
- Buffer3.prototype.readIntBE = function readIntBE(offset, byteLength3, noAssert) {
7325
- offset = offset >>> 0;
7326
- byteLength3 = byteLength3 >>> 0;
7327
- if (!noAssert) checkOffset(offset, byteLength3, this.length);
7328
- let i = byteLength3;
7329
- let mul = 1;
7330
- let val = this[offset + --i];
7331
- while (i > 0 && (mul *= 256)) {
7332
- val += this[offset + --i] * mul;
7333
- }
7334
- mul *= 128;
7335
- if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
7336
- return val;
7337
- };
7338
- Buffer3.prototype.readInt8 = function readInt8(offset, noAssert) {
7339
- offset = offset >>> 0;
7340
- if (!noAssert) checkOffset(offset, 1, this.length);
7341
- if (!(this[offset] & 128)) return this[offset];
7342
- return (255 - this[offset] + 1) * -1;
7343
- };
7344
- Buffer3.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
7345
- offset = offset >>> 0;
7346
- if (!noAssert) checkOffset(offset, 2, this.length);
7347
- const val = this[offset] | this[offset + 1] << 8;
7348
- return val & 32768 ? val | 4294901760 : val;
7349
- };
7350
- Buffer3.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
7351
- offset = offset >>> 0;
7352
- if (!noAssert) checkOffset(offset, 2, this.length);
7353
- const val = this[offset + 1] | this[offset] << 8;
7354
- return val & 32768 ? val | 4294901760 : val;
7355
- };
7356
- Buffer3.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
7357
- offset = offset >>> 0;
7358
- if (!noAssert) checkOffset(offset, 4, this.length);
7359
- return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
7360
- };
7361
- Buffer3.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
7362
- offset = offset >>> 0;
7363
- if (!noAssert) checkOffset(offset, 4, this.length);
7364
- return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
7365
- };
7366
- Buffer3.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
7367
- offset = offset >>> 0;
7368
- validateNumber(offset, "offset");
7369
- const first = this[offset];
7370
- const last = this[offset + 7];
7371
- if (first === void 0 || last === void 0) {
7372
- boundsError(offset, this.length - 8);
7373
- }
7374
- const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
7375
- return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
7376
- });
7377
- Buffer3.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
7378
- offset = offset >>> 0;
7379
- validateNumber(offset, "offset");
7380
- const first = this[offset];
7381
- const last = this[offset + 7];
7382
- if (first === void 0 || last === void 0) {
7383
- boundsError(offset, this.length - 8);
7384
- }
7385
- const val = (first << 24) + // Overflow
7386
- this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
7387
- return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
7388
- });
7389
- Buffer3.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
7390
- offset = offset >>> 0;
7391
- if (!noAssert) checkOffset(offset, 4, this.length);
7392
- return ieee754$1$1.read(this, offset, true, 23, 4);
7393
- };
7394
- Buffer3.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
7395
- offset = offset >>> 0;
7396
- if (!noAssert) checkOffset(offset, 4, this.length);
7397
- return ieee754$1$1.read(this, offset, false, 23, 4);
7398
- };
7399
- Buffer3.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
7400
- offset = offset >>> 0;
7401
- if (!noAssert) checkOffset(offset, 8, this.length);
7402
- return ieee754$1$1.read(this, offset, true, 52, 8);
7403
- };
7404
- Buffer3.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
7405
- offset = offset >>> 0;
7406
- if (!noAssert) checkOffset(offset, 8, this.length);
7407
- return ieee754$1$1.read(this, offset, false, 52, 8);
7408
- };
7409
- function checkInt(buf, value, offset, ext, max2, min) {
7410
- if (!Buffer3.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
7411
- if (value > max2 || value < min) throw new RangeError('"value" argument is out of bounds');
7412
- if (offset + ext > buf.length) throw new RangeError("Index out of range");
7413
- }
7414
- Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength3, noAssert) {
7415
- value = +value;
7416
- offset = offset >>> 0;
7417
- byteLength3 = byteLength3 >>> 0;
7418
- if (!noAssert) {
7419
- const maxBytes = Math.pow(2, 8 * byteLength3) - 1;
7420
- checkInt(this, value, offset, byteLength3, maxBytes, 0);
7421
- }
7422
- let mul = 1;
7423
- let i = 0;
7424
- this[offset] = value & 255;
7425
- while (++i < byteLength3 && (mul *= 256)) {
7426
- this[offset + i] = value / mul & 255;
7427
- }
7428
- return offset + byteLength3;
7429
- };
7430
- Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength3, noAssert) {
7431
- value = +value;
7432
- offset = offset >>> 0;
7433
- byteLength3 = byteLength3 >>> 0;
7434
- if (!noAssert) {
7435
- const maxBytes = Math.pow(2, 8 * byteLength3) - 1;
7436
- checkInt(this, value, offset, byteLength3, maxBytes, 0);
7437
- }
7438
- let i = byteLength3 - 1;
7439
- let mul = 1;
7440
- this[offset + i] = value & 255;
7441
- while (--i >= 0 && (mul *= 256)) {
7442
- this[offset + i] = value / mul & 255;
7443
- }
7444
- return offset + byteLength3;
7445
- };
7446
- Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
7447
- value = +value;
7448
- offset = offset >>> 0;
7449
- if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
7450
- this[offset] = value & 255;
7451
- return offset + 1;
7452
- };
7453
- Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
7454
- value = +value;
7455
- offset = offset >>> 0;
7456
- if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
7457
- this[offset] = value & 255;
7458
- this[offset + 1] = value >>> 8;
7459
- return offset + 2;
7460
- };
7461
- Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
7462
- value = +value;
7463
- offset = offset >>> 0;
7464
- if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
7465
- this[offset] = value >>> 8;
7466
- this[offset + 1] = value & 255;
7467
- return offset + 2;
7468
- };
7469
- Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
7470
- value = +value;
7471
- offset = offset >>> 0;
7472
- if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
7473
- this[offset + 3] = value >>> 24;
7474
- this[offset + 2] = value >>> 16;
7475
- this[offset + 1] = value >>> 8;
7476
- this[offset] = value & 255;
7477
- return offset + 4;
7478
- };
7479
- Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
7480
- value = +value;
7481
- offset = offset >>> 0;
7482
- if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
7483
- this[offset] = value >>> 24;
7484
- this[offset + 1] = value >>> 16;
7485
- this[offset + 2] = value >>> 8;
7486
- this[offset + 3] = value & 255;
7487
- return offset + 4;
7488
- };
7489
- function wrtBigUInt64LE(buf, value, offset, min, max2) {
7490
- checkIntBI(value, min, max2, buf, offset, 7);
7491
- let lo = Number(value & BigInt(4294967295));
7492
- buf[offset++] = lo;
7493
- lo = lo >> 8;
7494
- buf[offset++] = lo;
7495
- lo = lo >> 8;
7496
- buf[offset++] = lo;
7497
- lo = lo >> 8;
7498
- buf[offset++] = lo;
7499
- let hi = Number(value >> BigInt(32) & BigInt(4294967295));
7500
- buf[offset++] = hi;
7501
- hi = hi >> 8;
7502
- buf[offset++] = hi;
7503
- hi = hi >> 8;
7504
- buf[offset++] = hi;
7505
- hi = hi >> 8;
7506
- buf[offset++] = hi;
7507
- return offset;
7508
- }
7509
- function wrtBigUInt64BE(buf, value, offset, min, max2) {
7510
- checkIntBI(value, min, max2, buf, offset, 7);
7511
- let lo = Number(value & BigInt(4294967295));
7512
- buf[offset + 7] = lo;
7513
- lo = lo >> 8;
7514
- buf[offset + 6] = lo;
7515
- lo = lo >> 8;
7516
- buf[offset + 5] = lo;
7517
- lo = lo >> 8;
7518
- buf[offset + 4] = lo;
7519
- let hi = Number(value >> BigInt(32) & BigInt(4294967295));
7520
- buf[offset + 3] = hi;
7521
- hi = hi >> 8;
7522
- buf[offset + 2] = hi;
7523
- hi = hi >> 8;
7524
- buf[offset + 1] = hi;
7525
- hi = hi >> 8;
7526
- buf[offset] = hi;
7527
- return offset + 8;
7528
- }
7529
- Buffer3.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
7530
- return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
7531
- });
7532
- Buffer3.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
7533
- return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
7534
- });
7535
- Buffer3.prototype.writeIntLE = function writeIntLE(value, offset, byteLength3, noAssert) {
7536
- value = +value;
7537
- offset = offset >>> 0;
7538
- if (!noAssert) {
7539
- const limit = Math.pow(2, 8 * byteLength3 - 1);
7540
- checkInt(this, value, offset, byteLength3, limit - 1, -limit);
7541
- }
7542
- let i = 0;
7543
- let mul = 1;
7544
- let sub = 0;
7545
- this[offset] = value & 255;
7546
- while (++i < byteLength3 && (mul *= 256)) {
7547
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
7548
- sub = 1;
7549
- }
7550
- this[offset + i] = (value / mul >> 0) - sub & 255;
7551
- }
7552
- return offset + byteLength3;
7553
- };
7554
- Buffer3.prototype.writeIntBE = function writeIntBE(value, offset, byteLength3, noAssert) {
7555
- value = +value;
7556
- offset = offset >>> 0;
7557
- if (!noAssert) {
7558
- const limit = Math.pow(2, 8 * byteLength3 - 1);
7559
- checkInt(this, value, offset, byteLength3, limit - 1, -limit);
7560
- }
7561
- let i = byteLength3 - 1;
7562
- let mul = 1;
7563
- let sub = 0;
7564
- this[offset + i] = value & 255;
7565
- while (--i >= 0 && (mul *= 256)) {
7566
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
7567
- sub = 1;
7568
- }
7569
- this[offset + i] = (value / mul >> 0) - sub & 255;
7570
- }
7571
- return offset + byteLength3;
7572
- };
7573
- Buffer3.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
7574
- value = +value;
7575
- offset = offset >>> 0;
7576
- if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
7577
- if (value < 0) value = 255 + value + 1;
7578
- this[offset] = value & 255;
7579
- return offset + 1;
7580
- };
7581
- Buffer3.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
7582
- value = +value;
7583
- offset = offset >>> 0;
7584
- if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
7585
- this[offset] = value & 255;
7586
- this[offset + 1] = value >>> 8;
7587
- return offset + 2;
7588
- };
7589
- Buffer3.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
7590
- value = +value;
7591
- offset = offset >>> 0;
7592
- if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
7593
- this[offset] = value >>> 8;
7594
- this[offset + 1] = value & 255;
7595
- return offset + 2;
7596
- };
7597
- Buffer3.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
7598
- value = +value;
7599
- offset = offset >>> 0;
7600
- if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
7601
- this[offset] = value & 255;
7602
- this[offset + 1] = value >>> 8;
7603
- this[offset + 2] = value >>> 16;
7604
- this[offset + 3] = value >>> 24;
7605
- return offset + 4;
7606
- };
7607
- Buffer3.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
7608
- value = +value;
7609
- offset = offset >>> 0;
7610
- if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
7611
- if (value < 0) value = 4294967295 + value + 1;
7612
- this[offset] = value >>> 24;
7613
- this[offset + 1] = value >>> 16;
7614
- this[offset + 2] = value >>> 8;
7615
- this[offset + 3] = value & 255;
7616
- return offset + 4;
7617
- };
7618
- Buffer3.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
7619
- return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
7620
- });
7621
- Buffer3.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
7622
- return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
7623
- });
7624
- function checkIEEE754(buf, value, offset, ext, max2, min) {
7625
- if (offset + ext > buf.length) throw new RangeError("Index out of range");
7626
- if (offset < 0) throw new RangeError("Index out of range");
7627
- }
7628
- function writeFloat(buf, value, offset, littleEndian, noAssert) {
7629
- value = +value;
7630
- offset = offset >>> 0;
7631
- if (!noAssert) {
7632
- checkIEEE754(buf, value, offset, 4);
7633
- }
7634
- ieee754$1$1.write(buf, value, offset, littleEndian, 23, 4);
7635
- return offset + 4;
7636
- }
7637
- Buffer3.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
7638
- return writeFloat(this, value, offset, true, noAssert);
7639
- };
7640
- Buffer3.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
7641
- return writeFloat(this, value, offset, false, noAssert);
7642
- };
7643
- function writeDouble(buf, value, offset, littleEndian, noAssert) {
7644
- value = +value;
7645
- offset = offset >>> 0;
7646
- if (!noAssert) {
7647
- checkIEEE754(buf, value, offset, 8);
7648
- }
7649
- ieee754$1$1.write(buf, value, offset, littleEndian, 52, 8);
7650
- return offset + 8;
7651
- }
7652
- Buffer3.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
7653
- return writeDouble(this, value, offset, true, noAssert);
7654
- };
7655
- Buffer3.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
7656
- return writeDouble(this, value, offset, false, noAssert);
7657
- };
7658
- Buffer3.prototype.copy = function copy(target, targetStart, start, end) {
7659
- if (!Buffer3.isBuffer(target)) throw new TypeError("argument should be a Buffer");
7660
- if (!start) start = 0;
7661
- if (!end && end !== 0) end = this.length;
7662
- if (targetStart >= target.length) targetStart = target.length;
7663
- if (!targetStart) targetStart = 0;
7664
- if (end > 0 && end < start) end = start;
7665
- if (end === start) return 0;
7666
- if (target.length === 0 || this.length === 0) return 0;
7667
- if (targetStart < 0) {
7668
- throw new RangeError("targetStart out of bounds");
7669
- }
7670
- if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
7671
- if (end < 0) throw new RangeError("sourceEnd out of bounds");
7672
- if (end > this.length) end = this.length;
7673
- if (target.length - targetStart < end - start) {
7674
- end = target.length - targetStart + start;
7675
- }
7676
- const len = end - start;
7677
- if (this === target && typeof GlobalUint8Array.prototype.copyWithin === "function") {
7678
- this.copyWithin(targetStart, start, end);
7679
- } else {
7680
- GlobalUint8Array.prototype.set.call(
7681
- target,
7682
- this.subarray(start, end),
7683
- targetStart
7684
- );
7685
- }
7686
- return len;
7687
- };
7688
- Buffer3.prototype.fill = function fill(val, start, end, encoding) {
7689
- if (typeof val === "string") {
7690
- if (typeof start === "string") {
7691
- encoding = start;
7692
- start = 0;
7693
- end = this.length;
7694
- } else if (typeof end === "string") {
7695
- encoding = end;
7696
- end = this.length;
7697
- }
7698
- if (encoding !== void 0 && typeof encoding !== "string") {
7699
- throw new TypeError("encoding must be a string");
7700
- }
7701
- if (typeof encoding === "string" && !Buffer3.isEncoding(encoding)) {
7702
- throw new TypeError("Unknown encoding: " + encoding);
7703
- }
7704
- if (val.length === 1) {
7705
- const code2 = val.charCodeAt(0);
7706
- if (encoding === "utf8" && code2 < 128 || encoding === "latin1") {
7707
- val = code2;
7708
- }
7709
- }
7710
- } else if (typeof val === "number") {
7711
- val = val & 255;
7712
- } else if (typeof val === "boolean") {
7713
- val = Number(val);
7714
- }
7715
- if (start < 0 || this.length < start || this.length < end) {
7716
- throw new RangeError("Out of range index");
7717
- }
7718
- if (end <= start) {
7719
- return this;
7720
- }
7721
- start = start >>> 0;
7722
- end = end === void 0 ? this.length : end >>> 0;
7723
- if (!val) val = 0;
7724
- let i;
7725
- if (typeof val === "number") {
7726
- for (i = start; i < end; ++i) {
7727
- this[i] = val;
7728
- }
7729
- } else {
7730
- const bytes2 = Buffer3.isBuffer(val) ? val : Buffer3.from(val, encoding);
7731
- const len = bytes2.length;
7732
- if (len === 0) {
7733
- throw new TypeError('The value "' + val + '" is invalid for argument "value"');
7734
- }
7735
- for (i = 0; i < end - start; ++i) {
7736
- this[i + start] = bytes2[i % len];
7737
- }
7738
- }
7739
- return this;
7740
- };
7741
- const errors = {};
7742
- function E(sym, getMessage, Base) {
7743
- errors[sym] = class NodeError extends Base {
7744
- constructor() {
7745
- super();
7746
- Object.defineProperty(this, "message", {
7747
- value: getMessage.apply(this, arguments),
7748
- writable: true,
7749
- configurable: true
7750
- });
7751
- this.name = `${this.name} [${sym}]`;
7752
- this.stack;
7753
- delete this.name;
7754
- }
7755
- get code() {
7756
- return sym;
7757
- }
7758
- set code(value) {
7759
- Object.defineProperty(this, "code", {
7760
- configurable: true,
7761
- enumerable: true,
7762
- value,
7763
- writable: true
7764
- });
7765
- }
7766
- toString() {
7767
- return `${this.name} [${sym}]: ${this.message}`;
7768
- }
7769
- };
7770
- }
7771
- E(
7772
- "ERR_BUFFER_OUT_OF_BOUNDS",
7773
- function(name) {
7774
- if (name) {
7775
- return `${name} is outside of buffer bounds`;
7776
- }
7777
- return "Attempt to access memory outside buffer bounds";
7778
- },
7779
- RangeError
7780
- );
7781
- E(
7782
- "ERR_INVALID_ARG_TYPE",
7783
- function(name, actual) {
7784
- return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
7785
- },
7786
- TypeError
7787
- );
7788
- E(
7789
- "ERR_OUT_OF_RANGE",
7790
- function(str, range, input) {
7791
- let msg = `The value of "${str}" is out of range.`;
7792
- let received = input;
7793
- if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
7794
- received = addNumericalSeparator(String(input));
7795
- } else if (typeof input === "bigint") {
7796
- received = String(input);
7797
- if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
7798
- received = addNumericalSeparator(received);
7799
- }
7800
- received += "n";
7801
- }
7802
- msg += ` It must be ${range}. Received ${received}`;
7803
- return msg;
7804
- },
7805
- RangeError
7806
- );
7807
- function addNumericalSeparator(val) {
7808
- let res = "";
7809
- let i = val.length;
7810
- const start = val[0] === "-" ? 1 : 0;
7811
- for (; i >= start + 4; i -= 3) {
7812
- res = `_${val.slice(i - 3, i)}${res}`;
7813
- }
7814
- return `${val.slice(0, i)}${res}`;
7815
- }
7816
- function checkBounds(buf, offset, byteLength3) {
7817
- validateNumber(offset, "offset");
7818
- if (buf[offset] === void 0 || buf[offset + byteLength3] === void 0) {
7819
- boundsError(offset, buf.length - (byteLength3 + 1));
7820
- }
7821
- }
7822
- function checkIntBI(value, min, max2, buf, offset, byteLength3) {
7823
- if (value > max2 || value < min) {
7824
- const n2 = typeof min === "bigint" ? "n" : "";
7825
- let range;
7826
- {
7827
- if (min === 0 || min === BigInt(0)) {
7828
- range = `>= 0${n2} and < 2${n2} ** ${(byteLength3 + 1) * 8}${n2}`;
7829
- } else {
7830
- range = `>= -(2${n2} ** ${(byteLength3 + 1) * 8 - 1}${n2}) and < 2 ** ${(byteLength3 + 1) * 8 - 1}${n2}`;
7831
- }
7832
- }
7833
- throw new errors.ERR_OUT_OF_RANGE("value", range, value);
7834
- }
7835
- checkBounds(buf, offset, byteLength3);
7836
- }
7837
- function validateNumber(value, name) {
7838
- if (typeof value !== "number") {
7839
- throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
7840
- }
7841
- }
7842
- function boundsError(value, length, type) {
7843
- if (Math.floor(value) !== value) {
7844
- validateNumber(value, type);
7845
- throw new errors.ERR_OUT_OF_RANGE("offset", "an integer", value);
7846
- }
7847
- if (length < 0) {
7848
- throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
7849
- }
7850
- throw new errors.ERR_OUT_OF_RANGE(
7851
- "offset",
7852
- `>= ${0} and <= ${length}`,
7853
- value
7854
- );
7855
- }
7856
- const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
7857
- function base64clean(str) {
7858
- str = str.split("=")[0];
7859
- str = str.trim().replace(INVALID_BASE64_RE, "");
7860
- if (str.length < 2) return "";
7861
- while (str.length % 4 !== 0) {
7862
- str = str + "=";
7863
- }
7864
- return str;
7865
- }
7866
- function utf8ToBytes2(string, units) {
7867
- units = units || Infinity;
7868
- let codePoint;
7869
- const length = string.length;
7870
- let leadSurrogate = null;
7871
- const bytes2 = [];
7872
- for (let i = 0; i < length; ++i) {
7873
- codePoint = string.charCodeAt(i);
7874
- if (codePoint > 55295 && codePoint < 57344) {
7875
- if (!leadSurrogate) {
7876
- if (codePoint > 56319) {
7877
- if ((units -= 3) > -1) bytes2.push(239, 191, 189);
7878
- continue;
7879
- } else if (i + 1 === length) {
7880
- if ((units -= 3) > -1) bytes2.push(239, 191, 189);
7881
- continue;
7882
- }
7883
- leadSurrogate = codePoint;
7884
- continue;
7885
- }
7886
- if (codePoint < 56320) {
7887
- if ((units -= 3) > -1) bytes2.push(239, 191, 189);
7888
- leadSurrogate = codePoint;
7889
- continue;
7890
- }
7891
- codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
7892
- } else if (leadSurrogate) {
7893
- if ((units -= 3) > -1) bytes2.push(239, 191, 189);
7894
- }
7895
- leadSurrogate = null;
7896
- if (codePoint < 128) {
7897
- if ((units -= 1) < 0) break;
7898
- bytes2.push(codePoint);
7899
- } else if (codePoint < 2048) {
7900
- if ((units -= 2) < 0) break;
7901
- bytes2.push(
7902
- codePoint >> 6 | 192,
7903
- codePoint & 63 | 128
7904
- );
7905
- } else if (codePoint < 65536) {
7906
- if ((units -= 3) < 0) break;
7907
- bytes2.push(
7908
- codePoint >> 12 | 224,
7909
- codePoint >> 6 & 63 | 128,
7910
- codePoint & 63 | 128
7911
- );
7912
- } else if (codePoint < 1114112) {
7913
- if ((units -= 4) < 0) break;
7914
- bytes2.push(
7915
- codePoint >> 18 | 240,
7916
- codePoint >> 12 & 63 | 128,
7917
- codePoint >> 6 & 63 | 128,
7918
- codePoint & 63 | 128
7919
- );
7920
- } else {
7921
- throw new Error("Invalid code point");
7922
- }
7923
- }
7924
- return bytes2;
7925
- }
7926
- function asciiToBytes(str) {
7927
- const byteArray = [];
7928
- for (let i = 0; i < str.length; ++i) {
7929
- byteArray.push(str.charCodeAt(i) & 255);
7930
- }
7931
- return byteArray;
7932
- }
7933
- function utf16leToBytes(str, units) {
7934
- let c, hi, lo;
7935
- const byteArray = [];
7936
- for (let i = 0; i < str.length; ++i) {
7937
- if ((units -= 2) < 0) break;
7938
- c = str.charCodeAt(i);
7939
- hi = c >> 8;
7940
- lo = c % 256;
7941
- byteArray.push(lo);
7942
- byteArray.push(hi);
7943
- }
7944
- return byteArray;
7945
- }
7946
- function base64ToBytes(str) {
7947
- return base64.toByteArray(base64clean(str));
7948
- }
7949
- function blitBuffer(src, dst, offset, length) {
7950
- let i;
7951
- for (i = 0; i < length; ++i) {
7952
- if (i + offset >= dst.length || i >= src.length) break;
7953
- dst[i + offset] = src[i];
7954
- }
7955
- return i;
7956
- }
7957
- function isInstance(obj, type) {
7958
- return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
7959
- }
7960
- function numberIsNaN(obj) {
7961
- return obj !== obj;
7962
- }
7963
- const hexSliceLookupTable = function() {
7964
- const alphabet = "0123456789abcdef";
7965
- const table = new Array(256);
7966
- for (let i = 0; i < 16; ++i) {
7967
- const i16 = i * 16;
7968
- for (let j = 0; j < 16; ++j) {
7969
- table[i16 + j] = alphabet[i] + alphabet[j];
7970
- }
7971
- }
7972
- return table;
7973
- }();
7974
- function defineBigIntMethod(fn) {
7975
- return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
7976
- }
7977
- function BufferBigIntNotDefined() {
7978
- throw new Error("BigInt not supported");
7979
- }
7980
- })(buffer);
7981
- const Buffer2 = buffer.Buffer;
7982
- const global$1 = globalThis || void 0 || self;
7983
6054
  function bind$1(fn, thisArg) {
7984
6055
  return function wrap() {
7985
6056
  return fn.apply(thisArg, arguments);
@@ -8074,7 +6145,7 @@ function findKey$1(obj, key) {
8074
6145
  }
8075
6146
  const _global$1 = (() => {
8076
6147
  if (typeof globalThis !== "undefined") return globalThis;
8077
- return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global$1;
6148
+ return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
8078
6149
  })();
8079
6150
  const isContextDefined$1 = (context) => !isUndefined$1(context) && context !== _global$1;
8080
6151
  function merge$1() {
@@ -8286,7 +6357,7 @@ const _setImmediate$1 = ((setImmediateSupported, postMessageSupported) => {
8286
6357
  typeof setImmediate === "function",
8287
6358
  isFunction$1(_global$1.postMessage)
8288
6359
  );
8289
- const asap$1 = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global$1) : typeof process$1$1 !== "undefined" && process$1$1.nextTick || _setImmediate$1;
6360
+ const asap$1 = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global$1) : typeof process !== "undefined" && process.nextTick || _setImmediate$1;
8290
6361
  const utils$1$1 = {
8291
6362
  isArray: isArray$1,
8292
6363
  isArrayBuffer: isArrayBuffer$1,
@@ -8345,7 +6416,7 @@ const utils$1$1 = {
8345
6416
  setImmediate: _setImmediate$1,
8346
6417
  asap: asap$1
8347
6418
  };
8348
- function AxiosError$2(message, code2, config, request, response) {
6419
+ function AxiosError$2(message, code, config, request, response) {
8349
6420
  Error.call(this);
8350
6421
  if (Error.captureStackTrace) {
8351
6422
  Error.captureStackTrace(this, this.constructor);
@@ -8354,7 +6425,7 @@ function AxiosError$2(message, code2, config, request, response) {
8354
6425
  }
8355
6426
  this.message = message;
8356
6427
  this.name = "AxiosError";
8357
- code2 && (this.code = code2);
6428
+ code && (this.code = code);
8358
6429
  config && (this.config = config);
8359
6430
  request && (this.request = request);
8360
6431
  if (response) {
@@ -8399,19 +6470,19 @@ const descriptors$1 = {};
8399
6470
  "ERR_NOT_SUPPORT",
8400
6471
  "ERR_INVALID_URL"
8401
6472
  // eslint-disable-next-line func-names
8402
- ].forEach((code2) => {
8403
- descriptors$1[code2] = { value: code2 };
6473
+ ].forEach((code) => {
6474
+ descriptors$1[code] = { value: code };
8404
6475
  });
8405
6476
  Object.defineProperties(AxiosError$2, descriptors$1);
8406
6477
  Object.defineProperty(prototype$1$1, "isAxiosError", { value: true });
8407
- AxiosError$2.from = (error, code2, config, request, response, customProps) => {
6478
+ AxiosError$2.from = (error, code, config, request, response, customProps) => {
8408
6479
  const axiosError = Object.create(prototype$1$1);
8409
6480
  utils$1$1.toFlatObject(error, axiosError, function filter22(obj) {
8410
6481
  return obj !== Error.prototype;
8411
6482
  }, (prop) => {
8412
6483
  return prop !== "isAxiosError";
8413
6484
  });
8414
- AxiosError$2.call(axiosError, error.message, code2, config, request, response);
6485
+ AxiosError$2.call(axiosError, error.message, code, config, request, response);
8415
6486
  axiosError.cause = error;
8416
6487
  axiosError.name = error.name;
8417
6488
  customProps && Object.assign(axiosError, customProps);
@@ -8467,7 +6538,7 @@ function toFormData$2(obj, formData, options) {
8467
6538
  throw new AxiosError$2("Blob is not supported. Use a Buffer instead.");
8468
6539
  }
8469
6540
  if (utils$1$1.isArrayBuffer(value) || utils$1$1.isTypedArray(value)) {
8470
- return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer2.from(value);
6541
+ return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
8471
6542
  }
8472
6543
  return value;
8473
6544
  }
@@ -10336,7 +8407,7 @@ axios$1.default = axios$1;
10336
8407
  const _Logger = class _Logger2 {
10337
8408
  constructor() {
10338
8409
  __publicField2(this, "isProduction");
10339
- this.isProduction = process$1$1.env.NODE_ENV === "production";
8410
+ this.isProduction = process.env.NODE_ENV === "production";
10340
8411
  }
10341
8412
  static getInstance() {
10342
8413
  if (!_Logger2.instance) {
@@ -10417,7 +8488,7 @@ class Auth {
10417
8488
  async signMessage(message) {
10418
8489
  const messageBytes = new TextEncoder().encode(message);
10419
8490
  const signatureBytes = await this.privateKey.sign(messageBytes);
10420
- return Buffer2.from(signatureBytes).toString("hex");
8491
+ return Buffer.from(signatureBytes).toString("hex");
10421
8492
  }
10422
8493
  }
10423
8494
  class ClientAuth {
@@ -10474,7 +8545,7 @@ class ClientAuth {
10474
8545
  const signatureBytes = await this.signer.sign([messageBytes], {
10475
8546
  encoding: "utf-8"
10476
8547
  });
10477
- return Buffer2.from(signatureBytes == null ? void 0 : signatureBytes[0].signature).toString("hex");
8548
+ return Buffer.from(signatureBytes == null ? void 0 : signatureBytes[0].signature).toString("hex");
10478
8549
  } catch (e) {
10479
8550
  this.logger.error(`Failed to sign message`, e);
10480
8551
  throw new Error("Failed to sign message");
@@ -10591,13 +8662,13 @@ let AbstractStreamReader$1 = class AbstractStreamReader {
10591
8662
  this.peekQueue.push(uint8Array.subarray(0, bytesRead));
10592
8663
  return bytesRead;
10593
8664
  }
10594
- async read(buffer2, mayBeLess = false) {
10595
- if (buffer2.length === 0) {
8665
+ async read(buffer, mayBeLess = false) {
8666
+ if (buffer.length === 0) {
10596
8667
  return 0;
10597
8668
  }
10598
- let bytesRead = this.readFromPeekBuffer(buffer2);
8669
+ let bytesRead = this.readFromPeekBuffer(buffer);
10599
8670
  if (!this.endOfStream) {
10600
- bytesRead += await this.readRemainderFromStream(buffer2.subarray(bytesRead), mayBeLess);
8671
+ bytesRead += await this.readRemainderFromStream(buffer.subarray(bytesRead), mayBeLess);
10601
8672
  }
10602
8673
  if (bytesRead === 0) {
10603
8674
  throw new EndOfStreamError$1();
@@ -10609,15 +8680,15 @@ let AbstractStreamReader$1 = class AbstractStreamReader {
10609
8680
  * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
10610
8681
  * @returns Number of bytes read
10611
8682
  */
10612
- readFromPeekBuffer(buffer2) {
10613
- let remaining = buffer2.length;
8683
+ readFromPeekBuffer(buffer) {
8684
+ let remaining = buffer.length;
10614
8685
  let bytesRead = 0;
10615
8686
  while (this.peekQueue.length > 0 && remaining > 0) {
10616
8687
  const peekData = this.peekQueue.pop();
10617
8688
  if (!peekData)
10618
8689
  throw new Error("peekData should be defined");
10619
8690
  const lenCopy = Math.min(peekData.length, remaining);
10620
- buffer2.set(peekData.subarray(0, lenCopy), bytesRead);
8691
+ buffer.set(peekData.subarray(0, lenCopy), bytesRead);
10621
8692
  bytesRead += lenCopy;
10622
8693
  remaining -= lenCopy;
10623
8694
  if (lenCopy < peekData.length) {
@@ -10626,18 +8697,18 @@ let AbstractStreamReader$1 = class AbstractStreamReader {
10626
8697
  }
10627
8698
  return bytesRead;
10628
8699
  }
10629
- async readRemainderFromStream(buffer2, mayBeLess) {
8700
+ async readRemainderFromStream(buffer, mayBeLess) {
10630
8701
  let bytesRead = 0;
10631
- while (bytesRead < buffer2.length && !this.endOfStream) {
8702
+ while (bytesRead < buffer.length && !this.endOfStream) {
10632
8703
  if (this.interrupted) {
10633
8704
  throw new AbortError$1();
10634
8705
  }
10635
- const chunkLen = await this.readFromStream(buffer2.subarray(bytesRead), mayBeLess);
8706
+ const chunkLen = await this.readFromStream(buffer.subarray(bytesRead), mayBeLess);
10636
8707
  if (chunkLen === 0)
10637
8708
  break;
10638
8709
  bytesRead += chunkLen;
10639
8710
  }
10640
- if (!mayBeLess && bytesRead < buffer2.length) {
8711
+ if (!mayBeLess && bytesRead < buffer.length) {
10641
8712
  throw new EndOfStreamError$1();
10642
8713
  }
10643
8714
  return bytesRead;
@@ -10662,15 +8733,15 @@ let WebStreamByobReader$1 = class WebStreamByobReader extends WebStreamReader$1
10662
8733
  * @param mayBeLess - If true, may fill the buffer partially
10663
8734
  * @protected Bytes read
10664
8735
  */
10665
- async readFromStream(buffer2, mayBeLess) {
10666
- if (buffer2.length === 0)
8736
+ async readFromStream(buffer, mayBeLess) {
8737
+ if (buffer.length === 0)
10667
8738
  return 0;
10668
- const result = await this.reader.read(new Uint8Array(buffer2.length), { min: mayBeLess ? void 0 : buffer2.length });
8739
+ const result = await this.reader.read(new Uint8Array(buffer.length), { min: mayBeLess ? void 0 : buffer.length });
10669
8740
  if (result.done) {
10670
8741
  this.endOfStream = result.done;
10671
8742
  }
10672
8743
  if (result.value) {
10673
- buffer2.set(result.value);
8744
+ buffer.set(result.value);
10674
8745
  return result.value.length;
10675
8746
  }
10676
8747
  return 0;
@@ -10701,21 +8772,21 @@ let WebStreamDefaultReader$1 = class WebStreamDefaultReader extends AbstractStre
10701
8772
  * @param mayBeLess - If true, may fill the buffer partially
10702
8773
  * @protected Bytes read
10703
8774
  */
10704
- async readFromStream(buffer2, mayBeLess) {
10705
- if (buffer2.length === 0)
8775
+ async readFromStream(buffer, mayBeLess) {
8776
+ if (buffer.length === 0)
10706
8777
  return 0;
10707
8778
  let totalBytesRead = 0;
10708
8779
  if (this.buffer) {
10709
- totalBytesRead += this.writeChunk(buffer2, this.buffer);
8780
+ totalBytesRead += this.writeChunk(buffer, this.buffer);
10710
8781
  }
10711
- while (totalBytesRead < buffer2.length && !this.endOfStream) {
8782
+ while (totalBytesRead < buffer.length && !this.endOfStream) {
10712
8783
  const result = await this.reader.read();
10713
8784
  if (result.done) {
10714
8785
  this.endOfStream = true;
10715
8786
  break;
10716
8787
  }
10717
8788
  if (result.value) {
10718
- totalBytesRead += this.writeChunk(buffer2.subarray(totalBytesRead), result.value);
8789
+ totalBytesRead += this.writeChunk(buffer.subarray(totalBytesRead), result.value);
10719
8790
  }
10720
8791
  }
10721
8792
  if (totalBytesRead === 0 && this.endOfStream) {
@@ -11102,11 +9173,11 @@ var _a$1 = freb$1(fleb$1, 2), fl$1 = _a$1.b, revfl$1 = _a$1.r;
11102
9173
  fl$1[28] = 258, revfl$1[258] = 28;
11103
9174
  var _b$1 = freb$1(fdeb$1, 0), fd$1 = _b$1.b;
11104
9175
  var rev$1 = new u16$1(32768);
11105
- for (var i$2 = 0; i$2 < 32768; ++i$2) {
11106
- var x$1 = (i$2 & 43690) >> 1 | (i$2 & 21845) << 1;
9176
+ for (var i$1 = 0; i$1 < 32768; ++i$1) {
9177
+ var x$1 = (i$1 & 43690) >> 1 | (i$1 & 21845) << 1;
11107
9178
  x$1 = (x$1 & 52428) >> 2 | (x$1 & 13107) << 2;
11108
9179
  x$1 = (x$1 & 61680) >> 4 | (x$1 & 3855) << 4;
11109
- rev$1[i$2] = ((x$1 & 65280) >> 8 | (x$1 & 255) << 8) >> 1;
9180
+ rev$1[i$1] = ((x$1 & 65280) >> 8 | (x$1 & 255) << 8) >> 1;
11110
9181
  }
11111
9182
  var hMap$1 = function(cd, mb, r) {
11112
9183
  var s = cd.length;
@@ -11138,17 +9209,17 @@ var hMap$1 = function(cd, mb, r) {
11138
9209
  return co;
11139
9210
  };
11140
9211
  var flt$1 = new u8$1(288);
11141
- for (var i$2 = 0; i$2 < 144; ++i$2)
11142
- flt$1[i$2] = 8;
11143
- for (var i$2 = 144; i$2 < 256; ++i$2)
11144
- flt$1[i$2] = 9;
11145
- for (var i$2 = 256; i$2 < 280; ++i$2)
11146
- flt$1[i$2] = 7;
11147
- for (var i$2 = 280; i$2 < 288; ++i$2)
11148
- flt$1[i$2] = 8;
9212
+ for (var i$1 = 0; i$1 < 144; ++i$1)
9213
+ flt$1[i$1] = 8;
9214
+ for (var i$1 = 144; i$1 < 256; ++i$1)
9215
+ flt$1[i$1] = 9;
9216
+ for (var i$1 = 256; i$1 < 280; ++i$1)
9217
+ flt$1[i$1] = 7;
9218
+ for (var i$1 = 280; i$1 < 288; ++i$1)
9219
+ flt$1[i$1] = 8;
11149
9220
  var fdt$1 = new u8$1(32);
11150
- for (var i$2 = 0; i$2 < 32; ++i$2)
11151
- fdt$1[i$2] = 5;
9221
+ for (var i$1 = 0; i$1 < 32; ++i$1)
9222
+ fdt$1[i$1] = 5;
11152
9223
  var flrm$1 = /* @__PURE__ */ hMap$1(flt$1, 9);
11153
9224
  var fdrm$1 = /* @__PURE__ */ hMap$1(fdt$1, 5);
11154
9225
  var max$1 = function(a) {
@@ -11832,8 +9903,8 @@ function requireBrowser$1() {
11832
9903
  r = exports.storage.getItem("debug");
11833
9904
  } catch (error) {
11834
9905
  }
11835
- if (!r && typeof process$1$1 !== "undefined" && "env" in process$1$1) {
11836
- r = process$1$1.env.DEBUG;
9906
+ if (!r && typeof process !== "undefined" && "env" in process) {
9907
+ r = process.env.DEBUG;
11837
9908
  }
11838
9909
  return r;
11839
9910
  }
@@ -11948,10 +10019,10 @@ let ZipHandler$1 = class ZipHandler {
11948
10019
  async findEndOfCentralDirectoryLocator() {
11949
10020
  const randomReadTokenizer = this.tokenizer;
11950
10021
  const chunkLength = Math.min(16 * 1024, randomReadTokenizer.fileInfo.size);
11951
- const buffer2 = this.syncBuffer.subarray(0, chunkLength);
11952
- await this.tokenizer.readBuffer(buffer2, { position: randomReadTokenizer.fileInfo.size - chunkLength });
11953
- for (let i = buffer2.length - 4; i >= 0; i--) {
11954
- if (buffer2[i] === eocdSignatureBytes$1[0] && buffer2[i + 1] === eocdSignatureBytes$1[1] && buffer2[i + 2] === eocdSignatureBytes$1[2] && buffer2[i + 3] === eocdSignatureBytes$1[3]) {
10022
+ const buffer = this.syncBuffer.subarray(0, chunkLength);
10023
+ await this.tokenizer.readBuffer(buffer, { position: randomReadTokenizer.fileInfo.size - chunkLength });
10024
+ for (let i = buffer.length - 4; i >= 0; i--) {
10025
+ if (buffer[i] === eocdSignatureBytes$1[0] && buffer[i + 1] === eocdSignatureBytes$1[1] && buffer[i + 2] === eocdSignatureBytes$1[2] && buffer[i + 3] === eocdSignatureBytes$1[3]) {
11955
10026
  return randomReadTokenizer.fileInfo.size - chunkLength + i;
11956
10027
  }
11957
10028
  }
@@ -12082,15 +10153,15 @@ let ZipHandler$1 = class ZipHandler {
12082
10153
  throw new Error("Unexpected signature");
12083
10154
  }
12084
10155
  };
12085
- function indexOf$1$1(buffer2, portion) {
12086
- const bufferLength = buffer2.length;
10156
+ function indexOf$1$1(buffer, portion) {
10157
+ const bufferLength = buffer.length;
12087
10158
  const portionLength = portion.length;
12088
10159
  if (portionLength > bufferLength)
12089
10160
  return -1;
12090
10161
  for (let i = 0; i <= bufferLength - portionLength; i++) {
12091
10162
  let found = true;
12092
10163
  for (let j = 0; j < portionLength; j++) {
12093
- if (buffer2[i + j] !== portion[j]) {
10164
+ if (buffer[i + j] !== portion[j]) {
12094
10165
  found = false;
12095
10166
  break;
12096
10167
  }
@@ -12117,23 +10188,23 @@ function mergeArrays$1(chunks) {
12117
10188
  new globalThis.TextEncoder();
12118
10189
  Array.from({ length: 256 }, (_, index) => index.toString(16).padStart(2, "0"));
12119
10190
  function getUintBE$1(view) {
12120
- const { byteLength: byteLength2 } = view;
12121
- if (byteLength2 === 6) {
10191
+ const { byteLength } = view;
10192
+ if (byteLength === 6) {
12122
10193
  return view.getUint16(0) * 2 ** 32 + view.getUint32(2);
12123
10194
  }
12124
- if (byteLength2 === 5) {
10195
+ if (byteLength === 5) {
12125
10196
  return view.getUint8(0) * 2 ** 32 + view.getUint32(1);
12126
10197
  }
12127
- if (byteLength2 === 4) {
10198
+ if (byteLength === 4) {
12128
10199
  return view.getUint32(0);
12129
10200
  }
12130
- if (byteLength2 === 3) {
10201
+ if (byteLength === 3) {
12131
10202
  return view.getUint8(0) * 2 ** 16 + view.getUint16(1);
12132
10203
  }
12133
- if (byteLength2 === 2) {
10204
+ if (byteLength === 2) {
12134
10205
  return view.getUint16(0);
12135
10206
  }
12136
- if (byteLength2 === 1) {
10207
+ if (byteLength === 1) {
12137
10208
  return view.getUint8(0);
12138
10209
  }
12139
10210
  }
@@ -12182,7 +10253,7 @@ function tarHeaderChecksumMatches$1(arrayBuffer, offset = 0) {
12182
10253
  return readSum === sum;
12183
10254
  }
12184
10255
  const uint32SyncSafeToken$1 = {
12185
- get: (buffer2, offset) => buffer2[offset + 3] & 127 | buffer2[offset + 2] << 7 | buffer2[offset + 1] << 14 | buffer2[offset] << 21,
10256
+ get: (buffer, offset) => buffer[offset + 3] & 127 | buffer[offset + 2] << 7 | buffer[offset + 1] << 14 | buffer[offset] << 21,
12186
10257
  len: 4
12187
10258
  };
12188
10259
  const extensions$1 = [
@@ -12662,17 +10733,17 @@ function getFileTypeFromMimeType$1(mimeType) {
12662
10733
  };
12663
10734
  }
12664
10735
  }
12665
- function _check$1(buffer2, headers, options) {
10736
+ function _check$1(buffer, headers, options) {
12666
10737
  options = {
12667
10738
  offset: 0,
12668
10739
  ...options
12669
10740
  };
12670
10741
  for (const [index, header] of headers.entries()) {
12671
10742
  if (options.mask) {
12672
- if (header !== (options.mask[index] & buffer2[index + options.offset])) {
10743
+ if (header !== (options.mask[index] & buffer[index + options.offset])) {
12673
10744
  return false;
12674
10745
  }
12675
- } else if (header !== buffer2[index + options.offset]) {
10746
+ } else if (header !== buffer[index + options.offset]) {
12676
10747
  return false;
12677
10748
  }
12678
10749
  }
@@ -13016,9 +11087,9 @@ let FileTypeParser$1 = class FileTypeParser {
13016
11087
  const skipBytes = 1350;
13017
11088
  if (skipBytes === await tokenizer.ignore(skipBytes)) {
13018
11089
  const maxBufferSize2 = 10 * 1024 * 1024;
13019
- const buffer2 = new Uint8Array(Math.min(maxBufferSize2, tokenizer.fileInfo.size - skipBytes));
13020
- await tokenizer.readBuffer(buffer2, { mayBeLess: true });
13021
- if (includes$1(buffer2, new TextEncoder().encode("AIPrivateData"))) {
11090
+ const buffer = new Uint8Array(Math.min(maxBufferSize2, tokenizer.fileInfo.size - skipBytes));
11091
+ await tokenizer.readBuffer(buffer, { mayBeLess: true });
11092
+ if (includes$1(buffer, new TextEncoder().encode("AIPrivateData"))) {
13022
11093
  return {
13023
11094
  ext: "ai",
13024
11095
  mime: "application/postscript"
@@ -13837,11 +11908,11 @@ let FileTypeParser$1 = class FileTypeParser {
13837
11908
  if (!(input instanceof Uint8Array || input instanceof ArrayBuffer)) {
13838
11909
  throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof input}\``);
13839
11910
  }
13840
- const buffer2 = input instanceof Uint8Array ? input : new Uint8Array(input);
13841
- if (!((buffer2 == null ? void 0 : buffer2.length) > 1)) {
11911
+ const buffer = input instanceof Uint8Array ? input : new Uint8Array(input);
11912
+ if (!((buffer == null ? void 0 : buffer.length) > 1)) {
13842
11913
  return;
13843
11914
  }
13844
- return this.fromTokenizer(fromBuffer$1(buffer2, this.tokenizerOptions));
11915
+ return this.fromTokenizer(fromBuffer$1(buffer, this.tokenizerOptions));
13845
11916
  }
13846
11917
  async fromBlob(blob) {
13847
11918
  return this.fromStream(blob.stream());
@@ -14103,8 +12174,8 @@ const _InscriptionSDK = class _InscriptionSDK2 {
14103
12174
  }
14104
12175
  try {
14105
12176
  const sanitizedBase64 = base64Data.replace(/\s/g, "");
14106
- const buffer2 = Buffer2.from(sanitizedBase64, "base64");
14107
- const typeResult = await fileTypeFromBuffer$1(buffer2);
12177
+ const buffer = Buffer.from(sanitizedBase64, "base64");
12178
+ const typeResult = await fileTypeFromBuffer$1(buffer);
14108
12179
  return (typeResult == null ? void 0 : typeResult.mime) || "application/octet-stream";
14109
12180
  } catch (err2) {
14110
12181
  this.logger.warn("Failed to detect MIME type from buffer");
@@ -14198,7 +12269,7 @@ const _InscriptionSDK = class _InscriptionSDK2 {
14198
12269
  const privateKey = PrivateKey.fromString(clientConfig.privateKey);
14199
12270
  client.setOperator(clientConfig.accountId, privateKey);
14200
12271
  const transaction = Transaction.fromBytes(
14201
- Buffer2.from(transactionBytes, "base64")
12272
+ Buffer.from(transactionBytes, "base64")
14202
12273
  );
14203
12274
  const signedTransaction = await transaction.sign(privateKey);
14204
12275
  const executeTx = await signedTransaction.execute(client);
@@ -14226,7 +12297,7 @@ const _InscriptionSDK = class _InscriptionSDK2 {
14226
12297
  async executeTransactionWithSigner(transactionBytes, signer) {
14227
12298
  try {
14228
12299
  const transaction = Transaction.fromBytes(
14229
- Buffer2.from(transactionBytes, "base64")
12300
+ Buffer.from(transactionBytes, "base64")
14230
12301
  );
14231
12302
  const executeTx = await transaction.executeWithSigner(signer);
14232
12303
  const receipt = await executeTx.getReceiptWithSigner(signer);
@@ -14961,7 +13032,7 @@ const utils$1 = {
14961
13032
  setImmediate: _setImmediate,
14962
13033
  asap
14963
13034
  };
14964
- function AxiosError$1(message, code2, config, request, response) {
13035
+ function AxiosError$1(message, code, config, request, response) {
14965
13036
  Error.call(this);
14966
13037
  if (Error.captureStackTrace) {
14967
13038
  Error.captureStackTrace(this, this.constructor);
@@ -14970,7 +13041,7 @@ function AxiosError$1(message, code2, config, request, response) {
14970
13041
  }
14971
13042
  this.message = message;
14972
13043
  this.name = "AxiosError";
14973
- code2 && (this.code = code2);
13044
+ code && (this.code = code);
14974
13045
  config && (this.config = config);
14975
13046
  request && (this.request = request);
14976
13047
  if (response) {
@@ -15015,19 +13086,19 @@ const descriptors = {};
15015
13086
  "ERR_NOT_SUPPORT",
15016
13087
  "ERR_INVALID_URL"
15017
13088
  // eslint-disable-next-line func-names
15018
- ].forEach((code2) => {
15019
- descriptors[code2] = { value: code2 };
13089
+ ].forEach((code) => {
13090
+ descriptors[code] = { value: code };
15020
13091
  });
15021
13092
  Object.defineProperties(AxiosError$1, descriptors);
15022
13093
  Object.defineProperty(prototype$1, "isAxiosError", { value: true });
15023
- AxiosError$1.from = (error, code2, config, request, response, customProps) => {
13094
+ AxiosError$1.from = (error, code, config, request, response, customProps) => {
15024
13095
  const axiosError = Object.create(prototype$1);
15025
13096
  utils$1.toFlatObject(error, axiosError, function filter3(obj) {
15026
13097
  return obj !== Error.prototype;
15027
13098
  }, (prop) => {
15028
13099
  return prop !== "isAxiosError";
15029
13100
  });
15030
- AxiosError$1.call(axiosError, error.message, code2, config, request, response);
13101
+ AxiosError$1.call(axiosError, error.message, code, config, request, response);
15031
13102
  axiosError.cause = error;
15032
13103
  axiosError.name = error.name;
15033
13104
  customProps && Object.assign(axiosError, customProps);
@@ -19960,7 +18031,7 @@ function requireMimeTypes() {
19960
18031
  exports.contentType = contentType;
19961
18032
  exports.extension = extension;
19962
18033
  exports.extensions = /* @__PURE__ */ Object.create(null);
19963
- exports.lookup = lookup2;
18034
+ exports.lookup = lookup;
19964
18035
  exports.types = /* @__PURE__ */ Object.create(null);
19965
18036
  populateMaps(exports.extensions, exports.types);
19966
18037
  function charset(type) {
@@ -20002,7 +18073,7 @@ function requireMimeTypes() {
20002
18073
  }
20003
18074
  return exts[0];
20004
18075
  }
20005
- function lookup2(path) {
18076
+ function lookup(path) {
20006
18077
  if (!path || typeof path !== "string") {
20007
18078
  return false;
20008
18079
  }
@@ -24660,7 +22731,7 @@ var hasRequiredIeee754;
24660
22731
  function requireIeee754() {
24661
22732
  if (hasRequiredIeee754) return ieee754;
24662
22733
  hasRequiredIeee754 = 1;
24663
- ieee754.read = function(buffer2, offset, isLE2, mLen, nBytes) {
22734
+ ieee754.read = function(buffer, offset, isLE2, mLen, nBytes) {
24664
22735
  var e, m;
24665
22736
  var eLen = nBytes * 8 - mLen - 1;
24666
22737
  var eMax = (1 << eLen) - 1;
@@ -24668,17 +22739,17 @@ function requireIeee754() {
24668
22739
  var nBits = -7;
24669
22740
  var i = isLE2 ? nBytes - 1 : 0;
24670
22741
  var d = isLE2 ? -1 : 1;
24671
- var s = buffer2[offset + i];
22742
+ var s = buffer[offset + i];
24672
22743
  i += d;
24673
22744
  e = s & (1 << -nBits) - 1;
24674
22745
  s >>= -nBits;
24675
22746
  nBits += eLen;
24676
- for (; nBits > 0; e = e * 256 + buffer2[offset + i], i += d, nBits -= 8) {
22747
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
24677
22748
  }
24678
22749
  m = e & (1 << -nBits) - 1;
24679
22750
  e >>= -nBits;
24680
22751
  nBits += mLen;
24681
- for (; nBits > 0; m = m * 256 + buffer2[offset + i], i += d, nBits -= 8) {
22752
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
24682
22753
  }
24683
22754
  if (e === 0) {
24684
22755
  e = 1 - eBias;
@@ -24690,7 +22761,7 @@ function requireIeee754() {
24690
22761
  }
24691
22762
  return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
24692
22763
  };
24693
- ieee754.write = function(buffer2, value, offset, isLE2, mLen, nBytes) {
22764
+ ieee754.write = function(buffer, value, offset, isLE2, mLen, nBytes) {
24694
22765
  var e, m, c;
24695
22766
  var eLen = nBytes * 8 - mLen - 1;
24696
22767
  var eMax = (1 << eLen) - 1;
@@ -24729,13 +22800,13 @@ function requireIeee754() {
24729
22800
  e = 0;
24730
22801
  }
24731
22802
  }
24732
- for (; mLen >= 8; buffer2[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
22803
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
24733
22804
  }
24734
22805
  e = e << mLen | m;
24735
22806
  eLen += mLen;
24736
- for (; eLen > 0; buffer2[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
22807
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
24737
22808
  }
24738
- buffer2[offset + i - d] |= s * 128;
22809
+ buffer[offset + i - d] |= s * 128;
24739
22810
  };
24740
22811
  return ieee754;
24741
22812
  }
@@ -24847,13 +22918,13 @@ class AbstractStreamReader2 {
24847
22918
  this.peekQueue.push(uint8Array.subarray(0, bytesRead));
24848
22919
  return bytesRead;
24849
22920
  }
24850
- async read(buffer2, mayBeLess = false) {
24851
- if (buffer2.length === 0) {
22921
+ async read(buffer, mayBeLess = false) {
22922
+ if (buffer.length === 0) {
24852
22923
  return 0;
24853
22924
  }
24854
- let bytesRead = this.readFromPeekBuffer(buffer2);
22925
+ let bytesRead = this.readFromPeekBuffer(buffer);
24855
22926
  if (!this.endOfStream) {
24856
- bytesRead += await this.readRemainderFromStream(buffer2.subarray(bytesRead), mayBeLess);
22927
+ bytesRead += await this.readRemainderFromStream(buffer.subarray(bytesRead), mayBeLess);
24857
22928
  }
24858
22929
  if (bytesRead === 0) {
24859
22930
  throw new EndOfStreamError2();
@@ -24865,15 +22936,15 @@ class AbstractStreamReader2 {
24865
22936
  * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in
24866
22937
  * @returns Number of bytes read
24867
22938
  */
24868
- readFromPeekBuffer(buffer2) {
24869
- let remaining = buffer2.length;
22939
+ readFromPeekBuffer(buffer) {
22940
+ let remaining = buffer.length;
24870
22941
  let bytesRead = 0;
24871
22942
  while (this.peekQueue.length > 0 && remaining > 0) {
24872
22943
  const peekData = this.peekQueue.pop();
24873
22944
  if (!peekData)
24874
22945
  throw new Error("peekData should be defined");
24875
22946
  const lenCopy = Math.min(peekData.length, remaining);
24876
- buffer2.set(peekData.subarray(0, lenCopy), bytesRead);
22947
+ buffer.set(peekData.subarray(0, lenCopy), bytesRead);
24877
22948
  bytesRead += lenCopy;
24878
22949
  remaining -= lenCopy;
24879
22950
  if (lenCopy < peekData.length) {
@@ -24882,18 +22953,18 @@ class AbstractStreamReader2 {
24882
22953
  }
24883
22954
  return bytesRead;
24884
22955
  }
24885
- async readRemainderFromStream(buffer2, mayBeLess) {
22956
+ async readRemainderFromStream(buffer, mayBeLess) {
24886
22957
  let bytesRead = 0;
24887
- while (bytesRead < buffer2.length && !this.endOfStream) {
22958
+ while (bytesRead < buffer.length && !this.endOfStream) {
24888
22959
  if (this.interrupted) {
24889
22960
  throw new AbortError2();
24890
22961
  }
24891
- const chunkLen = await this.readFromStream(buffer2.subarray(bytesRead), mayBeLess);
22962
+ const chunkLen = await this.readFromStream(buffer.subarray(bytesRead), mayBeLess);
24892
22963
  if (chunkLen === 0)
24893
22964
  break;
24894
22965
  bytesRead += chunkLen;
24895
22966
  }
24896
- if (!mayBeLess && bytesRead < buffer2.length) {
22967
+ if (!mayBeLess && bytesRead < buffer.length) {
24897
22968
  throw new EndOfStreamError2();
24898
22969
  }
24899
22970
  return bytesRead;
@@ -24918,15 +22989,15 @@ class WebStreamByobReader2 extends WebStreamReader2 {
24918
22989
  * @param mayBeLess - If true, may fill the buffer partially
24919
22990
  * @protected Bytes read
24920
22991
  */
24921
- async readFromStream(buffer2, mayBeLess) {
24922
- if (buffer2.length === 0)
22992
+ async readFromStream(buffer, mayBeLess) {
22993
+ if (buffer.length === 0)
24923
22994
  return 0;
24924
- const result = await this.reader.read(new Uint8Array(buffer2.length), { min: mayBeLess ? void 0 : buffer2.length });
22995
+ const result = await this.reader.read(new Uint8Array(buffer.length), { min: mayBeLess ? void 0 : buffer.length });
24925
22996
  if (result.done) {
24926
22997
  this.endOfStream = result.done;
24927
22998
  }
24928
22999
  if (result.value) {
24929
- buffer2.set(result.value);
23000
+ buffer.set(result.value);
24930
23001
  return result.value.length;
24931
23002
  }
24932
23003
  return 0;
@@ -24957,21 +23028,21 @@ class WebStreamDefaultReader2 extends AbstractStreamReader2 {
24957
23028
  * @param mayBeLess - If true, may fill the buffer partially
24958
23029
  * @protected Bytes read
24959
23030
  */
24960
- async readFromStream(buffer2, mayBeLess) {
24961
- if (buffer2.length === 0)
23031
+ async readFromStream(buffer, mayBeLess) {
23032
+ if (buffer.length === 0)
24962
23033
  return 0;
24963
23034
  let totalBytesRead = 0;
24964
23035
  if (this.buffer) {
24965
- totalBytesRead += this.writeChunk(buffer2, this.buffer);
23036
+ totalBytesRead += this.writeChunk(buffer, this.buffer);
24966
23037
  }
24967
- while (totalBytesRead < buffer2.length && !this.endOfStream) {
23038
+ while (totalBytesRead < buffer.length && !this.endOfStream) {
24968
23039
  const result = await this.reader.read();
24969
23040
  if (result.done) {
24970
23041
  this.endOfStream = true;
24971
23042
  break;
24972
23043
  }
24973
23044
  if (result.value) {
24974
- totalBytesRead += this.writeChunk(buffer2.subarray(totalBytesRead), result.value);
23045
+ totalBytesRead += this.writeChunk(buffer.subarray(totalBytesRead), result.value);
24975
23046
  }
24976
23047
  }
24977
23048
  if (totalBytesRead === 0 && this.endOfStream) {
@@ -26210,10 +24281,10 @@ class ZipHandler2 {
26210
24281
  async findEndOfCentralDirectoryLocator() {
26211
24282
  const randomReadTokenizer = this.tokenizer;
26212
24283
  const chunkLength = Math.min(16 * 1024, randomReadTokenizer.fileInfo.size);
26213
- const buffer2 = this.syncBuffer.subarray(0, chunkLength);
26214
- await this.tokenizer.readBuffer(buffer2, { position: randomReadTokenizer.fileInfo.size - chunkLength });
26215
- for (let i = buffer2.length - 4; i >= 0; i--) {
26216
- if (buffer2[i] === eocdSignatureBytes[0] && buffer2[i + 1] === eocdSignatureBytes[1] && buffer2[i + 2] === eocdSignatureBytes[2] && buffer2[i + 3] === eocdSignatureBytes[3]) {
24284
+ const buffer = this.syncBuffer.subarray(0, chunkLength);
24285
+ await this.tokenizer.readBuffer(buffer, { position: randomReadTokenizer.fileInfo.size - chunkLength });
24286
+ for (let i = buffer.length - 4; i >= 0; i--) {
24287
+ if (buffer[i] === eocdSignatureBytes[0] && buffer[i + 1] === eocdSignatureBytes[1] && buffer[i + 2] === eocdSignatureBytes[2] && buffer[i + 3] === eocdSignatureBytes[3]) {
26217
24288
  return randomReadTokenizer.fileInfo.size - chunkLength + i;
26218
24289
  }
26219
24290
  }
@@ -26344,15 +24415,15 @@ class ZipHandler2 {
26344
24415
  throw new Error("Unexpected signature");
26345
24416
  }
26346
24417
  }
26347
- function indexOf$1(buffer2, portion) {
26348
- const bufferLength = buffer2.length;
24418
+ function indexOf$1(buffer, portion) {
24419
+ const bufferLength = buffer.length;
26349
24420
  const portionLength = portion.length;
26350
24421
  if (portionLength > bufferLength)
26351
24422
  return -1;
26352
24423
  for (let i = 0; i <= bufferLength - portionLength; i++) {
26353
24424
  let found = true;
26354
24425
  for (let j = 0; j < portionLength; j++) {
26355
- if (buffer2[i + j] !== portion[j]) {
24426
+ if (buffer[i + j] !== portion[j]) {
26356
24427
  found = false;
26357
24428
  break;
26358
24429
  }
@@ -26379,23 +24450,23 @@ function mergeArrays(chunks) {
26379
24450
  new globalThis.TextEncoder();
26380
24451
  Array.from({ length: 256 }, (_, index) => index.toString(16).padStart(2, "0"));
26381
24452
  function getUintBE(view) {
26382
- const { byteLength: byteLength2 } = view;
26383
- if (byteLength2 === 6) {
24453
+ const { byteLength } = view;
24454
+ if (byteLength === 6) {
26384
24455
  return view.getUint16(0) * 2 ** 32 + view.getUint32(2);
26385
24456
  }
26386
- if (byteLength2 === 5) {
24457
+ if (byteLength === 5) {
26387
24458
  return view.getUint8(0) * 2 ** 32 + view.getUint32(1);
26388
24459
  }
26389
- if (byteLength2 === 4) {
24460
+ if (byteLength === 4) {
26390
24461
  return view.getUint32(0);
26391
24462
  }
26392
- if (byteLength2 === 3) {
24463
+ if (byteLength === 3) {
26393
24464
  return view.getUint8(0) * 2 ** 16 + view.getUint16(1);
26394
24465
  }
26395
- if (byteLength2 === 2) {
24466
+ if (byteLength === 2) {
26396
24467
  return view.getUint16(0);
26397
24468
  }
26398
- if (byteLength2 === 1) {
24469
+ if (byteLength === 1) {
26399
24470
  return view.getUint8(0);
26400
24471
  }
26401
24472
  }
@@ -26444,7 +24515,7 @@ function tarHeaderChecksumMatches(arrayBuffer, offset = 0) {
26444
24515
  return readSum === sum;
26445
24516
  }
26446
24517
  const uint32SyncSafeToken = {
26447
- get: (buffer2, offset) => buffer2[offset + 3] & 127 | buffer2[offset + 2] << 7 | buffer2[offset + 1] << 14 | buffer2[offset] << 21,
24518
+ get: (buffer, offset) => buffer[offset + 3] & 127 | buffer[offset + 2] << 7 | buffer[offset + 1] << 14 | buffer[offset] << 21,
26448
24519
  len: 4
26449
24520
  };
26450
24521
  const extensions = [
@@ -26924,17 +24995,17 @@ function getFileTypeFromMimeType(mimeType) {
26924
24995
  };
26925
24996
  }
26926
24997
  }
26927
- function _check(buffer2, headers, options) {
24998
+ function _check(buffer, headers, options) {
26928
24999
  options = {
26929
25000
  offset: 0,
26930
25001
  ...options
26931
25002
  };
26932
25003
  for (const [index, header] of headers.entries()) {
26933
25004
  if (options.mask) {
26934
- if (header !== (options.mask[index] & buffer2[index + options.offset])) {
25005
+ if (header !== (options.mask[index] & buffer[index + options.offset])) {
26935
25006
  return false;
26936
25007
  }
26937
- } else if (header !== buffer2[index + options.offset]) {
25008
+ } else if (header !== buffer[index + options.offset]) {
26938
25009
  return false;
26939
25010
  }
26940
25011
  }
@@ -27279,9 +25350,9 @@ class FileTypeParser2 {
27279
25350
  const skipBytes = 1350;
27280
25351
  if (skipBytes === await tokenizer.ignore(skipBytes)) {
27281
25352
  const maxBufferSize2 = 10 * 1024 * 1024;
27282
- const buffer2 = new Uint8Array(Math.min(maxBufferSize2, tokenizer.fileInfo.size - skipBytes));
27283
- await tokenizer.readBuffer(buffer2, { mayBeLess: true });
27284
- if (includes(buffer2, new TextEncoder().encode("AIPrivateData"))) {
25353
+ const buffer = new Uint8Array(Math.min(maxBufferSize2, tokenizer.fileInfo.size - skipBytes));
25354
+ await tokenizer.readBuffer(buffer, { mayBeLess: true });
25355
+ if (includes(buffer, new TextEncoder().encode("AIPrivateData"))) {
27285
25356
  return {
27286
25357
  ext: "ai",
27287
25358
  mime: "application/postscript"
@@ -28101,11 +26172,11 @@ class FileTypeParser2 {
28101
26172
  if (!(input instanceof Uint8Array || input instanceof ArrayBuffer)) {
28102
26173
  throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof input}\``);
28103
26174
  }
28104
- const buffer2 = input instanceof Uint8Array ? input : new Uint8Array(input);
28105
- if (!(buffer2?.length > 1)) {
26175
+ const buffer = input instanceof Uint8Array ? input : new Uint8Array(input);
26176
+ if (!(buffer?.length > 1)) {
28106
26177
  return;
28107
26178
  }
28108
- return this.fromTokenizer(fromBuffer(buffer2, this.tokenizerOptions));
26179
+ return this.fromTokenizer(fromBuffer(buffer, this.tokenizerOptions));
28109
26180
  }
28110
26181
  async fromBlob(blob) {
28111
26182
  return this.fromStream(blob.stream());
@@ -28582,7 +26653,7 @@ class HCS11Client {
28582
26653
  };
28583
26654
  }
28584
26655
  }
28585
- async inscribeImage(buffer2, fileName, options) {
26656
+ async inscribeImage(buffer, fileName, options) {
28586
26657
  try {
28587
26658
  const progressCallback = options?.progressCallback;
28588
26659
  const progressReporter = new ProgressReporter({
@@ -28600,7 +26671,7 @@ class HCS11Client {
28600
26671
  inscriptionResponse = await inscribeWithSigner(
28601
26672
  {
28602
26673
  type: "buffer",
28603
- buffer: buffer2,
26674
+ buffer,
28604
26675
  fileName,
28605
26676
  mimeType
28606
26677
  },
@@ -28640,7 +26711,7 @@ class HCS11Client {
28640
26711
  inscriptionResponse = await inscribe(
28641
26712
  {
28642
26713
  type: "buffer",
28643
- buffer: buffer2,
26714
+ buffer,
28644
26715
  fileName,
28645
26716
  mimeType
28646
26717
  },
@@ -28902,8 +26973,8 @@ class HCS11Client {
28902
26973
  }
28903
26974
  try {
28904
26975
  const sanitizedBase64 = base64Data.replace(/\s/g, "");
28905
- const buffer2 = Buffer.from(sanitizedBase64, "base64");
28906
- const typeResult = await fileTypeFromBuffer(buffer2);
26976
+ const buffer = Buffer.from(sanitizedBase64, "base64");
26977
+ const typeResult = await fileTypeFromBuffer(buffer);
28907
26978
  return typeResult?.mime || "application/octet-stream";
28908
26979
  } catch (err2) {
28909
26980
  this.logger.warn("Failed to detect MIME type from buffer");
@@ -29156,11 +27227,11 @@ class HCS10Client extends HCS10BaseClient {
29156
27227
  * @param fileName Filename
29157
27228
  * @returns Response with topic ID and transaction ID
29158
27229
  */
29159
- async inscribePfp(buffer2, fileName) {
27230
+ async inscribePfp(buffer, fileName) {
29160
27231
  try {
29161
27232
  this.logger.info("Inscribing profile picture using HCS-11 client");
29162
27233
  const imageResult = await this.hcs11Client.inscribeImage(
29163
- buffer2,
27234
+ buffer,
29164
27235
  fileName
29165
27236
  );
29166
27237
  if (!imageResult.success) {
@@ -29578,7 +27649,7 @@ class HCS10Client extends HCS10BaseClient {
29578
27649
  };
29579
27650
  return await this.submitPayload(outboundTopicId, payload);
29580
27651
  }
29581
- async inscribeFile(buffer2, fileName) {
27652
+ async inscribeFile(buffer, fileName) {
29582
27653
  this.logger.info("Inscribing file");
29583
27654
  if (!this.client.operatorAccountId) {
29584
27655
  this.logger.error("Operator account ID is not set");
@@ -29599,7 +27670,7 @@ class HCS10Client extends HCS10BaseClient {
29599
27670
  {
29600
27671
  file: {
29601
27672
  type: "base64",
29602
- base64: buffer2.toString("base64"),
27673
+ base64: buffer.toString("base64"),
29603
27674
  fileName,
29604
27675
  mimeType
29605
27676
  },
@@ -30265,54 +28336,22 @@ class BrowserHCSClient extends HCS10BaseClient {
30265
28336
  try {
30266
28337
  const progressCallback = options?.progressCallback;
30267
28338
  const progressReporter = new ProgressReporter({
30268
- module: "AgentCreation",
28339
+ module: "AgentCreate",
30269
28340
  logger: this.logger,
30270
28341
  callback: progressCallback
30271
28342
  });
30272
- progressReporter.preparing("Starting agent creation process", 0);
30273
- progressReporter.preparing("Creating agent outbound topic", 0);
30274
- const outboundTopicResult = await this.createTopic(
30275
- "hcs-10:0:60:1",
30276
- true,
30277
- true
30278
- );
30279
- if (!outboundTopicResult.success || !outboundTopicResult.topicId) {
30280
- progressReporter.failed("Failed to create outbound topic");
30281
- return {
30282
- outboundTopicId: "",
30283
- inboundTopicId: "",
30284
- pfpTopicId: "",
30285
- profileTopicId: "",
30286
- error: outboundTopicResult.error || "Failed to create outbound topic",
30287
- success: false
30288
- };
30289
- }
30290
- progressReporter.preparing("Outbound topic created", 5, {
30291
- outboundTopicId: outboundTopicResult.topicId
30292
- });
30293
- progressReporter.preparing("Creating agent inbound topic", 5);
30294
- const inboundTopicResult = await this.createTopic(
30295
- `hcs-10:0:60:0:${outboundTopicResult.topicId}`
30296
- );
30297
- if (!inboundTopicResult.success || !inboundTopicResult.topicId) {
30298
- progressReporter.failed("Failed to create inbound topic");
30299
- return {
30300
- outboundTopicId: outboundTopicResult.topicId,
30301
- inboundTopicId: "",
30302
- pfpTopicId: "",
30303
- profileTopicId: "",
30304
- error: inboundTopicResult.error || "Failed to create inbound topic",
30305
- success: false
30306
- };
30307
- }
30308
- progressReporter.preparing("Inbound topic created", 10, {
30309
- inboundTopicId: inboundTopicResult.topicId
30310
- });
30311
- let pfpTopicId = existingPfpTopicId;
30312
- if (!pfpTopicId) {
30313
- progressReporter.preparing("Preparing agent profile picture", 10);
28343
+ let state = options?.existingState || {
28344
+ currentStage: "init",
28345
+ completedPercentage: 0,
28346
+ createdResources: []
28347
+ };
28348
+ if (!state.pfpTopicId && !existingPfpTopicId) {
28349
+ state.currentStage = "pfp";
28350
+ progressReporter.preparing("Creating agent profile picture", 0, {
28351
+ state
28352
+ });
30314
28353
  const pfpProgress = progressReporter.createSubProgress({
30315
- minPercent: 10,
28354
+ minPercent: 0,
30316
28355
  maxPercent: 20,
30317
28356
  logPrefix: "PFP"
30318
28357
  });
@@ -30321,295 +28360,527 @@ class BrowserHCSClient extends HCS10BaseClient {
30321
28360
  pfpProgress.report({
30322
28361
  stage: data.stage,
30323
28362
  message: data.message,
30324
- progressPercent: data.progressPercent,
30325
- details: data.details
28363
+ progressPercent: data.progressPercent || 0,
28364
+ details: { ...data.details, state }
30326
28365
  });
30327
28366
  }
30328
28367
  });
30329
- if (!pfpResult.success) {
30330
- progressReporter.failed("Failed to inscribe profile picture");
28368
+ if (!pfpResult.success) {
28369
+ state.error = pfpResult.error || "Failed to inscribe profile picture";
28370
+ progressReporter.failed(
28371
+ `Failed to inscribe profile picture: ${state.error}`,
28372
+ { state }
28373
+ );
28374
+ return {
28375
+ outboundTopicId: "",
28376
+ inboundTopicId: "",
28377
+ pfpTopicId: "",
28378
+ profileTopicId: "",
28379
+ success: false,
28380
+ error: state.error,
28381
+ state
28382
+ };
28383
+ }
28384
+ state.pfpTopicId = pfpResult.pfpTopicId;
28385
+ state.completedPercentage = 20;
28386
+ if (state.createdResources) {
28387
+ state.createdResources.push(`pfp:${state.pfpTopicId}`);
28388
+ }
28389
+ progressReporter.preparing("Profile picture created", 20, { state });
28390
+ } else {
28391
+ state.pfpTopicId = existingPfpTopicId || state.pfpTopicId;
28392
+ if (state.currentStage === "init") {
28393
+ state.currentStage = "pfp";
28394
+ state.completedPercentage = 20;
28395
+ }
28396
+ progressReporter.preparing("Using existing profile picture", 20, {
28397
+ state
28398
+ });
28399
+ }
28400
+ if (!state.inboundTopicId || !state.outboundTopicId) {
28401
+ state.currentStage = "topics";
28402
+ progressReporter.preparing("Creating agent communication topics", 20, {
28403
+ state
28404
+ });
28405
+ if (!state.inboundTopicId) {
28406
+ const inboundResult = await this.createTopic(
28407
+ `Agent ${agentName} Inbound Topic`
28408
+ );
28409
+ if (!inboundResult.success || !inboundResult.topicId) {
28410
+ state.error = inboundResult.error || "Failed to create inbound topic";
28411
+ progressReporter.failed(
28412
+ `Failed to create inbound topic: ${state.error}`,
28413
+ { state }
28414
+ );
28415
+ return {
28416
+ outboundTopicId: "",
28417
+ inboundTopicId: "",
28418
+ pfpTopicId: state.pfpTopicId || "",
28419
+ profileTopicId: "",
28420
+ success: false,
28421
+ error: state.error,
28422
+ state
28423
+ };
28424
+ }
28425
+ state.inboundTopicId = inboundResult.topicId;
28426
+ if (state.createdResources) {
28427
+ state.createdResources.push(`inbound:${state.inboundTopicId}`);
28428
+ }
28429
+ }
28430
+ progressReporter.preparing("Inbound topic created", 30, { state });
28431
+ if (!state.outboundTopicId) {
28432
+ const outboundResult = await this.createTopic(
28433
+ `Agent ${agentName} Outbound Topic`
28434
+ );
28435
+ if (!outboundResult.success || !outboundResult.topicId) {
28436
+ state.error = outboundResult.error || "Failed to create outbound topic";
28437
+ progressReporter.failed(
28438
+ `Failed to create outbound topic: ${state.error}`,
28439
+ { state }
28440
+ );
28441
+ return {
28442
+ outboundTopicId: "",
28443
+ inboundTopicId: state.inboundTopicId || "",
28444
+ pfpTopicId: state.pfpTopicId || "",
28445
+ profileTopicId: "",
28446
+ success: false,
28447
+ error: state.error,
28448
+ state
28449
+ };
28450
+ }
28451
+ state.outboundTopicId = outboundResult.topicId;
28452
+ if (state.createdResources) {
28453
+ state.createdResources.push(`outbound:${state.outboundTopicId}`);
28454
+ }
28455
+ }
28456
+ progressReporter.preparing("Agent communication topics created", 40, {
28457
+ state
28458
+ });
28459
+ state.completedPercentage = 40;
28460
+ } else {
28461
+ progressReporter.preparing("Using existing communication topics", 40, {
28462
+ state
28463
+ });
28464
+ if (state.currentStage === "pfp") {
28465
+ state.currentStage = "topics";
28466
+ state.completedPercentage = 40;
28467
+ }
28468
+ }
28469
+ if (!state.profileTopicId) {
28470
+ state.currentStage = "profile";
28471
+ progressReporter.preparing("Creating agent profile", 40, { state });
28472
+ const profileProgress = progressReporter.createSubProgress({
28473
+ minPercent: 40,
28474
+ maxPercent: 100,
28475
+ logPrefix: "Profile"
28476
+ });
28477
+ if (!this.hcs11Client) {
28478
+ state.error = "HCS11Client is not available in this environment";
28479
+ progressReporter.failed(state.error, { state });
30331
28480
  return {
30332
- outboundTopicId: outboundTopicResult.topicId,
30333
- inboundTopicId: inboundTopicResult.topicId,
30334
- pfpTopicId: "",
28481
+ outboundTopicId: state.outboundTopicId || "",
28482
+ inboundTopicId: state.inboundTopicId || "",
28483
+ pfpTopicId: state.pfpTopicId || "",
30335
28484
  profileTopicId: "",
30336
- error: pfpResult.error || "Failed to inscribe profile picture",
30337
- success: false
28485
+ success: false,
28486
+ error: state.error,
28487
+ state
30338
28488
  };
30339
28489
  }
30340
- pfpTopicId = pfpResult.pfpTopicId;
30341
- progressReporter.preparing("Profile picture inscribed", 20, {
30342
- pfpTopicId
30343
- });
28490
+ const storeProfileResult = await this.storeHCS11Profile(
28491
+ agentName,
28492
+ agentDescription,
28493
+ state.inboundTopicId,
28494
+ state.outboundTopicId,
28495
+ capabilities,
28496
+ metadata,
28497
+ void 0,
28498
+ void 0,
28499
+ state.pfpTopicId,
28500
+ {
28501
+ progressCallback: (data) => {
28502
+ profileProgress.report({
28503
+ stage: data.stage,
28504
+ message: data.message,
28505
+ progressPercent: data.progressPercent || 0,
28506
+ details: { ...data.details, state }
28507
+ });
28508
+ }
28509
+ }
28510
+ );
28511
+ if (!storeProfileResult.success) {
28512
+ state.error = storeProfileResult.error || "Failed to store agent profile";
28513
+ progressReporter.failed(
28514
+ `Failed to store agent profile: ${state.error}`,
28515
+ { state }
28516
+ );
28517
+ return {
28518
+ outboundTopicId: state.outboundTopicId || "",
28519
+ inboundTopicId: state.inboundTopicId || "",
28520
+ pfpTopicId: state.pfpTopicId || "",
28521
+ profileTopicId: "",
28522
+ success: false,
28523
+ error: state.error,
28524
+ state
28525
+ };
28526
+ }
28527
+ state.profileTopicId = storeProfileResult.profileTopicId;
28528
+ if (state.createdResources) {
28529
+ state.createdResources.push(`profile:${state.profileTopicId}`);
28530
+ }
28531
+ state.currentStage = "complete";
28532
+ state.completedPercentage = 100;
30344
28533
  } else {
30345
- progressReporter.preparing("Using existing profile picture", 20, {
30346
- pfpTopicId
28534
+ progressReporter.preparing("Using existing agent profile", 100, {
28535
+ state
30347
28536
  });
30348
- }
30349
- progressReporter.preparing("Creating agent profile", 20);
30350
- const profileProgress = progressReporter.createSubProgress({
30351
- minPercent: 20,
30352
- maxPercent: 30,
30353
- logPrefix: "Profile"
30354
- });
30355
- const profileResult = await this.storeHCS11Profile(
30356
- agentName,
30357
- agentDescription,
30358
- inboundTopicResult.topicId,
30359
- outboundTopicResult.topicId,
30360
- capabilities,
30361
- metadata,
30362
- pfpBuffer,
30363
- pfpFileName,
30364
- pfpTopicId,
30365
- {
30366
- progressCallback: (data) => {
30367
- profileProgress.report({
30368
- stage: data.stage,
30369
- message: data.message,
30370
- progressPercent: data.progressPercent,
30371
- details: data.details
30372
- });
30373
- }
28537
+ if (state.currentStage === "topics") {
28538
+ state.currentStage = "complete";
28539
+ state.completedPercentage = 100;
30374
28540
  }
30375
- );
30376
- if (!profileResult.success) {
30377
- progressReporter.failed("Failed to store profile");
30378
- return {
30379
- outboundTopicId: outboundTopicResult.topicId,
30380
- inboundTopicId: inboundTopicResult.topicId,
30381
- pfpTopicId: pfpTopicId || "",
30382
- profileTopicId: "",
30383
- error: profileResult.error || "Failed to store profile",
30384
- success: false
30385
- };
30386
28541
  }
30387
28542
  progressReporter.completed("Agent successfully created", {
30388
- outboundTopicId: outboundTopicResult.topicId,
30389
- inboundTopicId: inboundTopicResult.topicId,
30390
- pfpTopicId: pfpTopicId || "",
30391
- profileTopicId: profileResult.profileTopicId
28543
+ inboundTopicId: state.inboundTopicId,
28544
+ outboundTopicId: state.outboundTopicId,
28545
+ pfpTopicId: state.pfpTopicId,
28546
+ profileTopicId: state.profileTopicId,
28547
+ state
30392
28548
  });
30393
28549
  return {
30394
- outboundTopicId: outboundTopicResult.topicId,
30395
- inboundTopicId: inboundTopicResult.topicId,
30396
- pfpTopicId: pfpTopicId || "",
30397
- profileTopicId: profileResult.profileTopicId,
30398
- success: true
28550
+ outboundTopicId: state.outboundTopicId || "",
28551
+ inboundTopicId: state.inboundTopicId || "",
28552
+ pfpTopicId: state.pfpTopicId || "",
28553
+ profileTopicId: state.profileTopicId || "",
28554
+ success: true,
28555
+ state
30399
28556
  };
30400
28557
  } catch (error) {
28558
+ this.logger.error(`Error creating agent: ${error.message}`);
30401
28559
  return {
30402
28560
  outboundTopicId: "",
30403
28561
  inboundTopicId: "",
30404
28562
  pfpTopicId: "",
30405
28563
  profileTopicId: "",
30406
- error: error.message,
30407
- success: false
28564
+ success: false,
28565
+ error: `Error creating agent: ${error.message}`,
28566
+ state: {
28567
+ currentStage: "init",
28568
+ completedPercentage: 0,
28569
+ error: error.message
28570
+ }
30408
28571
  };
30409
28572
  }
30410
28573
  }
30411
- async createAndRegisterAgent(name, description, capabilities, metadata, pfpBuffer, pfpFileName, network, existingPfpTopicId, options) {
28574
+ async registerAgentWithGuardedRegistry(accountId, inboundTopicId, network = this.network, options) {
30412
28575
  try {
30413
28576
  const progressCallback = options?.progressCallback;
30414
28577
  const progressReporter = new ProgressReporter({
30415
- module: "AgentCreateRegister",
28578
+ module: "AgentRegistration",
30416
28579
  logger: this.logger,
30417
28580
  callback: progressCallback
30418
28581
  });
30419
- progressReporter.preparing("Starting agent creation process", 0);
30420
- const agentResult = await this.createAgent(
30421
- pfpBuffer,
30422
- pfpFileName,
30423
- name,
30424
- description,
30425
- capabilities,
30426
- metadata,
30427
- existingPfpTopicId,
30428
- {
30429
- progressCallback: (progress) => {
30430
- const adjustedPercent = progress.progressPercent * 0.3;
30431
- progressReporter.report({
30432
- stage: progress.stage,
30433
- message: progress.message,
30434
- progressPercent: adjustedPercent,
30435
- details: progress.details
30436
- });
30437
- }
30438
- }
30439
- );
30440
- if (!agentResult.success) {
30441
- throw new Error(agentResult.error || "Failed to create agent");
30442
- }
30443
- progressReporter.preparing(
30444
- "Agent topics and profile created, preparing registration",
30445
- 30
28582
+ const state = this.initializeRegistrationState(
28583
+ inboundTopicId,
28584
+ options?.existingState
30446
28585
  );
30447
- const { accountId } = this.getAccountAndSigner();
30448
- const registrationResult = await this.registerAgentWithGuardedRegistry(
28586
+ progressReporter.preparing("Registering agent with guarded registry", 0, {
28587
+ state
28588
+ });
28589
+ const guardedRegistryUrl = this.buildGuardedRegistryUrl(network);
28590
+ progressReporter.submitting("Submitting agent registration request", 10, {
28591
+ state
28592
+ });
28593
+ const registrationResponse = await this.submitRegistrationRequest(
28594
+ guardedRegistryUrl,
30449
28595
  accountId,
30450
- agentResult.inboundTopicId,
30451
- network,
30452
- {
30453
- progressCallback: (progress) => {
30454
- const adjustedPercent = 30 + (progress.progressPercent || 0) * 0.7;
30455
- progressReporter.report({
30456
- stage: progress.stage,
30457
- message: progress.message,
30458
- progressPercent: adjustedPercent,
30459
- details: progress.details
30460
- });
30461
- },
30462
- maxAttempts: options?.maxAttempts,
30463
- delayMs: options?.delayMs
30464
- }
28596
+ inboundTopicId,
28597
+ network
30465
28598
  );
30466
- if (!registrationResult.success) {
30467
- throw new Error(
30468
- registrationResult.error || "Failed to register agent with registry"
28599
+ if (registrationResponse.validationErrors) {
28600
+ state.error = registrationResponse.error;
28601
+ return {
28602
+ success: false,
28603
+ error: registrationResponse.error,
28604
+ validationErrors: registrationResponse.validationErrors,
28605
+ state
28606
+ };
28607
+ }
28608
+ if (!registrationResponse.success) {
28609
+ state.error = registrationResponse.error;
28610
+ progressReporter.failed(
28611
+ `Registration request failed: ${registrationResponse.error}`,
28612
+ {
28613
+ state
28614
+ }
28615
+ );
28616
+ return {
28617
+ success: false,
28618
+ error: registrationResponse.error,
28619
+ state
28620
+ };
28621
+ }
28622
+ const data = registrationResponse.data;
28623
+ progressReporter.confirming(
28624
+ "Registration request submitted, confirming transaction",
28625
+ 30,
28626
+ { state }
28627
+ );
28628
+ if (data.transactionId) {
28629
+ const confirmationResult = await this.confirmRegistration(
28630
+ data.transactionId,
28631
+ network,
28632
+ inboundTopicId,
28633
+ state,
28634
+ options,
28635
+ progressReporter
30469
28636
  );
28637
+ return confirmationResult;
30470
28638
  }
30471
- progressReporter.completed("Agent creation and registration complete");
28639
+ state.error = "No transaction ID returned from registration endpoint";
28640
+ progressReporter.failed(state.error, { state });
30472
28641
  return {
30473
- accountId,
30474
- operatorId: `${agentResult.outboundTopicId}@${accountId}`,
30475
- inboundTopicId: agentResult.inboundTopicId,
30476
- outboundTopicId: agentResult.outboundTopicId,
30477
- profileTopicId: agentResult.profileTopicId,
30478
- pfpTopicId: agentResult.pfpTopicId,
30479
- client: this
28642
+ success: false,
28643
+ error: state.error,
28644
+ state
30480
28645
  };
30481
28646
  } catch (error) {
30482
- throw new Error(`Failed to create and register agent: ${error.message}`);
28647
+ const errorMessage = `Error registering agent: ${error.message}`;
28648
+ this.logger.error(errorMessage);
28649
+ return {
28650
+ success: false,
28651
+ error: errorMessage,
28652
+ state: {
28653
+ inboundTopicId,
28654
+ currentStage: "registration",
28655
+ completedPercentage: 0,
28656
+ error: errorMessage
28657
+ }
28658
+ };
30483
28659
  }
30484
28660
  }
30485
- async registerAgentWithGuardedRegistry(accountId, inboundTopicId, network = this.network, options) {
28661
+ initializeRegistrationState(inboundTopicId, existingState) {
28662
+ const state = existingState || {
28663
+ inboundTopicId,
28664
+ currentStage: "registration",
28665
+ completedPercentage: 0,
28666
+ createdResources: []
28667
+ };
28668
+ if (state.currentStage !== "registration" && state.currentStage !== "complete") {
28669
+ state.currentStage = "registration";
28670
+ }
28671
+ return state;
28672
+ }
28673
+ buildGuardedRegistryUrl(network) {
28674
+ return this.guardedRegistryBaseUrl ? `${this.guardedRegistryBaseUrl}/api/guarded-registry/register` : `https://app${network === "mainnet" ? "" : "-testnet"}.hashgraph.online/api/guarded-registry/register`;
28675
+ }
28676
+ async submitRegistrationRequest(guardedRegistryUrl, accountId, inboundTopicId, network) {
28677
+ const body = {
28678
+ requesterTopicId: inboundTopicId,
28679
+ requesterMirrorNode: network === "mainnet" ? "mainnet" : "testnet",
28680
+ accountId
28681
+ };
28682
+ try {
28683
+ const response = await fetch(guardedRegistryUrl, {
28684
+ method: "POST",
28685
+ headers: {
28686
+ "Content-Type": "application/json"
28687
+ },
28688
+ body: JSON.stringify(body)
28689
+ });
28690
+ if (!response.ok) {
28691
+ let errorText = `Failed to register agent: ${response.status} ${response.statusText}`;
28692
+ try {
28693
+ const errorData = await response.json();
28694
+ if (errorData.errors && Array.isArray(errorData.errors)) {
28695
+ return {
28696
+ success: false,
28697
+ error: errorText,
28698
+ validationErrors: errorData.errors
28699
+ };
28700
+ }
28701
+ if (errorData.error) {
28702
+ errorText = errorData.error;
28703
+ }
28704
+ } catch (e) {
28705
+ }
28706
+ return {
28707
+ success: false,
28708
+ error: errorText
28709
+ };
28710
+ }
28711
+ const data = await response.json();
28712
+ return {
28713
+ success: true,
28714
+ data
28715
+ };
28716
+ } catch (error) {
28717
+ return {
28718
+ success: false,
28719
+ error: `Request failed: ${error.message}`
28720
+ };
28721
+ }
28722
+ }
28723
+ async confirmRegistration(transactionId, network, inboundTopicId, state, options, progressReporter) {
28724
+ const maxAttempts = options?.maxAttempts || 30;
28725
+ const delayMs = options?.delayMs || 2e3;
28726
+ const confirmationProgress = progressReporter?.createSubProgress({
28727
+ minPercent: 30,
28728
+ maxPercent: 100,
28729
+ logPrefix: "Confirmation"
28730
+ });
28731
+ const confirmed = await this.waitForRegistrationConfirmation(
28732
+ transactionId,
28733
+ network,
28734
+ this.guardedRegistryBaseUrl,
28735
+ maxAttempts,
28736
+ delayMs,
28737
+ (currentAttempt, maxAttempts2) => {
28738
+ const percent = 30 + currentAttempt / maxAttempts2 * 70;
28739
+ confirmationProgress?.report({
28740
+ stage: "confirming",
28741
+ message: `Confirming registration (attempt ${currentAttempt}/${maxAttempts2})`,
28742
+ progressPercent: percent,
28743
+ details: {
28744
+ currentAttempt,
28745
+ maxAttempts: maxAttempts2,
28746
+ transactionId,
28747
+ state
28748
+ }
28749
+ });
28750
+ }
28751
+ );
28752
+ if (!confirmed) {
28753
+ state.error = "Registration could not be confirmed after maximum attempts";
28754
+ confirmationProgress?.failed(state.error, { state });
28755
+ return {
28756
+ success: false,
28757
+ transaction: { transactionId },
28758
+ transactionId,
28759
+ confirmed: false,
28760
+ error: state.error,
28761
+ state
28762
+ };
28763
+ }
28764
+ this.updateStateForCompletedRegistration(state, inboundTopicId);
28765
+ progressReporter?.completed("Agent registration complete", {
28766
+ transactionId,
28767
+ inboundTopicId,
28768
+ state
28769
+ });
28770
+ return {
28771
+ success: true,
28772
+ transaction: { transactionId },
28773
+ transactionId,
28774
+ confirmed: true,
28775
+ state
28776
+ };
28777
+ }
28778
+ updateStateForCompletedRegistration(state, inboundTopicId) {
28779
+ state.currentStage = "complete";
28780
+ state.completedPercentage = 100;
28781
+ if (state.createdResources) {
28782
+ state.createdResources.push(`registration:${inboundTopicId}`);
28783
+ }
28784
+ }
28785
+ async createAndRegisterAgent(name, description, capabilities, metadata, pfpBuffer, pfpFileName, network, existingPfpTopicId, options) {
30486
28786
  try {
30487
- this.logger.info("Registering agent with guarded registry");
30488
- const maxAttempts = options?.maxAttempts ?? 60;
30489
- const delayMs = options?.delayMs ?? 2e3;
30490
28787
  const progressCallback = options?.progressCallback;
30491
28788
  const progressReporter = new ProgressReporter({
30492
- module: "AgentRegistration",
28789
+ module: "AgentCreateRegister",
30493
28790
  logger: this.logger,
30494
28791
  callback: progressCallback
30495
28792
  });
30496
- progressReporter.preparing("Preparing registry request", 10);
30497
- await new Promise((resolve) => setTimeout(resolve, 500));
30498
- progressReporter.preparing("Contacting registry service", 20);
30499
- const registrationResult = await this.executeRegistration(
30500
- accountId,
30501
- inboundTopicId,
30502
- network,
30503
- this.guardedRegistryBaseUrl,
30504
- this.logger
30505
- );
30506
- if (!registrationResult.success) {
30507
- progressReporter.failed("Registration request failed", {
30508
- error: registrationResult.error
30509
- });
30510
- return registrationResult;
30511
- }
30512
- progressReporter.submitting("Preparing registry transaction", 30, {
30513
- transactionId: registrationResult.transactionId
30514
- });
30515
- if (registrationResult.transaction) {
30516
- await new Promise((resolve) => setTimeout(resolve, 500));
30517
- progressReporter.submitting("Signing registry transaction", 40, {
30518
- transactionId: registrationResult.transactionId
30519
- });
30520
- const transaction = Transaction.fromBytes(
30521
- Buffer.from(registrationResult.transaction, "base64")
30522
- );
30523
- this.logger.info(`Processing registration transaction`);
30524
- progressReporter.submitting("Submitting transaction to network", 50, {
30525
- transactionId: registrationResult.transactionId
30526
- });
30527
- const txResult = await this.hwc.executeTransactionWithErrorHandling(
30528
- transaction,
30529
- false
30530
- );
30531
- if (txResult.error) {
30532
- progressReporter.failed("Transaction submission failed", {
30533
- error: txResult.error
30534
- });
30535
- return {
30536
- ...registrationResult,
30537
- error: txResult.error,
30538
- success: false
30539
- };
30540
- }
30541
- this.logger.info(`Successfully processed registration transaction`);
30542
- progressReporter.confirming("Transaction submitted successfully", 60, {
30543
- transactionId: registrationResult.transactionId
30544
- });
30545
- }
30546
- progressReporter.confirming("Waiting for transaction confirmation", 70, {
30547
- accountId,
30548
- inboundTopicId,
30549
- transactionId: registrationResult.transactionId
28793
+ let state = options?.existingState || {
28794
+ currentStage: "init",
28795
+ completedPercentage: 0,
28796
+ createdResources: []
28797
+ };
28798
+ progressReporter.preparing("Starting agent creation process", 0, {
28799
+ state
30550
28800
  });
30551
- const attemptGroups = Math.min(5, Math.ceil(maxAttempts / 10));
30552
- let confirmed = false;
30553
- for (let group = 0; group < attemptGroups && !confirmed; group++) {
30554
- const groupAttempts = Math.ceil(maxAttempts / attemptGroups);
30555
- const startPercent = 70 + group * 30 / attemptGroups;
30556
- const endPercent = 70 + (group + 1) * 30 / attemptGroups;
30557
- progressReporter.confirming(
30558
- `Verifying registration with registry (attempt group ${group + 1}/${attemptGroups})`,
30559
- startPercent,
28801
+ if (state.currentStage !== "complete" || !state.inboundTopicId || !state.outboundTopicId || !state.profileTopicId) {
28802
+ const agentResult = await this.createAgent(
28803
+ pfpBuffer,
28804
+ pfpFileName,
28805
+ name,
28806
+ description,
28807
+ capabilities,
28808
+ metadata,
28809
+ existingPfpTopicId || state.pfpTopicId,
30560
28810
  {
30561
- attemptGroup: group + 1,
30562
- totalGroups: attemptGroups
30563
- }
30564
- );
30565
- confirmed = await this.waitForRegistrationConfirmation(
30566
- registrationResult.transactionId,
30567
- network,
30568
- this.guardedRegistryBaseUrl,
30569
- groupAttempts,
30570
- delayMs,
30571
- (currentAttempt, maxAttempts2) => {
30572
- const progressInGroup = currentAttempt / groupAttempts;
30573
- const percentInGroup = startPercent + progressInGroup * (endPercent - startPercent);
30574
- progressReporter.confirming(
30575
- `Verifying registration with registry (attempt ${currentAttempt + group * groupAttempts}/${maxAttempts2})`,
30576
- percentInGroup,
30577
- {
30578
- currentAttempt: currentAttempt + group * groupAttempts,
30579
- maxAttempts: maxAttempts2
30580
- }
30581
- );
28811
+ progressCallback: (progress) => {
28812
+ const adjustedPercent = progress.progressPercent * 0.3;
28813
+ progressReporter.report({
28814
+ stage: progress.stage,
28815
+ message: progress.message,
28816
+ progressPercent: adjustedPercent,
28817
+ details: {
28818
+ ...progress.details,
28819
+ state: progress.details?.state || state
28820
+ }
28821
+ });
28822
+ },
28823
+ existingState: state
30582
28824
  }
30583
28825
  );
30584
- if (confirmed) {
30585
- break;
28826
+ if (!agentResult.success) {
28827
+ throw new Error(agentResult.error || "Failed to create agent");
30586
28828
  }
28829
+ state = agentResult.state;
30587
28830
  }
30588
- if (confirmed) {
30589
- progressReporter.completed("Agent registration complete", {
30590
- confirmed,
30591
- transactionId: registrationResult.transactionId
30592
- });
30593
- } else {
30594
- progressReporter.verifying(
30595
- "Registration verification timeout, please check status later",
30596
- 100,
28831
+ progressReporter.preparing(
28832
+ "Agent topics and profile created, preparing registration",
28833
+ 30,
28834
+ { state }
28835
+ );
28836
+ const { accountId } = this.getAccountAndSigner();
28837
+ if (state.currentStage !== "complete" || !state.createdResources?.includes(
28838
+ `registration:${state.inboundTopicId}`
28839
+ )) {
28840
+ const registrationResult = await this.registerAgentWithGuardedRegistry(
28841
+ accountId,
28842
+ state.inboundTopicId,
28843
+ network,
30597
28844
  {
30598
- confirmed,
30599
- transactionId: registrationResult.transactionId
28845
+ progressCallback: (progress) => {
28846
+ const adjustedPercent = 30 + (progress.progressPercent || 0) * 0.7;
28847
+ progressReporter.report({
28848
+ stage: progress.stage,
28849
+ message: progress.message,
28850
+ progressPercent: adjustedPercent,
28851
+ details: {
28852
+ ...progress.details,
28853
+ state: progress.details?.state || state
28854
+ }
28855
+ });
28856
+ },
28857
+ maxAttempts: options?.maxAttempts,
28858
+ delayMs: options?.delayMs,
28859
+ existingState: state
30600
28860
  }
30601
28861
  );
28862
+ if (!registrationResult.success) {
28863
+ throw new Error(
28864
+ registrationResult.error || "Failed to register agent with registry"
28865
+ );
28866
+ }
28867
+ state = registrationResult.state;
30602
28868
  }
28869
+ progressReporter.completed("Agent creation and registration complete", {
28870
+ state
28871
+ });
30603
28872
  return {
30604
- ...registrationResult,
30605
- confirmed
28873
+ accountId,
28874
+ operatorId: `${state.outboundTopicId}@${accountId}`,
28875
+ inboundTopicId: state.inboundTopicId,
28876
+ outboundTopicId: state.outboundTopicId,
28877
+ profileTopicId: state.profileTopicId,
28878
+ pfpTopicId: state.pfpTopicId,
28879
+ client: this,
28880
+ state
30606
28881
  };
30607
28882
  } catch (error) {
30608
- this.logger.error(`Registration error: ${error.message}`);
30609
- return {
30610
- error: `Error during registration: ${error.message}`,
30611
- success: false
30612
- };
28883
+ throw new Error(`Failed to create and register agent: ${error.message}`);
30613
28884
  }
30614
28885
  }
30615
28886
  async waitForRegistrationConfirmation(transactionId, network, guardedRegistryBaseUrl, maxAttempts = 60, delayMs = 2e3, progressCallbackOrLogger) {
@@ -30859,12 +29130,11 @@ class BrowserHCSClient extends HCS10BaseClient {
30859
29130
  this.logger.debug("Submitting payload");
30860
29131
  const transaction = new TopicMessageSubmitTransaction().setTopicId(topicId).setMessage(JSON.stringify(payload));
30861
29132
  return await this.hwc.executeTransactionWithErrorHandling(
30862
- // @ts-ignore
30863
29133
  transaction,
30864
29134
  false
30865
29135
  );
30866
29136
  }
30867
- async inscribeFile(buffer2, fileName) {
29137
+ async inscribeFile(buffer, fileName) {
30868
29138
  const { accountId, signer } = this.getAccountAndSigner();
30869
29139
  const mimeType = mimeTypesExports.lookup(fileName) || "application/octet-stream";
30870
29140
  const sdk = await InscriptionSDK.createWithAuth({
@@ -30877,7 +29147,7 @@ class BrowserHCSClient extends HCS10BaseClient {
30877
29147
  {
30878
29148
  file: {
30879
29149
  type: "base64",
30880
- base64: buffer2.toString("base64"),
29150
+ base64: buffer.toString("base64"),
30881
29151
  fileName,
30882
29152
  mimeType
30883
29153
  },
@@ -30911,13 +29181,7 @@ class BrowserHCSClient extends HCS10BaseClient {
30911
29181
  }
30912
29182
  return { accountId, signer };
30913
29183
  }
30914
- /**
30915
- * Inscribes a profile picture file to the Hedera network
30916
- * @param buffer File buffer to inscribe
30917
- * @param fileName Filename for the inscription
30918
- * @returns Object containing the topic ID and success status
30919
- */
30920
- async inscribePfp(buffer2, fileName, options) {
29184
+ async inscribePfp(buffer, fileName, options) {
30921
29185
  try {
30922
29186
  const progressCallback = options?.progressCallback;
30923
29187
  const progressReporter = new ProgressReporter({
@@ -30946,7 +29210,7 @@ class BrowserHCSClient extends HCS10BaseClient {
30946
29210
  });
30947
29211
  };
30948
29212
  const imageResult = await this.hcs11Client.inscribeImage(
30949
- buffer2,
29213
+ buffer,
30950
29214
  fileName,
30951
29215
  { progressCallback: wrappedProgressCallback }
30952
29216
  );