diff --git a/docs/dist/fireproof.iife.js b/docs/dist/fireproof.iife.js new file mode 100644 index 0000000..1a6b479 --- /dev/null +++ b/docs/dist/fireproof.iife.js @@ -0,0 +1,134303 @@ +"use strict"; +var Fireproof = (() => { + var __create = Object.create; + var __defProp = Object.defineProperty; + var __getOwnPropDesc = Object.getOwnPropertyDescriptor; + var __getOwnPropNames = Object.getOwnPropertyNames; + var __getProtoOf = Object.getPrototypeOf; + var __hasOwnProp = Object.prototype.hasOwnProperty; + var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; + var __esm = (fn, res) => function __init() { + return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; + }; + var __commonJS = (cb, mod3) => function __require() { + return mod3 || (0, cb[__getOwnPropNames(cb)[0]])((mod3 = { exports: {} }).exports, mod3), mod3.exports; + }; + var __export = (target, all7) => { + for (var name15 in all7) + __defProp(target, name15, { get: all7[name15], enumerable: true }); + }; + var __copyProps = (to, from18, except, desc) => { + if (from18 && typeof from18 === "object" || typeof from18 === "function") { + for (let key of __getOwnPropNames(from18)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from18[key], enumerable: !(desc = __getOwnPropDesc(from18, key)) || desc.enumerable }); + } + return to; + }; + var __toESM = (mod3, isNodeMode, target) => (target = mod3 != null ? __create(__getProtoOf(mod3)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod3 || !mod3.__esModule ? __defProp(target, "default", { value: mod3, enumerable: true }) : target, + mod3 + )); + var __toCommonJS = (mod3) => __copyProps(__defProp({}, "__esModule", { value: true }), mod3); + var __publicField = (obj, key, value) => { + __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); + return value; + }; + var __accessCheck = (obj, member, msg) => { + if (!member.has(obj)) + throw TypeError("Cannot " + msg); + }; + var __privateGet = (obj, member, getter) => { + __accessCheck(obj, member, "read from private field"); + return getter ? getter.call(obj) : member.get(obj); + }; + var __privateAdd = (obj, member, value) => { + if (member.has(obj)) + throw TypeError("Cannot add the same private member more than once"); + member instanceof WeakSet ? member.add(obj) : member.set(obj, value); + }; + var __privateSet = (obj, member, value, setter) => { + __accessCheck(obj, member, "write to private field"); + setter ? setter.call(obj, value) : member.set(obj, value); + return value; + }; + var __privateMethod = (obj, member, method) => { + __accessCheck(obj, member, "access private method"); + return method; + }; + + // ../../node_modules/.pnpm/esbuild-plugin-polyfill-node@0.3.0_esbuild@0.18.20/node_modules/esbuild-plugin-polyfill-node/polyfills/__dirname.js + var init_dirname = __esm({ + "../../node_modules/.pnpm/esbuild-plugin-polyfill-node@0.3.0_esbuild@0.18.20/node_modules/esbuild-plugin-polyfill-node/polyfills/__dirname.js"() { + } + }); + + // ../../node_modules/.pnpm/esbuild-plugin-polyfill-node@0.3.0_esbuild@0.18.20/node_modules/esbuild-plugin-polyfill-node/polyfills/empty.js + var init_empty = __esm({ + "../../node_modules/.pnpm/esbuild-plugin-polyfill-node@0.3.0_esbuild@0.18.20/node_modules/esbuild-plugin-polyfill-node/polyfills/empty.js"() { + init_dirname(); + init_buffer2(); + init_process(); + } + }); + + // ../../node_modules/.pnpm/esbuild-plugin-polyfill-node@0.3.0_esbuild@0.18.20/node_modules/esbuild-plugin-polyfill-node/polyfills/process.js + var init_process = __esm({ + "../../node_modules/.pnpm/esbuild-plugin-polyfill-node@0.3.0_esbuild@0.18.20/node_modules/esbuild-plugin-polyfill-node/polyfills/process.js"() { + init_empty(); + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/buffer.js + function dew$2() { + if (_dewExec$2) + return exports$3; + _dewExec$2 = true; + exports$3.byteLength = byteLength; + exports$3.toByteArray = toByteArray; + exports$3.fromByteArray = fromByteArray; + var lookup2 = []; + var revLookup = []; + var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array; + var code15 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + for (var i8 = 0, len = code15.length; i8 < len; ++i8) { + lookup2[i8] = code15[i8]; + revLookup[code15.charCodeAt(i8)] = i8; + } + revLookup["-".charCodeAt(0)] = 62; + revLookup["_".charCodeAt(0)] = 63; + function getLens(b64) { + var len2 = b64.length; + if (len2 % 4 > 0) { + throw new Error("Invalid string. Length must be a multiple of 4"); + } + var validLen = b64.indexOf("="); + if (validLen === -1) + validLen = len2; + var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4; + return [validLen, placeHoldersLen]; + } + function byteLength(b64) { + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; + } + function _byteLength(b64, validLen, placeHoldersLen) { + return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; + } + function toByteArray(b64) { + var tmp; + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); + var curByte = 0; + var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen; + var i9; + for (i9 = 0; i9 < len2; i9 += 4) { + tmp = revLookup[b64.charCodeAt(i9)] << 18 | revLookup[b64.charCodeAt(i9 + 1)] << 12 | revLookup[b64.charCodeAt(i9 + 2)] << 6 | revLookup[b64.charCodeAt(i9 + 3)]; + arr[curByte++] = tmp >> 16 & 255; + arr[curByte++] = tmp >> 8 & 255; + arr[curByte++] = tmp & 255; + } + if (placeHoldersLen === 2) { + tmp = revLookup[b64.charCodeAt(i9)] << 2 | revLookup[b64.charCodeAt(i9 + 1)] >> 4; + arr[curByte++] = tmp & 255; + } + if (placeHoldersLen === 1) { + tmp = revLookup[b64.charCodeAt(i9)] << 10 | revLookup[b64.charCodeAt(i9 + 1)] << 4 | revLookup[b64.charCodeAt(i9 + 2)] >> 2; + arr[curByte++] = tmp >> 8 & 255; + arr[curByte++] = tmp & 255; + } + return arr; + } + function tripletToBase64(num) { + return lookup2[num >> 18 & 63] + lookup2[num >> 12 & 63] + lookup2[num >> 6 & 63] + lookup2[num & 63]; + } + function encodeChunk(uint8, start, end) { + var tmp; + var output = []; + for (var i9 = start; i9 < end; i9 += 3) { + tmp = (uint8[i9] << 16 & 16711680) + (uint8[i9 + 1] << 8 & 65280) + (uint8[i9 + 2] & 255); + output.push(tripletToBase64(tmp)); + } + return output.join(""); + } + function fromByteArray(uint8) { + var tmp; + var len2 = uint8.length; + var extraBytes = len2 % 3; + var parts = []; + var maxChunkLength = 16383; + for (var i9 = 0, len22 = len2 - extraBytes; i9 < len22; i9 += maxChunkLength) { + parts.push(encodeChunk(uint8, i9, i9 + maxChunkLength > len22 ? len22 : i9 + maxChunkLength)); + } + if (extraBytes === 1) { + tmp = uint8[len2 - 1]; + parts.push(lookup2[tmp >> 2] + lookup2[tmp << 4 & 63] + "=="); + } else if (extraBytes === 2) { + tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1]; + parts.push(lookup2[tmp >> 10] + lookup2[tmp >> 4 & 63] + lookup2[tmp << 2 & 63] + "="); + } + return parts.join(""); + } + return exports$3; + } + function dew$1() { + if (_dewExec$1) + return exports$2; + _dewExec$1 = true; + exports$2.read = function(buffer4, offset2, isLE, mLen, nBytes) { + var e12, m7; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = -7; + var i8 = isLE ? nBytes - 1 : 0; + var d7 = isLE ? -1 : 1; + var s7 = buffer4[offset2 + i8]; + i8 += d7; + e12 = s7 & (1 << -nBits) - 1; + s7 >>= -nBits; + nBits += eLen; + for (; nBits > 0; e12 = e12 * 256 + buffer4[offset2 + i8], i8 += d7, nBits -= 8) { + } + m7 = e12 & (1 << -nBits) - 1; + e12 >>= -nBits; + nBits += mLen; + for (; nBits > 0; m7 = m7 * 256 + buffer4[offset2 + i8], i8 += d7, nBits -= 8) { + } + if (e12 === 0) { + e12 = 1 - eBias; + } else if (e12 === eMax) { + return m7 ? NaN : (s7 ? -1 : 1) * Infinity; + } else { + m7 = m7 + Math.pow(2, mLen); + e12 = e12 - eBias; + } + return (s7 ? -1 : 1) * m7 * Math.pow(2, e12 - mLen); + }; + exports$2.write = function(buffer4, value, offset2, isLE, mLen, nBytes) { + var e12, m7, c8; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; + var i8 = isLE ? 0 : nBytes - 1; + var d7 = isLE ? 1 : -1; + var s7 = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; + value = Math.abs(value); + if (isNaN(value) || value === Infinity) { + m7 = isNaN(value) ? 1 : 0; + e12 = eMax; + } else { + e12 = Math.floor(Math.log(value) / Math.LN2); + if (value * (c8 = Math.pow(2, -e12)) < 1) { + e12--; + c8 *= 2; + } + if (e12 + eBias >= 1) { + value += rt / c8; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c8 >= 2) { + e12++; + c8 /= 2; + } + if (e12 + eBias >= eMax) { + m7 = 0; + e12 = eMax; + } else if (e12 + eBias >= 1) { + m7 = (value * c8 - 1) * Math.pow(2, mLen); + e12 = e12 + eBias; + } else { + m7 = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e12 = 0; + } + } + for (; mLen >= 8; buffer4[offset2 + i8] = m7 & 255, i8 += d7, m7 /= 256, mLen -= 8) { + } + e12 = e12 << mLen | m7; + eLen += mLen; + for (; eLen > 0; buffer4[offset2 + i8] = e12 & 255, i8 += d7, e12 /= 256, eLen -= 8) { + } + buffer4[offset2 + i8 - d7] |= s7 * 128; + }; + return exports$2; + } + function dew() { + if (_dewExec) + return exports$1; + _dewExec = true; + const base643 = dew$2(); + const ieee754 = dew$1(); + const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null; + exports$1.Buffer = Buffer2; + exports$1.SlowBuffer = SlowBuffer; + exports$1.INSPECT_MAX_BYTES = 50; + const K_MAX_LENGTH = 2147483647; + exports$1.kMaxLength = K_MAX_LENGTH; + Buffer2.TYPED_ARRAY_SUPPORT = typedArraySupport(); + if (!Buffer2.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { + console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."); + } + function typedArraySupport() { + try { + const arr = new Uint8Array(1); + const proto = { + foo: function() { + return 42; + } + }; + Object.setPrototypeOf(proto, Uint8Array.prototype); + Object.setPrototypeOf(arr, proto); + return arr.foo() === 42; + } catch (e12) { + return false; + } + } + Object.defineProperty(Buffer2.prototype, "parent", { + enumerable: true, + get: function() { + if (!Buffer2.isBuffer(this)) + return void 0; + return this.buffer; + } + }); + Object.defineProperty(Buffer2.prototype, "offset", { + enumerable: true, + get: function() { + if (!Buffer2.isBuffer(this)) + return void 0; + return this.byteOffset; + } + }); + function createBuffer(length3) { + if (length3 > K_MAX_LENGTH) { + throw new RangeError('The value "' + length3 + '" is invalid for option "size"'); + } + const buf3 = new Uint8Array(length3); + Object.setPrototypeOf(buf3, Buffer2.prototype); + return buf3; + } + function Buffer2(arg, encodingOrOffset, length3) { + if (typeof arg === "number") { + if (typeof encodingOrOffset === "string") { + throw new TypeError('The "string" argument must be of type string. Received type number'); + } + return allocUnsafe2(arg); + } + return from18(arg, encodingOrOffset, length3); + } + Buffer2.poolSize = 8192; + function from18(value, encodingOrOffset, length3) { + if (typeof value === "string") { + return fromString6(value, encodingOrOffset); + } + if (ArrayBuffer.isView(value)) { + return fromArrayView(value); + } + if (value == null) { + throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); + } + if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) { + return fromArrayBuffer(value, encodingOrOffset, length3); + } + if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length3); + } + if (typeof value === "number") { + throw new TypeError('The "value" argument must not be of type number. Received type number'); + } + const valueOf = value.valueOf && value.valueOf(); + if (valueOf != null && valueOf !== value) { + return Buffer2.from(valueOf, encodingOrOffset, length3); + } + const b6 = fromObject(value); + if (b6) + return b6; + if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") { + return Buffer2.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length3); + } + throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); + } + Buffer2.from = function(value, encodingOrOffset, length3) { + return from18(value, encodingOrOffset, length3); + }; + Object.setPrototypeOf(Buffer2.prototype, Uint8Array.prototype); + Object.setPrototypeOf(Buffer2, Uint8Array); + function assertSize(size4) { + if (typeof size4 !== "number") { + throw new TypeError('"size" argument must be of type number'); + } else if (size4 < 0) { + throw new RangeError('The value "' + size4 + '" is invalid for option "size"'); + } + } + function alloc3(size4, fill, encoding) { + assertSize(size4); + if (size4 <= 0) { + return createBuffer(size4); + } + if (fill !== void 0) { + return typeof encoding === "string" ? createBuffer(size4).fill(fill, encoding) : createBuffer(size4).fill(fill); + } + return createBuffer(size4); + } + Buffer2.alloc = function(size4, fill, encoding) { + return alloc3(size4, fill, encoding); + }; + function allocUnsafe2(size4) { + assertSize(size4); + return createBuffer(size4 < 0 ? 0 : checked(size4) | 0); + } + Buffer2.allocUnsafe = function(size4) { + return allocUnsafe2(size4); + }; + Buffer2.allocUnsafeSlow = function(size4) { + return allocUnsafe2(size4); + }; + function fromString6(string4, encoding) { + if (typeof encoding !== "string" || encoding === "") { + encoding = "utf8"; + } + if (!Buffer2.isEncoding(encoding)) { + throw new TypeError("Unknown encoding: " + encoding); + } + const length3 = byteLength(string4, encoding) | 0; + let buf3 = createBuffer(length3); + const actual = buf3.write(string4, encoding); + if (actual !== length3) { + buf3 = buf3.slice(0, actual); + } + return buf3; + } + function fromArrayLike(array3) { + const length3 = array3.length < 0 ? 0 : checked(array3.length) | 0; + const buf3 = createBuffer(length3); + for (let i8 = 0; i8 < length3; i8 += 1) { + buf3[i8] = array3[i8] & 255; + } + return buf3; + } + function fromArrayView(arrayView) { + if (isInstance(arrayView, Uint8Array)) { + const copy = new Uint8Array(arrayView); + return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength); + } + return fromArrayLike(arrayView); + } + function fromArrayBuffer(array3, byteOffset, length3) { + if (byteOffset < 0 || array3.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds'); + } + if (array3.byteLength < byteOffset + (length3 || 0)) { + throw new RangeError('"length" is outside of buffer bounds'); + } + let buf3; + if (byteOffset === void 0 && length3 === void 0) { + buf3 = new Uint8Array(array3); + } else if (length3 === void 0) { + buf3 = new Uint8Array(array3, byteOffset); + } else { + buf3 = new Uint8Array(array3, byteOffset, length3); + } + Object.setPrototypeOf(buf3, Buffer2.prototype); + return buf3; + } + function fromObject(obj) { + if (Buffer2.isBuffer(obj)) { + const len = checked(obj.length) | 0; + const buf3 = createBuffer(len); + if (buf3.length === 0) { + return buf3; + } + obj.copy(buf3, 0, 0, len); + return buf3; + } + if (obj.length !== void 0) { + if (typeof obj.length !== "number" || numberIsNaN(obj.length)) { + return createBuffer(0); + } + return fromArrayLike(obj); + } + if (obj.type === "Buffer" && Array.isArray(obj.data)) { + return fromArrayLike(obj.data); + } + } + function checked(length3) { + if (length3 >= K_MAX_LENGTH) { + throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes"); + } + return length3 | 0; + } + function SlowBuffer(length3) { + if (+length3 != length3) { + length3 = 0; + } + return Buffer2.alloc(+length3); + } + Buffer2.isBuffer = function isBuffer7(b6) { + return b6 != null && b6._isBuffer === true && b6 !== Buffer2.prototype; + }; + Buffer2.compare = function compare7(a8, b6) { + if (isInstance(a8, Uint8Array)) + a8 = Buffer2.from(a8, a8.offset, a8.byteLength); + if (isInstance(b6, Uint8Array)) + b6 = Buffer2.from(b6, b6.offset, b6.byteLength); + if (!Buffer2.isBuffer(a8) || !Buffer2.isBuffer(b6)) { + throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); + } + if (a8 === b6) + return 0; + let x5 = a8.length; + let y7 = b6.length; + for (let i8 = 0, len = Math.min(x5, y7); i8 < len; ++i8) { + if (a8[i8] !== b6[i8]) { + x5 = a8[i8]; + y7 = b6[i8]; + break; + } + } + if (x5 < y7) + return -1; + if (y7 < x5) + return 1; + return 0; + }; + Buffer2.isEncoding = function isEncoding(encoding) { + switch (String(encoding).toLowerCase()) { + case "hex": + case "utf8": + case "utf-8": + case "ascii": + case "latin1": + case "binary": + case "base64": + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return true; + default: + return false; + } + }; + Buffer2.concat = function concat6(list10, length3) { + if (!Array.isArray(list10)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } + if (list10.length === 0) { + return Buffer2.alloc(0); + } + let i8; + if (length3 === void 0) { + length3 = 0; + for (i8 = 0; i8 < list10.length; ++i8) { + length3 += list10[i8].length; + } + } + const buffer4 = Buffer2.allocUnsafe(length3); + let pos = 0; + for (i8 = 0; i8 < list10.length; ++i8) { + let buf3 = list10[i8]; + if (isInstance(buf3, Uint8Array)) { + if (pos + buf3.length > buffer4.length) { + if (!Buffer2.isBuffer(buf3)) + buf3 = Buffer2.from(buf3); + buf3.copy(buffer4, pos); + } else { + Uint8Array.prototype.set.call(buffer4, buf3, pos); + } + } else if (!Buffer2.isBuffer(buf3)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } else { + buf3.copy(buffer4, pos); + } + pos += buf3.length; + } + return buffer4; + }; + function byteLength(string4, encoding) { + if (Buffer2.isBuffer(string4)) { + return string4.length; + } + if (ArrayBuffer.isView(string4) || isInstance(string4, ArrayBuffer)) { + return string4.byteLength; + } + if (typeof string4 !== "string") { + throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string4); + } + const len = string4.length; + const mustMatch = arguments.length > 2 && arguments[2] === true; + if (!mustMatch && len === 0) + return 0; + let loweredCase = false; + for (; ; ) { + switch (encoding) { + case "ascii": + case "latin1": + case "binary": + return len; + case "utf8": + case "utf-8": + return utf8ToBytes3(string4).length; + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return len * 2; + case "hex": + return len >>> 1; + case "base64": + return base64ToBytes(string4).length; + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes3(string4).length; + } + encoding = ("" + encoding).toLowerCase(); + loweredCase = true; + } + } + } + Buffer2.byteLength = byteLength; + function slowToString(encoding, start, end) { + let loweredCase = false; + if (start === void 0 || start < 0) { + start = 0; + } + if (start > this.length) { + return ""; + } + if (end === void 0 || end > this.length) { + end = this.length; + } + if (end <= 0) { + return ""; + } + end >>>= 0; + start >>>= 0; + if (end <= start) { + return ""; + } + if (!encoding) + encoding = "utf8"; + while (true) { + switch (encoding) { + case "hex": + return hexSlice(this, start, end); + case "utf8": + case "utf-8": + return utf8Slice3(this, start, end); + case "ascii": + return asciiSlice(this, start, end); + case "latin1": + case "binary": + return latin1Slice(this, start, end); + case "base64": + return base64Slice(this, start, end); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return utf16leSlice(this, start, end); + default: + if (loweredCase) + throw new TypeError("Unknown encoding: " + encoding); + encoding = (encoding + "").toLowerCase(); + loweredCase = true; + } + } + } + Buffer2.prototype._isBuffer = true; + function swap(b6, n9, m7) { + const i8 = b6[n9]; + b6[n9] = b6[m7]; + b6[m7] = i8; + } + Buffer2.prototype.swap16 = function swap16() { + const len = this.length; + if (len % 2 !== 0) { + throw new RangeError("Buffer size must be a multiple of 16-bits"); + } + for (let i8 = 0; i8 < len; i8 += 2) { + swap(this, i8, i8 + 1); + } + return this; + }; + Buffer2.prototype.swap32 = function swap32() { + const len = this.length; + if (len % 4 !== 0) { + throw new RangeError("Buffer size must be a multiple of 32-bits"); + } + for (let i8 = 0; i8 < len; i8 += 4) { + swap(this, i8, i8 + 3); + swap(this, i8 + 1, i8 + 2); + } + return this; + }; + Buffer2.prototype.swap64 = function swap64() { + const len = this.length; + if (len % 8 !== 0) { + throw new RangeError("Buffer size must be a multiple of 64-bits"); + } + for (let i8 = 0; i8 < len; i8 += 8) { + swap(this, i8, i8 + 7); + swap(this, i8 + 1, i8 + 6); + swap(this, i8 + 2, i8 + 5); + swap(this, i8 + 3, i8 + 4); + } + return this; + }; + Buffer2.prototype.toString = function toString6() { + const length3 = this.length; + if (length3 === 0) + return ""; + if (arguments.length === 0) + return utf8Slice3(this, 0, length3); + return slowToString.apply(this, arguments); + }; + Buffer2.prototype.toLocaleString = Buffer2.prototype.toString; + Buffer2.prototype.equals = function equals6(b6) { + if (!Buffer2.isBuffer(b6)) + throw new TypeError("Argument must be a Buffer"); + if (this === b6) + return true; + return Buffer2.compare(this, b6) === 0; + }; + Buffer2.prototype.inspect = function inspect3() { + let str = ""; + const max = exports$1.INSPECT_MAX_BYTES; + str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim(); + if (this.length > max) + str += " ... "; + return ""; + }; + if (customInspectSymbol) { + Buffer2.prototype[customInspectSymbol] = Buffer2.prototype.inspect; + } + Buffer2.prototype.compare = function compare7(target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer2.from(target, target.offset, target.byteLength); + } + if (!Buffer2.isBuffer(target)) { + throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target); + } + if (start === void 0) { + start = 0; + } + if (end === void 0) { + end = target ? target.length : 0; + } + if (thisStart === void 0) { + thisStart = 0; + } + if (thisEnd === void 0) { + thisEnd = this.length; + } + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError("out of range index"); + } + if (thisStart >= thisEnd && start >= end) { + return 0; + } + if (thisStart >= thisEnd) { + return -1; + } + if (start >= end) { + return 1; + } + start >>>= 0; + end >>>= 0; + thisStart >>>= 0; + thisEnd >>>= 0; + if (this === target) + return 0; + let x5 = thisEnd - thisStart; + let y7 = end - start; + const len = Math.min(x5, y7); + const thisCopy = this.slice(thisStart, thisEnd); + const targetCopy = target.slice(start, end); + for (let i8 = 0; i8 < len; ++i8) { + if (thisCopy[i8] !== targetCopy[i8]) { + x5 = thisCopy[i8]; + y7 = targetCopy[i8]; + break; + } + } + if (x5 < y7) + return -1; + if (y7 < x5) + return 1; + return 0; + }; + function bidirectionalIndexOf(buffer4, val, byteOffset, encoding, dir) { + if (buffer4.length === 0) + return -1; + if (typeof byteOffset === "string") { + encoding = byteOffset; + byteOffset = 0; + } else if (byteOffset > 2147483647) { + byteOffset = 2147483647; + } else if (byteOffset < -2147483648) { + byteOffset = -2147483648; + } + byteOffset = +byteOffset; + if (numberIsNaN(byteOffset)) { + byteOffset = dir ? 0 : buffer4.length - 1; + } + if (byteOffset < 0) + byteOffset = buffer4.length + byteOffset; + if (byteOffset >= buffer4.length) { + if (dir) + return -1; + else + byteOffset = buffer4.length - 1; + } else if (byteOffset < 0) { + if (dir) + byteOffset = 0; + else + return -1; + } + if (typeof val === "string") { + val = Buffer2.from(val, encoding); + } + if (Buffer2.isBuffer(val)) { + if (val.length === 0) { + return -1; + } + return arrayIndexOf(buffer4, val, byteOffset, encoding, dir); + } else if (typeof val === "number") { + val = val & 255; + if (typeof Uint8Array.prototype.indexOf === "function") { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer4, val, byteOffset); + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer4, val, byteOffset); + } + } + return arrayIndexOf(buffer4, [val], byteOffset, encoding, dir); + } + throw new TypeError("val must be string, number or Buffer"); + } + function arrayIndexOf(arr, val, byteOffset, encoding, dir) { + let indexSize = 1; + let arrLength = arr.length; + let valLength = val.length; + if (encoding !== void 0) { + encoding = String(encoding).toLowerCase(); + if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") { + if (arr.length < 2 || val.length < 2) { + return -1; + } + indexSize = 2; + arrLength /= 2; + valLength /= 2; + byteOffset /= 2; + } + } + function read13(buf3, i9) { + if (indexSize === 1) { + return buf3[i9]; + } else { + return buf3.readUInt16BE(i9 * indexSize); + } + } + let i8; + if (dir) { + let foundIndex = -1; + for (i8 = byteOffset; i8 < arrLength; i8++) { + if (read13(arr, i8) === read13(val, foundIndex === -1 ? 0 : i8 - foundIndex)) { + if (foundIndex === -1) + foundIndex = i8; + if (i8 - foundIndex + 1 === valLength) + return foundIndex * indexSize; + } else { + if (foundIndex !== -1) + i8 -= i8 - foundIndex; + foundIndex = -1; + } + } + } else { + if (byteOffset + valLength > arrLength) + byteOffset = arrLength - valLength; + for (i8 = byteOffset; i8 >= 0; i8--) { + let found = true; + for (let j5 = 0; j5 < valLength; j5++) { + if (read13(arr, i8 + j5) !== read13(val, j5)) { + found = false; + break; + } + } + if (found) + return i8; + } + } + return -1; + } + Buffer2.prototype.includes = function includes(val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1; + }; + Buffer2.prototype.indexOf = function indexOf2(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true); + }; + Buffer2.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false); + }; + function hexWrite(buf3, string4, offset2, length3) { + offset2 = Number(offset2) || 0; + const remaining = buf3.length - offset2; + if (!length3) { + length3 = remaining; + } else { + length3 = Number(length3); + if (length3 > remaining) { + length3 = remaining; + } + } + const strLen = string4.length; + if (length3 > strLen / 2) { + length3 = strLen / 2; + } + let i8; + for (i8 = 0; i8 < length3; ++i8) { + const parsed = parseInt(string4.substr(i8 * 2, 2), 16); + if (numberIsNaN(parsed)) + return i8; + buf3[offset2 + i8] = parsed; + } + return i8; + } + function utf8Write(buf3, string4, offset2, length3) { + return blitBuffer(utf8ToBytes3(string4, buf3.length - offset2), buf3, offset2, length3); + } + function asciiWrite(buf3, string4, offset2, length3) { + return blitBuffer(asciiToBytes(string4), buf3, offset2, length3); + } + function base64Write(buf3, string4, offset2, length3) { + return blitBuffer(base64ToBytes(string4), buf3, offset2, length3); + } + function ucs2Write(buf3, string4, offset2, length3) { + return blitBuffer(utf16leToBytes(string4, buf3.length - offset2), buf3, offset2, length3); + } + Buffer2.prototype.write = function write11(string4, offset2, length3, encoding) { + if (offset2 === void 0) { + encoding = "utf8"; + length3 = this.length; + offset2 = 0; + } else if (length3 === void 0 && typeof offset2 === "string") { + encoding = offset2; + length3 = this.length; + offset2 = 0; + } else if (isFinite(offset2)) { + offset2 = offset2 >>> 0; + if (isFinite(length3)) { + length3 = length3 >>> 0; + if (encoding === void 0) + encoding = "utf8"; + } else { + encoding = length3; + length3 = void 0; + } + } else { + throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported"); + } + const remaining = this.length - offset2; + if (length3 === void 0 || length3 > remaining) + length3 = remaining; + if (string4.length > 0 && (length3 < 0 || offset2 < 0) || offset2 > this.length) { + throw new RangeError("Attempt to write outside buffer bounds"); + } + if (!encoding) + encoding = "utf8"; + let loweredCase = false; + for (; ; ) { + switch (encoding) { + case "hex": + return hexWrite(this, string4, offset2, length3); + case "utf8": + case "utf-8": + return utf8Write(this, string4, offset2, length3); + case "ascii": + case "latin1": + case "binary": + return asciiWrite(this, string4, offset2, length3); + case "base64": + return base64Write(this, string4, offset2, length3); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return ucs2Write(this, string4, offset2, length3); + default: + if (loweredCase) + throw new TypeError("Unknown encoding: " + encoding); + encoding = ("" + encoding).toLowerCase(); + loweredCase = true; + } + } + }; + Buffer2.prototype.toJSON = function toJSON4() { + return { + type: "Buffer", + data: Array.prototype.slice.call(this._arr || this, 0) + }; + }; + function base64Slice(buf3, start, end) { + if (start === 0 && end === buf3.length) { + return base643.fromByteArray(buf3); + } else { + return base643.fromByteArray(buf3.slice(start, end)); + } + } + function utf8Slice3(buf3, start, end) { + end = Math.min(buf3.length, end); + const res = []; + let i8 = start; + while (i8 < end) { + const firstByte = buf3[i8]; + let codePoint = null; + let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1; + if (i8 + bytesPerSequence <= end) { + let secondByte, thirdByte, fourthByte, tempCodePoint; + switch (bytesPerSequence) { + case 1: + if (firstByte < 128) { + codePoint = firstByte; + } + break; + case 2: + secondByte = buf3[i8 + 1]; + if ((secondByte & 192) === 128) { + tempCodePoint = (firstByte & 31) << 6 | secondByte & 63; + if (tempCodePoint > 127) { + codePoint = tempCodePoint; + } + } + break; + case 3: + secondByte = buf3[i8 + 1]; + thirdByte = buf3[i8 + 2]; + if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) { + tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63; + if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) { + codePoint = tempCodePoint; + } + } + break; + case 4: + secondByte = buf3[i8 + 1]; + thirdByte = buf3[i8 + 2]; + fourthByte = buf3[i8 + 3]; + if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) { + tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63; + if (tempCodePoint > 65535 && tempCodePoint < 1114112) { + codePoint = tempCodePoint; + } + } + } + } + if (codePoint === null) { + codePoint = 65533; + bytesPerSequence = 1; + } else if (codePoint > 65535) { + codePoint -= 65536; + res.push(codePoint >>> 10 & 1023 | 55296); + codePoint = 56320 | codePoint & 1023; + } + res.push(codePoint); + i8 += bytesPerSequence; + } + return decodeCodePointsArray3(res); + } + const MAX_ARGUMENTS_LENGTH3 = 4096; + function decodeCodePointsArray3(codePoints) { + const len = codePoints.length; + if (len <= MAX_ARGUMENTS_LENGTH3) { + return String.fromCharCode.apply(String, codePoints); + } + let res = ""; + let i8 = 0; + while (i8 < len) { + res += String.fromCharCode.apply(String, codePoints.slice(i8, i8 += MAX_ARGUMENTS_LENGTH3)); + } + return res; + } + function asciiSlice(buf3, start, end) { + let ret = ""; + end = Math.min(buf3.length, end); + for (let i8 = start; i8 < end; ++i8) { + ret += String.fromCharCode(buf3[i8] & 127); + } + return ret; + } + function latin1Slice(buf3, start, end) { + let ret = ""; + end = Math.min(buf3.length, end); + for (let i8 = start; i8 < end; ++i8) { + ret += String.fromCharCode(buf3[i8]); + } + return ret; + } + function hexSlice(buf3, start, end) { + const len = buf3.length; + if (!start || start < 0) + start = 0; + if (!end || end < 0 || end > len) + end = len; + let out = ""; + for (let i8 = start; i8 < end; ++i8) { + out += hexSliceLookupTable[buf3[i8]]; + } + return out; + } + function utf16leSlice(buf3, start, end) { + const bytes2 = buf3.slice(start, end); + let res = ""; + for (let i8 = 0; i8 < bytes2.length - 1; i8 += 2) { + res += String.fromCharCode(bytes2[i8] + bytes2[i8 + 1] * 256); + } + return res; + } + Buffer2.prototype.slice = function slice4(start, end) { + const len = this.length; + start = ~~start; + end = end === void 0 ? len : ~~end; + if (start < 0) { + start += len; + if (start < 0) + start = 0; + } else if (start > len) { + start = len; + } + if (end < 0) { + end += len; + if (end < 0) + end = 0; + } else if (end > len) { + end = len; + } + if (end < start) + end = start; + const newBuf = this.subarray(start, end); + Object.setPrototypeOf(newBuf, Buffer2.prototype); + return newBuf; + }; + function checkOffset(offset2, ext, length3) { + if (offset2 % 1 !== 0 || offset2 < 0) + throw new RangeError("offset is not uint"); + if (offset2 + ext > length3) + throw new RangeError("Trying to access beyond buffer length"); + } + Buffer2.prototype.readUintLE = Buffer2.prototype.readUIntLE = function readUIntLE(offset2, byteLength2, noAssert) { + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) + checkOffset(offset2, byteLength2, this.length); + let val = this[offset2]; + let mul = 1; + let i8 = 0; + while (++i8 < byteLength2 && (mul *= 256)) { + val += this[offset2 + i8] * mul; + } + return val; + }; + Buffer2.prototype.readUintBE = Buffer2.prototype.readUIntBE = function readUIntBE(offset2, byteLength2, noAssert) { + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) { + checkOffset(offset2, byteLength2, this.length); + } + let val = this[offset2 + --byteLength2]; + let mul = 1; + while (byteLength2 > 0 && (mul *= 256)) { + val += this[offset2 + --byteLength2] * mul; + } + return val; + }; + Buffer2.prototype.readUint8 = Buffer2.prototype.readUInt8 = function readUInt8(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 1, this.length); + return this[offset2]; + }; + Buffer2.prototype.readUint16LE = Buffer2.prototype.readUInt16LE = function readUInt16LE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 2, this.length); + return this[offset2] | this[offset2 + 1] << 8; + }; + Buffer2.prototype.readUint16BE = Buffer2.prototype.readUInt16BE = function readUInt16BE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 2, this.length); + return this[offset2] << 8 | this[offset2 + 1]; + }; + Buffer2.prototype.readUint32LE = Buffer2.prototype.readUInt32LE = function readUInt32LE3(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return (this[offset2] | this[offset2 + 1] << 8 | this[offset2 + 2] << 16) + this[offset2 + 3] * 16777216; + }; + Buffer2.prototype.readUint32BE = Buffer2.prototype.readUInt32BE = function readUInt32BE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return this[offset2] * 16777216 + (this[offset2 + 1] << 16 | this[offset2 + 2] << 8 | this[offset2 + 3]); + }; + Buffer2.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset2) { + offset2 = offset2 >>> 0; + validateNumber(offset2, "offset"); + const first = this[offset2]; + const last2 = this[offset2 + 7]; + if (first === void 0 || last2 === void 0) { + boundsError(offset2, this.length - 8); + } + const lo = first + this[++offset2] * 2 ** 8 + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 24; + const hi = this[++offset2] + this[++offset2] * 2 ** 8 + this[++offset2] * 2 ** 16 + last2 * 2 ** 24; + return BigInt(lo) + (BigInt(hi) << BigInt(32)); + }); + Buffer2.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset2) { + offset2 = offset2 >>> 0; + validateNumber(offset2, "offset"); + const first = this[offset2]; + const last2 = this[offset2 + 7]; + if (first === void 0 || last2 === void 0) { + boundsError(offset2, this.length - 8); + } + const hi = first * 2 ** 24 + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 8 + this[++offset2]; + const lo = this[++offset2] * 2 ** 24 + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 8 + last2; + return (BigInt(hi) << BigInt(32)) + BigInt(lo); + }); + Buffer2.prototype.readIntLE = function readIntLE(offset2, byteLength2, noAssert) { + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) + checkOffset(offset2, byteLength2, this.length); + let val = this[offset2]; + let mul = 1; + let i8 = 0; + while (++i8 < byteLength2 && (mul *= 256)) { + val += this[offset2 + i8] * mul; + } + mul *= 128; + if (val >= mul) + val -= Math.pow(2, 8 * byteLength2); + return val; + }; + Buffer2.prototype.readIntBE = function readIntBE(offset2, byteLength2, noAssert) { + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) + checkOffset(offset2, byteLength2, this.length); + let i8 = byteLength2; + let mul = 1; + let val = this[offset2 + --i8]; + while (i8 > 0 && (mul *= 256)) { + val += this[offset2 + --i8] * mul; + } + mul *= 128; + if (val >= mul) + val -= Math.pow(2, 8 * byteLength2); + return val; + }; + Buffer2.prototype.readInt8 = function readInt8(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 1, this.length); + if (!(this[offset2] & 128)) + return this[offset2]; + return (255 - this[offset2] + 1) * -1; + }; + Buffer2.prototype.readInt16LE = function readInt16LE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 2, this.length); + const val = this[offset2] | this[offset2 + 1] << 8; + return val & 32768 ? val | 4294901760 : val; + }; + Buffer2.prototype.readInt16BE = function readInt16BE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 2, this.length); + const val = this[offset2 + 1] | this[offset2] << 8; + return val & 32768 ? val | 4294901760 : val; + }; + Buffer2.prototype.readInt32LE = function readInt32LE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return this[offset2] | this[offset2 + 1] << 8 | this[offset2 + 2] << 16 | this[offset2 + 3] << 24; + }; + Buffer2.prototype.readInt32BE = function readInt32BE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return this[offset2] << 24 | this[offset2 + 1] << 16 | this[offset2 + 2] << 8 | this[offset2 + 3]; + }; + Buffer2.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset2) { + offset2 = offset2 >>> 0; + validateNumber(offset2, "offset"); + const first = this[offset2]; + const last2 = this[offset2 + 7]; + if (first === void 0 || last2 === void 0) { + boundsError(offset2, this.length - 8); + } + const val = this[offset2 + 4] + this[offset2 + 5] * 2 ** 8 + this[offset2 + 6] * 2 ** 16 + (last2 << 24); + return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset2] * 2 ** 8 + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 24); + }); + Buffer2.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset2) { + offset2 = offset2 >>> 0; + validateNumber(offset2, "offset"); + const first = this[offset2]; + const last2 = this[offset2 + 7]; + if (first === void 0 || last2 === void 0) { + boundsError(offset2, this.length - 8); + } + const val = (first << 24) + // Overflow + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 8 + this[++offset2]; + return (BigInt(val) << BigInt(32)) + BigInt(this[++offset2] * 2 ** 24 + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 8 + last2); + }); + Buffer2.prototype.readFloatLE = function readFloatLE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return ieee754.read(this, offset2, true, 23, 4); + }; + Buffer2.prototype.readFloatBE = function readFloatBE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return ieee754.read(this, offset2, false, 23, 4); + }; + Buffer2.prototype.readDoubleLE = function readDoubleLE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 8, this.length); + return ieee754.read(this, offset2, true, 52, 8); + }; + Buffer2.prototype.readDoubleBE = function readDoubleBE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 8, this.length); + return ieee754.read(this, offset2, false, 52, 8); + }; + function checkInt(buf3, value, offset2, ext, max, min) { + if (!Buffer2.isBuffer(buf3)) + throw new TypeError('"buffer" argument must be a Buffer instance'); + if (value > max || value < min) + throw new RangeError('"value" argument is out of bounds'); + if (offset2 + ext > buf3.length) + throw new RangeError("Index out of range"); + } + Buffer2.prototype.writeUintLE = Buffer2.prototype.writeUIntLE = function writeUIntLE(value, offset2, byteLength2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) { + const maxBytes = Math.pow(2, 8 * byteLength2) - 1; + checkInt(this, value, offset2, byteLength2, maxBytes, 0); + } + let mul = 1; + let i8 = 0; + this[offset2] = value & 255; + while (++i8 < byteLength2 && (mul *= 256)) { + this[offset2 + i8] = value / mul & 255; + } + return offset2 + byteLength2; + }; + Buffer2.prototype.writeUintBE = Buffer2.prototype.writeUIntBE = function writeUIntBE(value, offset2, byteLength2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) { + const maxBytes = Math.pow(2, 8 * byteLength2) - 1; + checkInt(this, value, offset2, byteLength2, maxBytes, 0); + } + let i8 = byteLength2 - 1; + let mul = 1; + this[offset2 + i8] = value & 255; + while (--i8 >= 0 && (mul *= 256)) { + this[offset2 + i8] = value / mul & 255; + } + return offset2 + byteLength2; + }; + Buffer2.prototype.writeUint8 = Buffer2.prototype.writeUInt8 = function writeUInt8(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 1, 255, 0); + this[offset2] = value & 255; + return offset2 + 1; + }; + Buffer2.prototype.writeUint16LE = Buffer2.prototype.writeUInt16LE = function writeUInt16LE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 2, 65535, 0); + this[offset2] = value & 255; + this[offset2 + 1] = value >>> 8; + return offset2 + 2; + }; + Buffer2.prototype.writeUint16BE = Buffer2.prototype.writeUInt16BE = function writeUInt16BE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 2, 65535, 0); + this[offset2] = value >>> 8; + this[offset2 + 1] = value & 255; + return offset2 + 2; + }; + Buffer2.prototype.writeUint32LE = Buffer2.prototype.writeUInt32LE = function writeUInt32LE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 4, 4294967295, 0); + this[offset2 + 3] = value >>> 24; + this[offset2 + 2] = value >>> 16; + this[offset2 + 1] = value >>> 8; + this[offset2] = value & 255; + return offset2 + 4; + }; + Buffer2.prototype.writeUint32BE = Buffer2.prototype.writeUInt32BE = function writeUInt32BE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 4, 4294967295, 0); + this[offset2] = value >>> 24; + this[offset2 + 1] = value >>> 16; + this[offset2 + 2] = value >>> 8; + this[offset2 + 3] = value & 255; + return offset2 + 4; + }; + function wrtBigUInt64LE(buf3, value, offset2, min, max) { + checkIntBI(value, min, max, buf3, offset2, 7); + let lo = Number(value & BigInt(4294967295)); + buf3[offset2++] = lo; + lo = lo >> 8; + buf3[offset2++] = lo; + lo = lo >> 8; + buf3[offset2++] = lo; + lo = lo >> 8; + buf3[offset2++] = lo; + let hi = Number(value >> BigInt(32) & BigInt(4294967295)); + buf3[offset2++] = hi; + hi = hi >> 8; + buf3[offset2++] = hi; + hi = hi >> 8; + buf3[offset2++] = hi; + hi = hi >> 8; + buf3[offset2++] = hi; + return offset2; + } + function wrtBigUInt64BE(buf3, value, offset2, min, max) { + checkIntBI(value, min, max, buf3, offset2, 7); + let lo = Number(value & BigInt(4294967295)); + buf3[offset2 + 7] = lo; + lo = lo >> 8; + buf3[offset2 + 6] = lo; + lo = lo >> 8; + buf3[offset2 + 5] = lo; + lo = lo >> 8; + buf3[offset2 + 4] = lo; + let hi = Number(value >> BigInt(32) & BigInt(4294967295)); + buf3[offset2 + 3] = hi; + hi = hi >> 8; + buf3[offset2 + 2] = hi; + hi = hi >> 8; + buf3[offset2 + 1] = hi; + hi = hi >> 8; + buf3[offset2] = hi; + return offset2 + 8; + } + Buffer2.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset2 = 0) { + return wrtBigUInt64LE(this, value, offset2, BigInt(0), BigInt("0xffffffffffffffff")); + }); + Buffer2.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset2 = 0) { + return wrtBigUInt64BE(this, value, offset2, BigInt(0), BigInt("0xffffffffffffffff")); + }); + Buffer2.prototype.writeIntLE = function writeIntLE(value, offset2, byteLength2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) { + const limit = Math.pow(2, 8 * byteLength2 - 1); + checkInt(this, value, offset2, byteLength2, limit - 1, -limit); + } + let i8 = 0; + let mul = 1; + let sub = 0; + this[offset2] = value & 255; + while (++i8 < byteLength2 && (mul *= 256)) { + if (value < 0 && sub === 0 && this[offset2 + i8 - 1] !== 0) { + sub = 1; + } + this[offset2 + i8] = (value / mul >> 0) - sub & 255; + } + return offset2 + byteLength2; + }; + Buffer2.prototype.writeIntBE = function writeIntBE(value, offset2, byteLength2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) { + const limit = Math.pow(2, 8 * byteLength2 - 1); + checkInt(this, value, offset2, byteLength2, limit - 1, -limit); + } + let i8 = byteLength2 - 1; + let mul = 1; + let sub = 0; + this[offset2 + i8] = value & 255; + while (--i8 >= 0 && (mul *= 256)) { + if (value < 0 && sub === 0 && this[offset2 + i8 + 1] !== 0) { + sub = 1; + } + this[offset2 + i8] = (value / mul >> 0) - sub & 255; + } + return offset2 + byteLength2; + }; + Buffer2.prototype.writeInt8 = function writeInt8(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 1, 127, -128); + if (value < 0) + value = 255 + value + 1; + this[offset2] = value & 255; + return offset2 + 1; + }; + Buffer2.prototype.writeInt16LE = function writeInt16LE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 2, 32767, -32768); + this[offset2] = value & 255; + this[offset2 + 1] = value >>> 8; + return offset2 + 2; + }; + Buffer2.prototype.writeInt16BE = function writeInt16BE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 2, 32767, -32768); + this[offset2] = value >>> 8; + this[offset2 + 1] = value & 255; + return offset2 + 2; + }; + Buffer2.prototype.writeInt32LE = function writeInt32LE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 4, 2147483647, -2147483648); + this[offset2] = value & 255; + this[offset2 + 1] = value >>> 8; + this[offset2 + 2] = value >>> 16; + this[offset2 + 3] = value >>> 24; + return offset2 + 4; + }; + Buffer2.prototype.writeInt32BE = function writeInt32BE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 4, 2147483647, -2147483648); + if (value < 0) + value = 4294967295 + value + 1; + this[offset2] = value >>> 24; + this[offset2 + 1] = value >>> 16; + this[offset2 + 2] = value >>> 8; + this[offset2 + 3] = value & 255; + return offset2 + 4; + }; + Buffer2.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset2 = 0) { + return wrtBigUInt64LE(this, value, offset2, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); + }); + Buffer2.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset2 = 0) { + return wrtBigUInt64BE(this, value, offset2, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); + }); + function checkIEEE754(buf3, value, offset2, ext, max, min) { + if (offset2 + ext > buf3.length) + throw new RangeError("Index out of range"); + if (offset2 < 0) + throw new RangeError("Index out of range"); + } + function writeFloat(buf3, value, offset2, littleEndian, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) { + checkIEEE754(buf3, value, offset2, 4); + } + ieee754.write(buf3, value, offset2, littleEndian, 23, 4); + return offset2 + 4; + } + Buffer2.prototype.writeFloatLE = function writeFloatLE(value, offset2, noAssert) { + return writeFloat(this, value, offset2, true, noAssert); + }; + Buffer2.prototype.writeFloatBE = function writeFloatBE(value, offset2, noAssert) { + return writeFloat(this, value, offset2, false, noAssert); + }; + function writeDouble(buf3, value, offset2, littleEndian, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) { + checkIEEE754(buf3, value, offset2, 8); + } + ieee754.write(buf3, value, offset2, littleEndian, 52, 8); + return offset2 + 8; + } + Buffer2.prototype.writeDoubleLE = function writeDoubleLE(value, offset2, noAssert) { + return writeDouble(this, value, offset2, true, noAssert); + }; + Buffer2.prototype.writeDoubleBE = function writeDoubleBE(value, offset2, noAssert) { + return writeDouble(this, value, offset2, false, noAssert); + }; + Buffer2.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer2.isBuffer(target)) + throw new TypeError("argument should be a Buffer"); + if (!start) + start = 0; + if (!end && end !== 0) + end = this.length; + if (targetStart >= target.length) + targetStart = target.length; + if (!targetStart) + targetStart = 0; + if (end > 0 && end < start) + end = start; + if (end === start) + return 0; + if (target.length === 0 || this.length === 0) + return 0; + if (targetStart < 0) { + throw new RangeError("targetStart out of bounds"); + } + if (start < 0 || start >= this.length) + throw new RangeError("Index out of range"); + if (end < 0) + throw new RangeError("sourceEnd out of bounds"); + if (end > this.length) + end = this.length; + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start; + } + const len = end - start; + if (this === target && typeof Uint8Array.prototype.copyWithin === "function") { + this.copyWithin(targetStart, start, end); + } else { + Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart); + } + return len; + }; + Buffer2.prototype.fill = function fill(val, start, end, encoding) { + if (typeof val === "string") { + if (typeof start === "string") { + encoding = start; + start = 0; + end = this.length; + } else if (typeof end === "string") { + encoding = end; + end = this.length; + } + if (encoding !== void 0 && typeof encoding !== "string") { + throw new TypeError("encoding must be a string"); + } + if (typeof encoding === "string" && !Buffer2.isEncoding(encoding)) { + throw new TypeError("Unknown encoding: " + encoding); + } + if (val.length === 1) { + const code15 = val.charCodeAt(0); + if (encoding === "utf8" && code15 < 128 || encoding === "latin1") { + val = code15; + } + } + } else if (typeof val === "number") { + val = val & 255; + } else if (typeof val === "boolean") { + val = Number(val); + } + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError("Out of range index"); + } + if (end <= start) { + return this; + } + start = start >>> 0; + end = end === void 0 ? this.length : end >>> 0; + if (!val) + val = 0; + let i8; + if (typeof val === "number") { + for (i8 = start; i8 < end; ++i8) { + this[i8] = val; + } + } else { + const bytes2 = Buffer2.isBuffer(val) ? val : Buffer2.from(val, encoding); + const len = bytes2.length; + if (len === 0) { + throw new TypeError('The value "' + val + '" is invalid for argument "value"'); + } + for (i8 = 0; i8 < end - start; ++i8) { + this[i8 + start] = bytes2[i8 % len]; + } + } + return this; + }; + const errors = {}; + function E5(sym, getMessage, Base2) { + errors[sym] = class NodeError extends Base2 { + constructor() { + super(); + Object.defineProperty(this, "message", { + value: getMessage.apply(this, arguments), + writable: true, + configurable: true + }); + this.name = `${this.name} [${sym}]`; + this.stack; + delete this.name; + } + get code() { + return sym; + } + set code(value) { + Object.defineProperty(this, "code", { + configurable: true, + enumerable: true, + value, + writable: true + }); + } + toString() { + return `${this.name} [${sym}]: ${this.message}`; + } + }; + } + E5("ERR_BUFFER_OUT_OF_BOUNDS", function(name15) { + if (name15) { + return `${name15} is outside of buffer bounds`; + } + return "Attempt to access memory outside buffer bounds"; + }, RangeError); + E5("ERR_INVALID_ARG_TYPE", function(name15, actual) { + return `The "${name15}" argument must be of type number. Received type ${typeof actual}`; + }, TypeError); + E5("ERR_OUT_OF_RANGE", function(str, range, input) { + let msg = `The value of "${str}" is out of range.`; + let received = input; + if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) { + received = addNumericalSeparator(String(input)); + } else if (typeof input === "bigint") { + received = String(input); + if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) { + received = addNumericalSeparator(received); + } + received += "n"; + } + msg += ` It must be ${range}. Received ${received}`; + return msg; + }, RangeError); + function addNumericalSeparator(val) { + let res = ""; + let i8 = val.length; + const start = val[0] === "-" ? 1 : 0; + for (; i8 >= start + 4; i8 -= 3) { + res = `_${val.slice(i8 - 3, i8)}${res}`; + } + return `${val.slice(0, i8)}${res}`; + } + function checkBounds(buf3, offset2, byteLength2) { + validateNumber(offset2, "offset"); + if (buf3[offset2] === void 0 || buf3[offset2 + byteLength2] === void 0) { + boundsError(offset2, buf3.length - (byteLength2 + 1)); + } + } + function checkIntBI(value, min, max, buf3, offset2, byteLength2) { + if (value > max || value < min) { + const n9 = typeof min === "bigint" ? "n" : ""; + let range; + if (byteLength2 > 3) { + if (min === 0 || min === BigInt(0)) { + range = `>= 0${n9} and < 2${n9} ** ${(byteLength2 + 1) * 8}${n9}`; + } else { + range = `>= -(2${n9} ** ${(byteLength2 + 1) * 8 - 1}${n9}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n9}`; + } + } else { + range = `>= ${min}${n9} and <= ${max}${n9}`; + } + throw new errors.ERR_OUT_OF_RANGE("value", range, value); + } + checkBounds(buf3, offset2, byteLength2); + } + function validateNumber(value, name15) { + if (typeof value !== "number") { + throw new errors.ERR_INVALID_ARG_TYPE(name15, "number", value); + } + } + function boundsError(value, length3, type3) { + if (Math.floor(value) !== value) { + validateNumber(value, type3); + throw new errors.ERR_OUT_OF_RANGE(type3 || "offset", "an integer", value); + } + if (length3 < 0) { + throw new errors.ERR_BUFFER_OUT_OF_BOUNDS(); + } + throw new errors.ERR_OUT_OF_RANGE(type3 || "offset", `>= ${type3 ? 1 : 0} and <= ${length3}`, value); + } + const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; + function base64clean(str) { + str = str.split("=")[0]; + str = str.trim().replace(INVALID_BASE64_RE, ""); + if (str.length < 2) + return ""; + while (str.length % 4 !== 0) { + str = str + "="; + } + return str; + } + function utf8ToBytes3(string4, units) { + units = units || Infinity; + let codePoint; + const length3 = string4.length; + let leadSurrogate = null; + const bytes2 = []; + for (let i8 = 0; i8 < length3; ++i8) { + codePoint = string4.charCodeAt(i8); + if (codePoint > 55295 && codePoint < 57344) { + if (!leadSurrogate) { + if (codePoint > 56319) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + continue; + } else if (i8 + 1 === length3) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + continue; + } + leadSurrogate = codePoint; + continue; + } + if (codePoint < 56320) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + leadSurrogate = codePoint; + continue; + } + codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536; + } else if (leadSurrogate) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + } + leadSurrogate = null; + if (codePoint < 128) { + if ((units -= 1) < 0) + break; + bytes2.push(codePoint); + } else if (codePoint < 2048) { + if ((units -= 2) < 0) + break; + bytes2.push(codePoint >> 6 | 192, codePoint & 63 | 128); + } else if (codePoint < 65536) { + if ((units -= 3) < 0) + break; + bytes2.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128); + } else if (codePoint < 1114112) { + if ((units -= 4) < 0) + break; + bytes2.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128); + } else { + throw new Error("Invalid code point"); + } + } + return bytes2; + } + function asciiToBytes(str) { + const byteArray = []; + for (let i8 = 0; i8 < str.length; ++i8) { + byteArray.push(str.charCodeAt(i8) & 255); + } + return byteArray; + } + function utf16leToBytes(str, units) { + let c8, hi, lo; + const byteArray = []; + for (let i8 = 0; i8 < str.length; ++i8) { + if ((units -= 2) < 0) + break; + c8 = str.charCodeAt(i8); + hi = c8 >> 8; + lo = c8 % 256; + byteArray.push(lo); + byteArray.push(hi); + } + return byteArray; + } + function base64ToBytes(str) { + return base643.toByteArray(base64clean(str)); + } + function blitBuffer(src3, dst, offset2, length3) { + let i8; + for (i8 = 0; i8 < length3; ++i8) { + if (i8 + offset2 >= dst.length || i8 >= src3.length) + break; + dst[i8 + offset2] = src3[i8]; + } + return i8; + } + function isInstance(obj, type3) { + return obj instanceof type3 || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type3.name; + } + function numberIsNaN(obj) { + return obj !== obj; + } + const hexSliceLookupTable = function() { + const alphabet2 = "0123456789abcdef"; + const table = new Array(256); + for (let i8 = 0; i8 < 16; ++i8) { + const i16 = i8 * 16; + for (let j5 = 0; j5 < 16; ++j5) { + table[i16 + j5] = alphabet2[i8] + alphabet2[j5]; + } + } + return table; + }(); + function defineBigIntMethod(fn) { + return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn; + } + function BufferBigIntNotDefined() { + throw new Error("BigInt not supported"); + } + return exports$1; + } + var exports$3, _dewExec$2, exports$2, _dewExec$1, exports$1, _dewExec, exports2, Buffer, INSPECT_MAX_BYTES, kMaxLength; + var init_buffer = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/buffer.js"() { + init_dirname(); + init_buffer2(); + init_process(); + exports$3 = {}; + _dewExec$2 = false; + exports$2 = {}; + _dewExec$1 = false; + exports$1 = {}; + _dewExec = false; + exports2 = dew(); + exports2["Buffer"]; + exports2["SlowBuffer"]; + exports2["INSPECT_MAX_BYTES"]; + exports2["kMaxLength"]; + Buffer = exports2.Buffer; + INSPECT_MAX_BYTES = exports2.INSPECT_MAX_BYTES; + kMaxLength = exports2.kMaxLength; + } + }); + + // ../../node_modules/.pnpm/esbuild-plugin-polyfill-node@0.3.0_esbuild@0.18.20/node_modules/esbuild-plugin-polyfill-node/polyfills/buffer.js + var init_buffer2 = __esm({ + "../../node_modules/.pnpm/esbuild-plugin-polyfill-node@0.3.0_esbuild@0.18.20/node_modules/esbuild-plugin-polyfill-node/polyfills/buffer.js"() { + init_buffer(); + } + }); + + // ../../node_modules/.pnpm/cross-fetch@4.0.0/node_modules/cross-fetch/dist/browser-ponyfill.js + var require_browser_ponyfill = __commonJS({ + "../../node_modules/.pnpm/cross-fetch@4.0.0/node_modules/cross-fetch/dist/browser-ponyfill.js"(exports12, module3) { + init_dirname(); + init_buffer2(); + init_process(); + var __global__ = typeof globalThis !== "undefined" && globalThis || typeof self !== "undefined" && self || typeof global !== "undefined" && global; + var __globalThis__ = function() { + function F5() { + this.fetch = false; + this.DOMException = __global__.DOMException; + } + F5.prototype = __global__; + return new F5(); + }(); + (function(globalThis2) { + var irrelevant = function(exports13) { + var global2 = typeof globalThis2 !== "undefined" && globalThis2 || typeof self !== "undefined" && self || typeof global2 !== "undefined" && global2; + var support = { + searchParams: "URLSearchParams" in global2, + iterable: "Symbol" in global2 && "iterator" in Symbol, + blob: "FileReader" in global2 && "Blob" in global2 && function() { + try { + new Blob(); + return true; + } catch (e12) { + return false; + } + }(), + formData: "FormData" in global2, + arrayBuffer: "ArrayBuffer" in global2 + }; + function isDataView(obj) { + return obj && DataView.prototype.isPrototypeOf(obj); + } + if (support.arrayBuffer) { + var viewClasses = [ + "[object Int8Array]", + "[object Uint8Array]", + "[object Uint8ClampedArray]", + "[object Int16Array]", + "[object Uint16Array]", + "[object Int32Array]", + "[object Uint32Array]", + "[object Float32Array]", + "[object Float64Array]" + ]; + var isArrayBufferView = ArrayBuffer.isView || function(obj) { + return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1; + }; + } + function normalizeName(name15) { + if (typeof name15 !== "string") { + name15 = String(name15); + } + if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name15) || name15 === "") { + throw new TypeError('Invalid character in header field name: "' + name15 + '"'); + } + return name15.toLowerCase(); + } + function normalizeValue(value) { + if (typeof value !== "string") { + value = String(value); + } + return value; + } + function iteratorFor(items) { + var iterator = { + next: function() { + var value = items.shift(); + return { done: value === void 0, value }; + } + }; + if (support.iterable) { + iterator[Symbol.iterator] = function() { + return iterator; + }; + } + return iterator; + } + function Headers(headers) { + this.map = {}; + if (headers instanceof Headers) { + headers.forEach(function(value, name15) { + this.append(name15, value); + }, this); + } else if (Array.isArray(headers)) { + headers.forEach(function(header) { + this.append(header[0], header[1]); + }, this); + } else if (headers) { + Object.getOwnPropertyNames(headers).forEach(function(name15) { + this.append(name15, headers[name15]); + }, this); + } + } + Headers.prototype.append = function(name15, value) { + name15 = normalizeName(name15); + value = normalizeValue(value); + var oldValue = this.map[name15]; + this.map[name15] = oldValue ? oldValue + ", " + value : value; + }; + Headers.prototype["delete"] = function(name15) { + delete this.map[normalizeName(name15)]; + }; + Headers.prototype.get = function(name15) { + name15 = normalizeName(name15); + return this.has(name15) ? this.map[name15] : null; + }; + Headers.prototype.has = function(name15) { + return this.map.hasOwnProperty(normalizeName(name15)); + }; + Headers.prototype.set = function(name15, value) { + this.map[normalizeName(name15)] = normalizeValue(value); + }; + Headers.prototype.forEach = function(callback, thisArg) { + for (var name15 in this.map) { + if (this.map.hasOwnProperty(name15)) { + callback.call(thisArg, this.map[name15], name15, this); + } + } + }; + Headers.prototype.keys = function() { + var items = []; + this.forEach(function(value, name15) { + items.push(name15); + }); + return iteratorFor(items); + }; + Headers.prototype.values = function() { + var items = []; + this.forEach(function(value) { + items.push(value); + }); + return iteratorFor(items); + }; + Headers.prototype.entries = function() { + var items = []; + this.forEach(function(value, name15) { + items.push([name15, value]); + }); + return iteratorFor(items); + }; + if (support.iterable) { + Headers.prototype[Symbol.iterator] = Headers.prototype.entries; + } + function consumed(body) { + if (body.bodyUsed) { + return Promise.reject(new TypeError("Already read")); + } + body.bodyUsed = true; + } + function fileReaderReady(reader2) { + return new Promise(function(resolve7, reject) { + reader2.onload = function() { + resolve7(reader2.result); + }; + reader2.onerror = function() { + reject(reader2.error); + }; + }); + } + function readBlobAsArrayBuffer(blob) { + var reader2 = new FileReader(); + var promise = fileReaderReady(reader2); + reader2.readAsArrayBuffer(blob); + return promise; + } + function readBlobAsText(blob) { + var reader2 = new FileReader(); + var promise = fileReaderReady(reader2); + reader2.readAsText(blob); + return promise; + } + function readArrayBufferAsText(buf3) { + var view10 = new Uint8Array(buf3); + var chars = new Array(view10.length); + for (var i8 = 0; i8 < view10.length; i8++) { + chars[i8] = String.fromCharCode(view10[i8]); + } + return chars.join(""); + } + function bufferClone(buf3) { + if (buf3.slice) { + return buf3.slice(0); + } else { + var view10 = new Uint8Array(buf3.byteLength); + view10.set(new Uint8Array(buf3)); + return view10.buffer; + } + } + function Body() { + this.bodyUsed = false; + this._initBody = function(body) { + this.bodyUsed = this.bodyUsed; + this._bodyInit = body; + if (!body) { + this._bodyText = ""; + } else if (typeof body === "string") { + this._bodyText = body; + } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { + this._bodyBlob = body; + } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { + this._bodyFormData = body; + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this._bodyText = body.toString(); + } else if (support.arrayBuffer && support.blob && isDataView(body)) { + this._bodyArrayBuffer = bufferClone(body.buffer); + this._bodyInit = new Blob([this._bodyArrayBuffer]); + } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { + this._bodyArrayBuffer = bufferClone(body); + } else { + this._bodyText = body = Object.prototype.toString.call(body); + } + if (!this.headers.get("content-type")) { + if (typeof body === "string") { + this.headers.set("content-type", "text/plain;charset=UTF-8"); + } else if (this._bodyBlob && this._bodyBlob.type) { + this.headers.set("content-type", this._bodyBlob.type); + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"); + } + } + }; + if (support.blob) { + this.blob = function() { + var rejected = consumed(this); + if (rejected) { + return rejected; + } + if (this._bodyBlob) { + return Promise.resolve(this._bodyBlob); + } else if (this._bodyArrayBuffer) { + return Promise.resolve(new Blob([this._bodyArrayBuffer])); + } else if (this._bodyFormData) { + throw new Error("could not read FormData body as blob"); + } else { + return Promise.resolve(new Blob([this._bodyText])); + } + }; + this.arrayBuffer = function() { + if (this._bodyArrayBuffer) { + var isConsumed = consumed(this); + if (isConsumed) { + return isConsumed; + } + if (ArrayBuffer.isView(this._bodyArrayBuffer)) { + return Promise.resolve( + this._bodyArrayBuffer.buffer.slice( + this._bodyArrayBuffer.byteOffset, + this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength + ) + ); + } else { + return Promise.resolve(this._bodyArrayBuffer); + } + } else { + return this.blob().then(readBlobAsArrayBuffer); + } + }; + } + this.text = function() { + var rejected = consumed(this); + if (rejected) { + return rejected; + } + if (this._bodyBlob) { + return readBlobAsText(this._bodyBlob); + } else if (this._bodyArrayBuffer) { + return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)); + } else if (this._bodyFormData) { + throw new Error("could not read FormData body as text"); + } else { + return Promise.resolve(this._bodyText); + } + }; + if (support.formData) { + this.formData = function() { + return this.text().then(decode46); + }; + } + this.json = function() { + return this.text().then(JSON.parse); + }; + return this; + } + var methods2 = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"]; + function normalizeMethod(method) { + var upcased = method.toUpperCase(); + return methods2.indexOf(upcased) > -1 ? upcased : method; + } + function Request(input, options) { + if (!(this instanceof Request)) { + throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.'); + } + options = options || {}; + var body = options.body; + if (input instanceof Request) { + if (input.bodyUsed) { + throw new TypeError("Already read"); + } + this.url = input.url; + this.credentials = input.credentials; + if (!options.headers) { + this.headers = new Headers(input.headers); + } + this.method = input.method; + this.mode = input.mode; + this.signal = input.signal; + if (!body && input._bodyInit != null) { + body = input._bodyInit; + input.bodyUsed = true; + } + } else { + this.url = String(input); + } + this.credentials = options.credentials || this.credentials || "same-origin"; + if (options.headers || !this.headers) { + this.headers = new Headers(options.headers); + } + this.method = normalizeMethod(options.method || this.method || "GET"); + this.mode = options.mode || this.mode || null; + this.signal = options.signal || this.signal; + this.referrer = null; + if ((this.method === "GET" || this.method === "HEAD") && body) { + throw new TypeError("Body not allowed for GET or HEAD requests"); + } + this._initBody(body); + if (this.method === "GET" || this.method === "HEAD") { + if (options.cache === "no-store" || options.cache === "no-cache") { + var reParamSearch = /([?&])_=[^&]*/; + if (reParamSearch.test(this.url)) { + this.url = this.url.replace(reParamSearch, "$1_=" + (/* @__PURE__ */ new Date()).getTime()); + } else { + var reQueryString = /\?/; + this.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime(); + } + } + } + } + Request.prototype.clone = function() { + return new Request(this, { body: this._bodyInit }); + }; + function decode46(body) { + var form = new FormData(); + body.trim().split("&").forEach(function(bytes2) { + if (bytes2) { + var split2 = bytes2.split("="); + var name15 = split2.shift().replace(/\+/g, " "); + var value = split2.join("=").replace(/\+/g, " "); + form.append(decodeURIComponent(name15), decodeURIComponent(value)); + } + }); + return form; + } + function parseHeaders(rawHeaders) { + var headers = new Headers(); + var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " "); + preProcessedHeaders.split("\r").map(function(header) { + return header.indexOf("\n") === 0 ? header.substr(1, header.length) : header; + }).forEach(function(line) { + var parts = line.split(":"); + var key = parts.shift().trim(); + if (key) { + var value = parts.join(":").trim(); + headers.append(key, value); + } + }); + return headers; + } + Body.call(Request.prototype); + function Response(bodyInit, options) { + if (!(this instanceof Response)) { + throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.'); + } + if (!options) { + options = {}; + } + this.type = "default"; + this.status = options.status === void 0 ? 200 : options.status; + this.ok = this.status >= 200 && this.status < 300; + this.statusText = options.statusText === void 0 ? "" : "" + options.statusText; + this.headers = new Headers(options.headers); + this.url = options.url || ""; + this._initBody(bodyInit); + } + Body.call(Response.prototype); + Response.prototype.clone = function() { + return new Response(this._bodyInit, { + status: this.status, + statusText: this.statusText, + headers: new Headers(this.headers), + url: this.url + }); + }; + Response.error = function() { + var response = new Response(null, { status: 0, statusText: "" }); + response.type = "error"; + return response; + }; + var redirectStatuses = [301, 302, 303, 307, 308]; + Response.redirect = function(url, status) { + if (redirectStatuses.indexOf(status) === -1) { + throw new RangeError("Invalid status code"); + } + return new Response(null, { status, headers: { location: url } }); + }; + exports13.DOMException = global2.DOMException; + try { + new exports13.DOMException(); + } catch (err) { + exports13.DOMException = function(message2, name15) { + this.message = message2; + this.name = name15; + var error7 = Error(message2); + this.stack = error7.stack; + }; + exports13.DOMException.prototype = Object.create(Error.prototype); + exports13.DOMException.prototype.constructor = exports13.DOMException; + } + function fetch4(input, init3) { + return new Promise(function(resolve7, reject) { + var request = new Request(input, init3); + if (request.signal && request.signal.aborted) { + return reject(new exports13.DOMException("Aborted", "AbortError")); + } + var xhr = new XMLHttpRequest(); + function abortXhr() { + xhr.abort(); + } + xhr.onload = function() { + var options = { + status: xhr.status, + statusText: xhr.statusText, + headers: parseHeaders(xhr.getAllResponseHeaders() || "") + }; + options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL"); + var body = "response" in xhr ? xhr.response : xhr.responseText; + setTimeout(function() { + resolve7(new Response(body, options)); + }, 0); + }; + xhr.onerror = function() { + setTimeout(function() { + reject(new TypeError("Network request failed")); + }, 0); + }; + xhr.ontimeout = function() { + setTimeout(function() { + reject(new TypeError("Network request failed")); + }, 0); + }; + xhr.onabort = function() { + setTimeout(function() { + reject(new exports13.DOMException("Aborted", "AbortError")); + }, 0); + }; + function fixUrl(url) { + try { + return url === "" && global2.location.href ? global2.location.href : url; + } catch (e12) { + return url; + } + } + xhr.open(request.method, fixUrl(request.url), true); + if (request.credentials === "include") { + xhr.withCredentials = true; + } else if (request.credentials === "omit") { + xhr.withCredentials = false; + } + if ("responseType" in xhr) { + if (support.blob) { + xhr.responseType = "blob"; + } else if (support.arrayBuffer && request.headers.get("Content-Type") && request.headers.get("Content-Type").indexOf("application/octet-stream") !== -1) { + xhr.responseType = "arraybuffer"; + } + } + if (init3 && typeof init3.headers === "object" && !(init3.headers instanceof Headers)) { + Object.getOwnPropertyNames(init3.headers).forEach(function(name15) { + xhr.setRequestHeader(name15, normalizeValue(init3.headers[name15])); + }); + } else { + request.headers.forEach(function(value, name15) { + xhr.setRequestHeader(name15, value); + }); + } + if (request.signal) { + request.signal.addEventListener("abort", abortXhr); + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + request.signal.removeEventListener("abort", abortXhr); + } + }; + } + xhr.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit); + }); + } + fetch4.polyfill = true; + if (!global2.fetch) { + global2.fetch = fetch4; + global2.Headers = Headers; + global2.Request = Request; + global2.Response = Response; + } + exports13.Headers = Headers; + exports13.Request = Request; + exports13.Response = Response; + exports13.fetch = fetch4; + return exports13; + }({}); + })(__globalThis__); + __globalThis__.fetch.ponyfill = true; + delete __globalThis__.fetch.polyfill; + var ctx = __global__.fetch ? __global__ : __globalThis__; + exports12 = ctx.fetch; + exports12.default = ctx.fetch; + exports12.fetch = ctx.fetch; + exports12.Headers = ctx.Headers; + exports12.Request = ctx.Request; + exports12.Response = ctx.Response; + module3.exports = exports12; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/is.js + function is(value) { + if (value === null) { + return "null"; + } + if (value === void 0) { + return "undefined"; + } + if (value === true || value === false) { + return "boolean"; + } + const typeOf = typeof value; + if (typeofs.includes(typeOf)) { + return typeOf; + } + if (typeOf === "function") { + return "Function"; + } + if (Array.isArray(value)) { + return "Array"; + } + if (isBuffer(value)) { + return "Buffer"; + } + const objectType2 = getObjectType(value); + if (objectType2) { + return objectType2; + } + return "Object"; + } + function isBuffer(value) { + return value && value.constructor && value.constructor.isBuffer && value.constructor.isBuffer.call(null, value); + } + function getObjectType(value) { + const objectTypeName = Object.prototype.toString.call(value).slice(8, -1); + if (objectTypeNames.includes(objectTypeName)) { + return objectTypeName; + } + return void 0; + } + var typeofs, objectTypeNames; + var init_is = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/is.js"() { + init_dirname(); + init_buffer2(); + init_process(); + typeofs = [ + "string", + "number", + "bigint", + "symbol" + ]; + objectTypeNames = [ + "Function", + "Generator", + "AsyncGenerator", + "GeneratorFunction", + "AsyncGeneratorFunction", + "AsyncFunction", + "Observable", + "Array", + "Buffer", + "Object", + "RegExp", + "Date", + "Error", + "Map", + "Set", + "WeakMap", + "WeakSet", + "ArrayBuffer", + "SharedArrayBuffer", + "DataView", + "Promise", + "URL", + "HTMLElement", + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + "BigInt64Array", + "BigUint64Array" + ]; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/token.js + var Type, Token; + var init_token = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/token.js"() { + init_dirname(); + init_buffer2(); + init_process(); + Type = class { + constructor(major, name15, terminal) { + this.major = major; + this.majorEncoded = major << 5; + this.name = name15; + this.terminal = terminal; + } + toString() { + return `Type[${this.major}].${this.name}`; + } + compare(typ) { + return this.major < typ.major ? -1 : this.major > typ.major ? 1 : 0; + } + }; + Type.uint = new Type(0, "uint", true); + Type.negint = new Type(1, "negint", true); + Type.bytes = new Type(2, "bytes", true); + Type.string = new Type(3, "string", true); + Type.array = new Type(4, "array", false); + Type.map = new Type(5, "map", false); + Type.tag = new Type(6, "tag", false); + Type.float = new Type(7, "float", true); + Type.false = new Type(7, "false", true); + Type.true = new Type(7, "true", true); + Type.null = new Type(7, "null", true); + Type.undefined = new Type(7, "undefined", true); + Type.break = new Type(7, "break", true); + Token = class { + constructor(type3, value, encodedLength) { + this.type = type3; + this.value = value; + this.encodedLength = encodedLength; + this.encodedBytes = void 0; + this.byteValue = void 0; + } + toString() { + return `Token[${this.type}].${this.value}`; + } + }; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/byte-utils.js + function isBuffer2(buf3) { + return useBuffer && globalThis.Buffer.isBuffer(buf3); + } + function asU8A(buf3) { + if (!(buf3 instanceof Uint8Array)) { + return Uint8Array.from(buf3); + } + return isBuffer2(buf3) ? new Uint8Array(buf3.buffer, buf3.byteOffset, buf3.byteLength) : buf3; + } + function compare(b1, b22) { + if (isBuffer2(b1) && isBuffer2(b22)) { + return b1.compare(b22); + } + for (let i8 = 0; i8 < b1.length; i8++) { + if (b1[i8] === b22[i8]) { + continue; + } + return b1[i8] < b22[i8] ? -1 : 1; + } + return 0; + } + function utf8ToBytes(string4, units = Infinity) { + let codePoint; + const length3 = string4.length; + let leadSurrogate = null; + const bytes2 = []; + for (let i8 = 0; i8 < length3; ++i8) { + codePoint = string4.charCodeAt(i8); + if (codePoint > 55295 && codePoint < 57344) { + if (!leadSurrogate) { + if (codePoint > 56319) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + continue; + } else if (i8 + 1 === length3) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + continue; + } + leadSurrogate = codePoint; + continue; + } + if (codePoint < 56320) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + leadSurrogate = codePoint; + continue; + } + codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536; + } else if (leadSurrogate) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + } + leadSurrogate = null; + if (codePoint < 128) { + if ((units -= 1) < 0) + break; + bytes2.push(codePoint); + } else if (codePoint < 2048) { + if ((units -= 2) < 0) + break; + bytes2.push(codePoint >> 6 | 192, codePoint & 63 | 128); + } else if (codePoint < 65536) { + if ((units -= 3) < 0) + break; + bytes2.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128); + } else if (codePoint < 1114112) { + if ((units -= 4) < 0) + break; + bytes2.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128); + } else { + throw new Error("Invalid code point"); + } + } + return bytes2; + } + function utf8Slice(buf3, offset2, end) { + const res = []; + while (offset2 < end) { + const firstByte = buf3[offset2]; + let codePoint = null; + let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1; + if (offset2 + bytesPerSequence <= end) { + let secondByte, thirdByte, fourthByte, tempCodePoint; + switch (bytesPerSequence) { + case 1: + if (firstByte < 128) { + codePoint = firstByte; + } + break; + case 2: + secondByte = buf3[offset2 + 1]; + if ((secondByte & 192) === 128) { + tempCodePoint = (firstByte & 31) << 6 | secondByte & 63; + if (tempCodePoint > 127) { + codePoint = tempCodePoint; + } + } + break; + case 3: + secondByte = buf3[offset2 + 1]; + thirdByte = buf3[offset2 + 2]; + if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) { + tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63; + if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) { + codePoint = tempCodePoint; + } + } + break; + case 4: + secondByte = buf3[offset2 + 1]; + thirdByte = buf3[offset2 + 2]; + fourthByte = buf3[offset2 + 3]; + if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) { + tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63; + if (tempCodePoint > 65535 && tempCodePoint < 1114112) { + codePoint = tempCodePoint; + } + } + } + } + if (codePoint === null) { + codePoint = 65533; + bytesPerSequence = 1; + } else if (codePoint > 65535) { + codePoint -= 65536; + res.push(codePoint >>> 10 & 1023 | 55296); + codePoint = 56320 | codePoint & 1023; + } + res.push(codePoint); + offset2 += bytesPerSequence; + } + return decodeCodePointsArray(res); + } + function decodeCodePointsArray(codePoints) { + const len = codePoints.length; + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints); + } + let res = ""; + let i8 = 0; + while (i8 < len) { + res += String.fromCharCode.apply(String, codePoints.slice(i8, i8 += MAX_ARGUMENTS_LENGTH)); + } + return res; + } + var useBuffer, textDecoder, textEncoder, toString, fromString, fromArray, slice, concat, alloc, MAX_ARGUMENTS_LENGTH; + var init_byte_utils = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/byte-utils.js"() { + init_dirname(); + init_buffer2(); + init_process(); + useBuffer = globalThis.process && !globalThis.process.browser && globalThis.Buffer && typeof globalThis.Buffer.isBuffer === "function"; + textDecoder = new TextDecoder(); + textEncoder = new TextEncoder(); + toString = useBuffer ? (bytes2, start, end) => { + return end - start > 64 ? globalThis.Buffer.from(bytes2.subarray(start, end)).toString("utf8") : utf8Slice(bytes2, start, end); + } : (bytes2, start, end) => { + return end - start > 64 ? textDecoder.decode(bytes2.subarray(start, end)) : utf8Slice(bytes2, start, end); + }; + fromString = useBuffer ? (string4) => { + return string4.length > 64 ? globalThis.Buffer.from(string4) : utf8ToBytes(string4); + } : (string4) => { + return string4.length > 64 ? textEncoder.encode(string4) : utf8ToBytes(string4); + }; + fromArray = (arr) => { + return Uint8Array.from(arr); + }; + slice = useBuffer ? (bytes2, start, end) => { + if (isBuffer2(bytes2)) { + return new Uint8Array(bytes2.subarray(start, end)); + } + return bytes2.slice(start, end); + } : (bytes2, start, end) => { + return bytes2.slice(start, end); + }; + concat = useBuffer ? (chunks, length3) => { + chunks = chunks.map((c8) => c8 instanceof Uint8Array ? c8 : globalThis.Buffer.from(c8)); + return asU8A(globalThis.Buffer.concat(chunks, length3)); + } : (chunks, length3) => { + const out = new Uint8Array(length3); + let off = 0; + for (let b6 of chunks) { + if (off + b6.length > out.length) { + b6 = b6.subarray(0, out.length - off); + } + out.set(b6, off); + off += b6.length; + } + return out; + }; + alloc = useBuffer ? (size4) => { + return globalThis.Buffer.allocUnsafe(size4); + } : (size4) => { + return new Uint8Array(size4); + }; + MAX_ARGUMENTS_LENGTH = 4096; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/bl.js + var defaultChunkSize, Bl; + var init_bl = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/bl.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_byte_utils(); + defaultChunkSize = 256; + Bl = class { + constructor(chunkSize = defaultChunkSize) { + this.chunkSize = chunkSize; + this.cursor = 0; + this.maxCursor = -1; + this.chunks = []; + this._initReuseChunk = null; + } + reset() { + this.cursor = 0; + this.maxCursor = -1; + if (this.chunks.length) { + this.chunks = []; + } + if (this._initReuseChunk !== null) { + this.chunks.push(this._initReuseChunk); + this.maxCursor = this._initReuseChunk.length - 1; + } + } + push(bytes2) { + let topChunk = this.chunks[this.chunks.length - 1]; + const newMax = this.cursor + bytes2.length; + if (newMax <= this.maxCursor + 1) { + const chunkPos = topChunk.length - (this.maxCursor - this.cursor) - 1; + topChunk.set(bytes2, chunkPos); + } else { + if (topChunk) { + const chunkPos = topChunk.length - (this.maxCursor - this.cursor) - 1; + if (chunkPos < topChunk.length) { + this.chunks[this.chunks.length - 1] = topChunk.subarray(0, chunkPos); + this.maxCursor = this.cursor - 1; + } + } + if (bytes2.length < 64 && bytes2.length < this.chunkSize) { + topChunk = alloc(this.chunkSize); + this.chunks.push(topChunk); + this.maxCursor += topChunk.length; + if (this._initReuseChunk === null) { + this._initReuseChunk = topChunk; + } + topChunk.set(bytes2, 0); + } else { + this.chunks.push(bytes2); + this.maxCursor += bytes2.length; + } + } + this.cursor += bytes2.length; + } + toBytes(reset = false) { + let byts; + if (this.chunks.length === 1) { + const chunk = this.chunks[0]; + if (reset && this.cursor > chunk.length / 2) { + byts = this.cursor === chunk.length ? chunk : chunk.subarray(0, this.cursor); + this._initReuseChunk = null; + this.chunks = []; + } else { + byts = slice(chunk, 0, this.cursor); + } + } else { + byts = concat(this.chunks, this.cursor); + } + if (reset) { + this.reset(); + } + return byts; + } + }; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/common.js + function assertEnoughData(data, pos, need) { + if (data.length - pos < need) { + throw new Error(`${decodeErrPrefix} not enough data for type`); + } + } + var decodeErrPrefix, encodeErrPrefix, uintMinorPrefixBytes; + var init_common = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/common.js"() { + init_dirname(); + init_buffer2(); + init_process(); + decodeErrPrefix = "CBOR decode error:"; + encodeErrPrefix = "CBOR encode error:"; + uintMinorPrefixBytes = []; + uintMinorPrefixBytes[23] = 1; + uintMinorPrefixBytes[24] = 2; + uintMinorPrefixBytes[25] = 3; + uintMinorPrefixBytes[26] = 5; + uintMinorPrefixBytes[27] = 9; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/0uint.js + function readUint8(data, offset2, options) { + assertEnoughData(data, offset2, 1); + const value = data[offset2]; + if (options.strict === true && value < uintBoundaries[0]) { + throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`); + } + return value; + } + function readUint16(data, offset2, options) { + assertEnoughData(data, offset2, 2); + const value = data[offset2] << 8 | data[offset2 + 1]; + if (options.strict === true && value < uintBoundaries[1]) { + throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`); + } + return value; + } + function readUint32(data, offset2, options) { + assertEnoughData(data, offset2, 4); + const value = data[offset2] * 16777216 + (data[offset2 + 1] << 16) + (data[offset2 + 2] << 8) + data[offset2 + 3]; + if (options.strict === true && value < uintBoundaries[2]) { + throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`); + } + return value; + } + function readUint64(data, offset2, options) { + assertEnoughData(data, offset2, 8); + const hi = data[offset2] * 16777216 + (data[offset2 + 1] << 16) + (data[offset2 + 2] << 8) + data[offset2 + 3]; + const lo = data[offset2 + 4] * 16777216 + (data[offset2 + 5] << 16) + (data[offset2 + 6] << 8) + data[offset2 + 7]; + const value = (BigInt(hi) << BigInt(32)) + BigInt(lo); + if (options.strict === true && value < uintBoundaries[3]) { + throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`); + } + if (value <= Number.MAX_SAFE_INTEGER) { + return Number(value); + } + if (options.allowBigInt === true) { + return value; + } + throw new Error(`${decodeErrPrefix} integers outside of the safe integer range are not supported`); + } + function decodeUint8(data, pos, _minor, options) { + return new Token(Type.uint, readUint8(data, pos + 1, options), 2); + } + function decodeUint16(data, pos, _minor, options) { + return new Token(Type.uint, readUint16(data, pos + 1, options), 3); + } + function decodeUint32(data, pos, _minor, options) { + return new Token(Type.uint, readUint32(data, pos + 1, options), 5); + } + function decodeUint64(data, pos, _minor, options) { + return new Token(Type.uint, readUint64(data, pos + 1, options), 9); + } + function encodeUint(buf3, token) { + return encodeUintValue(buf3, 0, token.value); + } + function encodeUintValue(buf3, major, uint) { + if (uint < uintBoundaries[0]) { + const nuint = Number(uint); + buf3.push([major | nuint]); + } else if (uint < uintBoundaries[1]) { + const nuint = Number(uint); + buf3.push([ + major | 24, + nuint + ]); + } else if (uint < uintBoundaries[2]) { + const nuint = Number(uint); + buf3.push([ + major | 25, + nuint >>> 8, + nuint & 255 + ]); + } else if (uint < uintBoundaries[3]) { + const nuint = Number(uint); + buf3.push([ + major | 26, + nuint >>> 24 & 255, + nuint >>> 16 & 255, + nuint >>> 8 & 255, + nuint & 255 + ]); + } else { + const buint = BigInt(uint); + if (buint < uintBoundaries[4]) { + const set5 = [ + major | 27, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ]; + let lo = Number(buint & BigInt(4294967295)); + let hi = Number(buint >> BigInt(32) & BigInt(4294967295)); + set5[8] = lo & 255; + lo = lo >> 8; + set5[7] = lo & 255; + lo = lo >> 8; + set5[6] = lo & 255; + lo = lo >> 8; + set5[5] = lo & 255; + set5[4] = hi & 255; + hi = hi >> 8; + set5[3] = hi & 255; + hi = hi >> 8; + set5[2] = hi & 255; + hi = hi >> 8; + set5[1] = hi & 255; + buf3.push(set5); + } else { + throw new Error(`${decodeErrPrefix} encountered BigInt larger than allowable range`); + } + } + } + var uintBoundaries; + var init_uint = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/0uint.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_token(); + init_common(); + uintBoundaries = [ + 24, + 256, + 65536, + 4294967296, + BigInt("18446744073709551616") + ]; + encodeUint.encodedSize = function encodedSize(token) { + return encodeUintValue.encodedSize(token.value); + }; + encodeUintValue.encodedSize = function encodedSize2(uint) { + if (uint < uintBoundaries[0]) { + return 1; + } + if (uint < uintBoundaries[1]) { + return 2; + } + if (uint < uintBoundaries[2]) { + return 3; + } + if (uint < uintBoundaries[3]) { + return 5; + } + return 9; + }; + encodeUint.compareTokens = function compareTokens(tok1, tok2) { + return tok1.value < tok2.value ? -1 : tok1.value > tok2.value ? 1 : 0; + }; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/1negint.js + function decodeNegint8(data, pos, _minor, options) { + return new Token(Type.negint, -1 - readUint8(data, pos + 1, options), 2); + } + function decodeNegint16(data, pos, _minor, options) { + return new Token(Type.negint, -1 - readUint16(data, pos + 1, options), 3); + } + function decodeNegint32(data, pos, _minor, options) { + return new Token(Type.negint, -1 - readUint32(data, pos + 1, options), 5); + } + function decodeNegint64(data, pos, _minor, options) { + const int = readUint64(data, pos + 1, options); + if (typeof int !== "bigint") { + const value = -1 - int; + if (value >= Number.MIN_SAFE_INTEGER) { + return new Token(Type.negint, value, 9); + } + } + if (options.allowBigInt !== true) { + throw new Error(`${decodeErrPrefix} integers outside of the safe integer range are not supported`); + } + return new Token(Type.negint, neg1b - BigInt(int), 9); + } + function encodeNegint(buf3, token) { + const negint = token.value; + const unsigned = typeof negint === "bigint" ? negint * neg1b - pos1b : negint * -1 - 1; + encodeUintValue(buf3, token.type.majorEncoded, unsigned); + } + var neg1b, pos1b; + var init_negint = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/1negint.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_token(); + init_uint(); + init_common(); + neg1b = BigInt(-1); + pos1b = BigInt(1); + encodeNegint.encodedSize = function encodedSize3(token) { + const negint = token.value; + const unsigned = typeof negint === "bigint" ? negint * neg1b - pos1b : negint * -1 - 1; + if (unsigned < uintBoundaries[0]) { + return 1; + } + if (unsigned < uintBoundaries[1]) { + return 2; + } + if (unsigned < uintBoundaries[2]) { + return 3; + } + if (unsigned < uintBoundaries[3]) { + return 5; + } + return 9; + }; + encodeNegint.compareTokens = function compareTokens2(tok1, tok2) { + return tok1.value < tok2.value ? 1 : tok1.value > tok2.value ? -1 : 0; + }; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/2bytes.js + function toToken(data, pos, prefix, length3) { + assertEnoughData(data, pos, prefix + length3); + const buf3 = slice(data, pos + prefix, pos + prefix + length3); + return new Token(Type.bytes, buf3, prefix + length3); + } + function decodeBytesCompact(data, pos, minor, _options2) { + return toToken(data, pos, 1, minor); + } + function decodeBytes8(data, pos, _minor, options) { + return toToken(data, pos, 2, readUint8(data, pos + 1, options)); + } + function decodeBytes16(data, pos, _minor, options) { + return toToken(data, pos, 3, readUint16(data, pos + 1, options)); + } + function decodeBytes32(data, pos, _minor, options) { + return toToken(data, pos, 5, readUint32(data, pos + 1, options)); + } + function decodeBytes64(data, pos, _minor, options) { + const l8 = readUint64(data, pos + 1, options); + if (typeof l8 === "bigint") { + throw new Error(`${decodeErrPrefix} 64-bit integer bytes lengths not supported`); + } + return toToken(data, pos, 9, l8); + } + function tokenBytes(token) { + if (token.encodedBytes === void 0) { + token.encodedBytes = token.type === Type.string ? fromString(token.value) : token.value; + } + return token.encodedBytes; + } + function encodeBytes(buf3, token) { + const bytes2 = tokenBytes(token); + encodeUintValue(buf3, token.type.majorEncoded, bytes2.length); + buf3.push(bytes2); + } + function compareBytes(b1, b22) { + return b1.length < b22.length ? -1 : b1.length > b22.length ? 1 : compare(b1, b22); + } + var init_bytes = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/2bytes.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_token(); + init_common(); + init_uint(); + init_byte_utils(); + encodeBytes.encodedSize = function encodedSize4(token) { + const bytes2 = tokenBytes(token); + return encodeUintValue.encodedSize(bytes2.length) + bytes2.length; + }; + encodeBytes.compareTokens = function compareTokens3(tok1, tok2) { + return compareBytes(tokenBytes(tok1), tokenBytes(tok2)); + }; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/3string.js + function toToken2(data, pos, prefix, length3, options) { + const totLength = prefix + length3; + assertEnoughData(data, pos, totLength); + const tok = new Token(Type.string, toString(data, pos + prefix, pos + totLength), totLength); + if (options.retainStringBytes === true) { + tok.byteValue = slice(data, pos + prefix, pos + totLength); + } + return tok; + } + function decodeStringCompact(data, pos, minor, options) { + return toToken2(data, pos, 1, minor, options); + } + function decodeString8(data, pos, _minor, options) { + return toToken2(data, pos, 2, readUint8(data, pos + 1, options), options); + } + function decodeString16(data, pos, _minor, options) { + return toToken2(data, pos, 3, readUint16(data, pos + 1, options), options); + } + function decodeString32(data, pos, _minor, options) { + return toToken2(data, pos, 5, readUint32(data, pos + 1, options), options); + } + function decodeString64(data, pos, _minor, options) { + const l8 = readUint64(data, pos + 1, options); + if (typeof l8 === "bigint") { + throw new Error(`${decodeErrPrefix} 64-bit integer string lengths not supported`); + } + return toToken2(data, pos, 9, l8, options); + } + var encodeString; + var init_string = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/3string.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_token(); + init_common(); + init_uint(); + init_bytes(); + init_byte_utils(); + encodeString = encodeBytes; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/4array.js + function toToken3(_data2, _pos, prefix, length3) { + return new Token(Type.array, length3, prefix); + } + function decodeArrayCompact(data, pos, minor, _options2) { + return toToken3(data, pos, 1, minor); + } + function decodeArray8(data, pos, _minor, options) { + return toToken3(data, pos, 2, readUint8(data, pos + 1, options)); + } + function decodeArray16(data, pos, _minor, options) { + return toToken3(data, pos, 3, readUint16(data, pos + 1, options)); + } + function decodeArray32(data, pos, _minor, options) { + return toToken3(data, pos, 5, readUint32(data, pos + 1, options)); + } + function decodeArray64(data, pos, _minor, options) { + const l8 = readUint64(data, pos + 1, options); + if (typeof l8 === "bigint") { + throw new Error(`${decodeErrPrefix} 64-bit integer array lengths not supported`); + } + return toToken3(data, pos, 9, l8); + } + function decodeArrayIndefinite(data, pos, _minor, options) { + if (options.allowIndefinite === false) { + throw new Error(`${decodeErrPrefix} indefinite length items not allowed`); + } + return toToken3(data, pos, 1, Infinity); + } + function encodeArray(buf3, token) { + encodeUintValue(buf3, Type.array.majorEncoded, token.value); + } + var init_array = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/4array.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_token(); + init_uint(); + init_common(); + encodeArray.compareTokens = encodeUint.compareTokens; + encodeArray.encodedSize = function encodedSize5(token) { + return encodeUintValue.encodedSize(token.value); + }; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/5map.js + function toToken4(_data2, _pos, prefix, length3) { + return new Token(Type.map, length3, prefix); + } + function decodeMapCompact(data, pos, minor, _options2) { + return toToken4(data, pos, 1, minor); + } + function decodeMap8(data, pos, _minor, options) { + return toToken4(data, pos, 2, readUint8(data, pos + 1, options)); + } + function decodeMap16(data, pos, _minor, options) { + return toToken4(data, pos, 3, readUint16(data, pos + 1, options)); + } + function decodeMap32(data, pos, _minor, options) { + return toToken4(data, pos, 5, readUint32(data, pos + 1, options)); + } + function decodeMap64(data, pos, _minor, options) { + const l8 = readUint64(data, pos + 1, options); + if (typeof l8 === "bigint") { + throw new Error(`${decodeErrPrefix} 64-bit integer map lengths not supported`); + } + return toToken4(data, pos, 9, l8); + } + function decodeMapIndefinite(data, pos, _minor, options) { + if (options.allowIndefinite === false) { + throw new Error(`${decodeErrPrefix} indefinite length items not allowed`); + } + return toToken4(data, pos, 1, Infinity); + } + function encodeMap(buf3, token) { + encodeUintValue(buf3, Type.map.majorEncoded, token.value); + } + var init_map = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/5map.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_token(); + init_uint(); + init_common(); + encodeMap.compareTokens = encodeUint.compareTokens; + encodeMap.encodedSize = function encodedSize6(token) { + return encodeUintValue.encodedSize(token.value); + }; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/6tag.js + function decodeTagCompact(_data2, _pos, minor, _options2) { + return new Token(Type.tag, minor, 1); + } + function decodeTag8(data, pos, _minor, options) { + return new Token(Type.tag, readUint8(data, pos + 1, options), 2); + } + function decodeTag16(data, pos, _minor, options) { + return new Token(Type.tag, readUint16(data, pos + 1, options), 3); + } + function decodeTag32(data, pos, _minor, options) { + return new Token(Type.tag, readUint32(data, pos + 1, options), 5); + } + function decodeTag64(data, pos, _minor, options) { + return new Token(Type.tag, readUint64(data, pos + 1, options), 9); + } + function encodeTag(buf3, token) { + encodeUintValue(buf3, Type.tag.majorEncoded, token.value); + } + var init_tag = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/6tag.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_token(); + init_uint(); + encodeTag.compareTokens = encodeUint.compareTokens; + encodeTag.encodedSize = function encodedSize7(token) { + return encodeUintValue.encodedSize(token.value); + }; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/7float.js + function decodeUndefined(_data2, _pos, _minor, options) { + if (options.allowUndefined === false) { + throw new Error(`${decodeErrPrefix} undefined values are not supported`); + } else if (options.coerceUndefinedToNull === true) { + return new Token(Type.null, null, 1); + } + return new Token(Type.undefined, void 0, 1); + } + function decodeBreak(_data2, _pos, _minor, options) { + if (options.allowIndefinite === false) { + throw new Error(`${decodeErrPrefix} indefinite length items not allowed`); + } + return new Token(Type.break, void 0, 1); + } + function createToken(value, bytes2, options) { + if (options) { + if (options.allowNaN === false && Number.isNaN(value)) { + throw new Error(`${decodeErrPrefix} NaN values are not supported`); + } + if (options.allowInfinity === false && (value === Infinity || value === -Infinity)) { + throw new Error(`${decodeErrPrefix} Infinity values are not supported`); + } + } + return new Token(Type.float, value, bytes2); + } + function decodeFloat16(data, pos, _minor, options) { + return createToken(readFloat16(data, pos + 1), 3, options); + } + function decodeFloat32(data, pos, _minor, options) { + return createToken(readFloat32(data, pos + 1), 5, options); + } + function decodeFloat64(data, pos, _minor, options) { + return createToken(readFloat64(data, pos + 1), 9, options); + } + function encodeFloat(buf3, token, options) { + const float3 = token.value; + if (float3 === false) { + buf3.push([Type.float.majorEncoded | MINOR_FALSE]); + } else if (float3 === true) { + buf3.push([Type.float.majorEncoded | MINOR_TRUE]); + } else if (float3 === null) { + buf3.push([Type.float.majorEncoded | MINOR_NULL]); + } else if (float3 === void 0) { + buf3.push([Type.float.majorEncoded | MINOR_UNDEFINED]); + } else { + let decoded; + let success = false; + if (!options || options.float64 !== true) { + encodeFloat16(float3); + decoded = readFloat16(ui8a, 1); + if (float3 === decoded || Number.isNaN(float3)) { + ui8a[0] = 249; + buf3.push(ui8a.slice(0, 3)); + success = true; + } else { + encodeFloat32(float3); + decoded = readFloat32(ui8a, 1); + if (float3 === decoded) { + ui8a[0] = 250; + buf3.push(ui8a.slice(0, 5)); + success = true; + } + } + } + if (!success) { + encodeFloat64(float3); + decoded = readFloat64(ui8a, 1); + ui8a[0] = 251; + buf3.push(ui8a.slice(0, 9)); + } + } + } + function encodeFloat16(inp) { + if (inp === Infinity) { + dataView.setUint16(0, 31744, false); + } else if (inp === -Infinity) { + dataView.setUint16(0, 64512, false); + } else if (Number.isNaN(inp)) { + dataView.setUint16(0, 32256, false); + } else { + dataView.setFloat32(0, inp); + const valu32 = dataView.getUint32(0); + const exponent = (valu32 & 2139095040) >> 23; + const mantissa = valu32 & 8388607; + if (exponent === 255) { + dataView.setUint16(0, 31744, false); + } else if (exponent === 0) { + dataView.setUint16(0, (inp & 2147483648) >> 16 | mantissa >> 13, false); + } else { + const logicalExponent = exponent - 127; + if (logicalExponent < -24) { + dataView.setUint16(0, 0); + } else if (logicalExponent < -14) { + dataView.setUint16(0, (valu32 & 2147483648) >> 16 | 1 << 24 + logicalExponent, false); + } else { + dataView.setUint16(0, (valu32 & 2147483648) >> 16 | logicalExponent + 15 << 10 | mantissa >> 13, false); + } + } + } + } + function readFloat16(ui8a3, pos) { + if (ui8a3.length - pos < 2) { + throw new Error(`${decodeErrPrefix} not enough data for float16`); + } + const half = (ui8a3[pos] << 8) + ui8a3[pos + 1]; + if (half === 31744) { + return Infinity; + } + if (half === 64512) { + return -Infinity; + } + if (half === 32256) { + return NaN; + } + const exp = half >> 10 & 31; + const mant = half & 1023; + let val; + if (exp === 0) { + val = mant * 2 ** -24; + } else if (exp !== 31) { + val = (mant + 1024) * 2 ** (exp - 25); + } else { + val = mant === 0 ? Infinity : NaN; + } + return half & 32768 ? -val : val; + } + function encodeFloat32(inp) { + dataView.setFloat32(0, inp, false); + } + function readFloat32(ui8a3, pos) { + if (ui8a3.length - pos < 4) { + throw new Error(`${decodeErrPrefix} not enough data for float32`); + } + const offset2 = (ui8a3.byteOffset || 0) + pos; + return new DataView(ui8a3.buffer, offset2, 4).getFloat32(0, false); + } + function encodeFloat64(inp) { + dataView.setFloat64(0, inp, false); + } + function readFloat64(ui8a3, pos) { + if (ui8a3.length - pos < 8) { + throw new Error(`${decodeErrPrefix} not enough data for float64`); + } + const offset2 = (ui8a3.byteOffset || 0) + pos; + return new DataView(ui8a3.buffer, offset2, 8).getFloat64(0, false); + } + var MINOR_FALSE, MINOR_TRUE, MINOR_NULL, MINOR_UNDEFINED, buffer, dataView, ui8a; + var init_float = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/7float.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_token(); + init_common(); + init_uint(); + MINOR_FALSE = 20; + MINOR_TRUE = 21; + MINOR_NULL = 22; + MINOR_UNDEFINED = 23; + encodeFloat.encodedSize = function encodedSize8(token, options) { + const float3 = token.value; + if (float3 === false || float3 === true || float3 === null || float3 === void 0) { + return 1; + } + if (!options || options.float64 !== true) { + encodeFloat16(float3); + let decoded = readFloat16(ui8a, 1); + if (float3 === decoded || Number.isNaN(float3)) { + return 3; + } + encodeFloat32(float3); + decoded = readFloat32(ui8a, 1); + if (float3 === decoded) { + return 5; + } + } + return 9; + }; + buffer = new ArrayBuffer(9); + dataView = new DataView(buffer, 1); + ui8a = new Uint8Array(buffer, 0); + encodeFloat.compareTokens = encodeUint.compareTokens; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/jump.js + function invalidMinor(data, pos, minor) { + throw new Error(`${decodeErrPrefix} encountered invalid minor (${minor}) for major ${data[pos] >>> 5}`); + } + function errorer(msg) { + return () => { + throw new Error(`${decodeErrPrefix} ${msg}`); + }; + } + function quickEncodeToken(token) { + switch (token.type) { + case Type.false: + return fromArray([244]); + case Type.true: + return fromArray([245]); + case Type.null: + return fromArray([246]); + case Type.bytes: + if (!token.value.length) { + return fromArray([64]); + } + return; + case Type.string: + if (token.value === "") { + return fromArray([96]); + } + return; + case Type.array: + if (token.value === 0) { + return fromArray([128]); + } + return; + case Type.map: + if (token.value === 0) { + return fromArray([160]); + } + return; + case Type.uint: + if (token.value < 24) { + return fromArray([Number(token.value)]); + } + return; + case Type.negint: + if (token.value >= -24) { + return fromArray([31 - Number(token.value)]); + } + } + } + var jump, quick; + var init_jump = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/jump.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_token(); + init_uint(); + init_negint(); + init_bytes(); + init_string(); + init_array(); + init_map(); + init_tag(); + init_float(); + init_common(); + init_byte_utils(); + jump = []; + for (let i8 = 0; i8 <= 23; i8++) { + jump[i8] = invalidMinor; + } + jump[24] = decodeUint8; + jump[25] = decodeUint16; + jump[26] = decodeUint32; + jump[27] = decodeUint64; + jump[28] = invalidMinor; + jump[29] = invalidMinor; + jump[30] = invalidMinor; + jump[31] = invalidMinor; + for (let i8 = 32; i8 <= 55; i8++) { + jump[i8] = invalidMinor; + } + jump[56] = decodeNegint8; + jump[57] = decodeNegint16; + jump[58] = decodeNegint32; + jump[59] = decodeNegint64; + jump[60] = invalidMinor; + jump[61] = invalidMinor; + jump[62] = invalidMinor; + jump[63] = invalidMinor; + for (let i8 = 64; i8 <= 87; i8++) { + jump[i8] = decodeBytesCompact; + } + jump[88] = decodeBytes8; + jump[89] = decodeBytes16; + jump[90] = decodeBytes32; + jump[91] = decodeBytes64; + jump[92] = invalidMinor; + jump[93] = invalidMinor; + jump[94] = invalidMinor; + jump[95] = errorer("indefinite length bytes/strings are not supported"); + for (let i8 = 96; i8 <= 119; i8++) { + jump[i8] = decodeStringCompact; + } + jump[120] = decodeString8; + jump[121] = decodeString16; + jump[122] = decodeString32; + jump[123] = decodeString64; + jump[124] = invalidMinor; + jump[125] = invalidMinor; + jump[126] = invalidMinor; + jump[127] = errorer("indefinite length bytes/strings are not supported"); + for (let i8 = 128; i8 <= 151; i8++) { + jump[i8] = decodeArrayCompact; + } + jump[152] = decodeArray8; + jump[153] = decodeArray16; + jump[154] = decodeArray32; + jump[155] = decodeArray64; + jump[156] = invalidMinor; + jump[157] = invalidMinor; + jump[158] = invalidMinor; + jump[159] = decodeArrayIndefinite; + for (let i8 = 160; i8 <= 183; i8++) { + jump[i8] = decodeMapCompact; + } + jump[184] = decodeMap8; + jump[185] = decodeMap16; + jump[186] = decodeMap32; + jump[187] = decodeMap64; + jump[188] = invalidMinor; + jump[189] = invalidMinor; + jump[190] = invalidMinor; + jump[191] = decodeMapIndefinite; + for (let i8 = 192; i8 <= 215; i8++) { + jump[i8] = decodeTagCompact; + } + jump[216] = decodeTag8; + jump[217] = decodeTag16; + jump[218] = decodeTag32; + jump[219] = decodeTag64; + jump[220] = invalidMinor; + jump[221] = invalidMinor; + jump[222] = invalidMinor; + jump[223] = invalidMinor; + for (let i8 = 224; i8 <= 243; i8++) { + jump[i8] = errorer("simple values are not supported"); + } + jump[244] = invalidMinor; + jump[245] = invalidMinor; + jump[246] = invalidMinor; + jump[247] = decodeUndefined; + jump[248] = errorer("simple values are not supported"); + jump[249] = decodeFloat16; + jump[250] = decodeFloat32; + jump[251] = decodeFloat64; + jump[252] = invalidMinor; + jump[253] = invalidMinor; + jump[254] = invalidMinor; + jump[255] = decodeBreak; + quick = []; + for (let i8 = 0; i8 < 24; i8++) { + quick[i8] = new Token(Type.uint, i8, 1); + } + for (let i8 = -1; i8 >= -24; i8--) { + quick[31 - i8] = new Token(Type.negint, i8, 1); + } + quick[64] = new Token(Type.bytes, new Uint8Array(0), 1); + quick[96] = new Token(Type.string, "", 1); + quick[128] = new Token(Type.array, 0, 1); + quick[160] = new Token(Type.map, 0, 1); + quick[244] = new Token(Type.false, false, 1); + quick[245] = new Token(Type.true, true, 1); + quick[246] = new Token(Type.null, null, 1); + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/encode.js + function makeCborEncoders() { + const encoders = []; + encoders[Type.uint.major] = encodeUint; + encoders[Type.negint.major] = encodeNegint; + encoders[Type.bytes.major] = encodeBytes; + encoders[Type.string.major] = encodeString; + encoders[Type.array.major] = encodeArray; + encoders[Type.map.major] = encodeMap; + encoders[Type.tag.major] = encodeTag; + encoders[Type.float.major] = encodeFloat; + return encoders; + } + function objectToTokens(obj, options = {}, refStack) { + const typ = is(obj); + const customTypeEncoder = options && options.typeEncoders && options.typeEncoders[typ] || typeEncoders[typ]; + if (typeof customTypeEncoder === "function") { + const tokens = customTypeEncoder(obj, typ, options, refStack); + if (tokens != null) { + return tokens; + } + } + const typeEncoder = typeEncoders[typ]; + if (!typeEncoder) { + throw new Error(`${encodeErrPrefix} unsupported type: ${typ}`); + } + return typeEncoder(obj, typ, options, refStack); + } + function sortMapEntries(entries6, options) { + if (options.mapSorter) { + entries6.sort(options.mapSorter); + } + } + function mapSorter(e1, e22) { + const keyToken1 = Array.isArray(e1[0]) ? e1[0][0] : e1[0]; + const keyToken2 = Array.isArray(e22[0]) ? e22[0][0] : e22[0]; + if (keyToken1.type !== keyToken2.type) { + return keyToken1.type.compare(keyToken2.type); + } + const major = keyToken1.type.major; + const tcmp = cborEncoders[major].compareTokens(keyToken1, keyToken2); + if (tcmp === 0) { + console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"); + } + return tcmp; + } + function tokensToEncoded(buf3, tokens, encoders, options) { + if (Array.isArray(tokens)) { + for (const token of tokens) { + tokensToEncoded(buf3, token, encoders, options); + } + } else { + encoders[tokens.type.major](buf3, tokens, options); + } + } + function encodeCustom(data, encoders, options) { + const tokens = objectToTokens(data, options); + if (!Array.isArray(tokens) && options.quickEncodeToken) { + const quickBytes = options.quickEncodeToken(tokens); + if (quickBytes) { + return quickBytes; + } + const encoder4 = encoders[tokens.type.major]; + if (encoder4.encodedSize) { + const size4 = encoder4.encodedSize(tokens, options); + const buf3 = new Bl(size4); + encoder4(buf3, tokens, options); + if (buf3.chunks.length !== 1) { + throw new Error(`Unexpected error: pre-calculated length for ${tokens} was wrong`); + } + return asU8A(buf3.chunks[0]); + } + } + buf.reset(); + tokensToEncoded(buf, tokens, encoders, options); + return buf.toBytes(true); + } + function encode(data, options) { + options = Object.assign({}, defaultEncodeOptions, options); + return encodeCustom(data, cborEncoders, options); + } + var defaultEncodeOptions, cborEncoders, buf, Ref, simpleTokens, typeEncoders; + var init_encode = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/encode.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_is(); + init_token(); + init_bl(); + init_common(); + init_jump(); + init_byte_utils(); + init_uint(); + init_negint(); + init_bytes(); + init_string(); + init_array(); + init_map(); + init_tag(); + init_float(); + defaultEncodeOptions = { + float64: false, + mapSorter, + quickEncodeToken + }; + cborEncoders = makeCborEncoders(); + buf = new Bl(); + Ref = class _Ref { + constructor(obj, parent) { + this.obj = obj; + this.parent = parent; + } + includes(obj) { + let p8 = this; + do { + if (p8.obj === obj) { + return true; + } + } while (p8 = p8.parent); + return false; + } + static createCheck(stack, obj) { + if (stack && stack.includes(obj)) { + throw new Error(`${encodeErrPrefix} object contains circular references`); + } + return new _Ref(obj, stack); + } + }; + simpleTokens = { + null: new Token(Type.null, null), + undefined: new Token(Type.undefined, void 0), + true: new Token(Type.true, true), + false: new Token(Type.false, false), + emptyArray: new Token(Type.array, 0), + emptyMap: new Token(Type.map, 0) + }; + typeEncoders = { + number(obj, _typ, _options2, _refStack) { + if (!Number.isInteger(obj) || !Number.isSafeInteger(obj)) { + return new Token(Type.float, obj); + } else if (obj >= 0) { + return new Token(Type.uint, obj); + } else { + return new Token(Type.negint, obj); + } + }, + bigint(obj, _typ, _options2, _refStack) { + if (obj >= BigInt(0)) { + return new Token(Type.uint, obj); + } else { + return new Token(Type.negint, obj); + } + }, + Uint8Array(obj, _typ, _options2, _refStack) { + return new Token(Type.bytes, obj); + }, + string(obj, _typ, _options2, _refStack) { + return new Token(Type.string, obj); + }, + boolean(obj, _typ, _options2, _refStack) { + return obj ? simpleTokens.true : simpleTokens.false; + }, + null(_obj, _typ, _options2, _refStack) { + return simpleTokens.null; + }, + undefined(_obj, _typ, _options2, _refStack) { + return simpleTokens.undefined; + }, + ArrayBuffer(obj, _typ, _options2, _refStack) { + return new Token(Type.bytes, new Uint8Array(obj)); + }, + DataView(obj, _typ, _options2, _refStack) { + return new Token(Type.bytes, new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength)); + }, + Array(obj, _typ, options, refStack) { + if (!obj.length) { + if (options.addBreakTokens === true) { + return [ + simpleTokens.emptyArray, + new Token(Type.break) + ]; + } + return simpleTokens.emptyArray; + } + refStack = Ref.createCheck(refStack, obj); + const entries6 = []; + let i8 = 0; + for (const e12 of obj) { + entries6[i8++] = objectToTokens(e12, options, refStack); + } + if (options.addBreakTokens) { + return [ + new Token(Type.array, obj.length), + entries6, + new Token(Type.break) + ]; + } + return [ + new Token(Type.array, obj.length), + entries6 + ]; + }, + Object(obj, typ, options, refStack) { + const isMap = typ !== "Object"; + const keys2 = isMap ? obj.keys() : Object.keys(obj); + const length3 = isMap ? obj.size : keys2.length; + if (!length3) { + if (options.addBreakTokens === true) { + return [ + simpleTokens.emptyMap, + new Token(Type.break) + ]; + } + return simpleTokens.emptyMap; + } + refStack = Ref.createCheck(refStack, obj); + const entries6 = []; + let i8 = 0; + for (const key of keys2) { + entries6[i8++] = [ + objectToTokens(key, options, refStack), + objectToTokens(isMap ? obj.get(key) : obj[key], options, refStack) + ]; + } + sortMapEntries(entries6, options); + if (options.addBreakTokens) { + return [ + new Token(Type.map, length3), + entries6, + new Token(Type.break) + ]; + } + return [ + new Token(Type.map, length3), + entries6 + ]; + } + }; + typeEncoders.Map = typeEncoders.Object; + typeEncoders.Buffer = typeEncoders.Uint8Array; + for (const typ of "Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" ")) { + typeEncoders[`${typ}Array`] = typeEncoders.DataView; + } + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/decode.js + function tokenToArray(token, tokeniser, options) { + const arr = []; + for (let i8 = 0; i8 < token.value; i8++) { + const value = tokensToObject(tokeniser, options); + if (value === BREAK) { + if (token.value === Infinity) { + break; + } + throw new Error(`${decodeErrPrefix} got unexpected break to lengthed array`); + } + if (value === DONE) { + throw new Error(`${decodeErrPrefix} found array but not enough entries (got ${i8}, expected ${token.value})`); + } + arr[i8] = value; + } + return arr; + } + function tokenToMap(token, tokeniser, options) { + const useMaps = options.useMaps === true; + const obj = useMaps ? void 0 : {}; + const m7 = useMaps ? /* @__PURE__ */ new Map() : void 0; + for (let i8 = 0; i8 < token.value; i8++) { + const key = tokensToObject(tokeniser, options); + if (key === BREAK) { + if (token.value === Infinity) { + break; + } + throw new Error(`${decodeErrPrefix} got unexpected break to lengthed map`); + } + if (key === DONE) { + throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i8} [no key], expected ${token.value})`); + } + if (useMaps !== true && typeof key !== "string") { + throw new Error(`${decodeErrPrefix} non-string keys not supported (got ${typeof key})`); + } + if (options.rejectDuplicateMapKeys === true) { + if (useMaps && m7.has(key) || !useMaps && key in obj) { + throw new Error(`${decodeErrPrefix} found repeat map key "${key}"`); + } + } + const value = tokensToObject(tokeniser, options); + if (value === DONE) { + throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i8} [no value], expected ${token.value})`); + } + if (useMaps) { + m7.set(key, value); + } else { + obj[key] = value; + } + } + return useMaps ? m7 : obj; + } + function tokensToObject(tokeniser, options) { + if (tokeniser.done()) { + return DONE; + } + const token = tokeniser.next(); + if (token.type === Type.break) { + return BREAK; + } + if (token.type.terminal) { + return token.value; + } + if (token.type === Type.array) { + return tokenToArray(token, tokeniser, options); + } + if (token.type === Type.map) { + return tokenToMap(token, tokeniser, options); + } + if (token.type === Type.tag) { + if (options.tags && typeof options.tags[token.value] === "function") { + const tagged = tokensToObject(tokeniser, options); + return options.tags[token.value](tagged); + } + throw new Error(`${decodeErrPrefix} tag not supported (${token.value})`); + } + throw new Error("unsupported"); + } + function decode(data, options) { + if (!(data instanceof Uint8Array)) { + throw new Error(`${decodeErrPrefix} data to decode must be a Uint8Array`); + } + options = Object.assign({}, defaultDecodeOptions, options); + const tokeniser = options.tokenizer || new Tokeniser(data, options); + const decoded = tokensToObject(tokeniser, options); + if (decoded === DONE) { + throw new Error(`${decodeErrPrefix} did not find any content to decode`); + } + if (decoded === BREAK) { + throw new Error(`${decodeErrPrefix} got unexpected break`); + } + if (!tokeniser.done()) { + throw new Error(`${decodeErrPrefix} too many terminals, data makes no sense`); + } + return decoded; + } + var defaultDecodeOptions, Tokeniser, DONE, BREAK; + var init_decode = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/decode.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_common(); + init_token(); + init_jump(); + defaultDecodeOptions = { + strict: false, + allowIndefinite: true, + allowUndefined: true, + allowBigInt: true + }; + Tokeniser = class { + constructor(data, options = {}) { + this.pos = 0; + this.data = data; + this.options = options; + } + done() { + return this.pos >= this.data.length; + } + next() { + const byt = this.data[this.pos]; + let token = quick[byt]; + if (token === void 0) { + const decoder4 = jump[byt]; + if (!decoder4) { + throw new Error(`${decodeErrPrefix} no decoder for major type ${byt >>> 5} (byte 0x${byt.toString(16).padStart(2, "0")})`); + } + const minor = byt & 31; + token = decoder4(this.data, this.pos, minor, this.options); + } + this.pos += token.encodedLength; + return token; + } + }; + DONE = Symbol.for("DONE"); + BREAK = Symbol.for("BREAK"); + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/cborg.js + var init_cborg = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/cborg.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_encode(); + init_decode(); + init_token(); + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/vendor/varint.js + function encode2(num, out, offset2) { + out = out || []; + offset2 = offset2 || 0; + var oldOffset = offset2; + while (num >= INT) { + out[offset2++] = num & 255 | MSB; + num /= 128; + } + while (num & MSBALL) { + out[offset2++] = num & 255 | MSB; + num >>>= 7; + } + out[offset2] = num | 0; + encode2.bytes = offset2 - oldOffset + 1; + return out; + } + function read(buf3, offset2) { + var res = 0, offset2 = offset2 || 0, shift = 0, counter = offset2, b6, l8 = buf3.length; + do { + if (counter >= l8) { + read.bytes = 0; + throw new RangeError("Could not decode varint"); + } + b6 = buf3[counter++]; + res += shift < 28 ? (b6 & REST$1) << shift : (b6 & REST$1) * Math.pow(2, shift); + shift += 7; + } while (b6 >= MSB$1); + read.bytes = counter - offset2; + return res; + } + var encode_1, MSB, REST, MSBALL, INT, decode2, MSB$1, REST$1, N1, N2, N3, N4, N5, N6, N7, N8, N9, length, varint, _brrp_varint, varint_default; + var init_varint = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/vendor/varint.js"() { + init_dirname(); + init_buffer2(); + init_process(); + encode_1 = encode2; + MSB = 128; + REST = 127; + MSBALL = ~REST; + INT = Math.pow(2, 31); + decode2 = read; + MSB$1 = 128; + REST$1 = 127; + N1 = Math.pow(2, 7); + N2 = Math.pow(2, 14); + N3 = Math.pow(2, 21); + N4 = Math.pow(2, 28); + N5 = Math.pow(2, 35); + N6 = Math.pow(2, 42); + N7 = Math.pow(2, 49); + N8 = Math.pow(2, 56); + N9 = Math.pow(2, 63); + length = function(value) { + return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10; + }; + varint = { + encode: encode_1, + decode: decode2, + encodingLength: length + }; + _brrp_varint = varint; + varint_default = _brrp_varint; + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/varint.js + var decode3, encodeTo, encodingLength; + var init_varint2 = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/varint.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_varint(); + decode3 = (data, offset2 = 0) => { + const code15 = varint_default.decode(data, offset2); + return [code15, varint_default.decode.bytes]; + }; + encodeTo = (int, target, offset2 = 0) => { + varint_default.encode(int, target, offset2); + return target; + }; + encodingLength = (int) => { + return varint_default.encodingLength(int); + }; + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bytes.js + var bytes_exports2 = {}; + __export(bytes_exports2, { + coerce: () => coerce, + empty: () => empty, + equals: () => equals, + fromHex: () => fromHex, + fromString: () => fromString2, + isBinary: () => isBinary, + toHex: () => toHex, + toString: () => toString2 + }); + var empty, toHex, fromHex, equals, coerce, isBinary, fromString2, toString2; + var init_bytes2 = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bytes.js"() { + init_dirname(); + init_buffer2(); + init_process(); + empty = new Uint8Array(0); + toHex = (d7) => d7.reduce((hex, byte) => hex + byte.toString(16).padStart(2, "0"), ""); + fromHex = (hex) => { + const hexes2 = hex.match(/../g); + return hexes2 ? new Uint8Array(hexes2.map((b6) => parseInt(b6, 16))) : empty; + }; + equals = (aa, bb) => { + if (aa === bb) + return true; + if (aa.byteLength !== bb.byteLength) { + return false; + } + for (let ii = 0; ii < aa.byteLength; ii++) { + if (aa[ii] !== bb[ii]) { + return false; + } + } + return true; + }; + coerce = (o9) => { + if (o9 instanceof Uint8Array && o9.constructor.name === "Uint8Array") + return o9; + if (o9 instanceof ArrayBuffer) + return new Uint8Array(o9); + if (ArrayBuffer.isView(o9)) { + return new Uint8Array(o9.buffer, o9.byteOffset, o9.byteLength); + } + throw new Error("Unknown type, must be binary type"); + }; + isBinary = (o9) => o9 instanceof ArrayBuffer || ArrayBuffer.isView(o9); + fromString2 = (str) => new TextEncoder().encode(str); + toString2 = (b6) => new TextDecoder().decode(b6); + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/hashes/digest.js + var create, decode4, equals2, Digest; + var init_digest = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/hashes/digest.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_bytes2(); + init_varint2(); + create = (code15, digest3) => { + const size4 = digest3.byteLength; + const sizeOffset = encodingLength(code15); + const digestOffset = sizeOffset + encodingLength(size4); + const bytes2 = new Uint8Array(digestOffset + size4); + encodeTo(code15, bytes2, 0); + encodeTo(size4, bytes2, sizeOffset); + bytes2.set(digest3, digestOffset); + return new Digest(code15, size4, digest3, bytes2); + }; + decode4 = (multihash) => { + const bytes2 = coerce(multihash); + const [code15, sizeOffset] = decode3(bytes2); + const [size4, digestOffset] = decode3(bytes2.subarray(sizeOffset)); + const digest3 = bytes2.subarray(sizeOffset + digestOffset); + if (digest3.byteLength !== size4) { + throw new Error("Incorrect length"); + } + return new Digest(code15, size4, digest3, bytes2); + }; + equals2 = (a8, b6) => { + if (a8 === b6) { + return true; + } else { + const data = ( + /** @type {{code?:unknown, size?:unknown, bytes?:unknown}} */ + b6 + ); + return a8.code === data.code && a8.size === data.size && data.bytes instanceof Uint8Array && equals(a8.bytes, data.bytes); + } + }; + Digest = class { + /** + * Creates a multihash digest. + * + * @param {Code} code + * @param {Size} size + * @param {Uint8Array} digest + * @param {Uint8Array} bytes + */ + constructor(code15, size4, digest3, bytes2) { + this.code = code15; + this.size = size4; + this.digest = digest3; + this.bytes = bytes2; + } + }; + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/vendor/base-x.js + function base(ALPHABET, name15) { + if (ALPHABET.length >= 255) { + throw new TypeError("Alphabet too long"); + } + var BASE_MAP = new Uint8Array(256); + for (var j5 = 0; j5 < BASE_MAP.length; j5++) { + BASE_MAP[j5] = 255; + } + for (var i8 = 0; i8 < ALPHABET.length; i8++) { + var x5 = ALPHABET.charAt(i8); + var xc = x5.charCodeAt(0); + if (BASE_MAP[xc] !== 255) { + throw new TypeError(x5 + " is ambiguous"); + } + BASE_MAP[xc] = i8; + } + var BASE = ALPHABET.length; + var LEADER = ALPHABET.charAt(0); + var FACTOR = Math.log(BASE) / Math.log(256); + var iFACTOR = Math.log(256) / Math.log(BASE); + function encode41(source) { + if (source instanceof Uint8Array) + ; + else if (ArrayBuffer.isView(source)) { + source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength); + } else if (Array.isArray(source)) { + source = Uint8Array.from(source); + } + if (!(source instanceof Uint8Array)) { + throw new TypeError("Expected Uint8Array"); + } + if (source.length === 0) { + return ""; + } + var zeroes = 0; + var length3 = 0; + var pbegin = 0; + var pend = source.length; + while (pbegin !== pend && source[pbegin] === 0) { + pbegin++; + zeroes++; + } + var size4 = (pend - pbegin) * iFACTOR + 1 >>> 0; + var b58 = new Uint8Array(size4); + while (pbegin !== pend) { + var carry = source[pbegin]; + var i9 = 0; + for (var it1 = size4 - 1; (carry !== 0 || i9 < length3) && it1 !== -1; it1--, i9++) { + carry += 256 * b58[it1] >>> 0; + b58[it1] = carry % BASE >>> 0; + carry = carry / BASE >>> 0; + } + if (carry !== 0) { + throw new Error("Non-zero carry"); + } + length3 = i9; + pbegin++; + } + var it22 = size4 - length3; + while (it22 !== size4 && b58[it22] === 0) { + it22++; + } + var str = LEADER.repeat(zeroes); + for (; it22 < size4; ++it22) { + str += ALPHABET.charAt(b58[it22]); + } + return str; + } + function decodeUnsafe(source) { + if (typeof source !== "string") { + throw new TypeError("Expected String"); + } + if (source.length === 0) { + return new Uint8Array(); + } + var psz = 0; + if (source[psz] === " ") { + return; + } + var zeroes = 0; + var length3 = 0; + while (source[psz] === LEADER) { + zeroes++; + psz++; + } + var size4 = (source.length - psz) * FACTOR + 1 >>> 0; + var b256 = new Uint8Array(size4); + while (source[psz]) { + var carry = BASE_MAP[source.charCodeAt(psz)]; + if (carry === 255) { + return; + } + var i9 = 0; + for (var it32 = size4 - 1; (carry !== 0 || i9 < length3) && it32 !== -1; it32--, i9++) { + carry += BASE * b256[it32] >>> 0; + b256[it32] = carry % 256 >>> 0; + carry = carry / 256 >>> 0; + } + if (carry !== 0) { + throw new Error("Non-zero carry"); + } + length3 = i9; + psz++; + } + if (source[psz] === " ") { + return; + } + var it4 = size4 - length3; + while (it4 !== size4 && b256[it4] === 0) { + it4++; + } + var vch = new Uint8Array(zeroes + (size4 - it4)); + var j6 = zeroes; + while (it4 !== size4) { + vch[j6++] = b256[it4++]; + } + return vch; + } + function decode46(string4) { + var buffer4 = decodeUnsafe(string4); + if (buffer4) { + return buffer4; + } + throw new Error(`Non-${name15} character`); + } + return { + encode: encode41, + decodeUnsafe, + decode: decode46 + }; + } + var src, _brrp__multiformats_scope_baseX, base_x_default; + var init_base_x = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/vendor/base-x.js"() { + init_dirname(); + init_buffer2(); + init_process(); + src = base; + _brrp__multiformats_scope_baseX = src; + base_x_default = _brrp__multiformats_scope_baseX; + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bases/interface.js + var init_interface = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bases/interface.js"() { + init_dirname(); + init_buffer2(); + init_process(); + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bases/base.js + var Encoder, Decoder, ComposedDecoder, or, Codec, from, baseX, decode5, encode3, rfc4648; + var init_base = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bases/base.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_base_x(); + init_bytes2(); + init_interface(); + Encoder = class { + /** + * @param {Base} name + * @param {Prefix} prefix + * @param {(bytes:Uint8Array) => string} baseEncode + */ + constructor(name15, prefix, baseEncode) { + this.name = name15; + this.prefix = prefix; + this.baseEncode = baseEncode; + } + /** + * @param {Uint8Array} bytes + * @returns {API.Multibase} + */ + encode(bytes2) { + if (bytes2 instanceof Uint8Array) { + return `${this.prefix}${this.baseEncode(bytes2)}`; + } else { + throw Error("Unknown type, must be binary type"); + } + } + }; + Decoder = class { + /** + * @param {Base} name + * @param {Prefix} prefix + * @param {(text:string) => Uint8Array} baseDecode + */ + constructor(name15, prefix, baseDecode) { + this.name = name15; + this.prefix = prefix; + if (prefix.codePointAt(0) === void 0) { + throw new Error("Invalid prefix character"); + } + this.prefixCodePoint = /** @type {number} */ + prefix.codePointAt(0); + this.baseDecode = baseDecode; + } + /** + * @param {string} text + */ + decode(text3) { + if (typeof text3 === "string") { + if (text3.codePointAt(0) !== this.prefixCodePoint) { + throw Error(`Unable to decode multibase string ${JSON.stringify(text3)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`); + } + return this.baseDecode(text3.slice(this.prefix.length)); + } else { + throw Error("Can only multibase decode strings"); + } + } + /** + * @template {string} OtherPrefix + * @param {API.UnibaseDecoder|ComposedDecoder} decoder + * @returns {ComposedDecoder} + */ + or(decoder4) { + return or(this, decoder4); + } + }; + ComposedDecoder = class { + /** + * @param {Decoders} decoders + */ + constructor(decoders) { + this.decoders = decoders; + } + /** + * @template {string} OtherPrefix + * @param {API.UnibaseDecoder|ComposedDecoder} decoder + * @returns {ComposedDecoder} + */ + or(decoder4) { + return or(this, decoder4); + } + /** + * @param {string} input + * @returns {Uint8Array} + */ + decode(input) { + const prefix = ( + /** @type {Prefix} */ + input[0] + ); + const decoder4 = this.decoders[prefix]; + if (decoder4) { + return decoder4.decode(input); + } else { + throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); + } + } + }; + or = (left, right) => new ComposedDecoder( + /** @type {Decoders} */ + { + ...left.decoders || { [ + /** @type API.UnibaseDecoder */ + left.prefix + ]: left }, + ...right.decoders || { [ + /** @type API.UnibaseDecoder */ + right.prefix + ]: right } + } + ); + Codec = class { + /** + * @param {Base} name + * @param {Prefix} prefix + * @param {(bytes:Uint8Array) => string} baseEncode + * @param {(text:string) => Uint8Array} baseDecode + */ + constructor(name15, prefix, baseEncode, baseDecode) { + this.name = name15; + this.prefix = prefix; + this.baseEncode = baseEncode; + this.baseDecode = baseDecode; + this.encoder = new Encoder(name15, prefix, baseEncode); + this.decoder = new Decoder(name15, prefix, baseDecode); + } + /** + * @param {Uint8Array} input + */ + encode(input) { + return this.encoder.encode(input); + } + /** + * @param {string} input + */ + decode(input) { + return this.decoder.decode(input); + } + }; + from = ({ name: name15, prefix, encode: encode41, decode: decode46 }) => new Codec(name15, prefix, encode41, decode46); + baseX = ({ prefix, name: name15, alphabet: alphabet2 }) => { + const { encode: encode41, decode: decode46 } = base_x_default(alphabet2, name15); + return from({ + prefix, + name: name15, + encode: encode41, + /** + * @param {string} text + */ + decode: (text3) => coerce(decode46(text3)) + }); + }; + decode5 = (string4, alphabet2, bitsPerChar, name15) => { + const codes = {}; + for (let i8 = 0; i8 < alphabet2.length; ++i8) { + codes[alphabet2[i8]] = i8; + } + let end = string4.length; + while (string4[end - 1] === "=") { + --end; + } + const out = new Uint8Array(end * bitsPerChar / 8 | 0); + let bits = 0; + let buffer4 = 0; + let written = 0; + for (let i8 = 0; i8 < end; ++i8) { + const value = codes[string4[i8]]; + if (value === void 0) { + throw new SyntaxError(`Non-${name15} character`); + } + buffer4 = buffer4 << bitsPerChar | value; + bits += bitsPerChar; + if (bits >= 8) { + bits -= 8; + out[written++] = 255 & buffer4 >> bits; + } + } + if (bits >= bitsPerChar || 255 & buffer4 << 8 - bits) { + throw new SyntaxError("Unexpected end of data"); + } + return out; + }; + encode3 = (data, alphabet2, bitsPerChar) => { + const pad = alphabet2[alphabet2.length - 1] === "="; + const mask2 = (1 << bitsPerChar) - 1; + let out = ""; + let bits = 0; + let buffer4 = 0; + for (let i8 = 0; i8 < data.length; ++i8) { + buffer4 = buffer4 << 8 | data[i8]; + bits += 8; + while (bits > bitsPerChar) { + bits -= bitsPerChar; + out += alphabet2[mask2 & buffer4 >> bits]; + } + } + if (bits) { + out += alphabet2[mask2 & buffer4 << bitsPerChar - bits]; + } + if (pad) { + while (out.length * bitsPerChar & 7) { + out += "="; + } + } + return out; + }; + rfc4648 = ({ name: name15, prefix, bitsPerChar, alphabet: alphabet2 }) => { + return from({ + prefix, + name: name15, + encode(input) { + return encode3(input, alphabet2, bitsPerChar); + }, + decode(input) { + return decode5(input, alphabet2, bitsPerChar, name15); + } + }); + }; + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bases/base58.js + var base58btc, base58flickr; + var init_base58 = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bases/base58.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_base(); + base58btc = baseX({ + name: "base58btc", + prefix: "z", + alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" + }); + base58flickr = baseX({ + name: "base58flickr", + prefix: "Z", + alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" + }); + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bases/base32.js + var base32, base32upper, base32pad, base32padupper, base32hex, base32hexupper, base32hexpad, base32hexpadupper, base32z; + var init_base32 = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bases/base32.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_base(); + base32 = rfc4648({ + prefix: "b", + name: "base32", + alphabet: "abcdefghijklmnopqrstuvwxyz234567", + bitsPerChar: 5 + }); + base32upper = rfc4648({ + prefix: "B", + name: "base32upper", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", + bitsPerChar: 5 + }); + base32pad = rfc4648({ + prefix: "c", + name: "base32pad", + alphabet: "abcdefghijklmnopqrstuvwxyz234567=", + bitsPerChar: 5 + }); + base32padupper = rfc4648({ + prefix: "C", + name: "base32padupper", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", + bitsPerChar: 5 + }); + base32hex = rfc4648({ + prefix: "v", + name: "base32hex", + alphabet: "0123456789abcdefghijklmnopqrstuv", + bitsPerChar: 5 + }); + base32hexupper = rfc4648({ + prefix: "V", + name: "base32hexupper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", + bitsPerChar: 5 + }); + base32hexpad = rfc4648({ + prefix: "t", + name: "base32hexpad", + alphabet: "0123456789abcdefghijklmnopqrstuv=", + bitsPerChar: 5 + }); + base32hexpadupper = rfc4648({ + prefix: "T", + name: "base32hexpadupper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", + bitsPerChar: 5 + }); + base32z = rfc4648({ + prefix: "h", + name: "base32z", + alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", + bitsPerChar: 5 + }); + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/link/interface.js + var init_interface2 = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/link/interface.js"() { + init_dirname(); + init_buffer2(); + init_process(); + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/cid.js + var format, cache, baseCache, CID, parseCIDtoBytes, toStringV0, toStringV1, DAG_PB_CODE, SHA_256_CODE, encodeCID, cidSymbol; + var init_cid = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/cid.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_varint2(); + init_digest(); + init_base58(); + init_base32(); + init_bytes2(); + init_interface2(); + init_interface2(); + format = (link10, base3) => { + const { bytes: bytes2, version: version3 } = link10; + switch (version3) { + case 0: + return toStringV0( + bytes2, + baseCache(link10), + /** @type {API.MultibaseEncoder<"z">} */ + base3 || base58btc.encoder + ); + default: + return toStringV1( + bytes2, + baseCache(link10), + /** @type {API.MultibaseEncoder} */ + base3 || base32.encoder + ); + } + }; + cache = /* @__PURE__ */ new WeakMap(); + baseCache = (cid) => { + const baseCache3 = cache.get(cid); + if (baseCache3 == null) { + const baseCache4 = /* @__PURE__ */ new Map(); + cache.set(cid, baseCache4); + return baseCache4; + } + return baseCache3; + }; + CID = class _CID { + /** + * @param {Version} version - Version of the CID + * @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv + * @param {API.MultihashDigest} multihash - (Multi)hash of the of the content. + * @param {Uint8Array} bytes + * + */ + constructor(version3, code15, multihash, bytes2) { + this.code = code15; + this.version = version3; + this.multihash = multihash; + this.bytes = bytes2; + this["/"] = bytes2; + } + /** + * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes` + * please either use `CID.asCID(cid)` or switch to new signalling mechanism + * + * @deprecated + */ + get asCID() { + return this; + } + // ArrayBufferView + get byteOffset() { + return this.bytes.byteOffset; + } + // ArrayBufferView + get byteLength() { + return this.bytes.byteLength; + } + /** + * @returns {CID} + */ + toV0() { + switch (this.version) { + case 0: { + return ( + /** @type {CID} */ + this + ); + } + case 1: { + const { code: code15, multihash } = this; + if (code15 !== DAG_PB_CODE) { + throw new Error("Cannot convert a non dag-pb CID to CIDv0"); + } + if (multihash.code !== SHA_256_CODE) { + throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0"); + } + return ( + /** @type {CID} */ + _CID.createV0( + /** @type {API.MultihashDigest} */ + multihash + ) + ); + } + default: { + throw Error( + `Can not convert CID version ${this.version} to version 0. This is a bug please report` + ); + } + } + } + /** + * @returns {CID} + */ + toV1() { + switch (this.version) { + case 0: { + const { code: code15, digest: digest3 } = this.multihash; + const multihash = create(code15, digest3); + return ( + /** @type {CID} */ + _CID.createV1(this.code, multihash) + ); + } + case 1: { + return ( + /** @type {CID} */ + this + ); + } + default: { + throw Error( + `Can not convert CID version ${this.version} to version 1. This is a bug please report` + ); + } + } + } + /** + * @param {unknown} other + * @returns {other is CID} + */ + equals(other) { + return _CID.equals(this, other); + } + /** + * @template {unknown} Data + * @template {number} Format + * @template {number} Alg + * @template {API.Version} Version + * @param {API.Link} self + * @param {unknown} other + * @returns {other is CID} + */ + static equals(self2, other) { + const unknown3 = ( + /** @type {{code?:unknown, version?:unknown, multihash?:unknown}} */ + other + ); + return unknown3 && self2.code === unknown3.code && self2.version === unknown3.version && equals2(self2.multihash, unknown3.multihash); + } + /** + * @param {API.MultibaseEncoder} [base] + * @returns {string} + */ + toString(base3) { + return format(this, base3); + } + toJSON() { + return { "/": format(this) }; + } + link() { + return this; + } + get [Symbol.toStringTag]() { + return "CID"; + } + // Legacy + [Symbol.for("nodejs.util.inspect.custom")]() { + return `CID(${this.toString()})`; + } + /** + * Takes any input `value` and returns a `CID` instance if it was + * a `CID` otherwise returns `null`. If `value` is instanceof `CID` + * it will return value back. If `value` is not instance of this CID + * class, but is compatible CID it will return new instance of this + * `CID` class. Otherwise returns null. + * + * This allows two different incompatible versions of CID library to + * co-exist and interop as long as binary interface is compatible. + * + * @template {unknown} Data + * @template {number} Format + * @template {number} Alg + * @template {API.Version} Version + * @template {unknown} U + * @param {API.Link|U} input + * @returns {CID|null} + */ + static asCID(input) { + if (input == null) { + return null; + } + const value = ( + /** @type {any} */ + input + ); + if (value instanceof _CID) { + return value; + } else if (value["/"] != null && value["/"] === value.bytes || value.asCID === value) { + const { version: version3, code: code15, multihash, bytes: bytes2 } = value; + return new _CID( + version3, + code15, + /** @type {API.MultihashDigest} */ + multihash, + bytes2 || encodeCID(version3, code15, multihash.bytes) + ); + } else if (value[cidSymbol] === true) { + const { version: version3, multihash, code: code15 } = value; + const digest3 = ( + /** @type {API.MultihashDigest} */ + decode4(multihash) + ); + return _CID.create(version3, code15, digest3); + } else { + return null; + } + } + /** + * + * @template {unknown} Data + * @template {number} Format + * @template {number} Alg + * @template {API.Version} Version + * @param {Version} version - Version of the CID + * @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv + * @param {API.MultihashDigest} digest - (Multi)hash of the of the content. + * @returns {CID} + */ + static create(version3, code15, digest3) { + if (typeof code15 !== "number") { + throw new Error("String codecs are no longer supported"); + } + if (!(digest3.bytes instanceof Uint8Array)) { + throw new Error("Invalid digest"); + } + switch (version3) { + case 0: { + if (code15 !== DAG_PB_CODE) { + throw new Error( + `Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding` + ); + } else { + return new _CID(version3, code15, digest3, digest3.bytes); + } + } + case 1: { + const bytes2 = encodeCID(version3, code15, digest3.bytes); + return new _CID(version3, code15, digest3, bytes2); + } + default: { + throw new Error("Invalid version"); + } + } + } + /** + * Simplified version of `create` for CIDv0. + * + * @template {unknown} [T=unknown] + * @param {API.MultihashDigest} digest - Multihash. + * @returns {CID} + */ + static createV0(digest3) { + return _CID.create(0, DAG_PB_CODE, digest3); + } + /** + * Simplified version of `create` for CIDv1. + * + * @template {unknown} Data + * @template {number} Code + * @template {number} Alg + * @param {Code} code - Content encoding format code. + * @param {API.MultihashDigest} digest - Miltihash of the content. + * @returns {CID} + */ + static createV1(code15, digest3) { + return _CID.create(1, code15, digest3); + } + /** + * Decoded a CID from its binary representation. The byte array must contain + * only the CID with no additional bytes. + * + * An error will be thrown if the bytes provided do not contain a valid + * binary representation of a CID. + * + * @template {unknown} Data + * @template {number} Code + * @template {number} Alg + * @template {API.Version} Ver + * @param {API.ByteView>} bytes + * @returns {CID} + */ + static decode(bytes2) { + const [cid, remainder] = _CID.decodeFirst(bytes2); + if (remainder.length) { + throw new Error("Incorrect length"); + } + return cid; + } + /** + * Decoded a CID from its binary representation at the beginning of a byte + * array. + * + * Returns an array with the first element containing the CID and the second + * element containing the remainder of the original byte array. The remainder + * will be a zero-length byte array if the provided bytes only contained a + * binary CID representation. + * + * @template {unknown} T + * @template {number} C + * @template {number} A + * @template {API.Version} V + * @param {API.ByteView>} bytes + * @returns {[CID, Uint8Array]} + */ + static decodeFirst(bytes2) { + const specs = _CID.inspectBytes(bytes2); + const prefixSize = specs.size - specs.multihashSize; + const multihashBytes = coerce( + bytes2.subarray(prefixSize, prefixSize + specs.multihashSize) + ); + if (multihashBytes.byteLength !== specs.multihashSize) { + throw new Error("Incorrect length"); + } + const digestBytes = multihashBytes.subarray( + specs.multihashSize - specs.digestSize + ); + const digest3 = new Digest( + specs.multihashCode, + specs.digestSize, + digestBytes, + multihashBytes + ); + const cid = specs.version === 0 ? _CID.createV0( + /** @type {API.MultihashDigest} */ + digest3 + ) : _CID.createV1(specs.codec, digest3); + return [ + /** @type {CID} */ + cid, + bytes2.subarray(specs.size) + ]; + } + /** + * Inspect the initial bytes of a CID to determine its properties. + * + * Involves decoding up to 4 varints. Typically this will require only 4 to 6 + * bytes but for larger multicodec code values and larger multihash digest + * lengths these varints can be quite large. It is recommended that at least + * 10 bytes be made available in the `initialBytes` argument for a complete + * inspection. + * + * @template {unknown} T + * @template {number} C + * @template {number} A + * @template {API.Version} V + * @param {API.ByteView>} initialBytes + * @returns {{ version:V, codec:C, multihashCode:A, digestSize:number, multihashSize:number, size:number }} + */ + static inspectBytes(initialBytes) { + let offset2 = 0; + const next = () => { + const [i8, length3] = decode3(initialBytes.subarray(offset2)); + offset2 += length3; + return i8; + }; + let version3 = ( + /** @type {V} */ + next() + ); + let codec = ( + /** @type {C} */ + DAG_PB_CODE + ); + if ( + /** @type {number} */ + version3 === 18 + ) { + version3 = /** @type {V} */ + 0; + offset2 = 0; + } else { + codec = /** @type {C} */ + next(); + } + if (version3 !== 0 && version3 !== 1) { + throw new RangeError(`Invalid CID version ${version3}`); + } + const prefixSize = offset2; + const multihashCode = ( + /** @type {A} */ + next() + ); + const digestSize = next(); + const size4 = offset2 + digestSize; + const multihashSize = size4 - prefixSize; + return { version: version3, codec, multihashCode, digestSize, multihashSize, size: size4 }; + } + /** + * Takes cid in a string representation and creates an instance. If `base` + * decoder is not provided will use a default from the configuration. It will + * throw an error if encoding of the CID is not compatible with supplied (or + * a default decoder). + * + * @template {string} Prefix + * @template {unknown} Data + * @template {number} Code + * @template {number} Alg + * @template {API.Version} Ver + * @param {API.ToString, Prefix>} source + * @param {API.MultibaseDecoder} [base] + * @returns {CID} + */ + static parse(source, base3) { + const [prefix, bytes2] = parseCIDtoBytes(source, base3); + const cid = _CID.decode(bytes2); + if (cid.version === 0 && source[0] !== "Q") { + throw Error("Version 0 CID string must not include multibase prefix"); + } + baseCache(cid).set(prefix, source); + return cid; + } + }; + parseCIDtoBytes = (source, base3) => { + switch (source[0]) { + case "Q": { + const decoder4 = base3 || base58btc; + return [ + /** @type {Prefix} */ + base58btc.prefix, + decoder4.decode(`${base58btc.prefix}${source}`) + ]; + } + case base58btc.prefix: { + const decoder4 = base3 || base58btc; + return [ + /** @type {Prefix} */ + base58btc.prefix, + decoder4.decode(source) + ]; + } + case base32.prefix: { + const decoder4 = base3 || base32; + return [ + /** @type {Prefix} */ + base32.prefix, + decoder4.decode(source) + ]; + } + default: { + if (base3 == null) { + throw Error( + "To parse non base32 or base58btc encoded CID multibase decoder must be provided" + ); + } + return [ + /** @type {Prefix} */ + source[0], + base3.decode(source) + ]; + } + } + }; + toStringV0 = (bytes2, cache3, base3) => { + const { prefix } = base3; + if (prefix !== base58btc.prefix) { + throw Error(`Cannot string encode V0 in ${base3.name} encoding`); + } + const cid = cache3.get(prefix); + if (cid == null) { + const cid2 = base3.encode(bytes2).slice(1); + cache3.set(prefix, cid2); + return cid2; + } else { + return cid; + } + }; + toStringV1 = (bytes2, cache3, base3) => { + const { prefix } = base3; + const cid = cache3.get(prefix); + if (cid == null) { + const cid2 = base3.encode(bytes2); + cache3.set(prefix, cid2); + return cid2; + } else { + return cid; + } + }; + DAG_PB_CODE = 112; + SHA_256_CODE = 18; + encodeCID = (version3, code15, multihash) => { + const codeOffset = encodingLength(version3); + const hashOffset = codeOffset + encodingLength(code15); + const bytes2 = new Uint8Array(hashOffset + multihash.byteLength); + encodeTo(version3, bytes2, 0); + encodeTo(code15, bytes2, codeOffset); + bytes2.set(multihash, hashOffset); + return bytes2; + }; + cidSymbol = Symbol.for("@ipld/js-cid/CID"); + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/json/encode.js + function mapSorter2(e1, e22) { + if (Array.isArray(e1[0]) || Array.isArray(e22[0])) { + throw new Error(`${encodeErrPrefix} complex map keys are not supported`); + } + const keyToken1 = e1[0]; + const keyToken2 = e22[0]; + if (keyToken1.type !== Type.string || keyToken2.type !== Type.string) { + throw new Error(`${encodeErrPrefix} non-string map keys are not supported`); + } + if (keyToken1 < keyToken2) { + return -1; + } + if (keyToken1 > keyToken2) { + return 1; + } + throw new Error(`${encodeErrPrefix} unexpected duplicate map keys, this is not supported`); + } + function encode12(data, options) { + options = Object.assign({}, defaultEncodeOptions2, options); + return encodeCustom(data, new JSONEncoder(), options); + } + var JSONEncoder, defaultEncodeOptions2; + var init_encode2 = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/json/encode.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_token(); + init_encode(); + init_common(); + init_byte_utils(); + JSONEncoder = class extends Array { + constructor() { + super(); + this.inRecursive = []; + } + prefix(buf3) { + const recurs = this.inRecursive[this.inRecursive.length - 1]; + if (recurs) { + if (recurs.type === Type.array) { + recurs.elements++; + if (recurs.elements !== 1) { + buf3.push([44]); + } + } + if (recurs.type === Type.map) { + recurs.elements++; + if (recurs.elements !== 1) { + if (recurs.elements % 2 === 1) { + buf3.push([44]); + } else { + buf3.push([58]); + } + } + } + } + } + [Type.uint.major](buf3, token) { + this.prefix(buf3); + const is3 = String(token.value); + const isa = []; + for (let i8 = 0; i8 < is3.length; i8++) { + isa[i8] = is3.charCodeAt(i8); + } + buf3.push(isa); + } + [Type.negint.major](buf3, token) { + this[Type.uint.major](buf3, token); + } + [Type.bytes.major](_buf, _token) { + throw new Error(`${encodeErrPrefix} unsupported type: Uint8Array`); + } + [Type.string.major](buf3, token) { + this.prefix(buf3); + const byts = fromString(JSON.stringify(token.value)); + buf3.push(byts.length > 32 ? asU8A(byts) : byts); + } + [Type.array.major](buf3, _token) { + this.prefix(buf3); + this.inRecursive.push({ + type: Type.array, + elements: 0 + }); + buf3.push([91]); + } + [Type.map.major](buf3, _token) { + this.prefix(buf3); + this.inRecursive.push({ + type: Type.map, + elements: 0 + }); + buf3.push([123]); + } + [Type.tag.major](_buf, _token) { + } + [Type.float.major](buf3, token) { + if (token.type.name === "break") { + const recurs = this.inRecursive.pop(); + if (recurs) { + if (recurs.type === Type.array) { + buf3.push([93]); + } else if (recurs.type === Type.map) { + buf3.push([125]); + } else { + throw new Error("Unexpected recursive type; this should not happen!"); + } + return; + } + throw new Error("Unexpected break; this should not happen!"); + } + if (token.value === void 0) { + throw new Error(`${encodeErrPrefix} unsupported type: undefined`); + } + this.prefix(buf3); + if (token.type.name === "true") { + buf3.push([ + 116, + 114, + 117, + 101 + ]); + return; + } else if (token.type.name === "false") { + buf3.push([ + 102, + 97, + 108, + 115, + 101 + ]); + return; + } else if (token.type.name === "null") { + buf3.push([ + 110, + 117, + 108, + 108 + ]); + return; + } + const is3 = String(token.value); + const isa = []; + let dp = false; + for (let i8 = 0; i8 < is3.length; i8++) { + isa[i8] = is3.charCodeAt(i8); + if (!dp && (isa[i8] === 46 || isa[i8] === 101 || isa[i8] === 69)) { + dp = true; + } + } + if (!dp) { + isa.push(46); + isa.push(48); + } + buf3.push(isa); + } + }; + defaultEncodeOptions2 = { + addBreakTokens: true, + mapSorter: mapSorter2 + }; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/json/decode.js + function decode15(data, options) { + options = Object.assign({ tokenizer: new Tokenizer(data, options) }, options); + return decode(data, options); + } + var Tokenizer; + var init_decode2 = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/json/decode.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_decode(); + init_token(); + init_byte_utils(); + init_common(); + Tokenizer = class { + constructor(data, options = {}) { + this.pos = 0; + this.data = data; + this.options = options; + this.modeStack = ["value"]; + this.lastToken = ""; + } + done() { + return this.pos >= this.data.length; + } + ch() { + return this.data[this.pos]; + } + currentMode() { + return this.modeStack[this.modeStack.length - 1]; + } + skipWhitespace() { + let c8 = this.ch(); + while (c8 === 32 || c8 === 9 || c8 === 13 || c8 === 10) { + c8 = this.data[++this.pos]; + } + } + expect(str) { + if (this.data.length - this.pos < str.length) { + throw new Error(`${decodeErrPrefix} unexpected end of input at position ${this.pos}`); + } + for (let i8 = 0; i8 < str.length; i8++) { + if (this.data[this.pos++] !== str[i8]) { + throw new Error(`${decodeErrPrefix} unexpected token at position ${this.pos}, expected to find '${String.fromCharCode(...str)}'`); + } + } + } + parseNumber() { + const startPos = this.pos; + let negative = false; + let float3 = false; + const swallow = (chars) => { + while (!this.done()) { + const ch = this.ch(); + if (chars.includes(ch)) { + this.pos++; + } else { + break; + } + } + }; + if (this.ch() === 45) { + negative = true; + this.pos++; + } + if (this.ch() === 48) { + this.pos++; + if (this.ch() === 46) { + this.pos++; + float3 = true; + } else { + return new Token(Type.uint, 0, this.pos - startPos); + } + } + swallow([ + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57 + ]); + if (negative && this.pos === startPos + 1) { + throw new Error(`${decodeErrPrefix} unexpected token at position ${this.pos}`); + } + if (!this.done() && this.ch() === 46) { + if (float3) { + throw new Error(`${decodeErrPrefix} unexpected token at position ${this.pos}`); + } + float3 = true; + this.pos++; + swallow([ + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57 + ]); + } + if (!this.done() && (this.ch() === 101 || this.ch() === 69)) { + float3 = true; + this.pos++; + if (!this.done() && (this.ch() === 43 || this.ch() === 45)) { + this.pos++; + } + swallow([ + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57 + ]); + } + const numStr = String.fromCharCode.apply(null, this.data.subarray(startPos, this.pos)); + const num = parseFloat(numStr); + if (float3) { + return new Token(Type.float, num, this.pos - startPos); + } + if (this.options.allowBigInt !== true || Number.isSafeInteger(num)) { + return new Token(num >= 0 ? Type.uint : Type.negint, num, this.pos - startPos); + } + return new Token(num >= 0 ? Type.uint : Type.negint, BigInt(numStr), this.pos - startPos); + } + parseString() { + if (this.ch() !== 34) { + throw new Error(`${decodeErrPrefix} unexpected character at position ${this.pos}; this shouldn't happen`); + } + this.pos++; + for (let i8 = this.pos, l8 = 0; i8 < this.data.length && l8 < 65536; i8++, l8++) { + const ch = this.data[i8]; + if (ch === 92 || ch < 32 || ch >= 128) { + break; + } + if (ch === 34) { + const str = String.fromCharCode.apply(null, this.data.subarray(this.pos, i8)); + this.pos = i8 + 1; + return new Token(Type.string, str, l8); + } + } + const startPos = this.pos; + const chars = []; + const readu4 = () => { + if (this.pos + 4 >= this.data.length) { + throw new Error(`${decodeErrPrefix} unexpected end of unicode escape sequence at position ${this.pos}`); + } + let u42 = 0; + for (let i8 = 0; i8 < 4; i8++) { + let ch = this.ch(); + if (ch >= 48 && ch <= 57) { + ch -= 48; + } else if (ch >= 97 && ch <= 102) { + ch = ch - 97 + 10; + } else if (ch >= 65 && ch <= 70) { + ch = ch - 65 + 10; + } else { + throw new Error(`${decodeErrPrefix} unexpected unicode escape character at position ${this.pos}`); + } + u42 = u42 * 16 + ch; + this.pos++; + } + return u42; + }; + const readUtf8Char = () => { + const firstByte = this.ch(); + let codePoint = null; + let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1; + if (this.pos + bytesPerSequence > this.data.length) { + throw new Error(`${decodeErrPrefix} unexpected unicode sequence at position ${this.pos}`); + } + let secondByte, thirdByte, fourthByte, tempCodePoint; + switch (bytesPerSequence) { + case 1: + if (firstByte < 128) { + codePoint = firstByte; + } + break; + case 2: + secondByte = this.data[this.pos + 1]; + if ((secondByte & 192) === 128) { + tempCodePoint = (firstByte & 31) << 6 | secondByte & 63; + if (tempCodePoint > 127) { + codePoint = tempCodePoint; + } + } + break; + case 3: + secondByte = this.data[this.pos + 1]; + thirdByte = this.data[this.pos + 2]; + if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) { + tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63; + if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) { + codePoint = tempCodePoint; + } + } + break; + case 4: + secondByte = this.data[this.pos + 1]; + thirdByte = this.data[this.pos + 2]; + fourthByte = this.data[this.pos + 3]; + if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) { + tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63; + if (tempCodePoint > 65535 && tempCodePoint < 1114112) { + codePoint = tempCodePoint; + } + } + } + if (codePoint === null) { + codePoint = 65533; + bytesPerSequence = 1; + } else if (codePoint > 65535) { + codePoint -= 65536; + chars.push(codePoint >>> 10 & 1023 | 55296); + codePoint = 56320 | codePoint & 1023; + } + chars.push(codePoint); + this.pos += bytesPerSequence; + }; + while (!this.done()) { + const ch = this.ch(); + let ch1; + switch (ch) { + case 92: + this.pos++; + if (this.done()) { + throw new Error(`${decodeErrPrefix} unexpected string termination at position ${this.pos}`); + } + ch1 = this.ch(); + this.pos++; + switch (ch1) { + case 34: + case 39: + case 92: + case 47: + chars.push(ch1); + break; + case 98: + chars.push(8); + break; + case 116: + chars.push(9); + break; + case 110: + chars.push(10); + break; + case 102: + chars.push(12); + break; + case 114: + chars.push(13); + break; + case 117: + chars.push(readu4()); + break; + default: + throw new Error(`${decodeErrPrefix} unexpected string escape character at position ${this.pos}`); + } + break; + case 34: + this.pos++; + return new Token(Type.string, decodeCodePointsArray(chars), this.pos - startPos); + default: + if (ch < 32) { + throw new Error(`${decodeErrPrefix} invalid control character at position ${this.pos}`); + } else if (ch < 128) { + chars.push(ch); + this.pos++; + } else { + readUtf8Char(); + } + } + } + throw new Error(`${decodeErrPrefix} unexpected end of string at position ${this.pos}`); + } + parseValue() { + switch (this.ch()) { + case 123: + this.modeStack.push("obj-start"); + this.pos++; + return new Token(Type.map, Infinity, 1); + case 91: + this.modeStack.push("array-start"); + this.pos++; + return new Token(Type.array, Infinity, 1); + case 34: { + return this.parseString(); + } + case 110: + this.expect([ + 110, + 117, + 108, + 108 + ]); + return new Token(Type.null, null, 4); + case 102: + this.expect([ + 102, + 97, + 108, + 115, + 101 + ]); + return new Token(Type.false, false, 5); + case 116: + this.expect([ + 116, + 114, + 117, + 101 + ]); + return new Token(Type.true, true, 4); + case 45: + case 48: + case 49: + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + return this.parseNumber(); + default: + throw new Error(`${decodeErrPrefix} unexpected character at position ${this.pos}`); + } + } + next() { + this.skipWhitespace(); + switch (this.currentMode()) { + case "value": + this.modeStack.pop(); + return this.parseValue(); + case "array-value": { + this.modeStack.pop(); + if (this.ch() === 93) { + this.pos++; + this.skipWhitespace(); + return new Token(Type.break, void 0, 1); + } + if (this.ch() !== 44) { + throw new Error(`${decodeErrPrefix} unexpected character at position ${this.pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`); + } + this.pos++; + this.modeStack.push("array-value"); + this.skipWhitespace(); + return this.parseValue(); + } + case "array-start": { + this.modeStack.pop(); + if (this.ch() === 93) { + this.pos++; + this.skipWhitespace(); + return new Token(Type.break, void 0, 1); + } + this.modeStack.push("array-value"); + this.skipWhitespace(); + return this.parseValue(); + } + case "obj-key": + if (this.ch() === 125) { + this.modeStack.pop(); + this.pos++; + this.skipWhitespace(); + return new Token(Type.break, void 0, 1); + } + if (this.ch() !== 44) { + throw new Error(`${decodeErrPrefix} unexpected character at position ${this.pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`); + } + this.pos++; + this.skipWhitespace(); + case "obj-start": { + this.modeStack.pop(); + if (this.ch() === 125) { + this.pos++; + this.skipWhitespace(); + return new Token(Type.break, void 0, 1); + } + const token = this.parseString(); + this.skipWhitespace(); + if (this.ch() !== 58) { + throw new Error(`${decodeErrPrefix} unexpected character at position ${this.pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`); + } + this.pos++; + this.modeStack.push("obj-value"); + return token; + } + case "obj-value": { + this.modeStack.pop(); + this.modeStack.push("obj-key"); + this.skipWhitespace(); + return this.parseValue(); + } + default: + throw new Error(`${decodeErrPrefix} unexpected parse state at position ${this.pos}; this shouldn't happen`); + } + } + }; + } + }); + + // ../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/json/json.js + var init_json = __esm({ + "../../node_modules/.pnpm/cborg@2.0.4/node_modules/cborg/esm/lib/json/json.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_encode2(); + init_decode2(); + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/hashes/hasher.js + var from5, Hasher2; + var init_hasher = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/hashes/hasher.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_digest(); + from5 = ({ name: name15, code: code15, encode: encode41 }) => new Hasher2(name15, code15, encode41); + Hasher2 = class { + /** + * + * @param {Name} name + * @param {Code} code + * @param {(input: Uint8Array) => Await} encode + */ + constructor(name15, code15, encode41) { + this.name = name15; + this.code = code15; + this.encode = encode41; + } + /** + * @param {Uint8Array} input + * @returns {Await>} + */ + digest(input) { + if (input instanceof Uint8Array) { + const result = this.encode(input); + return result instanceof Uint8Array ? create(this.code, result) : result.then((digest3) => create(this.code, digest3)); + } else { + throw Error("Unknown type, must be binary type"); + } + } + }; + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/interface.js + var init_interface3 = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/interface.js"() { + init_dirname(); + init_buffer2(); + init_process(); + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/index.js + var init_src = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/index.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_cid(); + init_varint2(); + init_bytes2(); + init_hasher(); + init_digest(); + init_interface3(); + } + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bases/base64.js + var base642, base64pad2, base64url2, base64urlpad2; + var init_base64 = __esm({ + "../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/bases/base64.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_base(); + base642 = rfc4648({ + prefix: "m", + name: "base64", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", + bitsPerChar: 6 + }); + base64pad2 = rfc4648({ + prefix: "M", + name: "base64pad", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + bitsPerChar: 6 + }); + base64url2 = rfc4648({ + prefix: "u", + name: "base64url", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", + bitsPerChar: 6 + }); + base64urlpad2 = rfc4648({ + prefix: "U", + name: "base64urlpad", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", + bitsPerChar: 6 + }); + } + }); + + // ../../node_modules/.pnpm/@ipld+dag-json@10.1.3/node_modules/@ipld/dag-json/src/index.js + function cidEncoder2(obj) { + if (obj.asCID !== obj && obj["/"] !== obj.bytes) { + return null; + } + const cid = CID.asCID(obj); + if (!cid) { + return null; + } + const cidString = cid.toString(); + return [ + new Token(Type.map, Infinity, 1), + new Token(Type.string, "/", 1), + // key + new Token(Type.string, cidString, cidString.length), + // value + new Token(Type.break, void 0, 1) + ]; + } + function bytesEncoder(bytes2) { + const bytesString = base642.encode(bytes2).slice(1); + return [ + new Token(Type.map, Infinity, 1), + new Token(Type.string, "/", 1), + // key + new Token(Type.map, Infinity, 1), + // value + new Token(Type.string, "bytes", 5), + // inner key + new Token(Type.string, bytesString, bytesString.length), + // inner value + new Token(Type.break, void 0, 1), + new Token(Type.break, void 0, 1) + ]; + } + function taBytesEncoder(obj) { + return bytesEncoder(new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength)); + } + function abBytesEncoder(ab) { + return bytesEncoder(new Uint8Array(ab)); + } + function undefinedEncoder2() { + throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded"); + } + function numberEncoder2(num) { + if (Number.isNaN(num)) { + throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded"); + } + if (num === Infinity || num === -Infinity) { + throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded"); + } + return null; + } + var encodeOptions2, DagJsonTokenizer, decodeOptions2, encode13, decode16, format5, utf8Decoder, parse4, utf8Encoder; + var init_src2 = __esm({ + "../../node_modules/.pnpm/@ipld+dag-json@10.1.3/node_modules/@ipld/dag-json/src/index.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_cborg(); + init_json(); + init_src(); + init_base64(); + encodeOptions2 = { + typeEncoders: { + Object: cidEncoder2, + Buffer: bytesEncoder, + Uint8Array: bytesEncoder, + Int8Array: taBytesEncoder, + Uint16Array: taBytesEncoder, + Int16Array: taBytesEncoder, + Uint32Array: taBytesEncoder, + Int32Array: taBytesEncoder, + Float32Array: taBytesEncoder, + Float64Array: taBytesEncoder, + Uint8ClampedArray: taBytesEncoder, + BigInt64Array: taBytesEncoder, + BigUint64Array: taBytesEncoder, + DataView: taBytesEncoder, + ArrayBuffer: abBytesEncoder, + undefined: undefinedEncoder2, + number: numberEncoder2 + } + }; + DagJsonTokenizer = class extends Tokenizer { + /** + * @param {Uint8Array} data + * @param {object} [options] + */ + constructor(data, options) { + super(data, options); + this.tokenBuffer = []; + } + /** + * @returns {boolean} + */ + done() { + return this.tokenBuffer.length === 0 && super.done(); + } + /** + * @returns {Token} + */ + _next() { + if (this.tokenBuffer.length > 0) { + return this.tokenBuffer.pop(); + } + return super.next(); + } + /** + * Implements rules outlined in https://github.com/ipld/specs/pull/356 + * + * @returns {Token} + */ + next() { + const token = this._next(); + if (token.type === Type.map) { + const keyToken = this._next(); + if (keyToken.type === Type.string && keyToken.value === "/") { + const valueToken = this._next(); + if (valueToken.type === Type.string) { + const breakToken = this._next(); + if (breakToken.type !== Type.break) { + throw new Error("Invalid encoded CID form"); + } + this.tokenBuffer.push(valueToken); + return new Token(Type.tag, 42, 0); + } + if (valueToken.type === Type.map) { + const innerKeyToken = this._next(); + if (innerKeyToken.type === Type.string && innerKeyToken.value === "bytes") { + const innerValueToken = this._next(); + if (innerValueToken.type === Type.string) { + for (let i8 = 0; i8 < 2; i8++) { + const breakToken = this._next(); + if (breakToken.type !== Type.break) { + throw new Error("Invalid encoded Bytes form"); + } + } + const bytes2 = base642.decode(`m${innerValueToken.value}`); + return new Token(Type.bytes, bytes2, innerValueToken.value.length); + } + this.tokenBuffer.push(innerValueToken); + } + this.tokenBuffer.push(innerKeyToken); + } + this.tokenBuffer.push(valueToken); + } + this.tokenBuffer.push(keyToken); + } + return token; + } + }; + decodeOptions2 = { + allowIndefinite: false, + allowUndefined: false, + allowNaN: false, + allowInfinity: false, + allowBigInt: true, + // this will lead to BigInt for ints outside of + // safe-integer range, which may surprise users + strict: true, + useMaps: false, + rejectDuplicateMapKeys: true, + /** @type {import('cborg').TagDecoder[]} */ + tags: [] + }; + decodeOptions2.tags[42] = CID.parse; + encode13 = (node) => encode12(node, encodeOptions2); + decode16 = (data) => { + const options = Object.assign(decodeOptions2, { tokenizer: new DagJsonTokenizer(data, decodeOptions2) }); + return decode15(data, options); + }; + format5 = (node) => utf8Decoder.decode(encode13(node)); + utf8Decoder = new TextDecoder(); + parse4 = (data) => decode16(utf8Encoder.encode(data)); + utf8Encoder = new TextEncoder(); + } + }); + + // ../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/encode.js + var require_encode = __commonJS({ + "../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/encode.js"(exports12, module3) { + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = encode41; + var MSB3 = 128; + var REST3 = 127; + var MSBALL3 = ~REST3; + var INT3 = Math.pow(2, 31); + function encode41(num, out, offset2) { + if (Number.MAX_SAFE_INTEGER && num > Number.MAX_SAFE_INTEGER) { + encode41.bytes = 0; + throw new RangeError("Could not encode varint"); + } + out = out || []; + offset2 = offset2 || 0; + var oldOffset = offset2; + while (num >= INT3) { + out[offset2++] = num & 255 | MSB3; + num /= 128; + } + while (num & MSBALL3) { + out[offset2++] = num & 255 | MSB3; + num >>>= 7; + } + out[offset2] = num | 0; + encode41.bytes = offset2 - oldOffset + 1; + return out; + } + } + }); + + // ../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/decode.js + var require_decode = __commonJS({ + "../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/decode.js"(exports12, module3) { + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = read13; + var MSB3 = 128; + var REST3 = 127; + function read13(buf3, offset2) { + var res = 0, offset2 = offset2 || 0, shift = 0, counter = offset2, b6, l8 = buf3.length; + do { + if (counter >= l8 || shift > 49) { + read13.bytes = 0; + throw new RangeError("Could not decode varint"); + } + b6 = buf3[counter++]; + res += shift < 28 ? (b6 & REST3) << shift : (b6 & REST3) * Math.pow(2, shift); + shift += 7; + } while (b6 >= MSB3); + read13.bytes = counter - offset2; + return res; + } + } + }); + + // ../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/length.js + var require_length = __commonJS({ + "../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/length.js"(exports12, module3) { + init_dirname(); + init_buffer2(); + init_process(); + var N14 = Math.pow(2, 7); + var N23 = Math.pow(2, 14); + var N33 = Math.pow(2, 21); + var N43 = Math.pow(2, 28); + var N53 = Math.pow(2, 35); + var N63 = Math.pow(2, 42); + var N73 = Math.pow(2, 49); + var N83 = Math.pow(2, 56); + var N93 = Math.pow(2, 63); + module3.exports = function(value) { + return value < N14 ? 1 : value < N23 ? 2 : value < N33 ? 3 : value < N43 ? 4 : value < N53 ? 5 : value < N63 ? 6 : value < N73 ? 7 : value < N83 ? 8 : value < N93 ? 9 : 10; + }; + } + }); + + // ../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/index.js + var require_varint = __commonJS({ + "../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/index.js"(exports12, module3) { + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = { + encode: require_encode(), + decode: require_decode(), + encodingLength: require_length() + }; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-4bd36a8f.js + function o() { + o.init.call(this); + } + function u(e12) { + if ("function" != typeof e12) + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof e12); + } + function f(e12) { + return void 0 === e12._maxListeners ? o.defaultMaxListeners : e12._maxListeners; + } + function v(e12, t9, n9, r10) { + var i8, o9, s7, v7; + if (u(n9), void 0 === (o9 = e12._events) ? (o9 = e12._events = /* @__PURE__ */ Object.create(null), e12._eventsCount = 0) : (void 0 !== o9.newListener && (e12.emit("newListener", t9, n9.listener ? n9.listener : n9), o9 = e12._events), s7 = o9[t9]), void 0 === s7) + s7 = o9[t9] = n9, ++e12._eventsCount; + else if ("function" == typeof s7 ? s7 = o9[t9] = r10 ? [n9, s7] : [s7, n9] : r10 ? s7.unshift(n9) : s7.push(n9), (i8 = f(e12)) > 0 && s7.length > i8 && !s7.warned) { + s7.warned = true; + var a8 = new Error("Possible EventEmitter memory leak detected. " + s7.length + " " + String(t9) + " listeners added. Use emitter.setMaxListeners() to increase limit"); + a8.name = "MaxListenersExceededWarning", a8.emitter = e12, a8.type = t9, a8.count = s7.length, v7 = a8, console && console.warn && console.warn(v7); + } + return e12; + } + function a() { + if (!this.fired) + return this.target.removeListener(this.type, this.wrapFn), this.fired = true, 0 === arguments.length ? this.listener.call(this.target) : this.listener.apply(this.target, arguments); + } + function l(e12, t9, n9) { + var r10 = { fired: false, wrapFn: void 0, target: e12, type: t9, listener: n9 }, i8 = a.bind(r10); + return i8.listener = n9, r10.wrapFn = i8, i8; + } + function h(e12, t9, n9) { + var r10 = e12._events; + if (void 0 === r10) + return []; + var i8 = r10[t9]; + return void 0 === i8 ? [] : "function" == typeof i8 ? n9 ? [i8.listener || i8] : [i8] : n9 ? function(e13) { + for (var t10 = new Array(e13.length), n10 = 0; n10 < t10.length; ++n10) + t10[n10] = e13[n10].listener || e13[n10]; + return t10; + }(i8) : c(i8, i8.length); + } + function p(e12) { + var t9 = this._events; + if (void 0 !== t9) { + var n9 = t9[e12]; + if ("function" == typeof n9) + return 1; + if (void 0 !== n9) + return n9.length; + } + return 0; + } + function c(e12, t9) { + for (var n9 = new Array(t9), r10 = 0; r10 < t9; ++r10) + n9[r10] = e12[r10]; + return n9; + } + var e, t, n, r, i, s, y; + var init_chunk_4bd36a8f = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-4bd36a8f.js"() { + init_dirname(); + init_buffer2(); + init_process(); + n = "object" == typeof Reflect ? Reflect : null; + r = n && "function" == typeof n.apply ? n.apply : function(e12, t9, n9) { + return Function.prototype.apply.call(e12, t9, n9); + }; + t = n && "function" == typeof n.ownKeys ? n.ownKeys : Object.getOwnPropertySymbols ? function(e12) { + return Object.getOwnPropertyNames(e12).concat(Object.getOwnPropertySymbols(e12)); + } : function(e12) { + return Object.getOwnPropertyNames(e12); + }; + i = Number.isNaN || function(e12) { + return e12 != e12; + }; + e = o, o.EventEmitter = o, o.prototype._events = void 0, o.prototype._eventsCount = 0, o.prototype._maxListeners = void 0; + s = 10; + Object.defineProperty(o, "defaultMaxListeners", { enumerable: true, get: function() { + return s; + }, set: function(e12) { + if ("number" != typeof e12 || e12 < 0 || i(e12)) + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + e12 + "."); + s = e12; + } }), o.init = function() { + void 0 !== this._events && this._events !== Object.getPrototypeOf(this)._events || (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0; + }, o.prototype.setMaxListeners = function(e12) { + if ("number" != typeof e12 || e12 < 0 || i(e12)) + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + e12 + "."); + return this._maxListeners = e12, this; + }, o.prototype.getMaxListeners = function() { + return f(this); + }, o.prototype.emit = function(e12) { + for (var t9 = [], n9 = 1; n9 < arguments.length; n9++) + t9.push(arguments[n9]); + var i8 = "error" === e12, o9 = this._events; + if (void 0 !== o9) + i8 = i8 && void 0 === o9.error; + else if (!i8) + return false; + if (i8) { + var s7; + if (t9.length > 0 && (s7 = t9[0]), s7 instanceof Error) + throw s7; + var u8 = new Error("Unhandled error." + (s7 ? " (" + s7.message + ")" : "")); + throw u8.context = s7, u8; + } + var f9 = o9[e12]; + if (void 0 === f9) + return false; + if ("function" == typeof f9) + r(f9, this, t9); + else { + var v7 = f9.length, a8 = c(f9, v7); + for (n9 = 0; n9 < v7; ++n9) + r(a8[n9], this, t9); + } + return true; + }, o.prototype.addListener = function(e12, t9) { + return v(this, e12, t9, false); + }, o.prototype.on = o.prototype.addListener, o.prototype.prependListener = function(e12, t9) { + return v(this, e12, t9, true); + }, o.prototype.once = function(e12, t9) { + return u(t9), this.on(e12, l(this, e12, t9)), this; + }, o.prototype.prependOnceListener = function(e12, t9) { + return u(t9), this.prependListener(e12, l(this, e12, t9)), this; + }, o.prototype.removeListener = function(e12, t9) { + var n9, r10, i8, o9, s7; + if (u(t9), void 0 === (r10 = this._events)) + return this; + if (void 0 === (n9 = r10[e12])) + return this; + if (n9 === t9 || n9.listener === t9) + 0 == --this._eventsCount ? this._events = /* @__PURE__ */ Object.create(null) : (delete r10[e12], r10.removeListener && this.emit("removeListener", e12, n9.listener || t9)); + else if ("function" != typeof n9) { + for (i8 = -1, o9 = n9.length - 1; o9 >= 0; o9--) + if (n9[o9] === t9 || n9[o9].listener === t9) { + s7 = n9[o9].listener, i8 = o9; + break; + } + if (i8 < 0) + return this; + 0 === i8 ? n9.shift() : !function(e13, t10) { + for (; t10 + 1 < e13.length; t10++) + e13[t10] = e13[t10 + 1]; + e13.pop(); + }(n9, i8), 1 === n9.length && (r10[e12] = n9[0]), void 0 !== r10.removeListener && this.emit("removeListener", e12, s7 || t9); + } + return this; + }, o.prototype.off = o.prototype.removeListener, o.prototype.removeAllListeners = function(e12) { + var t9, n9, r10; + if (void 0 === (n9 = this._events)) + return this; + if (void 0 === n9.removeListener) + return 0 === arguments.length ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : void 0 !== n9[e12] && (0 == --this._eventsCount ? this._events = /* @__PURE__ */ Object.create(null) : delete n9[e12]), this; + if (0 === arguments.length) { + var i8, o9 = Object.keys(n9); + for (r10 = 0; r10 < o9.length; ++r10) + "removeListener" !== (i8 = o9[r10]) && this.removeAllListeners(i8); + return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this; + } + if ("function" == typeof (t9 = n9[e12])) + this.removeListener(e12, t9); + else if (void 0 !== t9) + for (r10 = t9.length - 1; r10 >= 0; r10--) + this.removeListener(e12, t9[r10]); + return this; + }, o.prototype.listeners = function(e12) { + return h(this, e12, true); + }, o.prototype.rawListeners = function(e12) { + return h(this, e12, false); + }, o.listenerCount = function(e12, t9) { + return "function" == typeof e12.listenerCount ? e12.listenerCount(t9) : p.call(e12, t9); + }, o.prototype.listenerCount = p, o.prototype.eventNames = function() { + return this._eventsCount > 0 ? t(this._events) : []; + }; + y = e; + y.EventEmitter; + y.defaultMaxListeners; + y.init; + y.listenerCount; + y.EventEmitter; + y.defaultMaxListeners; + y.init; + y.listenerCount; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-5decc758.js + function i2() { + throw new Error("setTimeout has not been defined"); + } + function u2() { + throw new Error("clearTimeout has not been defined"); + } + function c2(e12) { + if (t2 === setTimeout) + return setTimeout(e12, 0); + if ((t2 === i2 || !t2) && setTimeout) + return t2 = setTimeout, setTimeout(e12, 0); + try { + return t2(e12, 0); + } catch (n9) { + try { + return t2.call(null, e12, 0); + } catch (n10) { + return t2.call(this || r2, e12, 0); + } + } + } + function h2() { + f2 && l2 && (f2 = false, l2.length ? s2 = l2.concat(s2) : a2 = -1, s2.length && d()); + } + function d() { + if (!f2) { + var e12 = c2(h2); + f2 = true; + for (var t9 = s2.length; t9; ) { + for (l2 = s2, s2 = []; ++a2 < t9; ) + l2 && l2[a2].run(); + a2 = -1, t9 = s2.length; + } + l2 = null, f2 = false, function(e13) { + if (n2 === clearTimeout) + return clearTimeout(e13); + if ((n2 === u2 || !n2) && clearTimeout) + return n2 = clearTimeout, clearTimeout(e13); + try { + n2(e13); + } catch (t10) { + try { + return n2.call(null, e13); + } catch (t11) { + return n2.call(this || r2, e13); + } + } + }(e12); + } + } + function m(e12, t9) { + (this || r2).fun = e12, (this || r2).array = t9; + } + function p2() { + } + var e2, t2, n2, r2, o2, l2, s2, f2, a2, T; + var init_chunk_5decc758 = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-5decc758.js"() { + init_dirname(); + init_buffer2(); + init_process(); + r2 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + o2 = e2 = {}; + !function() { + try { + t2 = "function" == typeof setTimeout ? setTimeout : i2; + } catch (e12) { + t2 = i2; + } + try { + n2 = "function" == typeof clearTimeout ? clearTimeout : u2; + } catch (e12) { + n2 = u2; + } + }(); + s2 = []; + f2 = false; + a2 = -1; + o2.nextTick = function(e12) { + var t9 = new Array(arguments.length - 1); + if (arguments.length > 1) + for (var n9 = 1; n9 < arguments.length; n9++) + t9[n9 - 1] = arguments[n9]; + s2.push(new m(e12, t9)), 1 !== s2.length || f2 || c2(d); + }, m.prototype.run = function() { + (this || r2).fun.apply(null, (this || r2).array); + }, o2.title = "browser", o2.browser = true, o2.env = {}, o2.argv = [], o2.version = "", o2.versions = {}, o2.on = p2, o2.addListener = p2, o2.once = p2, o2.off = p2, o2.removeListener = p2, o2.removeAllListeners = p2, o2.emit = p2, o2.prependListener = p2, o2.prependOnceListener = p2, o2.listeners = function(e12) { + return []; + }, o2.binding = function(e12) { + throw new Error("process.binding is not supported"); + }, o2.cwd = function() { + return "/"; + }, o2.chdir = function(e12) { + throw new Error("process.chdir is not supported"); + }, o2.umask = function() { + return 0; + }; + T = e2; + T.addListener; + T.argv; + T.binding; + T.browser; + T.chdir; + T.cwd; + T.emit; + T.env; + T.listeners; + T.nextTick; + T.off; + T.on; + T.once; + T.prependListener; + T.prependOnceListener; + T.removeAllListeners; + T.removeListener; + T.title; + T.umask; + T.version; + T.versions; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-b4205b57.js + function c$1(e12) { + return e12.call.bind(e12); + } + function O(e12, t9) { + if ("object" != typeof e12) + return false; + try { + return t9(e12), true; + } catch (e13) { + return false; + } + } + function S(e12) { + return l$1 && y2 ? void 0 !== b(e12) : B(e12) || k(e12) || E(e12) || D(e12) || U(e12) || P(e12) || x(e12) || I(e12) || M(e12) || z(e12) || F(e12); + } + function B(e12) { + return l$1 && y2 ? "Uint8Array" === b(e12) : "[object Uint8Array]" === m2(e12) || u$1(e12) && void 0 !== e12.buffer; + } + function k(e12) { + return l$1 && y2 ? "Uint8ClampedArray" === b(e12) : "[object Uint8ClampedArray]" === m2(e12); + } + function E(e12) { + return l$1 && y2 ? "Uint16Array" === b(e12) : "[object Uint16Array]" === m2(e12); + } + function D(e12) { + return l$1 && y2 ? "Uint32Array" === b(e12) : "[object Uint32Array]" === m2(e12); + } + function U(e12) { + return l$1 && y2 ? "Int8Array" === b(e12) : "[object Int8Array]" === m2(e12); + } + function P(e12) { + return l$1 && y2 ? "Int16Array" === b(e12) : "[object Int16Array]" === m2(e12); + } + function x(e12) { + return l$1 && y2 ? "Int32Array" === b(e12) : "[object Int32Array]" === m2(e12); + } + function I(e12) { + return l$1 && y2 ? "Float32Array" === b(e12) : "[object Float32Array]" === m2(e12); + } + function M(e12) { + return l$1 && y2 ? "Float64Array" === b(e12) : "[object Float64Array]" === m2(e12); + } + function z(e12) { + return l$1 && y2 ? "BigInt64Array" === b(e12) : "[object BigInt64Array]" === m2(e12); + } + function F(e12) { + return l$1 && y2 ? "BigUint64Array" === b(e12) : "[object BigUint64Array]" === m2(e12); + } + function T2(e12) { + return "[object Map]" === m2(e12); + } + function N(e12) { + return "[object Set]" === m2(e12); + } + function W(e12) { + return "[object WeakMap]" === m2(e12); + } + function $(e12) { + return "[object WeakSet]" === m2(e12); + } + function C(e12) { + return "[object ArrayBuffer]" === m2(e12); + } + function V(e12) { + return "undefined" != typeof ArrayBuffer && (C.working ? C(e12) : e12 instanceof ArrayBuffer); + } + function G(e12) { + return "[object DataView]" === m2(e12); + } + function R(e12) { + return "undefined" != typeof DataView && (G.working ? G(e12) : e12 instanceof DataView); + } + function J(e12) { + return "[object SharedArrayBuffer]" === m2(e12); + } + function _(e12) { + return "undefined" != typeof SharedArrayBuffer && (J.working ? J(e12) : e12 instanceof SharedArrayBuffer); + } + function H(e12) { + return O(e12, h3); + } + function Z(e12) { + return O(e12, j); + } + function q(e12) { + return O(e12, A); + } + function K(e12) { + return s3 && O(e12, w); + } + function L(e12) { + return p3 && O(e12, v2); + } + function oe(e12, t9) { + var r10 = { seen: [], stylize: fe }; + return arguments.length >= 3 && (r10.depth = arguments[2]), arguments.length >= 4 && (r10.colors = arguments[3]), ye(t9) ? r10.showHidden = t9 : t9 && X._extend(r10, t9), be(r10.showHidden) && (r10.showHidden = false), be(r10.depth) && (r10.depth = 2), be(r10.colors) && (r10.colors = false), be(r10.customInspect) && (r10.customInspect = true), r10.colors && (r10.stylize = ue), ae(r10, e12, r10.depth); + } + function ue(e12, t9) { + var r10 = oe.styles[t9]; + return r10 ? "\x1B[" + oe.colors[r10][0] + "m" + e12 + "\x1B[" + oe.colors[r10][1] + "m" : e12; + } + function fe(e12, t9) { + return e12; + } + function ae(e12, t9, r10) { + if (e12.customInspect && t9 && we(t9.inspect) && t9.inspect !== X.inspect && (!t9.constructor || t9.constructor.prototype !== t9)) { + var n9 = t9.inspect(r10, e12); + return ge(n9) || (n9 = ae(e12, n9, r10)), n9; + } + var i8 = function(e13, t10) { + if (be(t10)) + return e13.stylize("undefined", "undefined"); + if (ge(t10)) { + var r11 = "'" + JSON.stringify(t10).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'"; + return e13.stylize(r11, "string"); + } + if (de(t10)) + return e13.stylize("" + t10, "number"); + if (ye(t10)) + return e13.stylize("" + t10, "boolean"); + if (le(t10)) + return e13.stylize("null", "null"); + }(e12, t9); + if (i8) + return i8; + var o9 = Object.keys(t9), u8 = function(e13) { + var t10 = {}; + return e13.forEach(function(e14, r11) { + t10[e14] = true; + }), t10; + }(o9); + if (e12.showHidden && (o9 = Object.getOwnPropertyNames(t9)), Ae(t9) && (o9.indexOf("message") >= 0 || o9.indexOf("description") >= 0)) + return ce(t9); + if (0 === o9.length) { + if (we(t9)) { + var f9 = t9.name ? ": " + t9.name : ""; + return e12.stylize("[Function" + f9 + "]", "special"); + } + if (me(t9)) + return e12.stylize(RegExp.prototype.toString.call(t9), "regexp"); + if (je(t9)) + return e12.stylize(Date.prototype.toString.call(t9), "date"); + if (Ae(t9)) + return ce(t9); + } + var a8, c8 = "", s7 = false, p8 = ["{", "}"]; + (pe(t9) && (s7 = true, p8 = ["[", "]"]), we(t9)) && (c8 = " [Function" + (t9.name ? ": " + t9.name : "") + "]"); + return me(t9) && (c8 = " " + RegExp.prototype.toString.call(t9)), je(t9) && (c8 = " " + Date.prototype.toUTCString.call(t9)), Ae(t9) && (c8 = " " + ce(t9)), 0 !== o9.length || s7 && 0 != t9.length ? r10 < 0 ? me(t9) ? e12.stylize(RegExp.prototype.toString.call(t9), "regexp") : e12.stylize("[Object]", "special") : (e12.seen.push(t9), a8 = s7 ? function(e13, t10, r11, n10, i9) { + for (var o10 = [], u9 = 0, f10 = t10.length; u9 < f10; ++u9) + ke(t10, String(u9)) ? o10.push(se(e13, t10, r11, n10, String(u9), true)) : o10.push(""); + return i9.forEach(function(i10) { + i10.match(/^\d+$/) || o10.push(se(e13, t10, r11, n10, i10, true)); + }), o10; + }(e12, t9, r10, u8, o9) : o9.map(function(n10) { + return se(e12, t9, r10, u8, n10, s7); + }), e12.seen.pop(), function(e13, t10, r11) { + var n10 = 0; + if (e13.reduce(function(e14, t11) { + return n10++, t11.indexOf("\n") >= 0 && n10++, e14 + t11.replace(/\u001b\[\d\d?m/g, "").length + 1; + }, 0) > 60) + return r11[0] + ("" === t10 ? "" : t10 + "\n ") + " " + e13.join(",\n ") + " " + r11[1]; + return r11[0] + t10 + " " + e13.join(", ") + " " + r11[1]; + }(a8, c8, p8)) : p8[0] + c8 + p8[1]; + } + function ce(e12) { + return "[" + Error.prototype.toString.call(e12) + "]"; + } + function se(e12, t9, r10, n9, i8, o9) { + var u8, f9, a8; + if ((a8 = Object.getOwnPropertyDescriptor(t9, i8) || { value: t9[i8] }).get ? f9 = a8.set ? e12.stylize("[Getter/Setter]", "special") : e12.stylize("[Getter]", "special") : a8.set && (f9 = e12.stylize("[Setter]", "special")), ke(n9, i8) || (u8 = "[" + i8 + "]"), f9 || (e12.seen.indexOf(a8.value) < 0 ? (f9 = le(r10) ? ae(e12, a8.value, null) : ae(e12, a8.value, r10 - 1)).indexOf("\n") > -1 && (f9 = o9 ? f9.split("\n").map(function(e13) { + return " " + e13; + }).join("\n").substr(2) : "\n" + f9.split("\n").map(function(e13) { + return " " + e13; + }).join("\n")) : f9 = e12.stylize("[Circular]", "special")), be(u8)) { + if (o9 && i8.match(/^\d+$/)) + return f9; + (u8 = JSON.stringify("" + i8)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/) ? (u8 = u8.substr(1, u8.length - 2), u8 = e12.stylize(u8, "name")) : (u8 = u8.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"), u8 = e12.stylize(u8, "string")); + } + return u8 + ": " + f9; + } + function pe(e12) { + return Array.isArray(e12); + } + function ye(e12) { + return "boolean" == typeof e12; + } + function le(e12) { + return null === e12; + } + function de(e12) { + return "number" == typeof e12; + } + function ge(e12) { + return "string" == typeof e12; + } + function be(e12) { + return void 0 === e12; + } + function me(e12) { + return he(e12) && "[object RegExp]" === ve(e12); + } + function he(e12) { + return "object" == typeof e12 && null !== e12; + } + function je(e12) { + return he(e12) && "[object Date]" === ve(e12); + } + function Ae(e12) { + return he(e12) && ("[object Error]" === ve(e12) || e12 instanceof Error); + } + function we(e12) { + return "function" == typeof e12; + } + function ve(e12) { + return Object.prototype.toString.call(e12); + } + function Oe(e12) { + return e12 < 10 ? "0" + e12.toString(10) : e12.toString(10); + } + function Be() { + var e12 = /* @__PURE__ */ new Date(), t9 = [Oe(e12.getHours()), Oe(e12.getMinutes()), Oe(e12.getSeconds())].join(":"); + return [e12.getDate(), Se[e12.getMonth()], t9].join(" "); + } + function ke(e12, t9) { + return Object.prototype.hasOwnProperty.call(e12, t9); + } + function De(e12, t9) { + if (!e12) { + var r10 = new Error("Promise was rejected with a falsy value"); + r10.reason = e12, e12 = r10; + } + return t9(e12); + } + var t3, e3, o3, n3, r3, l3, t$1, o$1, n$1, e$1, r$1, c3, u3, i3, t$2, i$1, o$2, u$1, f3, a3, s3, p3, y2, l$1, d2, m2, h3, j, A, Q, X, Y, ee, te, re, ne, ie2, Se, Ee; + var init_chunk_b4205b57 = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-b4205b57.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_5decc758(); + t3 = "function" == typeof Symbol && "symbol" == typeof Symbol.toStringTag; + e3 = Object.prototype.toString; + o3 = function(o9) { + return !(t3 && o9 && "object" == typeof o9 && Symbol.toStringTag in o9) && "[object Arguments]" === e3.call(o9); + }; + n3 = function(t9) { + return !!o3(t9) || null !== t9 && "object" == typeof t9 && "number" == typeof t9.length && t9.length >= 0 && "[object Array]" !== e3.call(t9) && "[object Function]" === e3.call(t9.callee); + }; + r3 = function() { + return o3(arguments); + }(); + o3.isLegacyArguments = n3; + l3 = r3 ? o3 : n3; + t$1 = Object.prototype.toString; + o$1 = Function.prototype.toString; + n$1 = /^\s*(?:function)?\*/; + e$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.toStringTag; + r$1 = Object.getPrototypeOf; + c3 = function() { + if (!e$1) + return false; + try { + return Function("return function*() {}")(); + } catch (t9) { + } + }(); + u3 = c3 ? r$1(c3) : {}; + i3 = function(c8) { + return "function" == typeof c8 && (!!n$1.test(o$1.call(c8)) || (e$1 ? r$1(c8) === u3 : "[object GeneratorFunction]" === t$1.call(c8))); + }; + t$2 = "function" == typeof Object.create ? function(t9, e12) { + e12 && (t9.super_ = e12, t9.prototype = Object.create(e12.prototype, { constructor: { value: t9, enumerable: false, writable: true, configurable: true } })); + } : function(t9, e12) { + if (e12) { + t9.super_ = e12; + var o9 = function() { + }; + o9.prototype = e12.prototype, t9.prototype = new o9(), t9.prototype.constructor = t9; + } + }; + i$1 = function(e12) { + return e12 && "object" == typeof e12 && "function" == typeof e12.copy && "function" == typeof e12.fill && "function" == typeof e12.readUInt8; + }; + o$2 = {}; + u$1 = i$1; + f3 = l3; + a3 = i3; + s3 = "undefined" != typeof BigInt; + p3 = "undefined" != typeof Symbol; + y2 = p3 && void 0 !== Symbol.toStringTag; + l$1 = "undefined" != typeof Uint8Array; + d2 = "undefined" != typeof ArrayBuffer; + if (l$1 && y2) + var g = Object.getPrototypeOf(Uint8Array.prototype), b = c$1(Object.getOwnPropertyDescriptor(g, Symbol.toStringTag).get); + m2 = c$1(Object.prototype.toString); + h3 = c$1(Number.prototype.valueOf); + j = c$1(String.prototype.valueOf); + A = c$1(Boolean.prototype.valueOf); + if (s3) + var w = c$1(BigInt.prototype.valueOf); + if (p3) + var v2 = c$1(Symbol.prototype.valueOf); + o$2.isArgumentsObject = f3, o$2.isGeneratorFunction = a3, o$2.isPromise = function(e12) { + return "undefined" != typeof Promise && e12 instanceof Promise || null !== e12 && "object" == typeof e12 && "function" == typeof e12.then && "function" == typeof e12.catch; + }, o$2.isArrayBufferView = function(e12) { + return d2 && ArrayBuffer.isView ? ArrayBuffer.isView(e12) : S(e12) || R(e12); + }, o$2.isTypedArray = S, o$2.isUint8Array = B, o$2.isUint8ClampedArray = k, o$2.isUint16Array = E, o$2.isUint32Array = D, o$2.isInt8Array = U, o$2.isInt16Array = P, o$2.isInt32Array = x, o$2.isFloat32Array = I, o$2.isFloat64Array = M, o$2.isBigInt64Array = z, o$2.isBigUint64Array = F, T2.working = "undefined" != typeof Map && T2(/* @__PURE__ */ new Map()), o$2.isMap = function(e12) { + return "undefined" != typeof Map && (T2.working ? T2(e12) : e12 instanceof Map); + }, N.working = "undefined" != typeof Set && N(/* @__PURE__ */ new Set()), o$2.isSet = function(e12) { + return "undefined" != typeof Set && (N.working ? N(e12) : e12 instanceof Set); + }, W.working = "undefined" != typeof WeakMap && W(/* @__PURE__ */ new WeakMap()), o$2.isWeakMap = function(e12) { + return "undefined" != typeof WeakMap && (W.working ? W(e12) : e12 instanceof WeakMap); + }, $.working = "undefined" != typeof WeakSet && $(/* @__PURE__ */ new WeakSet()), o$2.isWeakSet = function(e12) { + return $(e12); + }, C.working = "undefined" != typeof ArrayBuffer && C(new ArrayBuffer()), o$2.isArrayBuffer = V, G.working = "undefined" != typeof ArrayBuffer && "undefined" != typeof DataView && G(new DataView(new ArrayBuffer(1), 0, 1)), o$2.isDataView = R, J.working = "undefined" != typeof SharedArrayBuffer && J(new SharedArrayBuffer()), o$2.isSharedArrayBuffer = _, o$2.isAsyncFunction = function(e12) { + return "[object AsyncFunction]" === m2(e12); + }, o$2.isMapIterator = function(e12) { + return "[object Map Iterator]" === m2(e12); + }, o$2.isSetIterator = function(e12) { + return "[object Set Iterator]" === m2(e12); + }, o$2.isGeneratorObject = function(e12) { + return "[object Generator]" === m2(e12); + }, o$2.isWebAssemblyCompiledModule = function(e12) { + return "[object WebAssembly.Module]" === m2(e12); + }, o$2.isNumberObject = H, o$2.isStringObject = Z, o$2.isBooleanObject = q, o$2.isBigIntObject = K, o$2.isSymbolObject = L, o$2.isBoxedPrimitive = function(e12) { + return H(e12) || Z(e12) || q(e12) || K(e12) || L(e12); + }, o$2.isAnyArrayBuffer = function(e12) { + return l$1 && (V(e12) || _(e12)); + }, ["isProxy", "isExternal", "isModuleNamespaceObject"].forEach(function(e12) { + Object.defineProperty(o$2, e12, { enumerable: false, value: function() { + throw new Error(e12 + " is not supported in userland"); + } }); + }); + Q = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + X = {}; + Y = T; + ee = Object.getOwnPropertyDescriptors || function(e12) { + for (var t9 = Object.keys(e12), r10 = {}, n9 = 0; n9 < t9.length; n9++) + r10[t9[n9]] = Object.getOwnPropertyDescriptor(e12, t9[n9]); + return r10; + }; + te = /%[sdj%]/g; + X.format = function(e12) { + if (!ge(e12)) { + for (var t9 = [], r10 = 0; r10 < arguments.length; r10++) + t9.push(oe(arguments[r10])); + return t9.join(" "); + } + r10 = 1; + for (var n9 = arguments, i8 = n9.length, o9 = String(e12).replace(te, function(e13) { + if ("%%" === e13) + return "%"; + if (r10 >= i8) + return e13; + switch (e13) { + case "%s": + return String(n9[r10++]); + case "%d": + return Number(n9[r10++]); + case "%j": + try { + return JSON.stringify(n9[r10++]); + } catch (e14) { + return "[Circular]"; + } + default: + return e13; + } + }), u8 = n9[r10]; r10 < i8; u8 = n9[++r10]) + le(u8) || !he(u8) ? o9 += " " + u8 : o9 += " " + oe(u8); + return o9; + }, X.deprecate = function(e12, t9) { + if (void 0 !== Y && true === Y.noDeprecation) + return e12; + if (void 0 === Y) + return function() { + return X.deprecate(e12, t9).apply(this || Q, arguments); + }; + var r10 = false; + return function() { + if (!r10) { + if (Y.throwDeprecation) + throw new Error(t9); + Y.traceDeprecation ? console.trace(t9) : console.error(t9), r10 = true; + } + return e12.apply(this || Q, arguments); + }; + }; + re = {}; + ne = /^$/; + if (Y.env.NODE_DEBUG) { + ie2 = Y.env.NODE_DEBUG; + ie2 = ie2.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*").replace(/,/g, "$|^").toUpperCase(), ne = new RegExp("^" + ie2 + "$", "i"); + } + X.debuglog = function(e12) { + if (e12 = e12.toUpperCase(), !re[e12]) + if (ne.test(e12)) { + var t9 = Y.pid; + re[e12] = function() { + var r10 = X.format.apply(X, arguments); + console.error("%s %d: %s", e12, t9, r10); + }; + } else + re[e12] = function() { + }; + return re[e12]; + }, X.inspect = oe, oe.colors = { bold: [1, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], white: [37, 39], grey: [90, 39], black: [30, 39], blue: [34, 39], cyan: [36, 39], green: [32, 39], magenta: [35, 39], red: [31, 39], yellow: [33, 39] }, oe.styles = { special: "cyan", number: "yellow", boolean: "yellow", undefined: "grey", null: "bold", string: "green", date: "magenta", regexp: "red" }, X.types = o$2, X.isArray = pe, X.isBoolean = ye, X.isNull = le, X.isNullOrUndefined = function(e12) { + return null == e12; + }, X.isNumber = de, X.isString = ge, X.isSymbol = function(e12) { + return "symbol" == typeof e12; + }, X.isUndefined = be, X.isRegExp = me, X.types.isRegExp = me, X.isObject = he, X.isDate = je, X.types.isDate = je, X.isError = Ae, X.types.isNativeError = Ae, X.isFunction = we, X.isPrimitive = function(e12) { + return null === e12 || "boolean" == typeof e12 || "number" == typeof e12 || "string" == typeof e12 || "symbol" == typeof e12 || void 0 === e12; + }, X.isBuffer = i$1; + Se = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + X.log = function() { + console.log("%s - %s", Be(), X.format.apply(X, arguments)); + }, X.inherits = t$2, X._extend = function(e12, t9) { + if (!t9 || !he(t9)) + return e12; + for (var r10 = Object.keys(t9), n9 = r10.length; n9--; ) + e12[r10[n9]] = t9[r10[n9]]; + return e12; + }; + Ee = "undefined" != typeof Symbol ? Symbol("util.promisify.custom") : void 0; + X.promisify = function(e12) { + if ("function" != typeof e12) + throw new TypeError('The "original" argument must be of type Function'); + if (Ee && e12[Ee]) { + var t9; + if ("function" != typeof (t9 = e12[Ee])) + throw new TypeError('The "util.promisify.custom" argument must be of type Function'); + return Object.defineProperty(t9, Ee, { value: t9, enumerable: false, writable: false, configurable: true }), t9; + } + function t9() { + for (var t10, r10, n9 = new Promise(function(e13, n10) { + t10 = e13, r10 = n10; + }), i8 = [], o9 = 0; o9 < arguments.length; o9++) + i8.push(arguments[o9]); + i8.push(function(e13, n10) { + e13 ? r10(e13) : t10(n10); + }); + try { + e12.apply(this || Q, i8); + } catch (e13) { + r10(e13); + } + return n9; + } + return Object.setPrototypeOf(t9, Object.getPrototypeOf(e12)), Ee && Object.defineProperty(t9, Ee, { value: t9, enumerable: false, writable: false, configurable: true }), Object.defineProperties(t9, ee(e12)); + }, X.promisify.custom = Ee, X.callbackify = function(e12) { + if ("function" != typeof e12) + throw new TypeError('The "original" argument must be of type Function'); + function t9() { + for (var t10 = [], r10 = 0; r10 < arguments.length; r10++) + t10.push(arguments[r10]); + var n9 = t10.pop(); + if ("function" != typeof n9) + throw new TypeError("The last argument must be of type Function"); + var i8 = this || Q, o9 = function() { + return n9.apply(i8, arguments); + }; + e12.apply(this || Q, t10).then(function(e13) { + Y.nextTick(o9.bind(null, null, e13)); + }, function(e13) { + Y.nextTick(De.bind(null, e13, o9)); + }); + } + return Object.setPrototypeOf(t9, Object.getPrototypeOf(e12)), Object.defineProperties(t9, ee(e12)), t9; + }; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-ce0fbc82.js + var _extend, callbackify, debuglog, deprecate, format8, inherits, inspect, isArray, isBoolean, isBuffer5, isDate, isError, isFunction, isNull, isNullOrUndefined, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, log, promisify, types, TextEncoder2, TextDecoder2; + var init_chunk_ce0fbc82 = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-ce0fbc82.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_b4205b57(); + init_chunk_5decc758(); + X._extend; + X.callbackify; + X.debuglog; + X.deprecate; + X.format; + X.inherits; + X.inspect; + X.isArray; + X.isBoolean; + X.isBuffer; + X.isDate; + X.isError; + X.isFunction; + X.isNull; + X.isNullOrUndefined; + X.isNumber; + X.isObject; + X.isPrimitive; + X.isRegExp; + X.isString; + X.isSymbol; + X.isUndefined; + X.log; + X.promisify; + _extend = X._extend; + callbackify = X.callbackify; + debuglog = X.debuglog; + deprecate = X.deprecate; + format8 = X.format; + inherits = X.inherits; + inspect = X.inspect; + isArray = X.isArray; + isBoolean = X.isBoolean; + isBuffer5 = X.isBuffer; + isDate = X.isDate; + isError = X.isError; + isFunction = X.isFunction; + isNull = X.isNull; + isNullOrUndefined = X.isNullOrUndefined; + isNumber = X.isNumber; + isObject = X.isObject; + isPrimitive = X.isPrimitive; + isRegExp = X.isRegExp; + isString = X.isString; + isSymbol = X.isSymbol; + isUndefined = X.isUndefined; + log = X.log; + promisify = X.promisify; + types = X.types; + TextEncoder2 = self.TextEncoder; + TextDecoder2 = self.TextDecoder; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-2eac56ff.js + function dew2() { + if (_dewExec2) + return exports3; + _dewExec2 = true; + var process3 = exports3 = {}; + var cachedSetTimeout; + var cachedClearTimeout; + function defaultSetTimout() { + throw new Error("setTimeout has not been defined"); + } + function defaultClearTimeout() { + throw new Error("clearTimeout has not been defined"); + } + (function() { + try { + if (typeof setTimeout === "function") { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e12) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === "function") { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e12) { + cachedClearTimeout = defaultClearTimeout; + } + })(); + function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + return setTimeout(fun, 0); + } + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + return cachedSetTimeout(fun, 0); + } catch (e12) { + try { + return cachedSetTimeout.call(null, fun, 0); + } catch (e13) { + return cachedSetTimeout.call(this || _global, fun, 0); + } + } + } + function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + return clearTimeout(marker); + } + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + return cachedClearTimeout(marker); + } catch (e12) { + try { + return cachedClearTimeout.call(null, marker); + } catch (e13) { + return cachedClearTimeout.call(this || _global, marker); + } + } + } + var queue = []; + var draining = false; + var currentQueue; + var queueIndex = -1; + function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } + } + function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + var len = queue.length; + while (len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); + } + process3.nextTick = function(fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i8 = 1; i8 < arguments.length; i8++) { + args[i8 - 1] = arguments[i8]; + } + } + queue.push(new Item2(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } + }; + function Item2(fun, array3) { + (this || _global).fun = fun; + (this || _global).array = array3; + } + Item2.prototype.run = function() { + (this || _global).fun.apply(null, (this || _global).array); + }; + process3.title = "browser"; + process3.browser = true; + process3.env = {}; + process3.argv = []; + process3.version = ""; + process3.versions = {}; + function noop2() { + } + process3.on = noop2; + process3.addListener = noop2; + process3.once = noop2; + process3.off = noop2; + process3.removeListener = noop2; + process3.removeAllListeners = noop2; + process3.emit = noop2; + process3.prependListener = noop2; + process3.prependOnceListener = noop2; + process3.listeners = function(name15) { + return []; + }; + process3.binding = function(name15) { + throw new Error("process.binding is not supported"); + }; + process3.cwd = function() { + return "/"; + }; + process3.chdir = function(dir) { + throw new Error("process.chdir is not supported"); + }; + process3.umask = function() { + return 0; + }; + return exports3; + } + var exports3, _dewExec2, _global, process2; + var init_chunk_2eac56ff = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-2eac56ff.js"() { + init_dirname(); + init_buffer2(); + init_process(); + exports3 = {}; + _dewExec2 = false; + _global = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + process2 = dew2(); + process2.platform = "browser"; + process2.addListener; + process2.argv; + process2.binding; + process2.browser; + process2.chdir; + process2.cwd; + process2.emit; + process2.env; + process2.listeners; + process2.nextTick; + process2.off; + process2.on; + process2.once; + process2.prependListener; + process2.prependOnceListener; + process2.removeAllListeners; + process2.removeListener; + process2.title; + process2.umask; + process2.version; + process2.versions; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-4ccc3a29.js + function u$2(r10) { + var t9 = r10.length; + if (t9 % 4 > 0) + throw new Error("Invalid string. Length must be a multiple of 4"); + var e12 = r10.indexOf("="); + return -1 === e12 && (e12 = t9), [e12, e12 === t9 ? 0 : 4 - e12 % 4]; + } + function c$12(r10, e12, n9) { + for (var o9, a8, h9 = [], u8 = e12; u8 < n9; u8 += 3) + o9 = (r10[u8] << 16 & 16711680) + (r10[u8 + 1] << 8 & 65280) + (255 & r10[u8 + 2]), h9.push(t$14[(a8 = o9) >> 18 & 63] + t$14[a8 >> 12 & 63] + t$14[a8 >> 6 & 63] + t$14[63 & a8]); + return h9.join(""); + } + function f$2(t9) { + if (t9 > 2147483647) + throw new RangeError('The value "' + t9 + '" is invalid for option "size"'); + var r10 = new Uint8Array(t9); + return Object.setPrototypeOf(r10, u$1$1.prototype), r10; + } + function u$1$1(t9, r10, e12) { + if ("number" == typeof t9) { + if ("string" == typeof r10) + throw new TypeError('The "string" argument must be of type string. Received type number'); + return a$2(t9); + } + return s$1(t9, r10, e12); + } + function s$1(t9, r10, e12) { + if ("string" == typeof t9) + return function(t10, r11) { + "string" == typeof r11 && "" !== r11 || (r11 = "utf8"); + if (!u$1$1.isEncoding(r11)) + throw new TypeError("Unknown encoding: " + r11); + var e13 = 0 | y3(t10, r11), n10 = f$2(e13), i9 = n10.write(t10, r11); + i9 !== e13 && (n10 = n10.slice(0, i9)); + return n10; + }(t9, r10); + if (ArrayBuffer.isView(t9)) + return p4(t9); + if (null == t9) + throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof t9); + if (F2(t9, ArrayBuffer) || t9 && F2(t9.buffer, ArrayBuffer)) + return c$1$1(t9, r10, e12); + if ("undefined" != typeof SharedArrayBuffer && (F2(t9, SharedArrayBuffer) || t9 && F2(t9.buffer, SharedArrayBuffer))) + return c$1$1(t9, r10, e12); + if ("number" == typeof t9) + throw new TypeError('The "value" argument must not be of type number. Received type number'); + var n9 = t9.valueOf && t9.valueOf(); + if (null != n9 && n9 !== t9) + return u$1$1.from(n9, r10, e12); + var i8 = function(t10) { + if (u$1$1.isBuffer(t10)) { + var r11 = 0 | l$12(t10.length), e13 = f$2(r11); + return 0 === e13.length || t10.copy(e13, 0, 0, r11), e13; + } + if (void 0 !== t10.length) + return "number" != typeof t10.length || N10(t10.length) ? f$2(0) : p4(t10); + if ("Buffer" === t10.type && Array.isArray(t10.data)) + return p4(t10.data); + }(t9); + if (i8) + return i8; + if ("undefined" != typeof Symbol && null != Symbol.toPrimitive && "function" == typeof t9[Symbol.toPrimitive]) + return u$1$1.from(t9[Symbol.toPrimitive]("string"), r10, e12); + throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof t9); + } + function h$1$1(t9) { + if ("number" != typeof t9) + throw new TypeError('"size" argument must be of type number'); + if (t9 < 0) + throw new RangeError('The value "' + t9 + '" is invalid for option "size"'); + } + function a$2(t9) { + return h$1$1(t9), f$2(t9 < 0 ? 0 : 0 | l$12(t9)); + } + function p4(t9) { + for (var r10 = t9.length < 0 ? 0 : 0 | l$12(t9.length), e12 = f$2(r10), n9 = 0; n9 < r10; n9 += 1) + e12[n9] = 255 & t9[n9]; + return e12; + } + function c$1$1(t9, r10, e12) { + if (r10 < 0 || t9.byteLength < r10) + throw new RangeError('"offset" is outside of buffer bounds'); + if (t9.byteLength < r10 + (e12 || 0)) + throw new RangeError('"length" is outside of buffer bounds'); + var n9; + return n9 = void 0 === r10 && void 0 === e12 ? new Uint8Array(t9) : void 0 === e12 ? new Uint8Array(t9, r10) : new Uint8Array(t9, r10, e12), Object.setPrototypeOf(n9, u$1$1.prototype), n9; + } + function l$12(t9) { + if (t9 >= 2147483647) + throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + 2147483647 .toString(16) + " bytes"); + return 0 | t9; + } + function y3(t9, r10) { + if (u$1$1.isBuffer(t9)) + return t9.length; + if (ArrayBuffer.isView(t9) || F2(t9, ArrayBuffer)) + return t9.byteLength; + if ("string" != typeof t9) + throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof t9); + var e12 = t9.length, n9 = arguments.length > 2 && true === arguments[2]; + if (!n9 && 0 === e12) + return 0; + for (var i8 = false; ; ) + switch (r10) { + case "ascii": + case "latin1": + case "binary": + return e12; + case "utf8": + case "utf-8": + return _2(t9).length; + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return 2 * e12; + case "hex": + return e12 >>> 1; + case "base64": + return z2(t9).length; + default: + if (i8) + return n9 ? -1 : _2(t9).length; + r10 = ("" + r10).toLowerCase(), i8 = true; + } + } + function g2(t9, r10, e12) { + var n9 = false; + if ((void 0 === r10 || r10 < 0) && (r10 = 0), r10 > this.length) + return ""; + if ((void 0 === e12 || e12 > this.length) && (e12 = this.length), e12 <= 0) + return ""; + if ((e12 >>>= 0) <= (r10 >>>= 0)) + return ""; + for (t9 || (t9 = "utf8"); ; ) + switch (t9) { + case "hex": + return O2(this, r10, e12); + case "utf8": + case "utf-8": + return I2(this, r10, e12); + case "ascii": + return S2(this, r10, e12); + case "latin1": + case "binary": + return R2(this, r10, e12); + case "base64": + return T3(this, r10, e12); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return L2(this, r10, e12); + default: + if (n9) + throw new TypeError("Unknown encoding: " + t9); + t9 = (t9 + "").toLowerCase(), n9 = true; + } + } + function w2(t9, r10, e12) { + var n9 = t9[r10]; + t9[r10] = t9[e12], t9[e12] = n9; + } + function d3(t9, r10, e12, n9, i8) { + if (0 === t9.length) + return -1; + if ("string" == typeof e12 ? (n9 = e12, e12 = 0) : e12 > 2147483647 ? e12 = 2147483647 : e12 < -2147483648 && (e12 = -2147483648), N10(e12 = +e12) && (e12 = i8 ? 0 : t9.length - 1), e12 < 0 && (e12 = t9.length + e12), e12 >= t9.length) { + if (i8) + return -1; + e12 = t9.length - 1; + } else if (e12 < 0) { + if (!i8) + return -1; + e12 = 0; + } + if ("string" == typeof r10 && (r10 = u$1$1.from(r10, n9)), u$1$1.isBuffer(r10)) + return 0 === r10.length ? -1 : v3(t9, r10, e12, n9, i8); + if ("number" == typeof r10) + return r10 &= 255, "function" == typeof Uint8Array.prototype.indexOf ? i8 ? Uint8Array.prototype.indexOf.call(t9, r10, e12) : Uint8Array.prototype.lastIndexOf.call(t9, r10, e12) : v3(t9, [r10], e12, n9, i8); + throw new TypeError("val must be string, number or Buffer"); + } + function v3(t9, r10, e12, n9, i8) { + var o9, f9 = 1, u8 = t9.length, s7 = r10.length; + if (void 0 !== n9 && ("ucs2" === (n9 = String(n9).toLowerCase()) || "ucs-2" === n9 || "utf16le" === n9 || "utf-16le" === n9)) { + if (t9.length < 2 || r10.length < 2) + return -1; + f9 = 2, u8 /= 2, s7 /= 2, e12 /= 2; + } + function h9(t10, r11) { + return 1 === f9 ? t10[r11] : t10.readUInt16BE(r11 * f9); + } + if (i8) { + var a8 = -1; + for (o9 = e12; o9 < u8; o9++) + if (h9(t9, o9) === h9(r10, -1 === a8 ? 0 : o9 - a8)) { + if (-1 === a8 && (a8 = o9), o9 - a8 + 1 === s7) + return a8 * f9; + } else + -1 !== a8 && (o9 -= o9 - a8), a8 = -1; + } else + for (e12 + s7 > u8 && (e12 = u8 - s7), o9 = e12; o9 >= 0; o9--) { + for (var p8 = true, c8 = 0; c8 < s7; c8++) + if (h9(t9, o9 + c8) !== h9(r10, c8)) { + p8 = false; + break; + } + if (p8) + return o9; + } + return -1; + } + function b2(t9, r10, e12, n9) { + e12 = Number(e12) || 0; + var i8 = t9.length - e12; + n9 ? (n9 = Number(n9)) > i8 && (n9 = i8) : n9 = i8; + var o9 = r10.length; + n9 > o9 / 2 && (n9 = o9 / 2); + for (var f9 = 0; f9 < n9; ++f9) { + var u8 = parseInt(r10.substr(2 * f9, 2), 16); + if (N10(u8)) + return f9; + t9[e12 + f9] = u8; + } + return f9; + } + function m3(t9, r10, e12, n9) { + return D2(_2(r10, t9.length - e12), t9, e12, n9); + } + function E2(t9, r10, e12, n9) { + return D2(function(t10) { + for (var r11 = [], e13 = 0; e13 < t10.length; ++e13) + r11.push(255 & t10.charCodeAt(e13)); + return r11; + }(r10), t9, e12, n9); + } + function B2(t9, r10, e12, n9) { + return E2(t9, r10, e12, n9); + } + function A2(t9, r10, e12, n9) { + return D2(z2(r10), t9, e12, n9); + } + function U2(t9, r10, e12, n9) { + return D2(function(t10, r11) { + for (var e13, n10, i8, o9 = [], f9 = 0; f9 < t10.length && !((r11 -= 2) < 0); ++f9) + e13 = t10.charCodeAt(f9), n10 = e13 >> 8, i8 = e13 % 256, o9.push(i8), o9.push(n10); + return o9; + }(r10, t9.length - e12), t9, e12, n9); + } + function T3(t9, r10, e12) { + return 0 === r10 && e12 === t9.length ? n$1$1.fromByteArray(t9) : n$1$1.fromByteArray(t9.slice(r10, e12)); + } + function I2(t9, r10, e12) { + e12 = Math.min(t9.length, e12); + for (var n9 = [], i8 = r10; i8 < e12; ) { + var o9, f9, u8, s7, h9 = t9[i8], a8 = null, p8 = h9 > 239 ? 4 : h9 > 223 ? 3 : h9 > 191 ? 2 : 1; + if (i8 + p8 <= e12) + switch (p8) { + case 1: + h9 < 128 && (a8 = h9); + break; + case 2: + 128 == (192 & (o9 = t9[i8 + 1])) && (s7 = (31 & h9) << 6 | 63 & o9) > 127 && (a8 = s7); + break; + case 3: + o9 = t9[i8 + 1], f9 = t9[i8 + 2], 128 == (192 & o9) && 128 == (192 & f9) && (s7 = (15 & h9) << 12 | (63 & o9) << 6 | 63 & f9) > 2047 && (s7 < 55296 || s7 > 57343) && (a8 = s7); + break; + case 4: + o9 = t9[i8 + 1], f9 = t9[i8 + 2], u8 = t9[i8 + 3], 128 == (192 & o9) && 128 == (192 & f9) && 128 == (192 & u8) && (s7 = (15 & h9) << 18 | (63 & o9) << 12 | (63 & f9) << 6 | 63 & u8) > 65535 && s7 < 1114112 && (a8 = s7); + } + null === a8 ? (a8 = 65533, p8 = 1) : a8 > 65535 && (a8 -= 65536, n9.push(a8 >>> 10 & 1023 | 55296), a8 = 56320 | 1023 & a8), n9.push(a8), i8 += p8; + } + return function(t10) { + var r11 = t10.length; + if (r11 <= 4096) + return String.fromCharCode.apply(String, t10); + var e13 = "", n10 = 0; + for (; n10 < r11; ) + e13 += String.fromCharCode.apply(String, t10.slice(n10, n10 += 4096)); + return e13; + }(n9); + } + function S2(t9, r10, e12) { + var n9 = ""; + e12 = Math.min(t9.length, e12); + for (var i8 = r10; i8 < e12; ++i8) + n9 += String.fromCharCode(127 & t9[i8]); + return n9; + } + function R2(t9, r10, e12) { + var n9 = ""; + e12 = Math.min(t9.length, e12); + for (var i8 = r10; i8 < e12; ++i8) + n9 += String.fromCharCode(t9[i8]); + return n9; + } + function O2(t9, r10, e12) { + var n9 = t9.length; + (!r10 || r10 < 0) && (r10 = 0), (!e12 || e12 < 0 || e12 > n9) && (e12 = n9); + for (var i8 = "", o9 = r10; o9 < e12; ++o9) + i8 += Y2[t9[o9]]; + return i8; + } + function L2(t9, r10, e12) { + for (var n9 = t9.slice(r10, e12), i8 = "", o9 = 0; o9 < n9.length; o9 += 2) + i8 += String.fromCharCode(n9[o9] + 256 * n9[o9 + 1]); + return i8; + } + function x2(t9, r10, e12) { + if (t9 % 1 != 0 || t9 < 0) + throw new RangeError("offset is not uint"); + if (t9 + r10 > e12) + throw new RangeError("Trying to access beyond buffer length"); + } + function C2(t9, r10, e12, n9, i8, o9) { + if (!u$1$1.isBuffer(t9)) + throw new TypeError('"buffer" argument must be a Buffer instance'); + if (r10 > i8 || r10 < o9) + throw new RangeError('"value" argument is out of bounds'); + if (e12 + n9 > t9.length) + throw new RangeError("Index out of range"); + } + function P2(t9, r10, e12, n9, i8, o9) { + if (e12 + n9 > t9.length) + throw new RangeError("Index out of range"); + if (e12 < 0) + throw new RangeError("Index out of range"); + } + function k2(t9, r10, e12, n9, o9) { + return r10 = +r10, e12 >>>= 0, o9 || P2(t9, 0, e12, 4), i$12.write(t9, r10, e12, n9, 23, 4), e12 + 4; + } + function M2(t9, r10, e12, n9, o9) { + return r10 = +r10, e12 >>>= 0, o9 || P2(t9, 0, e12, 8), i$12.write(t9, r10, e12, n9, 52, 8), e12 + 8; + } + function _2(t9, r10) { + var e12; + r10 = r10 || 1 / 0; + for (var n9 = t9.length, i8 = null, o9 = [], f9 = 0; f9 < n9; ++f9) { + if ((e12 = t9.charCodeAt(f9)) > 55295 && e12 < 57344) { + if (!i8) { + if (e12 > 56319) { + (r10 -= 3) > -1 && o9.push(239, 191, 189); + continue; + } + if (f9 + 1 === n9) { + (r10 -= 3) > -1 && o9.push(239, 191, 189); + continue; + } + i8 = e12; + continue; + } + if (e12 < 56320) { + (r10 -= 3) > -1 && o9.push(239, 191, 189), i8 = e12; + continue; + } + e12 = 65536 + (i8 - 55296 << 10 | e12 - 56320); + } else + i8 && (r10 -= 3) > -1 && o9.push(239, 191, 189); + if (i8 = null, e12 < 128) { + if ((r10 -= 1) < 0) + break; + o9.push(e12); + } else if (e12 < 2048) { + if ((r10 -= 2) < 0) + break; + o9.push(e12 >> 6 | 192, 63 & e12 | 128); + } else if (e12 < 65536) { + if ((r10 -= 3) < 0) + break; + o9.push(e12 >> 12 | 224, e12 >> 6 & 63 | 128, 63 & e12 | 128); + } else { + if (!(e12 < 1114112)) + throw new Error("Invalid code point"); + if ((r10 -= 4) < 0) + break; + o9.push(e12 >> 18 | 240, e12 >> 12 & 63 | 128, e12 >> 6 & 63 | 128, 63 & e12 | 128); + } + } + return o9; + } + function z2(t9) { + return n$1$1.toByteArray(function(t10) { + if ((t10 = (t10 = t10.split("=")[0]).trim().replace(j2, "")).length < 2) + return ""; + for (; t10.length % 4 != 0; ) + t10 += "="; + return t10; + }(t9)); + } + function D2(t9, r10, e12, n9) { + for (var i8 = 0; i8 < n9 && !(i8 + e12 >= r10.length || i8 >= t9.length); ++i8) + r10[i8 + e12] = t9[i8]; + return i8; + } + function F2(t9, r10) { + return t9 instanceof r10 || null != t9 && null != t9.constructor && null != t9.constructor.name && t9.constructor.name === r10.name; + } + function N10(t9) { + return t9 != t9; + } + function t4(r10, e12) { + for (var n9 in r10) + e12[n9] = r10[n9]; + } + function f4(r10, e12, n9) { + return o4(r10, e12, n9); + } + function a4(t9) { + var e12; + switch (this.encoding = function(t10) { + var e13 = function(t11) { + if (!t11) + return "utf8"; + for (var e14; ; ) + switch (t11) { + case "utf8": + case "utf-8": + return "utf8"; + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return "utf16le"; + case "latin1": + case "binary": + return "latin1"; + case "base64": + case "ascii": + case "hex": + return t11; + default: + if (e14) + return; + t11 = ("" + t11).toLowerCase(), e14 = true; + } + }(t10); + if ("string" != typeof e13 && (s4.isEncoding === i4 || !i4(t10))) + throw new Error("Unknown encoding: " + t10); + return e13 || t10; + }(t9), this.encoding) { + case "utf16le": + this.text = h4, this.end = l4, e12 = 4; + break; + case "utf8": + this.fillLast = n$12, e12 = 4; + break; + case "base64": + this.text = u$12, this.end = o$12, e12 = 3; + break; + default: + return this.write = f$1, this.end = c4, void 0; + } + this.lastNeed = 0, this.lastTotal = 0, this.lastChar = s4.allocUnsafe(e12); + } + function r4(t9) { + return t9 <= 127 ? 0 : t9 >> 5 == 6 ? 2 : t9 >> 4 == 14 ? 3 : t9 >> 3 == 30 ? 4 : t9 >> 6 == 2 ? -1 : -2; + } + function n$12(t9) { + var e12 = this.lastTotal - this.lastNeed, s7 = function(t10, e13, s8) { + if (128 != (192 & e13[0])) + return t10.lastNeed = 0, "\uFFFD"; + if (t10.lastNeed > 1 && e13.length > 1) { + if (128 != (192 & e13[1])) + return t10.lastNeed = 1, "\uFFFD"; + if (t10.lastNeed > 2 && e13.length > 2 && 128 != (192 & e13[2])) + return t10.lastNeed = 2, "\uFFFD"; + } + }(this, t9); + return void 0 !== s7 ? s7 : this.lastNeed <= t9.length ? (t9.copy(this.lastChar, e12, 0, this.lastNeed), this.lastChar.toString(this.encoding, 0, this.lastTotal)) : (t9.copy(this.lastChar, e12, 0, t9.length), this.lastNeed -= t9.length, void 0); + } + function h4(t9, e12) { + if ((t9.length - e12) % 2 == 0) { + var s7 = t9.toString("utf16le", e12); + if (s7) { + var i8 = s7.charCodeAt(s7.length - 1); + if (i8 >= 55296 && i8 <= 56319) + return this.lastNeed = 2, this.lastTotal = 4, this.lastChar[0] = t9[t9.length - 2], this.lastChar[1] = t9[t9.length - 1], s7.slice(0, -1); + } + return s7; + } + return this.lastNeed = 1, this.lastTotal = 2, this.lastChar[0] = t9[t9.length - 1], t9.toString("utf16le", e12, t9.length - 1); + } + function l4(t9) { + var e12 = t9 && t9.length ? this.write(t9) : ""; + if (this.lastNeed) { + var s7 = this.lastTotal - this.lastNeed; + return e12 + this.lastChar.toString("utf16le", 0, s7); + } + return e12; + } + function u$12(t9, e12) { + var s7 = (t9.length - e12) % 3; + return 0 === s7 ? t9.toString("base64", e12) : (this.lastNeed = 3 - s7, this.lastTotal = 3, 1 === s7 ? this.lastChar[0] = t9[t9.length - 1] : (this.lastChar[0] = t9[t9.length - 2], this.lastChar[1] = t9[t9.length - 1]), t9.toString("base64", e12, t9.length - s7)); + } + function o$12(t9) { + var e12 = t9 && t9.length ? this.write(t9) : ""; + return this.lastNeed ? e12 + this.lastChar.toString("base64", 0, 3 - this.lastNeed) : e12; + } + function f$1(t9) { + return t9.toString(this.encoding); + } + function c4(t9) { + return t9 && t9.length ? this.write(t9) : ""; + } + var r$14, t$14, e$23, n$23, o$24, a$13, h$13, a$1$1, e$1$1, n$1$1, i$12, o$1$1, j2, Y2, e4, n4, o4, u4, e$12, s4, i4; + var init_chunk_4ccc3a29 = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-4ccc3a29.js"() { + init_dirname(); + init_buffer2(); + init_process(); + for (r$14 = { byteLength: function(r10) { + var t9 = u$2(r10), e12 = t9[0], n9 = t9[1]; + return 3 * (e12 + n9) / 4 - n9; + }, toByteArray: function(r10) { + var t9, o9, a8 = u$2(r10), h9 = a8[0], c8 = a8[1], d7 = new n$23(function(r11, t10, e12) { + return 3 * (t10 + e12) / 4 - e12; + }(0, h9, c8)), f9 = 0, A5 = c8 > 0 ? h9 - 4 : h9; + for (o9 = 0; o9 < A5; o9 += 4) + t9 = e$23[r10.charCodeAt(o9)] << 18 | e$23[r10.charCodeAt(o9 + 1)] << 12 | e$23[r10.charCodeAt(o9 + 2)] << 6 | e$23[r10.charCodeAt(o9 + 3)], d7[f9++] = t9 >> 16 & 255, d7[f9++] = t9 >> 8 & 255, d7[f9++] = 255 & t9; + 2 === c8 && (t9 = e$23[r10.charCodeAt(o9)] << 2 | e$23[r10.charCodeAt(o9 + 1)] >> 4, d7[f9++] = 255 & t9); + 1 === c8 && (t9 = e$23[r10.charCodeAt(o9)] << 10 | e$23[r10.charCodeAt(o9 + 1)] << 4 | e$23[r10.charCodeAt(o9 + 2)] >> 2, d7[f9++] = t9 >> 8 & 255, d7[f9++] = 255 & t9); + return d7; + }, fromByteArray: function(r10) { + for (var e12, n9 = r10.length, o9 = n9 % 3, a8 = [], h9 = 0, u8 = n9 - o9; h9 < u8; h9 += 16383) + a8.push(c$12(r10, h9, h9 + 16383 > u8 ? u8 : h9 + 16383)); + 1 === o9 ? (e12 = r10[n9 - 1], a8.push(t$14[e12 >> 2] + t$14[e12 << 4 & 63] + "==")) : 2 === o9 && (e12 = (r10[n9 - 2] << 8) + r10[n9 - 1], a8.push(t$14[e12 >> 10] + t$14[e12 >> 4 & 63] + t$14[e12 << 2 & 63] + "=")); + return a8.join(""); + } }, t$14 = [], e$23 = [], n$23 = "undefined" != typeof Uint8Array ? Uint8Array : Array, o$24 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", a$13 = 0, h$13 = o$24.length; a$13 < h$13; ++a$13) + t$14[a$13] = o$24[a$13], e$23[o$24.charCodeAt(a$13)] = a$13; + e$23["-".charCodeAt(0)] = 62, e$23["_".charCodeAt(0)] = 63; + a$1$1 = { read: function(a8, t9, o9, r10, h9) { + var M5, f9, p8 = 8 * h9 - r10 - 1, w5 = (1 << p8) - 1, e12 = w5 >> 1, i8 = -7, N14 = o9 ? h9 - 1 : 0, n9 = o9 ? -1 : 1, u8 = a8[t9 + N14]; + for (N14 += n9, M5 = u8 & (1 << -i8) - 1, u8 >>= -i8, i8 += p8; i8 > 0; M5 = 256 * M5 + a8[t9 + N14], N14 += n9, i8 -= 8) + ; + for (f9 = M5 & (1 << -i8) - 1, M5 >>= -i8, i8 += r10; i8 > 0; f9 = 256 * f9 + a8[t9 + N14], N14 += n9, i8 -= 8) + ; + if (0 === M5) + M5 = 1 - e12; + else { + if (M5 === w5) + return f9 ? NaN : 1 / 0 * (u8 ? -1 : 1); + f9 += Math.pow(2, r10), M5 -= e12; + } + return (u8 ? -1 : 1) * f9 * Math.pow(2, M5 - r10); + }, write: function(a8, t9, o9, r10, h9, M5) { + var f9, p8, w5, e12 = 8 * M5 - h9 - 1, i8 = (1 << e12) - 1, N14 = i8 >> 1, n9 = 23 === h9 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, u8 = r10 ? 0 : M5 - 1, l8 = r10 ? 1 : -1, s7 = t9 < 0 || 0 === t9 && 1 / t9 < 0 ? 1 : 0; + for (t9 = Math.abs(t9), isNaN(t9) || t9 === 1 / 0 ? (p8 = isNaN(t9) ? 1 : 0, f9 = i8) : (f9 = Math.floor(Math.log(t9) / Math.LN2), t9 * (w5 = Math.pow(2, -f9)) < 1 && (f9--, w5 *= 2), (t9 += f9 + N14 >= 1 ? n9 / w5 : n9 * Math.pow(2, 1 - N14)) * w5 >= 2 && (f9++, w5 /= 2), f9 + N14 >= i8 ? (p8 = 0, f9 = i8) : f9 + N14 >= 1 ? (p8 = (t9 * w5 - 1) * Math.pow(2, h9), f9 += N14) : (p8 = t9 * Math.pow(2, N14 - 1) * Math.pow(2, h9), f9 = 0)); h9 >= 8; a8[o9 + u8] = 255 & p8, u8 += l8, p8 /= 256, h9 -= 8) + ; + for (f9 = f9 << h9 | p8, e12 += h9; e12 > 0; a8[o9 + u8] = 255 & f9, u8 += l8, f9 /= 256, e12 -= 8) + ; + a8[o9 + u8 - l8] |= 128 * s7; + } }; + e$1$1 = {}; + n$1$1 = r$14; + i$12 = a$1$1; + o$1$1 = "function" == typeof Symbol && "function" == typeof Symbol.for ? Symbol.for("nodejs.util.inspect.custom") : null; + e$1$1.Buffer = u$1$1, e$1$1.SlowBuffer = function(t9) { + +t9 != t9 && (t9 = 0); + return u$1$1.alloc(+t9); + }, e$1$1.INSPECT_MAX_BYTES = 50; + e$1$1.kMaxLength = 2147483647, u$1$1.TYPED_ARRAY_SUPPORT = function() { + try { + var t9 = new Uint8Array(1), r10 = { foo: function() { + return 42; + } }; + return Object.setPrototypeOf(r10, Uint8Array.prototype), Object.setPrototypeOf(t9, r10), 42 === t9.foo(); + } catch (t10) { + return false; + } + }(), u$1$1.TYPED_ARRAY_SUPPORT || "undefined" == typeof console || "function" != typeof console.error || console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."), Object.defineProperty(u$1$1.prototype, "parent", { enumerable: true, get: function() { + if (u$1$1.isBuffer(this)) + return this.buffer; + } }), Object.defineProperty(u$1$1.prototype, "offset", { enumerable: true, get: function() { + if (u$1$1.isBuffer(this)) + return this.byteOffset; + } }), u$1$1.poolSize = 8192, u$1$1.from = function(t9, r10, e12) { + return s$1(t9, r10, e12); + }, Object.setPrototypeOf(u$1$1.prototype, Uint8Array.prototype), Object.setPrototypeOf(u$1$1, Uint8Array), u$1$1.alloc = function(t9, r10, e12) { + return function(t10, r11, e13) { + return h$1$1(t10), t10 <= 0 ? f$2(t10) : void 0 !== r11 ? "string" == typeof e13 ? f$2(t10).fill(r11, e13) : f$2(t10).fill(r11) : f$2(t10); + }(t9, r10, e12); + }, u$1$1.allocUnsafe = function(t9) { + return a$2(t9); + }, u$1$1.allocUnsafeSlow = function(t9) { + return a$2(t9); + }, u$1$1.isBuffer = function(t9) { + return null != t9 && true === t9._isBuffer && t9 !== u$1$1.prototype; + }, u$1$1.compare = function(t9, r10) { + if (F2(t9, Uint8Array) && (t9 = u$1$1.from(t9, t9.offset, t9.byteLength)), F2(r10, Uint8Array) && (r10 = u$1$1.from(r10, r10.offset, r10.byteLength)), !u$1$1.isBuffer(t9) || !u$1$1.isBuffer(r10)) + throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); + if (t9 === r10) + return 0; + for (var e12 = t9.length, n9 = r10.length, i8 = 0, o9 = Math.min(e12, n9); i8 < o9; ++i8) + if (t9[i8] !== r10[i8]) { + e12 = t9[i8], n9 = r10[i8]; + break; + } + return e12 < n9 ? -1 : n9 < e12 ? 1 : 0; + }, u$1$1.isEncoding = function(t9) { + switch (String(t9).toLowerCase()) { + case "hex": + case "utf8": + case "utf-8": + case "ascii": + case "latin1": + case "binary": + case "base64": + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return true; + default: + return false; + } + }, u$1$1.concat = function(t9, r10) { + if (!Array.isArray(t9)) + throw new TypeError('"list" argument must be an Array of Buffers'); + if (0 === t9.length) + return u$1$1.alloc(0); + var e12; + if (void 0 === r10) + for (r10 = 0, e12 = 0; e12 < t9.length; ++e12) + r10 += t9[e12].length; + var n9 = u$1$1.allocUnsafe(r10), i8 = 0; + for (e12 = 0; e12 < t9.length; ++e12) { + var o9 = t9[e12]; + if (F2(o9, Uint8Array) && (o9 = u$1$1.from(o9)), !u$1$1.isBuffer(o9)) + throw new TypeError('"list" argument must be an Array of Buffers'); + o9.copy(n9, i8), i8 += o9.length; + } + return n9; + }, u$1$1.byteLength = y3, u$1$1.prototype._isBuffer = true, u$1$1.prototype.swap16 = function() { + var t9 = this.length; + if (t9 % 2 != 0) + throw new RangeError("Buffer size must be a multiple of 16-bits"); + for (var r10 = 0; r10 < t9; r10 += 2) + w2(this, r10, r10 + 1); + return this; + }, u$1$1.prototype.swap32 = function() { + var t9 = this.length; + if (t9 % 4 != 0) + throw new RangeError("Buffer size must be a multiple of 32-bits"); + for (var r10 = 0; r10 < t9; r10 += 4) + w2(this, r10, r10 + 3), w2(this, r10 + 1, r10 + 2); + return this; + }, u$1$1.prototype.swap64 = function() { + var t9 = this.length; + if (t9 % 8 != 0) + throw new RangeError("Buffer size must be a multiple of 64-bits"); + for (var r10 = 0; r10 < t9; r10 += 8) + w2(this, r10, r10 + 7), w2(this, r10 + 1, r10 + 6), w2(this, r10 + 2, r10 + 5), w2(this, r10 + 3, r10 + 4); + return this; + }, u$1$1.prototype.toString = function() { + var t9 = this.length; + return 0 === t9 ? "" : 0 === arguments.length ? I2(this, 0, t9) : g2.apply(this, arguments); + }, u$1$1.prototype.toLocaleString = u$1$1.prototype.toString, u$1$1.prototype.equals = function(t9) { + if (!u$1$1.isBuffer(t9)) + throw new TypeError("Argument must be a Buffer"); + return this === t9 || 0 === u$1$1.compare(this, t9); + }, u$1$1.prototype.inspect = function() { + var t9 = "", r10 = e$1$1.INSPECT_MAX_BYTES; + return t9 = this.toString("hex", 0, r10).replace(/(.{2})/g, "$1 ").trim(), this.length > r10 && (t9 += " ... "), ""; + }, o$1$1 && (u$1$1.prototype[o$1$1] = u$1$1.prototype.inspect), u$1$1.prototype.compare = function(t9, r10, e12, n9, i8) { + if (F2(t9, Uint8Array) && (t9 = u$1$1.from(t9, t9.offset, t9.byteLength)), !u$1$1.isBuffer(t9)) + throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof t9); + if (void 0 === r10 && (r10 = 0), void 0 === e12 && (e12 = t9 ? t9.length : 0), void 0 === n9 && (n9 = 0), void 0 === i8 && (i8 = this.length), r10 < 0 || e12 > t9.length || n9 < 0 || i8 > this.length) + throw new RangeError("out of range index"); + if (n9 >= i8 && r10 >= e12) + return 0; + if (n9 >= i8) + return -1; + if (r10 >= e12) + return 1; + if (this === t9) + return 0; + for (var o9 = (i8 >>>= 0) - (n9 >>>= 0), f9 = (e12 >>>= 0) - (r10 >>>= 0), s7 = Math.min(o9, f9), h9 = this.slice(n9, i8), a8 = t9.slice(r10, e12), p8 = 0; p8 < s7; ++p8) + if (h9[p8] !== a8[p8]) { + o9 = h9[p8], f9 = a8[p8]; + break; + } + return o9 < f9 ? -1 : f9 < o9 ? 1 : 0; + }, u$1$1.prototype.includes = function(t9, r10, e12) { + return -1 !== this.indexOf(t9, r10, e12); + }, u$1$1.prototype.indexOf = function(t9, r10, e12) { + return d3(this, t9, r10, e12, true); + }, u$1$1.prototype.lastIndexOf = function(t9, r10, e12) { + return d3(this, t9, r10, e12, false); + }, u$1$1.prototype.write = function(t9, r10, e12, n9) { + if (void 0 === r10) + n9 = "utf8", e12 = this.length, r10 = 0; + else if (void 0 === e12 && "string" == typeof r10) + n9 = r10, e12 = this.length, r10 = 0; + else { + if (!isFinite(r10)) + throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported"); + r10 >>>= 0, isFinite(e12) ? (e12 >>>= 0, void 0 === n9 && (n9 = "utf8")) : (n9 = e12, e12 = void 0); + } + var i8 = this.length - r10; + if ((void 0 === e12 || e12 > i8) && (e12 = i8), t9.length > 0 && (e12 < 0 || r10 < 0) || r10 > this.length) + throw new RangeError("Attempt to write outside buffer bounds"); + n9 || (n9 = "utf8"); + for (var o9 = false; ; ) + switch (n9) { + case "hex": + return b2(this, t9, r10, e12); + case "utf8": + case "utf-8": + return m3(this, t9, r10, e12); + case "ascii": + return E2(this, t9, r10, e12); + case "latin1": + case "binary": + return B2(this, t9, r10, e12); + case "base64": + return A2(this, t9, r10, e12); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return U2(this, t9, r10, e12); + default: + if (o9) + throw new TypeError("Unknown encoding: " + n9); + n9 = ("" + n9).toLowerCase(), o9 = true; + } + }, u$1$1.prototype.toJSON = function() { + return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) }; + }; + u$1$1.prototype.slice = function(t9, r10) { + var e12 = this.length; + (t9 = ~~t9) < 0 ? (t9 += e12) < 0 && (t9 = 0) : t9 > e12 && (t9 = e12), (r10 = void 0 === r10 ? e12 : ~~r10) < 0 ? (r10 += e12) < 0 && (r10 = 0) : r10 > e12 && (r10 = e12), r10 < t9 && (r10 = t9); + var n9 = this.subarray(t9, r10); + return Object.setPrototypeOf(n9, u$1$1.prototype), n9; + }, u$1$1.prototype.readUIntLE = function(t9, r10, e12) { + t9 >>>= 0, r10 >>>= 0, e12 || x2(t9, r10, this.length); + for (var n9 = this[t9], i8 = 1, o9 = 0; ++o9 < r10 && (i8 *= 256); ) + n9 += this[t9 + o9] * i8; + return n9; + }, u$1$1.prototype.readUIntBE = function(t9, r10, e12) { + t9 >>>= 0, r10 >>>= 0, e12 || x2(t9, r10, this.length); + for (var n9 = this[t9 + --r10], i8 = 1; r10 > 0 && (i8 *= 256); ) + n9 += this[t9 + --r10] * i8; + return n9; + }, u$1$1.prototype.readUInt8 = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 1, this.length), this[t9]; + }, u$1$1.prototype.readUInt16LE = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 2, this.length), this[t9] | this[t9 + 1] << 8; + }, u$1$1.prototype.readUInt16BE = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 2, this.length), this[t9] << 8 | this[t9 + 1]; + }, u$1$1.prototype.readUInt32LE = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 4, this.length), (this[t9] | this[t9 + 1] << 8 | this[t9 + 2] << 16) + 16777216 * this[t9 + 3]; + }, u$1$1.prototype.readUInt32BE = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 4, this.length), 16777216 * this[t9] + (this[t9 + 1] << 16 | this[t9 + 2] << 8 | this[t9 + 3]); + }, u$1$1.prototype.readIntLE = function(t9, r10, e12) { + t9 >>>= 0, r10 >>>= 0, e12 || x2(t9, r10, this.length); + for (var n9 = this[t9], i8 = 1, o9 = 0; ++o9 < r10 && (i8 *= 256); ) + n9 += this[t9 + o9] * i8; + return n9 >= (i8 *= 128) && (n9 -= Math.pow(2, 8 * r10)), n9; + }, u$1$1.prototype.readIntBE = function(t9, r10, e12) { + t9 >>>= 0, r10 >>>= 0, e12 || x2(t9, r10, this.length); + for (var n9 = r10, i8 = 1, o9 = this[t9 + --n9]; n9 > 0 && (i8 *= 256); ) + o9 += this[t9 + --n9] * i8; + return o9 >= (i8 *= 128) && (o9 -= Math.pow(2, 8 * r10)), o9; + }, u$1$1.prototype.readInt8 = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 1, this.length), 128 & this[t9] ? -1 * (255 - this[t9] + 1) : this[t9]; + }, u$1$1.prototype.readInt16LE = function(t9, r10) { + t9 >>>= 0, r10 || x2(t9, 2, this.length); + var e12 = this[t9] | this[t9 + 1] << 8; + return 32768 & e12 ? 4294901760 | e12 : e12; + }, u$1$1.prototype.readInt16BE = function(t9, r10) { + t9 >>>= 0, r10 || x2(t9, 2, this.length); + var e12 = this[t9 + 1] | this[t9] << 8; + return 32768 & e12 ? 4294901760 | e12 : e12; + }, u$1$1.prototype.readInt32LE = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 4, this.length), this[t9] | this[t9 + 1] << 8 | this[t9 + 2] << 16 | this[t9 + 3] << 24; + }, u$1$1.prototype.readInt32BE = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 4, this.length), this[t9] << 24 | this[t9 + 1] << 16 | this[t9 + 2] << 8 | this[t9 + 3]; + }, u$1$1.prototype.readFloatLE = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 4, this.length), i$12.read(this, t9, true, 23, 4); + }, u$1$1.prototype.readFloatBE = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 4, this.length), i$12.read(this, t9, false, 23, 4); + }, u$1$1.prototype.readDoubleLE = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 8, this.length), i$12.read(this, t9, true, 52, 8); + }, u$1$1.prototype.readDoubleBE = function(t9, r10) { + return t9 >>>= 0, r10 || x2(t9, 8, this.length), i$12.read(this, t9, false, 52, 8); + }, u$1$1.prototype.writeUIntLE = function(t9, r10, e12, n9) { + (t9 = +t9, r10 >>>= 0, e12 >>>= 0, n9) || C2(this, t9, r10, e12, Math.pow(2, 8 * e12) - 1, 0); + var i8 = 1, o9 = 0; + for (this[r10] = 255 & t9; ++o9 < e12 && (i8 *= 256); ) + this[r10 + o9] = t9 / i8 & 255; + return r10 + e12; + }, u$1$1.prototype.writeUIntBE = function(t9, r10, e12, n9) { + (t9 = +t9, r10 >>>= 0, e12 >>>= 0, n9) || C2(this, t9, r10, e12, Math.pow(2, 8 * e12) - 1, 0); + var i8 = e12 - 1, o9 = 1; + for (this[r10 + i8] = 255 & t9; --i8 >= 0 && (o9 *= 256); ) + this[r10 + i8] = t9 / o9 & 255; + return r10 + e12; + }, u$1$1.prototype.writeUInt8 = function(t9, r10, e12) { + return t9 = +t9, r10 >>>= 0, e12 || C2(this, t9, r10, 1, 255, 0), this[r10] = 255 & t9, r10 + 1; + }, u$1$1.prototype.writeUInt16LE = function(t9, r10, e12) { + return t9 = +t9, r10 >>>= 0, e12 || C2(this, t9, r10, 2, 65535, 0), this[r10] = 255 & t9, this[r10 + 1] = t9 >>> 8, r10 + 2; + }, u$1$1.prototype.writeUInt16BE = function(t9, r10, e12) { + return t9 = +t9, r10 >>>= 0, e12 || C2(this, t9, r10, 2, 65535, 0), this[r10] = t9 >>> 8, this[r10 + 1] = 255 & t9, r10 + 2; + }, u$1$1.prototype.writeUInt32LE = function(t9, r10, e12) { + return t9 = +t9, r10 >>>= 0, e12 || C2(this, t9, r10, 4, 4294967295, 0), this[r10 + 3] = t9 >>> 24, this[r10 + 2] = t9 >>> 16, this[r10 + 1] = t9 >>> 8, this[r10] = 255 & t9, r10 + 4; + }, u$1$1.prototype.writeUInt32BE = function(t9, r10, e12) { + return t9 = +t9, r10 >>>= 0, e12 || C2(this, t9, r10, 4, 4294967295, 0), this[r10] = t9 >>> 24, this[r10 + 1] = t9 >>> 16, this[r10 + 2] = t9 >>> 8, this[r10 + 3] = 255 & t9, r10 + 4; + }, u$1$1.prototype.writeIntLE = function(t9, r10, e12, n9) { + if (t9 = +t9, r10 >>>= 0, !n9) { + var i8 = Math.pow(2, 8 * e12 - 1); + C2(this, t9, r10, e12, i8 - 1, -i8); + } + var o9 = 0, f9 = 1, u8 = 0; + for (this[r10] = 255 & t9; ++o9 < e12 && (f9 *= 256); ) + t9 < 0 && 0 === u8 && 0 !== this[r10 + o9 - 1] && (u8 = 1), this[r10 + o9] = (t9 / f9 >> 0) - u8 & 255; + return r10 + e12; + }, u$1$1.prototype.writeIntBE = function(t9, r10, e12, n9) { + if (t9 = +t9, r10 >>>= 0, !n9) { + var i8 = Math.pow(2, 8 * e12 - 1); + C2(this, t9, r10, e12, i8 - 1, -i8); + } + var o9 = e12 - 1, f9 = 1, u8 = 0; + for (this[r10 + o9] = 255 & t9; --o9 >= 0 && (f9 *= 256); ) + t9 < 0 && 0 === u8 && 0 !== this[r10 + o9 + 1] && (u8 = 1), this[r10 + o9] = (t9 / f9 >> 0) - u8 & 255; + return r10 + e12; + }, u$1$1.prototype.writeInt8 = function(t9, r10, e12) { + return t9 = +t9, r10 >>>= 0, e12 || C2(this, t9, r10, 1, 127, -128), t9 < 0 && (t9 = 255 + t9 + 1), this[r10] = 255 & t9, r10 + 1; + }, u$1$1.prototype.writeInt16LE = function(t9, r10, e12) { + return t9 = +t9, r10 >>>= 0, e12 || C2(this, t9, r10, 2, 32767, -32768), this[r10] = 255 & t9, this[r10 + 1] = t9 >>> 8, r10 + 2; + }, u$1$1.prototype.writeInt16BE = function(t9, r10, e12) { + return t9 = +t9, r10 >>>= 0, e12 || C2(this, t9, r10, 2, 32767, -32768), this[r10] = t9 >>> 8, this[r10 + 1] = 255 & t9, r10 + 2; + }, u$1$1.prototype.writeInt32LE = function(t9, r10, e12) { + return t9 = +t9, r10 >>>= 0, e12 || C2(this, t9, r10, 4, 2147483647, -2147483648), this[r10] = 255 & t9, this[r10 + 1] = t9 >>> 8, this[r10 + 2] = t9 >>> 16, this[r10 + 3] = t9 >>> 24, r10 + 4; + }, u$1$1.prototype.writeInt32BE = function(t9, r10, e12) { + return t9 = +t9, r10 >>>= 0, e12 || C2(this, t9, r10, 4, 2147483647, -2147483648), t9 < 0 && (t9 = 4294967295 + t9 + 1), this[r10] = t9 >>> 24, this[r10 + 1] = t9 >>> 16, this[r10 + 2] = t9 >>> 8, this[r10 + 3] = 255 & t9, r10 + 4; + }, u$1$1.prototype.writeFloatLE = function(t9, r10, e12) { + return k2(this, t9, r10, true, e12); + }, u$1$1.prototype.writeFloatBE = function(t9, r10, e12) { + return k2(this, t9, r10, false, e12); + }, u$1$1.prototype.writeDoubleLE = function(t9, r10, e12) { + return M2(this, t9, r10, true, e12); + }, u$1$1.prototype.writeDoubleBE = function(t9, r10, e12) { + return M2(this, t9, r10, false, e12); + }, u$1$1.prototype.copy = function(t9, r10, e12, n9) { + if (!u$1$1.isBuffer(t9)) + throw new TypeError("argument should be a Buffer"); + if (e12 || (e12 = 0), n9 || 0 === n9 || (n9 = this.length), r10 >= t9.length && (r10 = t9.length), r10 || (r10 = 0), n9 > 0 && n9 < e12 && (n9 = e12), n9 === e12) + return 0; + if (0 === t9.length || 0 === this.length) + return 0; + if (r10 < 0) + throw new RangeError("targetStart out of bounds"); + if (e12 < 0 || e12 >= this.length) + throw new RangeError("Index out of range"); + if (n9 < 0) + throw new RangeError("sourceEnd out of bounds"); + n9 > this.length && (n9 = this.length), t9.length - r10 < n9 - e12 && (n9 = t9.length - r10 + e12); + var i8 = n9 - e12; + if (this === t9 && "function" == typeof Uint8Array.prototype.copyWithin) + this.copyWithin(r10, e12, n9); + else if (this === t9 && e12 < r10 && r10 < n9) + for (var o9 = i8 - 1; o9 >= 0; --o9) + t9[o9 + r10] = this[o9 + e12]; + else + Uint8Array.prototype.set.call(t9, this.subarray(e12, n9), r10); + return i8; + }, u$1$1.prototype.fill = function(t9, r10, e12, n9) { + if ("string" == typeof t9) { + if ("string" == typeof r10 ? (n9 = r10, r10 = 0, e12 = this.length) : "string" == typeof e12 && (n9 = e12, e12 = this.length), void 0 !== n9 && "string" != typeof n9) + throw new TypeError("encoding must be a string"); + if ("string" == typeof n9 && !u$1$1.isEncoding(n9)) + throw new TypeError("Unknown encoding: " + n9); + if (1 === t9.length) { + var i8 = t9.charCodeAt(0); + ("utf8" === n9 && i8 < 128 || "latin1" === n9) && (t9 = i8); + } + } else + "number" == typeof t9 ? t9 &= 255 : "boolean" == typeof t9 && (t9 = Number(t9)); + if (r10 < 0 || this.length < r10 || this.length < e12) + throw new RangeError("Out of range index"); + if (e12 <= r10) + return this; + var o9; + if (r10 >>>= 0, e12 = void 0 === e12 ? this.length : e12 >>> 0, t9 || (t9 = 0), "number" == typeof t9) + for (o9 = r10; o9 < e12; ++o9) + this[o9] = t9; + else { + var f9 = u$1$1.isBuffer(t9) ? t9 : u$1$1.from(t9, n9), s7 = f9.length; + if (0 === s7) + throw new TypeError('The value "' + t9 + '" is invalid for argument "value"'); + for (o9 = 0; o9 < e12 - r10; ++o9) + this[o9 + r10] = f9[o9 % s7]; + } + return this; + }; + j2 = /[^+/0-9A-Za-z-_]/g; + Y2 = function() { + for (var t9 = new Array(256), r10 = 0; r10 < 16; ++r10) + for (var e12 = 16 * r10, n9 = 0; n9 < 16; ++n9) + t9[e12 + n9] = "0123456789abcdef"[r10] + "0123456789abcdef"[n9]; + return t9; + }(); + e$1$1.Buffer; + e$1$1.INSPECT_MAX_BYTES; + e$1$1.kMaxLength; + e4 = {}; + n4 = e$1$1; + o4 = n4.Buffer; + o4.from && o4.alloc && o4.allocUnsafe && o4.allocUnsafeSlow ? e4 = n4 : (t4(n4, e4), e4.Buffer = f4), f4.prototype = Object.create(o4.prototype), t4(o4, f4), f4.from = function(r10, e12, n9) { + if ("number" == typeof r10) + throw new TypeError("Argument must not be a number"); + return o4(r10, e12, n9); + }, f4.alloc = function(r10, e12, n9) { + if ("number" != typeof r10) + throw new TypeError("Argument must be a number"); + var t9 = o4(r10); + return void 0 !== e12 ? "string" == typeof n9 ? t9.fill(e12, n9) : t9.fill(e12) : t9.fill(0), t9; + }, f4.allocUnsafe = function(r10) { + if ("number" != typeof r10) + throw new TypeError("Argument must be a number"); + return o4(r10); + }, f4.allocUnsafeSlow = function(r10) { + if ("number" != typeof r10) + throw new TypeError("Argument must be a number"); + return n4.SlowBuffer(r10); + }; + u4 = e4; + e$12 = {}; + s4 = u4.Buffer; + i4 = s4.isEncoding || function(t9) { + switch ((t9 = "" + t9) && t9.toLowerCase()) { + case "hex": + case "utf8": + case "utf-8": + case "ascii": + case "binary": + case "base64": + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + case "raw": + return true; + default: + return false; + } + }; + e$12.StringDecoder = a4, a4.prototype.write = function(t9) { + if (0 === t9.length) + return ""; + var e12, s7; + if (this.lastNeed) { + if (void 0 === (e12 = this.fillLast(t9))) + return ""; + s7 = this.lastNeed, this.lastNeed = 0; + } else + s7 = 0; + return s7 < t9.length ? e12 ? e12 + this.text(t9, s7) : this.text(t9, s7) : e12 || ""; + }, a4.prototype.end = function(t9) { + var e12 = t9 && t9.length ? this.write(t9) : ""; + return this.lastNeed ? e12 + "\uFFFD" : e12; + }, a4.prototype.text = function(t9, e12) { + var s7 = function(t10, e13, s8) { + var i9 = e13.length - 1; + if (i9 < s8) + return 0; + var a8 = r4(e13[i9]); + if (a8 >= 0) + return a8 > 0 && (t10.lastNeed = a8 - 1), a8; + if (--i9 < s8 || -2 === a8) + return 0; + if ((a8 = r4(e13[i9])) >= 0) + return a8 > 0 && (t10.lastNeed = a8 - 2), a8; + if (--i9 < s8 || -2 === a8) + return 0; + if ((a8 = r4(e13[i9])) >= 0) + return a8 > 0 && (2 === a8 ? a8 = 0 : t10.lastNeed = a8 - 3), a8; + return 0; + }(this, t9, e12); + if (!this.lastNeed) + return t9.toString("utf8", e12); + this.lastTotal = s7; + var i8 = t9.length - (s7 - this.lastNeed); + return t9.copy(this.lastChar, 0, i8), t9.toString("utf8", e12, i8); + }, a4.prototype.fillLast = function(t9) { + if (this.lastNeed <= t9.length) + return t9.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed), this.lastChar.toString(this.encoding, 0, this.lastTotal); + t9.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, t9.length), this.lastNeed -= t9.length; + }; + e$12.StringDecoder; + e$12.StringDecoder; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-44e51b61.js + function dew$2$1() { + if (_dewExec$2$1) + return exports$2$1; + _dewExec$2$1 = true; + exports$2$1.byteLength = byteLength; + exports$2$1.toByteArray = toByteArray; + exports$2$1.fromByteArray = fromByteArray; + var lookup2 = []; + var revLookup = []; + var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array; + var code15 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + for (var i8 = 0, len = code15.length; i8 < len; ++i8) { + lookup2[i8] = code15[i8]; + revLookup[code15.charCodeAt(i8)] = i8; + } + revLookup["-".charCodeAt(0)] = 62; + revLookup["_".charCodeAt(0)] = 63; + function getLens(b64) { + var len2 = b64.length; + if (len2 % 4 > 0) { + throw new Error("Invalid string. Length must be a multiple of 4"); + } + var validLen = b64.indexOf("="); + if (validLen === -1) + validLen = len2; + var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4; + return [validLen, placeHoldersLen]; + } + function byteLength(b64) { + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; + } + function _byteLength(b64, validLen, placeHoldersLen) { + return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; + } + function toByteArray(b64) { + var tmp; + var lens = getLens(b64); + var validLen = lens[0]; + var placeHoldersLen = lens[1]; + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); + var curByte = 0; + var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen; + var i9; + for (i9 = 0; i9 < len2; i9 += 4) { + tmp = revLookup[b64.charCodeAt(i9)] << 18 | revLookup[b64.charCodeAt(i9 + 1)] << 12 | revLookup[b64.charCodeAt(i9 + 2)] << 6 | revLookup[b64.charCodeAt(i9 + 3)]; + arr[curByte++] = tmp >> 16 & 255; + arr[curByte++] = tmp >> 8 & 255; + arr[curByte++] = tmp & 255; + } + if (placeHoldersLen === 2) { + tmp = revLookup[b64.charCodeAt(i9)] << 2 | revLookup[b64.charCodeAt(i9 + 1)] >> 4; + arr[curByte++] = tmp & 255; + } + if (placeHoldersLen === 1) { + tmp = revLookup[b64.charCodeAt(i9)] << 10 | revLookup[b64.charCodeAt(i9 + 1)] << 4 | revLookup[b64.charCodeAt(i9 + 2)] >> 2; + arr[curByte++] = tmp >> 8 & 255; + arr[curByte++] = tmp & 255; + } + return arr; + } + function tripletToBase64(num) { + return lookup2[num >> 18 & 63] + lookup2[num >> 12 & 63] + lookup2[num >> 6 & 63] + lookup2[num & 63]; + } + function encodeChunk(uint8, start, end) { + var tmp; + var output = []; + for (var i9 = start; i9 < end; i9 += 3) { + tmp = (uint8[i9] << 16 & 16711680) + (uint8[i9 + 1] << 8 & 65280) + (uint8[i9 + 2] & 255); + output.push(tripletToBase64(tmp)); + } + return output.join(""); + } + function fromByteArray(uint8) { + var tmp; + var len2 = uint8.length; + var extraBytes = len2 % 3; + var parts = []; + var maxChunkLength = 16383; + for (var i9 = 0, len22 = len2 - extraBytes; i9 < len22; i9 += maxChunkLength) { + parts.push(encodeChunk(uint8, i9, i9 + maxChunkLength > len22 ? len22 : i9 + maxChunkLength)); + } + if (extraBytes === 1) { + tmp = uint8[len2 - 1]; + parts.push(lookup2[tmp >> 2] + lookup2[tmp << 4 & 63] + "=="); + } else if (extraBytes === 2) { + tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1]; + parts.push(lookup2[tmp >> 10] + lookup2[tmp >> 4 & 63] + lookup2[tmp << 2 & 63] + "="); + } + return parts.join(""); + } + return exports$2$1; + } + function dew$1$1() { + if (_dewExec$1$1) + return exports$1$1; + _dewExec$1$1 = true; + exports$1$1.read = function(buffer4, offset2, isLE, mLen, nBytes) { + var e12, m7; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = -7; + var i8 = isLE ? nBytes - 1 : 0; + var d7 = isLE ? -1 : 1; + var s7 = buffer4[offset2 + i8]; + i8 += d7; + e12 = s7 & (1 << -nBits) - 1; + s7 >>= -nBits; + nBits += eLen; + for (; nBits > 0; e12 = e12 * 256 + buffer4[offset2 + i8], i8 += d7, nBits -= 8) { + } + m7 = e12 & (1 << -nBits) - 1; + e12 >>= -nBits; + nBits += mLen; + for (; nBits > 0; m7 = m7 * 256 + buffer4[offset2 + i8], i8 += d7, nBits -= 8) { + } + if (e12 === 0) { + e12 = 1 - eBias; + } else if (e12 === eMax) { + return m7 ? NaN : (s7 ? -1 : 1) * Infinity; + } else { + m7 = m7 + Math.pow(2, mLen); + e12 = e12 - eBias; + } + return (s7 ? -1 : 1) * m7 * Math.pow(2, e12 - mLen); + }; + exports$1$1.write = function(buffer4, value, offset2, isLE, mLen, nBytes) { + var e12, m7, c8; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; + var i8 = isLE ? 0 : nBytes - 1; + var d7 = isLE ? 1 : -1; + var s7 = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; + value = Math.abs(value); + if (isNaN(value) || value === Infinity) { + m7 = isNaN(value) ? 1 : 0; + e12 = eMax; + } else { + e12 = Math.floor(Math.log(value) / Math.LN2); + if (value * (c8 = Math.pow(2, -e12)) < 1) { + e12--; + c8 *= 2; + } + if (e12 + eBias >= 1) { + value += rt / c8; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c8 >= 2) { + e12++; + c8 /= 2; + } + if (e12 + eBias >= eMax) { + m7 = 0; + e12 = eMax; + } else if (e12 + eBias >= 1) { + m7 = (value * c8 - 1) * Math.pow(2, mLen); + e12 = e12 + eBias; + } else { + m7 = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e12 = 0; + } + } + for (; mLen >= 8; buffer4[offset2 + i8] = m7 & 255, i8 += d7, m7 /= 256, mLen -= 8) { + } + e12 = e12 << mLen | m7; + eLen += mLen; + for (; eLen > 0; buffer4[offset2 + i8] = e12 & 255, i8 += d7, e12 /= 256, eLen -= 8) { + } + buffer4[offset2 + i8 - d7] |= s7 * 128; + }; + return exports$1$1; + } + function dew$g() { + if (_dewExec$g) + return exports$g; + _dewExec$g = true; + const base643 = dew$2$1(); + const ieee754 = dew$1$1(); + const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null; + exports$g.Buffer = Buffer2; + exports$g.SlowBuffer = SlowBuffer; + exports$g.INSPECT_MAX_BYTES = 50; + const K_MAX_LENGTH = 2147483647; + exports$g.kMaxLength = K_MAX_LENGTH; + Buffer2.TYPED_ARRAY_SUPPORT = typedArraySupport(); + if (!Buffer2.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { + console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."); + } + function typedArraySupport() { + try { + const arr = new Uint8Array(1); + const proto = { + foo: function() { + return 42; + } + }; + Object.setPrototypeOf(proto, Uint8Array.prototype); + Object.setPrototypeOf(arr, proto); + return arr.foo() === 42; + } catch (e12) { + return false; + } + } + Object.defineProperty(Buffer2.prototype, "parent", { + enumerable: true, + get: function() { + if (!Buffer2.isBuffer(this)) + return void 0; + return this.buffer; + } + }); + Object.defineProperty(Buffer2.prototype, "offset", { + enumerable: true, + get: function() { + if (!Buffer2.isBuffer(this)) + return void 0; + return this.byteOffset; + } + }); + function createBuffer(length3) { + if (length3 > K_MAX_LENGTH) { + throw new RangeError('The value "' + length3 + '" is invalid for option "size"'); + } + const buf3 = new Uint8Array(length3); + Object.setPrototypeOf(buf3, Buffer2.prototype); + return buf3; + } + function Buffer2(arg, encodingOrOffset, length3) { + if (typeof arg === "number") { + if (typeof encodingOrOffset === "string") { + throw new TypeError('The "string" argument must be of type string. Received type number'); + } + return allocUnsafe2(arg); + } + return from18(arg, encodingOrOffset, length3); + } + Buffer2.poolSize = 8192; + function from18(value, encodingOrOffset, length3) { + if (typeof value === "string") { + return fromString6(value, encodingOrOffset); + } + if (ArrayBuffer.isView(value)) { + return fromArrayView(value); + } + if (value == null) { + throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); + } + if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) { + return fromArrayBuffer(value, encodingOrOffset, length3); + } + if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length3); + } + if (typeof value === "number") { + throw new TypeError('The "value" argument must not be of type number. Received type number'); + } + const valueOf = value.valueOf && value.valueOf(); + if (valueOf != null && valueOf !== value) { + return Buffer2.from(valueOf, encodingOrOffset, length3); + } + const b6 = fromObject(value); + if (b6) + return b6; + if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") { + return Buffer2.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length3); + } + throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); + } + Buffer2.from = function(value, encodingOrOffset, length3) { + return from18(value, encodingOrOffset, length3); + }; + Object.setPrototypeOf(Buffer2.prototype, Uint8Array.prototype); + Object.setPrototypeOf(Buffer2, Uint8Array); + function assertSize(size4) { + if (typeof size4 !== "number") { + throw new TypeError('"size" argument must be of type number'); + } else if (size4 < 0) { + throw new RangeError('The value "' + size4 + '" is invalid for option "size"'); + } + } + function alloc3(size4, fill, encoding) { + assertSize(size4); + if (size4 <= 0) { + return createBuffer(size4); + } + if (fill !== void 0) { + return typeof encoding === "string" ? createBuffer(size4).fill(fill, encoding) : createBuffer(size4).fill(fill); + } + return createBuffer(size4); + } + Buffer2.alloc = function(size4, fill, encoding) { + return alloc3(size4, fill, encoding); + }; + function allocUnsafe2(size4) { + assertSize(size4); + return createBuffer(size4 < 0 ? 0 : checked(size4) | 0); + } + Buffer2.allocUnsafe = function(size4) { + return allocUnsafe2(size4); + }; + Buffer2.allocUnsafeSlow = function(size4) { + return allocUnsafe2(size4); + }; + function fromString6(string4, encoding) { + if (typeof encoding !== "string" || encoding === "") { + encoding = "utf8"; + } + if (!Buffer2.isEncoding(encoding)) { + throw new TypeError("Unknown encoding: " + encoding); + } + const length3 = byteLength(string4, encoding) | 0; + let buf3 = createBuffer(length3); + const actual = buf3.write(string4, encoding); + if (actual !== length3) { + buf3 = buf3.slice(0, actual); + } + return buf3; + } + function fromArrayLike(array3) { + const length3 = array3.length < 0 ? 0 : checked(array3.length) | 0; + const buf3 = createBuffer(length3); + for (let i8 = 0; i8 < length3; i8 += 1) { + buf3[i8] = array3[i8] & 255; + } + return buf3; + } + function fromArrayView(arrayView) { + if (isInstance(arrayView, Uint8Array)) { + const copy = new Uint8Array(arrayView); + return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength); + } + return fromArrayLike(arrayView); + } + function fromArrayBuffer(array3, byteOffset, length3) { + if (byteOffset < 0 || array3.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds'); + } + if (array3.byteLength < byteOffset + (length3 || 0)) { + throw new RangeError('"length" is outside of buffer bounds'); + } + let buf3; + if (byteOffset === void 0 && length3 === void 0) { + buf3 = new Uint8Array(array3); + } else if (length3 === void 0) { + buf3 = new Uint8Array(array3, byteOffset); + } else { + buf3 = new Uint8Array(array3, byteOffset, length3); + } + Object.setPrototypeOf(buf3, Buffer2.prototype); + return buf3; + } + function fromObject(obj) { + if (Buffer2.isBuffer(obj)) { + const len = checked(obj.length) | 0; + const buf3 = createBuffer(len); + if (buf3.length === 0) { + return buf3; + } + obj.copy(buf3, 0, 0, len); + return buf3; + } + if (obj.length !== void 0) { + if (typeof obj.length !== "number" || numberIsNaN(obj.length)) { + return createBuffer(0); + } + return fromArrayLike(obj); + } + if (obj.type === "Buffer" && Array.isArray(obj.data)) { + return fromArrayLike(obj.data); + } + } + function checked(length3) { + if (length3 >= K_MAX_LENGTH) { + throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes"); + } + return length3 | 0; + } + function SlowBuffer(length3) { + if (+length3 != length3) { + length3 = 0; + } + return Buffer2.alloc(+length3); + } + Buffer2.isBuffer = function isBuffer7(b6) { + return b6 != null && b6._isBuffer === true && b6 !== Buffer2.prototype; + }; + Buffer2.compare = function compare7(a8, b6) { + if (isInstance(a8, Uint8Array)) + a8 = Buffer2.from(a8, a8.offset, a8.byteLength); + if (isInstance(b6, Uint8Array)) + b6 = Buffer2.from(b6, b6.offset, b6.byteLength); + if (!Buffer2.isBuffer(a8) || !Buffer2.isBuffer(b6)) { + throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); + } + if (a8 === b6) + return 0; + let x5 = a8.length; + let y7 = b6.length; + for (let i8 = 0, len = Math.min(x5, y7); i8 < len; ++i8) { + if (a8[i8] !== b6[i8]) { + x5 = a8[i8]; + y7 = b6[i8]; + break; + } + } + if (x5 < y7) + return -1; + if (y7 < x5) + return 1; + return 0; + }; + Buffer2.isEncoding = function isEncoding(encoding) { + switch (String(encoding).toLowerCase()) { + case "hex": + case "utf8": + case "utf-8": + case "ascii": + case "latin1": + case "binary": + case "base64": + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return true; + default: + return false; + } + }; + Buffer2.concat = function concat6(list10, length3) { + if (!Array.isArray(list10)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } + if (list10.length === 0) { + return Buffer2.alloc(0); + } + let i8; + if (length3 === void 0) { + length3 = 0; + for (i8 = 0; i8 < list10.length; ++i8) { + length3 += list10[i8].length; + } + } + const buffer4 = Buffer2.allocUnsafe(length3); + let pos = 0; + for (i8 = 0; i8 < list10.length; ++i8) { + let buf3 = list10[i8]; + if (isInstance(buf3, Uint8Array)) { + if (pos + buf3.length > buffer4.length) { + if (!Buffer2.isBuffer(buf3)) + buf3 = Buffer2.from(buf3); + buf3.copy(buffer4, pos); + } else { + Uint8Array.prototype.set.call(buffer4, buf3, pos); + } + } else if (!Buffer2.isBuffer(buf3)) { + throw new TypeError('"list" argument must be an Array of Buffers'); + } else { + buf3.copy(buffer4, pos); + } + pos += buf3.length; + } + return buffer4; + }; + function byteLength(string4, encoding) { + if (Buffer2.isBuffer(string4)) { + return string4.length; + } + if (ArrayBuffer.isView(string4) || isInstance(string4, ArrayBuffer)) { + return string4.byteLength; + } + if (typeof string4 !== "string") { + throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string4); + } + const len = string4.length; + const mustMatch = arguments.length > 2 && arguments[2] === true; + if (!mustMatch && len === 0) + return 0; + let loweredCase = false; + for (; ; ) { + switch (encoding) { + case "ascii": + case "latin1": + case "binary": + return len; + case "utf8": + case "utf-8": + return utf8ToBytes3(string4).length; + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return len * 2; + case "hex": + return len >>> 1; + case "base64": + return base64ToBytes(string4).length; + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes3(string4).length; + } + encoding = ("" + encoding).toLowerCase(); + loweredCase = true; + } + } + } + Buffer2.byteLength = byteLength; + function slowToString(encoding, start, end) { + let loweredCase = false; + if (start === void 0 || start < 0) { + start = 0; + } + if (start > this.length) { + return ""; + } + if (end === void 0 || end > this.length) { + end = this.length; + } + if (end <= 0) { + return ""; + } + end >>>= 0; + start >>>= 0; + if (end <= start) { + return ""; + } + if (!encoding) + encoding = "utf8"; + while (true) { + switch (encoding) { + case "hex": + return hexSlice(this, start, end); + case "utf8": + case "utf-8": + return utf8Slice3(this, start, end); + case "ascii": + return asciiSlice(this, start, end); + case "latin1": + case "binary": + return latin1Slice(this, start, end); + case "base64": + return base64Slice(this, start, end); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return utf16leSlice(this, start, end); + default: + if (loweredCase) + throw new TypeError("Unknown encoding: " + encoding); + encoding = (encoding + "").toLowerCase(); + loweredCase = true; + } + } + } + Buffer2.prototype._isBuffer = true; + function swap(b6, n9, m7) { + const i8 = b6[n9]; + b6[n9] = b6[m7]; + b6[m7] = i8; + } + Buffer2.prototype.swap16 = function swap16() { + const len = this.length; + if (len % 2 !== 0) { + throw new RangeError("Buffer size must be a multiple of 16-bits"); + } + for (let i8 = 0; i8 < len; i8 += 2) { + swap(this, i8, i8 + 1); + } + return this; + }; + Buffer2.prototype.swap32 = function swap32() { + const len = this.length; + if (len % 4 !== 0) { + throw new RangeError("Buffer size must be a multiple of 32-bits"); + } + for (let i8 = 0; i8 < len; i8 += 4) { + swap(this, i8, i8 + 3); + swap(this, i8 + 1, i8 + 2); + } + return this; + }; + Buffer2.prototype.swap64 = function swap64() { + const len = this.length; + if (len % 8 !== 0) { + throw new RangeError("Buffer size must be a multiple of 64-bits"); + } + for (let i8 = 0; i8 < len; i8 += 8) { + swap(this, i8, i8 + 7); + swap(this, i8 + 1, i8 + 6); + swap(this, i8 + 2, i8 + 5); + swap(this, i8 + 3, i8 + 4); + } + return this; + }; + Buffer2.prototype.toString = function toString6() { + const length3 = this.length; + if (length3 === 0) + return ""; + if (arguments.length === 0) + return utf8Slice3(this, 0, length3); + return slowToString.apply(this, arguments); + }; + Buffer2.prototype.toLocaleString = Buffer2.prototype.toString; + Buffer2.prototype.equals = function equals6(b6) { + if (!Buffer2.isBuffer(b6)) + throw new TypeError("Argument must be a Buffer"); + if (this === b6) + return true; + return Buffer2.compare(this, b6) === 0; + }; + Buffer2.prototype.inspect = function inspect3() { + let str = ""; + const max = exports$g.INSPECT_MAX_BYTES; + str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim(); + if (this.length > max) + str += " ... "; + return ""; + }; + if (customInspectSymbol) { + Buffer2.prototype[customInspectSymbol] = Buffer2.prototype.inspect; + } + Buffer2.prototype.compare = function compare7(target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer2.from(target, target.offset, target.byteLength); + } + if (!Buffer2.isBuffer(target)) { + throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target); + } + if (start === void 0) { + start = 0; + } + if (end === void 0) { + end = target ? target.length : 0; + } + if (thisStart === void 0) { + thisStart = 0; + } + if (thisEnd === void 0) { + thisEnd = this.length; + } + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError("out of range index"); + } + if (thisStart >= thisEnd && start >= end) { + return 0; + } + if (thisStart >= thisEnd) { + return -1; + } + if (start >= end) { + return 1; + } + start >>>= 0; + end >>>= 0; + thisStart >>>= 0; + thisEnd >>>= 0; + if (this === target) + return 0; + let x5 = thisEnd - thisStart; + let y7 = end - start; + const len = Math.min(x5, y7); + const thisCopy = this.slice(thisStart, thisEnd); + const targetCopy = target.slice(start, end); + for (let i8 = 0; i8 < len; ++i8) { + if (thisCopy[i8] !== targetCopy[i8]) { + x5 = thisCopy[i8]; + y7 = targetCopy[i8]; + break; + } + } + if (x5 < y7) + return -1; + if (y7 < x5) + return 1; + return 0; + }; + function bidirectionalIndexOf(buffer4, val, byteOffset, encoding, dir) { + if (buffer4.length === 0) + return -1; + if (typeof byteOffset === "string") { + encoding = byteOffset; + byteOffset = 0; + } else if (byteOffset > 2147483647) { + byteOffset = 2147483647; + } else if (byteOffset < -2147483648) { + byteOffset = -2147483648; + } + byteOffset = +byteOffset; + if (numberIsNaN(byteOffset)) { + byteOffset = dir ? 0 : buffer4.length - 1; + } + if (byteOffset < 0) + byteOffset = buffer4.length + byteOffset; + if (byteOffset >= buffer4.length) { + if (dir) + return -1; + else + byteOffset = buffer4.length - 1; + } else if (byteOffset < 0) { + if (dir) + byteOffset = 0; + else + return -1; + } + if (typeof val === "string") { + val = Buffer2.from(val, encoding); + } + if (Buffer2.isBuffer(val)) { + if (val.length === 0) { + return -1; + } + return arrayIndexOf(buffer4, val, byteOffset, encoding, dir); + } else if (typeof val === "number") { + val = val & 255; + if (typeof Uint8Array.prototype.indexOf === "function") { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer4, val, byteOffset); + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer4, val, byteOffset); + } + } + return arrayIndexOf(buffer4, [val], byteOffset, encoding, dir); + } + throw new TypeError("val must be string, number or Buffer"); + } + function arrayIndexOf(arr, val, byteOffset, encoding, dir) { + let indexSize = 1; + let arrLength = arr.length; + let valLength = val.length; + if (encoding !== void 0) { + encoding = String(encoding).toLowerCase(); + if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") { + if (arr.length < 2 || val.length < 2) { + return -1; + } + indexSize = 2; + arrLength /= 2; + valLength /= 2; + byteOffset /= 2; + } + } + function read13(buf3, i9) { + if (indexSize === 1) { + return buf3[i9]; + } else { + return buf3.readUInt16BE(i9 * indexSize); + } + } + let i8; + if (dir) { + let foundIndex = -1; + for (i8 = byteOffset; i8 < arrLength; i8++) { + if (read13(arr, i8) === read13(val, foundIndex === -1 ? 0 : i8 - foundIndex)) { + if (foundIndex === -1) + foundIndex = i8; + if (i8 - foundIndex + 1 === valLength) + return foundIndex * indexSize; + } else { + if (foundIndex !== -1) + i8 -= i8 - foundIndex; + foundIndex = -1; + } + } + } else { + if (byteOffset + valLength > arrLength) + byteOffset = arrLength - valLength; + for (i8 = byteOffset; i8 >= 0; i8--) { + let found = true; + for (let j5 = 0; j5 < valLength; j5++) { + if (read13(arr, i8 + j5) !== read13(val, j5)) { + found = false; + break; + } + } + if (found) + return i8; + } + } + return -1; + } + Buffer2.prototype.includes = function includes(val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1; + }; + Buffer2.prototype.indexOf = function indexOf2(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true); + }; + Buffer2.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false); + }; + function hexWrite(buf3, string4, offset2, length3) { + offset2 = Number(offset2) || 0; + const remaining = buf3.length - offset2; + if (!length3) { + length3 = remaining; + } else { + length3 = Number(length3); + if (length3 > remaining) { + length3 = remaining; + } + } + const strLen = string4.length; + if (length3 > strLen / 2) { + length3 = strLen / 2; + } + let i8; + for (i8 = 0; i8 < length3; ++i8) { + const parsed = parseInt(string4.substr(i8 * 2, 2), 16); + if (numberIsNaN(parsed)) + return i8; + buf3[offset2 + i8] = parsed; + } + return i8; + } + function utf8Write(buf3, string4, offset2, length3) { + return blitBuffer(utf8ToBytes3(string4, buf3.length - offset2), buf3, offset2, length3); + } + function asciiWrite(buf3, string4, offset2, length3) { + return blitBuffer(asciiToBytes(string4), buf3, offset2, length3); + } + function base64Write(buf3, string4, offset2, length3) { + return blitBuffer(base64ToBytes(string4), buf3, offset2, length3); + } + function ucs2Write(buf3, string4, offset2, length3) { + return blitBuffer(utf16leToBytes(string4, buf3.length - offset2), buf3, offset2, length3); + } + Buffer2.prototype.write = function write11(string4, offset2, length3, encoding) { + if (offset2 === void 0) { + encoding = "utf8"; + length3 = this.length; + offset2 = 0; + } else if (length3 === void 0 && typeof offset2 === "string") { + encoding = offset2; + length3 = this.length; + offset2 = 0; + } else if (isFinite(offset2)) { + offset2 = offset2 >>> 0; + if (isFinite(length3)) { + length3 = length3 >>> 0; + if (encoding === void 0) + encoding = "utf8"; + } else { + encoding = length3; + length3 = void 0; + } + } else { + throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported"); + } + const remaining = this.length - offset2; + if (length3 === void 0 || length3 > remaining) + length3 = remaining; + if (string4.length > 0 && (length3 < 0 || offset2 < 0) || offset2 > this.length) { + throw new RangeError("Attempt to write outside buffer bounds"); + } + if (!encoding) + encoding = "utf8"; + let loweredCase = false; + for (; ; ) { + switch (encoding) { + case "hex": + return hexWrite(this, string4, offset2, length3); + case "utf8": + case "utf-8": + return utf8Write(this, string4, offset2, length3); + case "ascii": + case "latin1": + case "binary": + return asciiWrite(this, string4, offset2, length3); + case "base64": + return base64Write(this, string4, offset2, length3); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return ucs2Write(this, string4, offset2, length3); + default: + if (loweredCase) + throw new TypeError("Unknown encoding: " + encoding); + encoding = ("" + encoding).toLowerCase(); + loweredCase = true; + } + } + }; + Buffer2.prototype.toJSON = function toJSON4() { + return { + type: "Buffer", + data: Array.prototype.slice.call(this._arr || this, 0) + }; + }; + function base64Slice(buf3, start, end) { + if (start === 0 && end === buf3.length) { + return base643.fromByteArray(buf3); + } else { + return base643.fromByteArray(buf3.slice(start, end)); + } + } + function utf8Slice3(buf3, start, end) { + end = Math.min(buf3.length, end); + const res = []; + let i8 = start; + while (i8 < end) { + const firstByte = buf3[i8]; + let codePoint = null; + let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1; + if (i8 + bytesPerSequence <= end) { + let secondByte, thirdByte, fourthByte, tempCodePoint; + switch (bytesPerSequence) { + case 1: + if (firstByte < 128) { + codePoint = firstByte; + } + break; + case 2: + secondByte = buf3[i8 + 1]; + if ((secondByte & 192) === 128) { + tempCodePoint = (firstByte & 31) << 6 | secondByte & 63; + if (tempCodePoint > 127) { + codePoint = tempCodePoint; + } + } + break; + case 3: + secondByte = buf3[i8 + 1]; + thirdByte = buf3[i8 + 2]; + if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) { + tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63; + if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) { + codePoint = tempCodePoint; + } + } + break; + case 4: + secondByte = buf3[i8 + 1]; + thirdByte = buf3[i8 + 2]; + fourthByte = buf3[i8 + 3]; + if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) { + tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63; + if (tempCodePoint > 65535 && tempCodePoint < 1114112) { + codePoint = tempCodePoint; + } + } + } + } + if (codePoint === null) { + codePoint = 65533; + bytesPerSequence = 1; + } else if (codePoint > 65535) { + codePoint -= 65536; + res.push(codePoint >>> 10 & 1023 | 55296); + codePoint = 56320 | codePoint & 1023; + } + res.push(codePoint); + i8 += bytesPerSequence; + } + return decodeCodePointsArray3(res); + } + const MAX_ARGUMENTS_LENGTH3 = 4096; + function decodeCodePointsArray3(codePoints) { + const len = codePoints.length; + if (len <= MAX_ARGUMENTS_LENGTH3) { + return String.fromCharCode.apply(String, codePoints); + } + let res = ""; + let i8 = 0; + while (i8 < len) { + res += String.fromCharCode.apply(String, codePoints.slice(i8, i8 += MAX_ARGUMENTS_LENGTH3)); + } + return res; + } + function asciiSlice(buf3, start, end) { + let ret = ""; + end = Math.min(buf3.length, end); + for (let i8 = start; i8 < end; ++i8) { + ret += String.fromCharCode(buf3[i8] & 127); + } + return ret; + } + function latin1Slice(buf3, start, end) { + let ret = ""; + end = Math.min(buf3.length, end); + for (let i8 = start; i8 < end; ++i8) { + ret += String.fromCharCode(buf3[i8]); + } + return ret; + } + function hexSlice(buf3, start, end) { + const len = buf3.length; + if (!start || start < 0) + start = 0; + if (!end || end < 0 || end > len) + end = len; + let out = ""; + for (let i8 = start; i8 < end; ++i8) { + out += hexSliceLookupTable[buf3[i8]]; + } + return out; + } + function utf16leSlice(buf3, start, end) { + const bytes2 = buf3.slice(start, end); + let res = ""; + for (let i8 = 0; i8 < bytes2.length - 1; i8 += 2) { + res += String.fromCharCode(bytes2[i8] + bytes2[i8 + 1] * 256); + } + return res; + } + Buffer2.prototype.slice = function slice4(start, end) { + const len = this.length; + start = ~~start; + end = end === void 0 ? len : ~~end; + if (start < 0) { + start += len; + if (start < 0) + start = 0; + } else if (start > len) { + start = len; + } + if (end < 0) { + end += len; + if (end < 0) + end = 0; + } else if (end > len) { + end = len; + } + if (end < start) + end = start; + const newBuf = this.subarray(start, end); + Object.setPrototypeOf(newBuf, Buffer2.prototype); + return newBuf; + }; + function checkOffset(offset2, ext, length3) { + if (offset2 % 1 !== 0 || offset2 < 0) + throw new RangeError("offset is not uint"); + if (offset2 + ext > length3) + throw new RangeError("Trying to access beyond buffer length"); + } + Buffer2.prototype.readUintLE = Buffer2.prototype.readUIntLE = function readUIntLE(offset2, byteLength2, noAssert) { + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) + checkOffset(offset2, byteLength2, this.length); + let val = this[offset2]; + let mul = 1; + let i8 = 0; + while (++i8 < byteLength2 && (mul *= 256)) { + val += this[offset2 + i8] * mul; + } + return val; + }; + Buffer2.prototype.readUintBE = Buffer2.prototype.readUIntBE = function readUIntBE(offset2, byteLength2, noAssert) { + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) { + checkOffset(offset2, byteLength2, this.length); + } + let val = this[offset2 + --byteLength2]; + let mul = 1; + while (byteLength2 > 0 && (mul *= 256)) { + val += this[offset2 + --byteLength2] * mul; + } + return val; + }; + Buffer2.prototype.readUint8 = Buffer2.prototype.readUInt8 = function readUInt8(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 1, this.length); + return this[offset2]; + }; + Buffer2.prototype.readUint16LE = Buffer2.prototype.readUInt16LE = function readUInt16LE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 2, this.length); + return this[offset2] | this[offset2 + 1] << 8; + }; + Buffer2.prototype.readUint16BE = Buffer2.prototype.readUInt16BE = function readUInt16BE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 2, this.length); + return this[offset2] << 8 | this[offset2 + 1]; + }; + Buffer2.prototype.readUint32LE = Buffer2.prototype.readUInt32LE = function readUInt32LE3(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return (this[offset2] | this[offset2 + 1] << 8 | this[offset2 + 2] << 16) + this[offset2 + 3] * 16777216; + }; + Buffer2.prototype.readUint32BE = Buffer2.prototype.readUInt32BE = function readUInt32BE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return this[offset2] * 16777216 + (this[offset2 + 1] << 16 | this[offset2 + 2] << 8 | this[offset2 + 3]); + }; + Buffer2.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset2) { + offset2 = offset2 >>> 0; + validateNumber(offset2, "offset"); + const first = this[offset2]; + const last2 = this[offset2 + 7]; + if (first === void 0 || last2 === void 0) { + boundsError(offset2, this.length - 8); + } + const lo = first + this[++offset2] * 2 ** 8 + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 24; + const hi = this[++offset2] + this[++offset2] * 2 ** 8 + this[++offset2] * 2 ** 16 + last2 * 2 ** 24; + return BigInt(lo) + (BigInt(hi) << BigInt(32)); + }); + Buffer2.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset2) { + offset2 = offset2 >>> 0; + validateNumber(offset2, "offset"); + const first = this[offset2]; + const last2 = this[offset2 + 7]; + if (first === void 0 || last2 === void 0) { + boundsError(offset2, this.length - 8); + } + const hi = first * 2 ** 24 + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 8 + this[++offset2]; + const lo = this[++offset2] * 2 ** 24 + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 8 + last2; + return (BigInt(hi) << BigInt(32)) + BigInt(lo); + }); + Buffer2.prototype.readIntLE = function readIntLE(offset2, byteLength2, noAssert) { + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) + checkOffset(offset2, byteLength2, this.length); + let val = this[offset2]; + let mul = 1; + let i8 = 0; + while (++i8 < byteLength2 && (mul *= 256)) { + val += this[offset2 + i8] * mul; + } + mul *= 128; + if (val >= mul) + val -= Math.pow(2, 8 * byteLength2); + return val; + }; + Buffer2.prototype.readIntBE = function readIntBE(offset2, byteLength2, noAssert) { + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) + checkOffset(offset2, byteLength2, this.length); + let i8 = byteLength2; + let mul = 1; + let val = this[offset2 + --i8]; + while (i8 > 0 && (mul *= 256)) { + val += this[offset2 + --i8] * mul; + } + mul *= 128; + if (val >= mul) + val -= Math.pow(2, 8 * byteLength2); + return val; + }; + Buffer2.prototype.readInt8 = function readInt8(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 1, this.length); + if (!(this[offset2] & 128)) + return this[offset2]; + return (255 - this[offset2] + 1) * -1; + }; + Buffer2.prototype.readInt16LE = function readInt16LE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 2, this.length); + const val = this[offset2] | this[offset2 + 1] << 8; + return val & 32768 ? val | 4294901760 : val; + }; + Buffer2.prototype.readInt16BE = function readInt16BE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 2, this.length); + const val = this[offset2 + 1] | this[offset2] << 8; + return val & 32768 ? val | 4294901760 : val; + }; + Buffer2.prototype.readInt32LE = function readInt32LE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return this[offset2] | this[offset2 + 1] << 8 | this[offset2 + 2] << 16 | this[offset2 + 3] << 24; + }; + Buffer2.prototype.readInt32BE = function readInt32BE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return this[offset2] << 24 | this[offset2 + 1] << 16 | this[offset2 + 2] << 8 | this[offset2 + 3]; + }; + Buffer2.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset2) { + offset2 = offset2 >>> 0; + validateNumber(offset2, "offset"); + const first = this[offset2]; + const last2 = this[offset2 + 7]; + if (first === void 0 || last2 === void 0) { + boundsError(offset2, this.length - 8); + } + const val = this[offset2 + 4] + this[offset2 + 5] * 2 ** 8 + this[offset2 + 6] * 2 ** 16 + (last2 << 24); + return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset2] * 2 ** 8 + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 24); + }); + Buffer2.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset2) { + offset2 = offset2 >>> 0; + validateNumber(offset2, "offset"); + const first = this[offset2]; + const last2 = this[offset2 + 7]; + if (first === void 0 || last2 === void 0) { + boundsError(offset2, this.length - 8); + } + const val = (first << 24) + // Overflow + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 8 + this[++offset2]; + return (BigInt(val) << BigInt(32)) + BigInt(this[++offset2] * 2 ** 24 + this[++offset2] * 2 ** 16 + this[++offset2] * 2 ** 8 + last2); + }); + Buffer2.prototype.readFloatLE = function readFloatLE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return ieee754.read(this, offset2, true, 23, 4); + }; + Buffer2.prototype.readFloatBE = function readFloatBE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 4, this.length); + return ieee754.read(this, offset2, false, 23, 4); + }; + Buffer2.prototype.readDoubleLE = function readDoubleLE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 8, this.length); + return ieee754.read(this, offset2, true, 52, 8); + }; + Buffer2.prototype.readDoubleBE = function readDoubleBE(offset2, noAssert) { + offset2 = offset2 >>> 0; + if (!noAssert) + checkOffset(offset2, 8, this.length); + return ieee754.read(this, offset2, false, 52, 8); + }; + function checkInt(buf3, value, offset2, ext, max, min) { + if (!Buffer2.isBuffer(buf3)) + throw new TypeError('"buffer" argument must be a Buffer instance'); + if (value > max || value < min) + throw new RangeError('"value" argument is out of bounds'); + if (offset2 + ext > buf3.length) + throw new RangeError("Index out of range"); + } + Buffer2.prototype.writeUintLE = Buffer2.prototype.writeUIntLE = function writeUIntLE(value, offset2, byteLength2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) { + const maxBytes = Math.pow(2, 8 * byteLength2) - 1; + checkInt(this, value, offset2, byteLength2, maxBytes, 0); + } + let mul = 1; + let i8 = 0; + this[offset2] = value & 255; + while (++i8 < byteLength2 && (mul *= 256)) { + this[offset2 + i8] = value / mul & 255; + } + return offset2 + byteLength2; + }; + Buffer2.prototype.writeUintBE = Buffer2.prototype.writeUIntBE = function writeUIntBE(value, offset2, byteLength2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + byteLength2 = byteLength2 >>> 0; + if (!noAssert) { + const maxBytes = Math.pow(2, 8 * byteLength2) - 1; + checkInt(this, value, offset2, byteLength2, maxBytes, 0); + } + let i8 = byteLength2 - 1; + let mul = 1; + this[offset2 + i8] = value & 255; + while (--i8 >= 0 && (mul *= 256)) { + this[offset2 + i8] = value / mul & 255; + } + return offset2 + byteLength2; + }; + Buffer2.prototype.writeUint8 = Buffer2.prototype.writeUInt8 = function writeUInt8(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 1, 255, 0); + this[offset2] = value & 255; + return offset2 + 1; + }; + Buffer2.prototype.writeUint16LE = Buffer2.prototype.writeUInt16LE = function writeUInt16LE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 2, 65535, 0); + this[offset2] = value & 255; + this[offset2 + 1] = value >>> 8; + return offset2 + 2; + }; + Buffer2.prototype.writeUint16BE = Buffer2.prototype.writeUInt16BE = function writeUInt16BE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 2, 65535, 0); + this[offset2] = value >>> 8; + this[offset2 + 1] = value & 255; + return offset2 + 2; + }; + Buffer2.prototype.writeUint32LE = Buffer2.prototype.writeUInt32LE = function writeUInt32LE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 4, 4294967295, 0); + this[offset2 + 3] = value >>> 24; + this[offset2 + 2] = value >>> 16; + this[offset2 + 1] = value >>> 8; + this[offset2] = value & 255; + return offset2 + 4; + }; + Buffer2.prototype.writeUint32BE = Buffer2.prototype.writeUInt32BE = function writeUInt32BE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 4, 4294967295, 0); + this[offset2] = value >>> 24; + this[offset2 + 1] = value >>> 16; + this[offset2 + 2] = value >>> 8; + this[offset2 + 3] = value & 255; + return offset2 + 4; + }; + function wrtBigUInt64LE(buf3, value, offset2, min, max) { + checkIntBI(value, min, max, buf3, offset2, 7); + let lo = Number(value & BigInt(4294967295)); + buf3[offset2++] = lo; + lo = lo >> 8; + buf3[offset2++] = lo; + lo = lo >> 8; + buf3[offset2++] = lo; + lo = lo >> 8; + buf3[offset2++] = lo; + let hi = Number(value >> BigInt(32) & BigInt(4294967295)); + buf3[offset2++] = hi; + hi = hi >> 8; + buf3[offset2++] = hi; + hi = hi >> 8; + buf3[offset2++] = hi; + hi = hi >> 8; + buf3[offset2++] = hi; + return offset2; + } + function wrtBigUInt64BE(buf3, value, offset2, min, max) { + checkIntBI(value, min, max, buf3, offset2, 7); + let lo = Number(value & BigInt(4294967295)); + buf3[offset2 + 7] = lo; + lo = lo >> 8; + buf3[offset2 + 6] = lo; + lo = lo >> 8; + buf3[offset2 + 5] = lo; + lo = lo >> 8; + buf3[offset2 + 4] = lo; + let hi = Number(value >> BigInt(32) & BigInt(4294967295)); + buf3[offset2 + 3] = hi; + hi = hi >> 8; + buf3[offset2 + 2] = hi; + hi = hi >> 8; + buf3[offset2 + 1] = hi; + hi = hi >> 8; + buf3[offset2] = hi; + return offset2 + 8; + } + Buffer2.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset2 = 0) { + return wrtBigUInt64LE(this, value, offset2, BigInt(0), BigInt("0xffffffffffffffff")); + }); + Buffer2.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset2 = 0) { + return wrtBigUInt64BE(this, value, offset2, BigInt(0), BigInt("0xffffffffffffffff")); + }); + Buffer2.prototype.writeIntLE = function writeIntLE(value, offset2, byteLength2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) { + const limit = Math.pow(2, 8 * byteLength2 - 1); + checkInt(this, value, offset2, byteLength2, limit - 1, -limit); + } + let i8 = 0; + let mul = 1; + let sub = 0; + this[offset2] = value & 255; + while (++i8 < byteLength2 && (mul *= 256)) { + if (value < 0 && sub === 0 && this[offset2 + i8 - 1] !== 0) { + sub = 1; + } + this[offset2 + i8] = (value / mul >> 0) - sub & 255; + } + return offset2 + byteLength2; + }; + Buffer2.prototype.writeIntBE = function writeIntBE(value, offset2, byteLength2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) { + const limit = Math.pow(2, 8 * byteLength2 - 1); + checkInt(this, value, offset2, byteLength2, limit - 1, -limit); + } + let i8 = byteLength2 - 1; + let mul = 1; + let sub = 0; + this[offset2 + i8] = value & 255; + while (--i8 >= 0 && (mul *= 256)) { + if (value < 0 && sub === 0 && this[offset2 + i8 + 1] !== 0) { + sub = 1; + } + this[offset2 + i8] = (value / mul >> 0) - sub & 255; + } + return offset2 + byteLength2; + }; + Buffer2.prototype.writeInt8 = function writeInt8(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 1, 127, -128); + if (value < 0) + value = 255 + value + 1; + this[offset2] = value & 255; + return offset2 + 1; + }; + Buffer2.prototype.writeInt16LE = function writeInt16LE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 2, 32767, -32768); + this[offset2] = value & 255; + this[offset2 + 1] = value >>> 8; + return offset2 + 2; + }; + Buffer2.prototype.writeInt16BE = function writeInt16BE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 2, 32767, -32768); + this[offset2] = value >>> 8; + this[offset2 + 1] = value & 255; + return offset2 + 2; + }; + Buffer2.prototype.writeInt32LE = function writeInt32LE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 4, 2147483647, -2147483648); + this[offset2] = value & 255; + this[offset2 + 1] = value >>> 8; + this[offset2 + 2] = value >>> 16; + this[offset2 + 3] = value >>> 24; + return offset2 + 4; + }; + Buffer2.prototype.writeInt32BE = function writeInt32BE(value, offset2, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) + checkInt(this, value, offset2, 4, 2147483647, -2147483648); + if (value < 0) + value = 4294967295 + value + 1; + this[offset2] = value >>> 24; + this[offset2 + 1] = value >>> 16; + this[offset2 + 2] = value >>> 8; + this[offset2 + 3] = value & 255; + return offset2 + 4; + }; + Buffer2.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset2 = 0) { + return wrtBigUInt64LE(this, value, offset2, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); + }); + Buffer2.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset2 = 0) { + return wrtBigUInt64BE(this, value, offset2, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); + }); + function checkIEEE754(buf3, value, offset2, ext, max, min) { + if (offset2 + ext > buf3.length) + throw new RangeError("Index out of range"); + if (offset2 < 0) + throw new RangeError("Index out of range"); + } + function writeFloat(buf3, value, offset2, littleEndian, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) { + checkIEEE754(buf3, value, offset2, 4); + } + ieee754.write(buf3, value, offset2, littleEndian, 23, 4); + return offset2 + 4; + } + Buffer2.prototype.writeFloatLE = function writeFloatLE(value, offset2, noAssert) { + return writeFloat(this, value, offset2, true, noAssert); + }; + Buffer2.prototype.writeFloatBE = function writeFloatBE(value, offset2, noAssert) { + return writeFloat(this, value, offset2, false, noAssert); + }; + function writeDouble(buf3, value, offset2, littleEndian, noAssert) { + value = +value; + offset2 = offset2 >>> 0; + if (!noAssert) { + checkIEEE754(buf3, value, offset2, 8); + } + ieee754.write(buf3, value, offset2, littleEndian, 52, 8); + return offset2 + 8; + } + Buffer2.prototype.writeDoubleLE = function writeDoubleLE(value, offset2, noAssert) { + return writeDouble(this, value, offset2, true, noAssert); + }; + Buffer2.prototype.writeDoubleBE = function writeDoubleBE(value, offset2, noAssert) { + return writeDouble(this, value, offset2, false, noAssert); + }; + Buffer2.prototype.copy = function copy(target, targetStart, start, end) { + if (!Buffer2.isBuffer(target)) + throw new TypeError("argument should be a Buffer"); + if (!start) + start = 0; + if (!end && end !== 0) + end = this.length; + if (targetStart >= target.length) + targetStart = target.length; + if (!targetStart) + targetStart = 0; + if (end > 0 && end < start) + end = start; + if (end === start) + return 0; + if (target.length === 0 || this.length === 0) + return 0; + if (targetStart < 0) { + throw new RangeError("targetStart out of bounds"); + } + if (start < 0 || start >= this.length) + throw new RangeError("Index out of range"); + if (end < 0) + throw new RangeError("sourceEnd out of bounds"); + if (end > this.length) + end = this.length; + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start; + } + const len = end - start; + if (this === target && typeof Uint8Array.prototype.copyWithin === "function") { + this.copyWithin(targetStart, start, end); + } else { + Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart); + } + return len; + }; + Buffer2.prototype.fill = function fill(val, start, end, encoding) { + if (typeof val === "string") { + if (typeof start === "string") { + encoding = start; + start = 0; + end = this.length; + } else if (typeof end === "string") { + encoding = end; + end = this.length; + } + if (encoding !== void 0 && typeof encoding !== "string") { + throw new TypeError("encoding must be a string"); + } + if (typeof encoding === "string" && !Buffer2.isEncoding(encoding)) { + throw new TypeError("Unknown encoding: " + encoding); + } + if (val.length === 1) { + const code15 = val.charCodeAt(0); + if (encoding === "utf8" && code15 < 128 || encoding === "latin1") { + val = code15; + } + } + } else if (typeof val === "number") { + val = val & 255; + } else if (typeof val === "boolean") { + val = Number(val); + } + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError("Out of range index"); + } + if (end <= start) { + return this; + } + start = start >>> 0; + end = end === void 0 ? this.length : end >>> 0; + if (!val) + val = 0; + let i8; + if (typeof val === "number") { + for (i8 = start; i8 < end; ++i8) { + this[i8] = val; + } + } else { + const bytes2 = Buffer2.isBuffer(val) ? val : Buffer2.from(val, encoding); + const len = bytes2.length; + if (len === 0) { + throw new TypeError('The value "' + val + '" is invalid for argument "value"'); + } + for (i8 = 0; i8 < end - start; ++i8) { + this[i8 + start] = bytes2[i8 % len]; + } + } + return this; + }; + const errors = {}; + function E5(sym, getMessage, Base2) { + errors[sym] = class NodeError extends Base2 { + constructor() { + super(); + Object.defineProperty(this, "message", { + value: getMessage.apply(this, arguments), + writable: true, + configurable: true + }); + this.name = `${this.name} [${sym}]`; + this.stack; + delete this.name; + } + get code() { + return sym; + } + set code(value) { + Object.defineProperty(this, "code", { + configurable: true, + enumerable: true, + value, + writable: true + }); + } + toString() { + return `${this.name} [${sym}]: ${this.message}`; + } + }; + } + E5("ERR_BUFFER_OUT_OF_BOUNDS", function(name15) { + if (name15) { + return `${name15} is outside of buffer bounds`; + } + return "Attempt to access memory outside buffer bounds"; + }, RangeError); + E5("ERR_INVALID_ARG_TYPE", function(name15, actual) { + return `The "${name15}" argument must be of type number. Received type ${typeof actual}`; + }, TypeError); + E5("ERR_OUT_OF_RANGE", function(str, range, input) { + let msg = `The value of "${str}" is out of range.`; + let received = input; + if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) { + received = addNumericalSeparator(String(input)); + } else if (typeof input === "bigint") { + received = String(input); + if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) { + received = addNumericalSeparator(received); + } + received += "n"; + } + msg += ` It must be ${range}. Received ${received}`; + return msg; + }, RangeError); + function addNumericalSeparator(val) { + let res = ""; + let i8 = val.length; + const start = val[0] === "-" ? 1 : 0; + for (; i8 >= start + 4; i8 -= 3) { + res = `_${val.slice(i8 - 3, i8)}${res}`; + } + return `${val.slice(0, i8)}${res}`; + } + function checkBounds(buf3, offset2, byteLength2) { + validateNumber(offset2, "offset"); + if (buf3[offset2] === void 0 || buf3[offset2 + byteLength2] === void 0) { + boundsError(offset2, buf3.length - (byteLength2 + 1)); + } + } + function checkIntBI(value, min, max, buf3, offset2, byteLength2) { + if (value > max || value < min) { + const n9 = typeof min === "bigint" ? "n" : ""; + let range; + if (byteLength2 > 3) { + if (min === 0 || min === BigInt(0)) { + range = `>= 0${n9} and < 2${n9} ** ${(byteLength2 + 1) * 8}${n9}`; + } else { + range = `>= -(2${n9} ** ${(byteLength2 + 1) * 8 - 1}${n9}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n9}`; + } + } else { + range = `>= ${min}${n9} and <= ${max}${n9}`; + } + throw new errors.ERR_OUT_OF_RANGE("value", range, value); + } + checkBounds(buf3, offset2, byteLength2); + } + function validateNumber(value, name15) { + if (typeof value !== "number") { + throw new errors.ERR_INVALID_ARG_TYPE(name15, "number", value); + } + } + function boundsError(value, length3, type3) { + if (Math.floor(value) !== value) { + validateNumber(value, type3); + throw new errors.ERR_OUT_OF_RANGE(type3 || "offset", "an integer", value); + } + if (length3 < 0) { + throw new errors.ERR_BUFFER_OUT_OF_BOUNDS(); + } + throw new errors.ERR_OUT_OF_RANGE(type3 || "offset", `>= ${type3 ? 1 : 0} and <= ${length3}`, value); + } + const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; + function base64clean(str) { + str = str.split("=")[0]; + str = str.trim().replace(INVALID_BASE64_RE, ""); + if (str.length < 2) + return ""; + while (str.length % 4 !== 0) { + str = str + "="; + } + return str; + } + function utf8ToBytes3(string4, units) { + units = units || Infinity; + let codePoint; + const length3 = string4.length; + let leadSurrogate = null; + const bytes2 = []; + for (let i8 = 0; i8 < length3; ++i8) { + codePoint = string4.charCodeAt(i8); + if (codePoint > 55295 && codePoint < 57344) { + if (!leadSurrogate) { + if (codePoint > 56319) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + continue; + } else if (i8 + 1 === length3) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + continue; + } + leadSurrogate = codePoint; + continue; + } + if (codePoint < 56320) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + leadSurrogate = codePoint; + continue; + } + codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536; + } else if (leadSurrogate) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + } + leadSurrogate = null; + if (codePoint < 128) { + if ((units -= 1) < 0) + break; + bytes2.push(codePoint); + } else if (codePoint < 2048) { + if ((units -= 2) < 0) + break; + bytes2.push(codePoint >> 6 | 192, codePoint & 63 | 128); + } else if (codePoint < 65536) { + if ((units -= 3) < 0) + break; + bytes2.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128); + } else if (codePoint < 1114112) { + if ((units -= 4) < 0) + break; + bytes2.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128); + } else { + throw new Error("Invalid code point"); + } + } + return bytes2; + } + function asciiToBytes(str) { + const byteArray = []; + for (let i8 = 0; i8 < str.length; ++i8) { + byteArray.push(str.charCodeAt(i8) & 255); + } + return byteArray; + } + function utf16leToBytes(str, units) { + let c8, hi, lo; + const byteArray = []; + for (let i8 = 0; i8 < str.length; ++i8) { + if ((units -= 2) < 0) + break; + c8 = str.charCodeAt(i8); + hi = c8 >> 8; + lo = c8 % 256; + byteArray.push(lo); + byteArray.push(hi); + } + return byteArray; + } + function base64ToBytes(str) { + return base643.toByteArray(base64clean(str)); + } + function blitBuffer(src3, dst, offset2, length3) { + let i8; + for (i8 = 0; i8 < length3; ++i8) { + if (i8 + offset2 >= dst.length || i8 >= src3.length) + break; + dst[i8 + offset2] = src3[i8]; + } + return i8; + } + function isInstance(obj, type3) { + return obj instanceof type3 || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type3.name; + } + function numberIsNaN(obj) { + return obj !== obj; + } + const hexSliceLookupTable = function() { + const alphabet2 = "0123456789abcdef"; + const table = new Array(256); + for (let i8 = 0; i8 < 16; ++i8) { + const i16 = i8 * 16; + for (let j5 = 0; j5 < 16; ++j5) { + table[i16 + j5] = alphabet2[i8] + alphabet2[j5]; + } + } + return table; + }(); + function defineBigIntMethod(fn) { + return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn; + } + function BufferBigIntNotDefined() { + throw new Error("BigInt not supported"); + } + return exports$g; + } + function dew$f() { + if (_dewExec$f) + return exports$f; + _dewExec$f = true; + if (typeof Object.create === "function") { + exports$f = function inherits3(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + } + }; + } else { + exports$f = function inherits3(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + }; + } + return exports$f; + } + function dew$e() { + if (_dewExec$e) + return exports$e; + _dewExec$e = true; + exports$e = y.EventEmitter; + return exports$e; + } + function dew$d() { + if (_dewExec$d) + return exports$d; + _dewExec$d = true; + function ownKeys(object, enumerableOnly) { + var keys2 = Object.keys(object); + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) + symbols = symbols.filter(function(sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys2.push.apply(keys2, symbols); + } + return keys2; + } + function _objectSpread(target) { + for (var i8 = 1; i8 < arguments.length; i8++) { + var source = arguments[i8] != null ? arguments[i8] : {}; + if (i8 % 2) { + ownKeys(Object(source), true).forEach(function(key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function(key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + return target; + } + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; + } + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + function _defineProperties(target, props) { + for (var i8 = 0; i8 < props.length; i8++) { + var descriptor = props[i8]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) + descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) + _defineProperties(Constructor.prototype, protoProps); + if (staticProps) + _defineProperties(Constructor, staticProps); + return Constructor; + } + var _require = buffer3, Buffer2 = _require.Buffer; + var _require2 = X, inspect3 = _require2.inspect; + var custom2 = inspect3 && inspect3.custom || "inspect"; + function copyBuffer(src3, target, offset2) { + Buffer2.prototype.copy.call(src3, target, offset2); + } + exports$d = /* @__PURE__ */ function() { + function BufferList() { + _classCallCheck(this, BufferList); + this.head = null; + this.tail = null; + this.length = 0; + } + _createClass(BufferList, [{ + key: "push", + value: function push2(v7) { + var entry = { + data: v7, + next: null + }; + if (this.length > 0) + this.tail.next = entry; + else + this.head = entry; + this.tail = entry; + ++this.length; + } + }, { + key: "unshift", + value: function unshift(v7) { + var entry = { + data: v7, + next: this.head + }; + if (this.length === 0) + this.tail = entry; + this.head = entry; + ++this.length; + } + }, { + key: "shift", + value: function shift() { + if (this.length === 0) + return; + var ret = this.head.data; + if (this.length === 1) + this.head = this.tail = null; + else + this.head = this.head.next; + --this.length; + return ret; + } + }, { + key: "clear", + value: function clear() { + this.head = this.tail = null; + this.length = 0; + } + }, { + key: "join", + value: function join3(s7) { + if (this.length === 0) + return ""; + var p8 = this.head; + var ret = "" + p8.data; + while (p8 = p8.next) { + ret += s7 + p8.data; + } + return ret; + } + }, { + key: "concat", + value: function concat6(n9) { + if (this.length === 0) + return Buffer2.alloc(0); + var ret = Buffer2.allocUnsafe(n9 >>> 0); + var p8 = this.head; + var i8 = 0; + while (p8) { + copyBuffer(p8.data, ret, i8); + i8 += p8.data.length; + p8 = p8.next; + } + return ret; + } + // Consumes a specified amount of bytes or characters from the buffered data. + }, { + key: "consume", + value: function consume(n9, hasStrings) { + var ret; + if (n9 < this.head.data.length) { + ret = this.head.data.slice(0, n9); + this.head.data = this.head.data.slice(n9); + } else if (n9 === this.head.data.length) { + ret = this.shift(); + } else { + ret = hasStrings ? this._getString(n9) : this._getBuffer(n9); + } + return ret; + } + }, { + key: "first", + value: function first() { + return this.head.data; + } + // Consumes a specified amount of characters from the buffered data. + }, { + key: "_getString", + value: function _getString(n9) { + var p8 = this.head; + var c8 = 1; + var ret = p8.data; + n9 -= ret.length; + while (p8 = p8.next) { + var str = p8.data; + var nb = n9 > str.length ? str.length : n9; + if (nb === str.length) + ret += str; + else + ret += str.slice(0, n9); + n9 -= nb; + if (n9 === 0) { + if (nb === str.length) { + ++c8; + if (p8.next) + this.head = p8.next; + else + this.head = this.tail = null; + } else { + this.head = p8; + p8.data = str.slice(nb); + } + break; + } + ++c8; + } + this.length -= c8; + return ret; + } + // Consumes a specified amount of bytes from the buffered data. + }, { + key: "_getBuffer", + value: function _getBuffer(n9) { + var ret = Buffer2.allocUnsafe(n9); + var p8 = this.head; + var c8 = 1; + p8.data.copy(ret); + n9 -= p8.data.length; + while (p8 = p8.next) { + var buf3 = p8.data; + var nb = n9 > buf3.length ? buf3.length : n9; + buf3.copy(ret, ret.length - n9, 0, nb); + n9 -= nb; + if (n9 === 0) { + if (nb === buf3.length) { + ++c8; + if (p8.next) + this.head = p8.next; + else + this.head = this.tail = null; + } else { + this.head = p8; + p8.data = buf3.slice(nb); + } + break; + } + ++c8; + } + this.length -= c8; + return ret; + } + // Make sure the linked list only shows the minimal necessary information. + }, { + key: custom2, + value: function value(_5, options) { + return inspect3(this, _objectSpread({}, options, { + // Only inspect one level. + depth: 0, + // It should not recurse. + customInspect: false + })); + } + }]); + return BufferList; + }(); + return exports$d; + } + function dew$c() { + if (_dewExec$c) + return exports$c; + _dewExec$c = true; + var process$1 = process2; + function destroy(err, cb) { + var _this = this; + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err) { + if (!this._writableState) { + process$1.nextTick(emitErrorNT, this, err); + } else if (!this._writableState.errorEmitted) { + this._writableState.errorEmitted = true; + process$1.nextTick(emitErrorNT, this, err); + } + } + return this; + } + if (this._readableState) { + this._readableState.destroyed = true; + } + if (this._writableState) { + this._writableState.destroyed = true; + } + this._destroy(err || null, function(err2) { + if (!cb && err2) { + if (!_this._writableState) { + process$1.nextTick(emitErrorAndCloseNT, _this, err2); + } else if (!_this._writableState.errorEmitted) { + _this._writableState.errorEmitted = true; + process$1.nextTick(emitErrorAndCloseNT, _this, err2); + } else { + process$1.nextTick(emitCloseNT, _this); + } + } else if (cb) { + process$1.nextTick(emitCloseNT, _this); + cb(err2); + } else { + process$1.nextTick(emitCloseNT, _this); + } + }); + return this; + } + function emitErrorAndCloseNT(self2, err) { + emitErrorNT(self2, err); + emitCloseNT(self2); + } + function emitCloseNT(self2) { + if (self2._writableState && !self2._writableState.emitClose) + return; + if (self2._readableState && !self2._readableState.emitClose) + return; + self2.emit("close"); + } + function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } + } + function emitErrorNT(self2, err) { + self2.emit("error", err); + } + function errorOrDestroy(stream2, err) { + var rState = stream2._readableState; + var wState = stream2._writableState; + if (rState && rState.autoDestroy || wState && wState.autoDestroy) + stream2.destroy(err); + else + stream2.emit("error", err); + } + exports$c = { + destroy, + undestroy, + errorOrDestroy + }; + return exports$c; + } + function dew$b() { + if (_dewExec$b) + return exports$b; + _dewExec$b = true; + const codes = {}; + function createErrorType(code15, message2, Base2) { + if (!Base2) { + Base2 = Error; + } + function getMessage(arg1, arg2, arg3) { + if (typeof message2 === "string") { + return message2; + } else { + return message2(arg1, arg2, arg3); + } + } + class NodeError extends Base2 { + constructor(arg1, arg2, arg3) { + super(getMessage(arg1, arg2, arg3)); + } + } + NodeError.prototype.name = Base2.name; + NodeError.prototype.code = code15; + codes[code15] = NodeError; + } + function oneOf(expected, thing) { + if (Array.isArray(expected)) { + const len = expected.length; + expected = expected.map((i8) => String(i8)); + if (len > 2) { + return `one of ${thing} ${expected.slice(0, len - 1).join(", ")}, or ` + expected[len - 1]; + } else if (len === 2) { + return `one of ${thing} ${expected[0]} or ${expected[1]}`; + } else { + return `of ${thing} ${expected[0]}`; + } + } else { + return `of ${thing} ${String(expected)}`; + } + } + function startsWith3(str, search, pos) { + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; + } + function endsWith3(str, search, this_len) { + if (this_len === void 0 || this_len > str.length) { + this_len = str.length; + } + return str.substring(this_len - search.length, this_len) === search; + } + function includes(str, search, start) { + if (typeof start !== "number") { + start = 0; + } + if (start + search.length > str.length) { + return false; + } else { + return str.indexOf(search, start) !== -1; + } + } + createErrorType("ERR_INVALID_OPT_VALUE", function(name15, value) { + return 'The value "' + value + '" is invalid for option "' + name15 + '"'; + }, TypeError); + createErrorType("ERR_INVALID_ARG_TYPE", function(name15, expected, actual) { + let determiner; + if (typeof expected === "string" && startsWith3(expected, "not ")) { + determiner = "must not be"; + expected = expected.replace(/^not /, ""); + } else { + determiner = "must be"; + } + let msg; + if (endsWith3(name15, " argument")) { + msg = `The ${name15} ${determiner} ${oneOf(expected, "type")}`; + } else { + const type3 = includes(name15, ".") ? "property" : "argument"; + msg = `The "${name15}" ${type3} ${determiner} ${oneOf(expected, "type")}`; + } + msg += `. Received type ${typeof actual}`; + return msg; + }, TypeError); + createErrorType("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF"); + createErrorType("ERR_METHOD_NOT_IMPLEMENTED", function(name15) { + return "The " + name15 + " method is not implemented"; + }); + createErrorType("ERR_STREAM_PREMATURE_CLOSE", "Premature close"); + createErrorType("ERR_STREAM_DESTROYED", function(name15) { + return "Cannot call " + name15 + " after a stream was destroyed"; + }); + createErrorType("ERR_MULTIPLE_CALLBACK", "Callback called multiple times"); + createErrorType("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable"); + createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end"); + createErrorType("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError); + createErrorType("ERR_UNKNOWN_ENCODING", function(arg) { + return "Unknown encoding: " + arg; + }, TypeError); + createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event"); + exports$b.codes = codes; + return exports$b; + } + function dew$a() { + if (_dewExec$a) + return exports$a; + _dewExec$a = true; + var ERR_INVALID_OPT_VALUE = dew$b().codes.ERR_INVALID_OPT_VALUE; + function highWaterMarkFrom(options, isDuplex2, duplexKey) { + return options.highWaterMark != null ? options.highWaterMark : isDuplex2 ? options[duplexKey] : null; + } + function getHighWaterMark(state, options, duplexKey, isDuplex2) { + var hwm = highWaterMarkFrom(options, isDuplex2, duplexKey); + if (hwm != null) { + if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { + var name15 = isDuplex2 ? duplexKey : "highWaterMark"; + throw new ERR_INVALID_OPT_VALUE(name15, hwm); + } + return Math.floor(hwm); + } + return state.objectMode ? 16 : 16 * 1024; + } + exports$a = { + getHighWaterMark + }; + return exports$a; + } + function dew$9() { + if (_dewExec$9) + return exports$9; + _dewExec$9 = true; + exports$9 = deprecate3; + function deprecate3(fn, msg) { + if (config2("noDeprecation")) { + return fn; + } + var warned = false; + function deprecated() { + if (!warned) { + if (config2("throwDeprecation")) { + throw new Error(msg); + } else if (config2("traceDeprecation")) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; + } + return fn.apply(this || _global$2, arguments); + } + return deprecated; + } + function config2(name15) { + try { + if (!_global$2.localStorage) + return false; + } catch (_5) { + return false; + } + var val = _global$2.localStorage[name15]; + if (null == val) + return false; + return String(val).toLowerCase() === "true"; + } + return exports$9; + } + function dew$8() { + if (_dewExec$8) + return exports$8; + _dewExec$8 = true; + var process$1 = process2; + exports$8 = Writable2; + function CorkedRequest(state) { + var _this = this; + this.next = null; + this.entry = null; + this.finish = function() { + onCorkedFinish(_this, state); + }; + } + var Duplex2; + Writable2.WritableState = WritableState; + var internalUtil = { + deprecate: dew$9() + }; + var Stream2 = dew$e(); + var Buffer2 = buffer3.Buffer; + var OurUint8Array = _global$1.Uint8Array || function() { + }; + function _uint8ArrayToBuffer(chunk) { + return Buffer2.from(chunk); + } + function _isUint8Array(obj) { + return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array; + } + var destroyImpl = dew$c(); + var _require = dew$a(), getHighWaterMark = _require.getHighWaterMark; + var _require$codes = dew$b().codes, ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; + var errorOrDestroy = destroyImpl.errorOrDestroy; + dew$f()(Writable2, Stream2); + function nop() { + } + function WritableState(options, stream2, isDuplex2) { + Duplex2 = Duplex2 || dew$7(); + options = options || {}; + if (typeof isDuplex2 !== "boolean") + isDuplex2 = stream2 instanceof Duplex2; + this.objectMode = !!options.objectMode; + if (isDuplex2) + this.objectMode = this.objectMode || !!options.writableObjectMode; + this.highWaterMark = getHighWaterMark(this, options, "writableHighWaterMark", isDuplex2); + this.finalCalled = false; + this.needDrain = false; + this.ending = false; + this.ended = false; + this.finished = false; + this.destroyed = false; + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + this.defaultEncoding = options.defaultEncoding || "utf8"; + this.length = 0; + this.writing = false; + this.corked = 0; + this.sync = true; + this.bufferProcessing = false; + this.onwrite = function(er) { + onwrite(stream2, er); + }; + this.writecb = null; + this.writelen = 0; + this.bufferedRequest = null; + this.lastBufferedRequest = null; + this.pendingcb = 0; + this.prefinished = false; + this.errorEmitted = false; + this.emitClose = options.emitClose !== false; + this.autoDestroy = !!options.autoDestroy; + this.bufferedRequestCount = 0; + this.corkedRequestsFree = new CorkedRequest(this); + } + WritableState.prototype.getBuffer = function getBuffer() { + var current2 = this.bufferedRequest; + var out = []; + while (current2) { + out.push(current2); + current2 = current2.next; + } + return out; + }; + (function() { + try { + Object.defineProperty(WritableState.prototype, "buffer", { + get: internalUtil.deprecate(function writableStateBufferGetter() { + return this.getBuffer(); + }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003") + }); + } catch (_5) { + } + })(); + var realHasInstance; + if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable2, Symbol.hasInstance, { + value: function value(object) { + if (realHasInstance.call(this, object)) + return true; + if (this !== Writable2) + return false; + return object && object._writableState instanceof WritableState; + } + }); + } else { + realHasInstance = function realHasInstance2(object) { + return object instanceof this; + }; + } + function Writable2(options) { + Duplex2 = Duplex2 || dew$7(); + var isDuplex2 = this instanceof Duplex2; + if (!isDuplex2 && !realHasInstance.call(Writable2, this)) + return new Writable2(options); + this._writableState = new WritableState(options, this, isDuplex2); + this.writable = true; + if (options) { + if (typeof options.write === "function") + this._write = options.write; + if (typeof options.writev === "function") + this._writev = options.writev; + if (typeof options.destroy === "function") + this._destroy = options.destroy; + if (typeof options.final === "function") + this._final = options.final; + } + Stream2.call(this); + } + Writable2.prototype.pipe = function() { + errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); + }; + function writeAfterEnd(stream2, cb) { + var er = new ERR_STREAM_WRITE_AFTER_END(); + errorOrDestroy(stream2, er); + process$1.nextTick(cb, er); + } + function validChunk(stream2, state, chunk, cb) { + var er; + if (chunk === null) { + er = new ERR_STREAM_NULL_VALUES(); + } else if (typeof chunk !== "string" && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer"], chunk); + } + if (er) { + errorOrDestroy(stream2, er); + process$1.nextTick(cb, er); + return false; + } + return true; + } + Writable2.prototype.write = function(chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); + if (isBuf && !Buffer2.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + if (typeof encoding === "function") { + cb = encoding; + encoding = null; + } + if (isBuf) + encoding = "buffer"; + else if (!encoding) + encoding = state.defaultEncoding; + if (typeof cb !== "function") + cb = nop; + if (state.ending) + writeAfterEnd(this, cb); + else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } + return ret; + }; + Writable2.prototype.cork = function() { + this._writableState.corked++; + }; + Writable2.prototype.uncork = function() { + var state = this._writableState; + if (state.corked) { + state.corked--; + if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) + clearBuffer(this, state); + } + }; + Writable2.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + if (typeof encoding === "string") + encoding = encoding.toLowerCase(); + if (!(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((encoding + "").toLowerCase()) > -1)) + throw new ERR_UNKNOWN_ENCODING(encoding); + this._writableState.defaultEncoding = encoding; + return this; + }; + Object.defineProperty(Writable2.prototype, "writableBuffer", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState && this._writableState.getBuffer(); + } + }); + function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") { + chunk = Buffer2.from(chunk, encoding); + } + return chunk; + } + Object.defineProperty(Writable2.prototype, "writableHighWaterMark", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState.highWaterMark; + } + }); + function writeOrBuffer(stream2, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = "buffer"; + chunk = newChunk; + } + } + var len = state.objectMode ? 1 : chunk.length; + state.length += len; + var ret = state.length < state.highWaterMark; + if (!ret) + state.needDrain = true; + if (state.writing || state.corked) { + var last2 = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk, + encoding, + isBuf, + callback: cb, + next: null + }; + if (last2) { + last2.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream2, state, false, len, chunk, encoding, cb); + } + return ret; + } + function doWrite(stream2, state, writev2, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (state.destroyed) + state.onwrite(new ERR_STREAM_DESTROYED("write")); + else if (writev2) + stream2._writev(chunk, state.onwrite); + else + stream2._write(chunk, encoding, state.onwrite); + state.sync = false; + } + function onwriteError(stream2, state, sync, er, cb) { + --state.pendingcb; + if (sync) { + process$1.nextTick(cb, er); + process$1.nextTick(finishMaybe, stream2, state); + stream2._writableState.errorEmitted = true; + errorOrDestroy(stream2, er); + } else { + cb(er); + stream2._writableState.errorEmitted = true; + errorOrDestroy(stream2, er); + finishMaybe(stream2, state); + } + } + function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; + } + function onwrite(stream2, er) { + var state = stream2._writableState; + var sync = state.sync; + var cb = state.writecb; + if (typeof cb !== "function") + throw new ERR_MULTIPLE_CALLBACK(); + onwriteStateUpdate(state); + if (er) + onwriteError(stream2, state, sync, er, cb); + else { + var finished2 = needFinish(state) || stream2.destroyed; + if (!finished2 && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream2, state); + } + if (sync) { + process$1.nextTick(afterWrite, stream2, state, finished2, cb); + } else { + afterWrite(stream2, state, finished2, cb); + } + } + } + function afterWrite(stream2, state, finished2, cb) { + if (!finished2) + onwriteDrain(stream2, state); + state.pendingcb--; + cb(); + finishMaybe(stream2, state); + } + function onwriteDrain(stream2, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream2.emit("drain"); + } + } + function clearBuffer(stream2, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + if (stream2._writev && entry && entry.next) { + var l8 = state.bufferedRequestCount; + var buffer4 = new Array(l8); + var holder = state.corkedRequestsFree; + holder.entry = entry; + var count = 0; + var allBuffers = true; + while (entry) { + buffer4[count] = entry; + if (!entry.isBuf) + allBuffers = false; + entry = entry.next; + count += 1; + } + buffer4.allBuffers = allBuffers; + doWrite(stream2, state, true, state.length, buffer4, "", holder.finish); + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + state.bufferedRequestCount = 0; + } else { + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + doWrite(stream2, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; + if (state.writing) { + break; + } + } + if (entry === null) + state.lastBufferedRequest = null; + } + state.bufferedRequest = entry; + state.bufferProcessing = false; + } + Writable2.prototype._write = function(chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED("_write()")); + }; + Writable2.prototype._writev = null; + Writable2.prototype.end = function(chunk, encoding, cb) { + var state = this._writableState; + if (typeof chunk === "function") { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === "function") { + cb = encoding; + encoding = null; + } + if (chunk !== null && chunk !== void 0) + this.write(chunk, encoding); + if (state.corked) { + state.corked = 1; + this.uncork(); + } + if (!state.ending) + endWritable(this, state, cb); + return this; + }; + Object.defineProperty(Writable2.prototype, "writableLength", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState.length; + } + }); + function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; + } + function callFinal(stream2, state) { + stream2._final(function(err) { + state.pendingcb--; + if (err) { + errorOrDestroy(stream2, err); + } + state.prefinished = true; + stream2.emit("prefinish"); + finishMaybe(stream2, state); + }); + } + function prefinish(stream2, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream2._final === "function" && !state.destroyed) { + state.pendingcb++; + state.finalCalled = true; + process$1.nextTick(callFinal, stream2, state); + } else { + state.prefinished = true; + stream2.emit("prefinish"); + } + } + } + function finishMaybe(stream2, state) { + var need = needFinish(state); + if (need) { + prefinish(stream2, state); + if (state.pendingcb === 0) { + state.finished = true; + stream2.emit("finish"); + if (state.autoDestroy) { + var rState = stream2._readableState; + if (!rState || rState.autoDestroy && rState.endEmitted) { + stream2.destroy(); + } + } + } + } + return need; + } + function endWritable(stream2, state, cb) { + state.ending = true; + finishMaybe(stream2, state); + if (cb) { + if (state.finished) + process$1.nextTick(cb); + else + stream2.once("finish", cb); + } + state.ended = true; + stream2.writable = false; + } + function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + state.corkedRequestsFree.next = corkReq; + } + Object.defineProperty(Writable2.prototype, "destroyed", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + if (this._writableState === void 0) { + return false; + } + return this._writableState.destroyed; + }, + set: function set5(value) { + if (!this._writableState) { + return; + } + this._writableState.destroyed = value; + } + }); + Writable2.prototype.destroy = destroyImpl.destroy; + Writable2.prototype._undestroy = destroyImpl.undestroy; + Writable2.prototype._destroy = function(err, cb) { + cb(err); + }; + return exports$8; + } + function dew$7() { + if (_dewExec$7) + return exports$7; + _dewExec$7 = true; + var process$1 = process2; + var objectKeys = Object.keys || function(obj) { + var keys3 = []; + for (var key in obj) { + keys3.push(key); + } + return keys3; + }; + exports$7 = Duplex2; + var Readable2 = dew$3(); + var Writable2 = dew$8(); + dew$f()(Duplex2, Readable2); + { + var keys2 = objectKeys(Writable2.prototype); + for (var v7 = 0; v7 < keys2.length; v7++) { + var method = keys2[v7]; + if (!Duplex2.prototype[method]) + Duplex2.prototype[method] = Writable2.prototype[method]; + } + } + function Duplex2(options) { + if (!(this instanceof Duplex2)) + return new Duplex2(options); + Readable2.call(this, options); + Writable2.call(this, options); + this.allowHalfOpen = true; + if (options) { + if (options.readable === false) + this.readable = false; + if (options.writable === false) + this.writable = false; + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once("end", onend); + } + } + } + Object.defineProperty(Duplex2.prototype, "writableHighWaterMark", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState.highWaterMark; + } + }); + Object.defineProperty(Duplex2.prototype, "writableBuffer", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState && this._writableState.getBuffer(); + } + }); + Object.defineProperty(Duplex2.prototype, "writableLength", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState.length; + } + }); + function onend() { + if (this._writableState.ended) + return; + process$1.nextTick(onEndNT, this); + } + function onEndNT(self2) { + self2.end(); + } + Object.defineProperty(Duplex2.prototype, "destroyed", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + if (this._readableState === void 0 || this._writableState === void 0) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function set5(value) { + if (this._readableState === void 0 || this._writableState === void 0) { + return; + } + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } + }); + return exports$7; + } + function dew$6() { + if (_dewExec$6) + return exports$6; + _dewExec$6 = true; + var ERR_STREAM_PREMATURE_CLOSE = dew$b().codes.ERR_STREAM_PREMATURE_CLOSE; + function once2(callback) { + var called = false; + return function() { + if (called) + return; + called = true; + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + callback.apply(this, args); + }; + } + function noop2() { + } + function isRequest(stream2) { + return stream2.setHeader && typeof stream2.abort === "function"; + } + function eos(stream2, opts, callback) { + if (typeof opts === "function") + return eos(stream2, null, opts); + if (!opts) + opts = {}; + callback = once2(callback || noop2); + var readable = opts.readable || opts.readable !== false && stream2.readable; + var writable = opts.writable || opts.writable !== false && stream2.writable; + var onlegacyfinish = function onlegacyfinish2() { + if (!stream2.writable) + onfinish(); + }; + var writableEnded = stream2._writableState && stream2._writableState.finished; + var onfinish = function onfinish2() { + writable = false; + writableEnded = true; + if (!readable) + callback.call(stream2); + }; + var readableEnded = stream2._readableState && stream2._readableState.endEmitted; + var onend = function onend2() { + readable = false; + readableEnded = true; + if (!writable) + callback.call(stream2); + }; + var onerror = function onerror2(err) { + callback.call(stream2, err); + }; + var onclose = function onclose2() { + var err; + if (readable && !readableEnded) { + if (!stream2._readableState || !stream2._readableState.ended) + err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream2, err); + } + if (writable && !writableEnded) { + if (!stream2._writableState || !stream2._writableState.ended) + err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream2, err); + } + }; + var onrequest = function onrequest2() { + stream2.req.on("finish", onfinish); + }; + if (isRequest(stream2)) { + stream2.on("complete", onfinish); + stream2.on("abort", onclose); + if (stream2.req) + onrequest(); + else + stream2.on("request", onrequest); + } else if (writable && !stream2._writableState) { + stream2.on("end", onlegacyfinish); + stream2.on("close", onlegacyfinish); + } + stream2.on("end", onend); + stream2.on("finish", onfinish); + if (opts.error !== false) + stream2.on("error", onerror); + stream2.on("close", onclose); + return function() { + stream2.removeListener("complete", onfinish); + stream2.removeListener("abort", onclose); + stream2.removeListener("request", onrequest); + if (stream2.req) + stream2.req.removeListener("finish", onfinish); + stream2.removeListener("end", onlegacyfinish); + stream2.removeListener("close", onlegacyfinish); + stream2.removeListener("finish", onfinish); + stream2.removeListener("end", onend); + stream2.removeListener("error", onerror); + stream2.removeListener("close", onclose); + }; + } + exports$6 = eos; + return exports$6; + } + function dew$5() { + if (_dewExec$5) + return exports$5; + _dewExec$5 = true; + var process$1 = process2; + var _Object$setPrototypeO; + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; + } + var finished2 = dew$6(); + var kLastResolve = Symbol("lastResolve"); + var kLastReject = Symbol("lastReject"); + var kError = Symbol("error"); + var kEnded = Symbol("ended"); + var kLastPromise = Symbol("lastPromise"); + var kHandlePromise = Symbol("handlePromise"); + var kStream = Symbol("stream"); + function createIterResult2(value, done) { + return { + value, + done + }; + } + function readAndResolve(iter) { + var resolve7 = iter[kLastResolve]; + if (resolve7 !== null) { + var data = iter[kStream].read(); + if (data !== null) { + iter[kLastPromise] = null; + iter[kLastResolve] = null; + iter[kLastReject] = null; + resolve7(createIterResult2(data, false)); + } + } + } + function onReadable(iter) { + process$1.nextTick(readAndResolve, iter); + } + function wrapForNext(lastPromise, iter) { + return function(resolve7, reject) { + lastPromise.then(function() { + if (iter[kEnded]) { + resolve7(createIterResult2(void 0, true)); + return; + } + iter[kHandlePromise](resolve7, reject); + }, reject); + }; + } + var AsyncIteratorPrototype = Object.getPrototypeOf(function() { + }); + var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { + get stream() { + return this[kStream]; + }, + next: function next() { + var _this = this; + var error7 = this[kError]; + if (error7 !== null) { + return Promise.reject(error7); + } + if (this[kEnded]) { + return Promise.resolve(createIterResult2(void 0, true)); + } + if (this[kStream].destroyed) { + return new Promise(function(resolve7, reject) { + process$1.nextTick(function() { + if (_this[kError]) { + reject(_this[kError]); + } else { + resolve7(createIterResult2(void 0, true)); + } + }); + }); + } + var lastPromise = this[kLastPromise]; + var promise; + if (lastPromise) { + promise = new Promise(wrapForNext(lastPromise, this)); + } else { + var data = this[kStream].read(); + if (data !== null) { + return Promise.resolve(createIterResult2(data, false)); + } + promise = new Promise(this[kHandlePromise]); + } + this[kLastPromise] = promise; + return promise; + } + }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function() { + return this; + }), _defineProperty(_Object$setPrototypeO, "return", function _return() { + var _this2 = this; + return new Promise(function(resolve7, reject) { + _this2[kStream].destroy(null, function(err) { + if (err) { + reject(err); + return; + } + resolve7(createIterResult2(void 0, true)); + }); + }); + }), _Object$setPrototypeO), AsyncIteratorPrototype); + var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator2(stream2) { + var _Object$create; + var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { + value: stream2, + writable: true + }), _defineProperty(_Object$create, kLastResolve, { + value: null, + writable: true + }), _defineProperty(_Object$create, kLastReject, { + value: null, + writable: true + }), _defineProperty(_Object$create, kError, { + value: null, + writable: true + }), _defineProperty(_Object$create, kEnded, { + value: stream2._readableState.endEmitted, + writable: true + }), _defineProperty(_Object$create, kHandlePromise, { + value: function value(resolve7, reject) { + var data = iterator[kStream].read(); + if (data) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve7(createIterResult2(data, false)); + } else { + iterator[kLastResolve] = resolve7; + iterator[kLastReject] = reject; + } + }, + writable: true + }), _Object$create)); + iterator[kLastPromise] = null; + finished2(stream2, function(err) { + if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") { + var reject = iterator[kLastReject]; + if (reject !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + reject(err); + } + iterator[kError] = err; + return; + } + var resolve7 = iterator[kLastResolve]; + if (resolve7 !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve7(createIterResult2(void 0, true)); + } + iterator[kEnded] = true; + }); + stream2.on("readable", onReadable.bind(null, iterator)); + return iterator; + }; + exports$5 = createReadableStreamAsyncIterator; + return exports$5; + } + function dew$4() { + if (_dewExec$4) + return exports$4; + _dewExec$4 = true; + exports$4 = function() { + throw new Error("Readable.from is not available in the browser"); + }; + return exports$4; + } + function dew$3() { + if (_dewExec$3) + return exports$32; + _dewExec$3 = true; + var process$1 = process2; + exports$32 = Readable2; + var Duplex2; + Readable2.ReadableState = ReadableState; + y.EventEmitter; + var EElistenerCount = function EElistenerCount2(emitter, type3) { + return emitter.listeners(type3).length; + }; + var Stream2 = dew$e(); + var Buffer2 = buffer3.Buffer; + var OurUint8Array = _global2.Uint8Array || function() { + }; + function _uint8ArrayToBuffer(chunk) { + return Buffer2.from(chunk); + } + function _isUint8Array(obj) { + return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array; + } + var debugUtil = X; + var debug; + if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog("stream"); + } else { + debug = function debug2() { + }; + } + var BufferList = dew$d(); + var destroyImpl = dew$c(); + var _require = dew$a(), getHighWaterMark = _require.getHighWaterMark; + var _require$codes = dew$b().codes, ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; + var StringDecoder; + var createReadableStreamAsyncIterator; + var from18; + dew$f()(Readable2, Stream2); + var errorOrDestroy = destroyImpl.errorOrDestroy; + var kProxyEvents = ["error", "close", "destroy", "pause", "resume"]; + function prependListener(emitter, event, fn) { + if (typeof emitter.prependListener === "function") + return emitter.prependListener(event, fn); + if (!emitter._events || !emitter._events[event]) + emitter.on(event, fn); + else if (Array.isArray(emitter._events[event])) + emitter._events[event].unshift(fn); + else + emitter._events[event] = [fn, emitter._events[event]]; + } + function ReadableState(options, stream2, isDuplex2) { + Duplex2 = Duplex2 || dew$7(); + options = options || {}; + if (typeof isDuplex2 !== "boolean") + isDuplex2 = stream2 instanceof Duplex2; + this.objectMode = !!options.objectMode; + if (isDuplex2) + this.objectMode = this.objectMode || !!options.readableObjectMode; + this.highWaterMark = getHighWaterMark(this, options, "readableHighWaterMark", isDuplex2); + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + this.sync = true; + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + this.paused = true; + this.emitClose = options.emitClose !== false; + this.autoDestroy = !!options.autoDestroy; + this.destroyed = false; + this.defaultEncoding = options.defaultEncoding || "utf8"; + this.awaitDrain = 0; + this.readingMore = false; + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) + StringDecoder = e$12.StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } + } + function Readable2(options) { + Duplex2 = Duplex2 || dew$7(); + if (!(this instanceof Readable2)) + return new Readable2(options); + var isDuplex2 = this instanceof Duplex2; + this._readableState = new ReadableState(options, this, isDuplex2); + this.readable = true; + if (options) { + if (typeof options.read === "function") + this._read = options.read; + if (typeof options.destroy === "function") + this._destroy = options.destroy; + } + Stream2.call(this); + } + Object.defineProperty(Readable2.prototype, "destroyed", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + if (this._readableState === void 0) { + return false; + } + return this._readableState.destroyed; + }, + set: function set5(value) { + if (!this._readableState) { + return; + } + this._readableState.destroyed = value; + } + }); + Readable2.prototype.destroy = destroyImpl.destroy; + Readable2.prototype._undestroy = destroyImpl.undestroy; + Readable2.prototype._destroy = function(err, cb) { + cb(err); + }; + Readable2.prototype.push = function(chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + if (!state.objectMode) { + if (typeof chunk === "string") { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer2.from(chunk, encoding); + encoding = ""; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); + }; + Readable2.prototype.unshift = function(chunk) { + return readableAddChunk(this, chunk, null, true, false); + }; + function readableAddChunk(stream2, chunk, encoding, addToFront, skipChunkCheck) { + debug("readableAddChunk", chunk); + var state = stream2._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream2, state); + } else { + var er; + if (!skipChunkCheck) + er = chunkInvalid(state, chunk); + if (er) { + errorOrDestroy(stream2, er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer2.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + if (addToFront) { + if (state.endEmitted) + errorOrDestroy(stream2, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT()); + else + addChunk(stream2, state, chunk, true); + } else if (state.ended) { + errorOrDestroy(stream2, new ERR_STREAM_PUSH_AFTER_EOF()); + } else if (state.destroyed) { + return false; + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) + addChunk(stream2, state, chunk, false); + else + maybeReadMore(stream2, state); + } else { + addChunk(stream2, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + maybeReadMore(stream2, state); + } + } + return !state.ended && (state.length < state.highWaterMark || state.length === 0); + } + function addChunk(stream2, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + state.awaitDrain = 0; + stream2.emit("data", chunk); + } else { + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) + state.buffer.unshift(chunk); + else + state.buffer.push(chunk); + if (state.needReadable) + emitReadable(stream2); + } + maybeReadMore(stream2, state); + } + function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer", "Uint8Array"], chunk); + } + return er; + } + Readable2.prototype.isPaused = function() { + return this._readableState.flowing === false; + }; + Readable2.prototype.setEncoding = function(enc) { + if (!StringDecoder) + StringDecoder = e$12.StringDecoder; + var decoder4 = new StringDecoder(enc); + this._readableState.decoder = decoder4; + this._readableState.encoding = this._readableState.decoder.encoding; + var p8 = this._readableState.buffer.head; + var content = ""; + while (p8 !== null) { + content += decoder4.write(p8.data); + p8 = p8.next; + } + this._readableState.buffer.clear(); + if (content !== "") + this._readableState.buffer.push(content); + this._readableState.length = content.length; + return this; + }; + var MAX_HWM = 1073741824; + function computeNewHighWaterMark(n9) { + if (n9 >= MAX_HWM) { + n9 = MAX_HWM; + } else { + n9--; + n9 |= n9 >>> 1; + n9 |= n9 >>> 2; + n9 |= n9 >>> 4; + n9 |= n9 >>> 8; + n9 |= n9 >>> 16; + n9++; + } + return n9; + } + function howMuchToRead(n9, state) { + if (n9 <= 0 || state.length === 0 && state.ended) + return 0; + if (state.objectMode) + return 1; + if (n9 !== n9) { + if (state.flowing && state.length) + return state.buffer.head.data.length; + else + return state.length; + } + if (n9 > state.highWaterMark) + state.highWaterMark = computeNewHighWaterMark(n9); + if (n9 <= state.length) + return n9; + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; + } + Readable2.prototype.read = function(n9) { + debug("read", n9); + n9 = parseInt(n9, 10); + var state = this._readableState; + var nOrig = n9; + if (n9 !== 0) + state.emittedReadable = false; + if (n9 === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { + debug("read: emitReadable", state.length, state.ended); + if (state.length === 0 && state.ended) + endReadable(this); + else + emitReadable(this); + return null; + } + n9 = howMuchToRead(n9, state); + if (n9 === 0 && state.ended) { + if (state.length === 0) + endReadable(this); + return null; + } + var doRead = state.needReadable; + debug("need readable", doRead); + if (state.length === 0 || state.length - n9 < state.highWaterMark) { + doRead = true; + debug("length less than watermark", doRead); + } + if (state.ended || state.reading) { + doRead = false; + debug("reading or ended", doRead); + } else if (doRead) { + debug("do read"); + state.reading = true; + state.sync = true; + if (state.length === 0) + state.needReadable = true; + this._read(state.highWaterMark); + state.sync = false; + if (!state.reading) + n9 = howMuchToRead(nOrig, state); + } + var ret; + if (n9 > 0) + ret = fromList(n9, state); + else + ret = null; + if (ret === null) { + state.needReadable = state.length <= state.highWaterMark; + n9 = 0; + } else { + state.length -= n9; + state.awaitDrain = 0; + } + if (state.length === 0) { + if (!state.ended) + state.needReadable = true; + if (nOrig !== n9 && state.ended) + endReadable(this); + } + if (ret !== null) + this.emit("data", ret); + return ret; + }; + function onEofChunk(stream2, state) { + debug("onEofChunk"); + if (state.ended) + return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + if (state.sync) { + emitReadable(stream2); + } else { + state.needReadable = false; + if (!state.emittedReadable) { + state.emittedReadable = true; + emitReadable_(stream2); + } + } + } + function emitReadable(stream2) { + var state = stream2._readableState; + debug("emitReadable", state.needReadable, state.emittedReadable); + state.needReadable = false; + if (!state.emittedReadable) { + debug("emitReadable", state.flowing); + state.emittedReadable = true; + process$1.nextTick(emitReadable_, stream2); + } + } + function emitReadable_(stream2) { + var state = stream2._readableState; + debug("emitReadable_", state.destroyed, state.length, state.ended); + if (!state.destroyed && (state.length || state.ended)) { + stream2.emit("readable"); + state.emittedReadable = false; + } + state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; + flow(stream2); + } + function maybeReadMore(stream2, state) { + if (!state.readingMore) { + state.readingMore = true; + process$1.nextTick(maybeReadMore_, stream2, state); + } + } + function maybeReadMore_(stream2, state) { + while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { + var len = state.length; + debug("maybeReadMore read 0"); + stream2.read(0); + if (len === state.length) + break; + } + state.readingMore = false; + } + Readable2.prototype._read = function(n9) { + errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED("_read()")); + }; + Readable2.prototype.pipe = function(dest, pipeOpts) { + var src3 = this; + var state = this._readableState; + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts); + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process$1.stdout && dest !== process$1.stderr; + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) + process$1.nextTick(endFn); + else + src3.once("end", endFn); + dest.on("unpipe", onunpipe); + function onunpipe(readable, unpipeInfo) { + debug("onunpipe"); + if (readable === src3) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + function onend() { + debug("onend"); + dest.end(); + } + var ondrain = pipeOnDrain(src3); + dest.on("drain", ondrain); + var cleanedUp = false; + function cleanup() { + debug("cleanup"); + dest.removeListener("close", onclose); + dest.removeListener("finish", onfinish); + dest.removeListener("drain", ondrain); + dest.removeListener("error", onerror); + dest.removeListener("unpipe", onunpipe); + src3.removeListener("end", onend); + src3.removeListener("end", unpipe); + src3.removeListener("data", ondata); + cleanedUp = true; + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) + ondrain(); + } + src3.on("data", ondata); + function ondata(chunk) { + debug("ondata"); + var ret = dest.write(chunk); + debug("dest.write", ret); + if (ret === false) { + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf2(state.pipes, dest) !== -1) && !cleanedUp) { + debug("false write response, pause", state.awaitDrain); + state.awaitDrain++; + } + src3.pause(); + } + } + function onerror(er) { + debug("onerror", er); + unpipe(); + dest.removeListener("error", onerror); + if (EElistenerCount(dest, "error") === 0) + errorOrDestroy(dest, er); + } + prependListener(dest, "error", onerror); + function onclose() { + dest.removeListener("finish", onfinish); + unpipe(); + } + dest.once("close", onclose); + function onfinish() { + debug("onfinish"); + dest.removeListener("close", onclose); + unpipe(); + } + dest.once("finish", onfinish); + function unpipe() { + debug("unpipe"); + src3.unpipe(dest); + } + dest.emit("pipe", src3); + if (!state.flowing) { + debug("pipe resume"); + src3.resume(); + } + return dest; + }; + function pipeOnDrain(src3) { + return function pipeOnDrainFunctionResult() { + var state = src3._readableState; + debug("pipeOnDrain", state.awaitDrain); + if (state.awaitDrain) + state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src3, "data")) { + state.flowing = true; + flow(src3); + } + }; + } + Readable2.prototype.unpipe = function(dest) { + var state = this._readableState; + var unpipeInfo = { + hasUnpiped: false + }; + if (state.pipesCount === 0) + return this; + if (state.pipesCount === 1) { + if (dest && dest !== state.pipes) + return this; + if (!dest) + dest = state.pipes; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) + dest.emit("unpipe", this, unpipeInfo); + return this; + } + if (!dest) { + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + for (var i8 = 0; i8 < len; i8++) { + dests[i8].emit("unpipe", this, { + hasUnpiped: false + }); + } + return this; + } + var index2 = indexOf2(state.pipes, dest); + if (index2 === -1) + return this; + state.pipes.splice(index2, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) + state.pipes = state.pipes[0]; + dest.emit("unpipe", this, unpipeInfo); + return this; + }; + Readable2.prototype.on = function(ev, fn) { + var res = Stream2.prototype.on.call(this, ev, fn); + var state = this._readableState; + if (ev === "data") { + state.readableListening = this.listenerCount("readable") > 0; + if (state.flowing !== false) + this.resume(); + } else if (ev === "readable") { + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.flowing = false; + state.emittedReadable = false; + debug("on readable", state.length, state.reading); + if (state.length) { + emitReadable(this); + } else if (!state.reading) { + process$1.nextTick(nReadingNextTick, this); + } + } + } + return res; + }; + Readable2.prototype.addListener = Readable2.prototype.on; + Readable2.prototype.removeListener = function(ev, fn) { + var res = Stream2.prototype.removeListener.call(this, ev, fn); + if (ev === "readable") { + process$1.nextTick(updateReadableListening, this); + } + return res; + }; + Readable2.prototype.removeAllListeners = function(ev) { + var res = Stream2.prototype.removeAllListeners.apply(this, arguments); + if (ev === "readable" || ev === void 0) { + process$1.nextTick(updateReadableListening, this); + } + return res; + }; + function updateReadableListening(self2) { + var state = self2._readableState; + state.readableListening = self2.listenerCount("readable") > 0; + if (state.resumeScheduled && !state.paused) { + state.flowing = true; + } else if (self2.listenerCount("data") > 0) { + self2.resume(); + } + } + function nReadingNextTick(self2) { + debug("readable nexttick read 0"); + self2.read(0); + } + Readable2.prototype.resume = function() { + var state = this._readableState; + if (!state.flowing) { + debug("resume"); + state.flowing = !state.readableListening; + resume2(this, state); + } + state.paused = false; + return this; + }; + function resume2(stream2, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + process$1.nextTick(resume_, stream2, state); + } + } + function resume_(stream2, state) { + debug("resume", state.reading); + if (!state.reading) { + stream2.read(0); + } + state.resumeScheduled = false; + stream2.emit("resume"); + flow(stream2); + if (state.flowing && !state.reading) + stream2.read(0); + } + Readable2.prototype.pause = function() { + debug("call pause flowing=%j", this._readableState.flowing); + if (this._readableState.flowing !== false) { + debug("pause"); + this._readableState.flowing = false; + this.emit("pause"); + } + this._readableState.paused = true; + return this; + }; + function flow(stream2) { + var state = stream2._readableState; + debug("flow", state.flowing); + while (state.flowing && stream2.read() !== null) { + } + } + Readable2.prototype.wrap = function(stream2) { + var _this = this; + var state = this._readableState; + var paused = false; + stream2.on("end", function() { + debug("wrapped end"); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) + _this.push(chunk); + } + _this.push(null); + }); + stream2.on("data", function(chunk) { + debug("wrapped data"); + if (state.decoder) + chunk = state.decoder.write(chunk); + if (state.objectMode && (chunk === null || chunk === void 0)) + return; + else if (!state.objectMode && (!chunk || !chunk.length)) + return; + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream2.pause(); + } + }); + for (var i8 in stream2) { + if (this[i8] === void 0 && typeof stream2[i8] === "function") { + this[i8] = function methodWrap(method) { + return function methodWrapReturnFunction() { + return stream2[method].apply(stream2, arguments); + }; + }(i8); + } + } + for (var n9 = 0; n9 < kProxyEvents.length; n9++) { + stream2.on(kProxyEvents[n9], this.emit.bind(this, kProxyEvents[n9])); + } + this._read = function(n10) { + debug("wrapped _read", n10); + if (paused) { + paused = false; + stream2.resume(); + } + }; + return this; + }; + if (typeof Symbol === "function") { + Readable2.prototype[Symbol.asyncIterator] = function() { + if (createReadableStreamAsyncIterator === void 0) { + createReadableStreamAsyncIterator = dew$5(); + } + return createReadableStreamAsyncIterator(this); + }; + } + Object.defineProperty(Readable2.prototype, "readableHighWaterMark", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._readableState.highWaterMark; + } + }); + Object.defineProperty(Readable2.prototype, "readableBuffer", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._readableState && this._readableState.buffer; + } + }); + Object.defineProperty(Readable2.prototype, "readableFlowing", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._readableState.flowing; + }, + set: function set5(state) { + if (this._readableState) { + this._readableState.flowing = state; + } + } + }); + Readable2._fromList = fromList; + Object.defineProperty(Readable2.prototype, "readableLength", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._readableState.length; + } + }); + function fromList(n9, state) { + if (state.length === 0) + return null; + var ret; + if (state.objectMode) + ret = state.buffer.shift(); + else if (!n9 || n9 >= state.length) { + if (state.decoder) + ret = state.buffer.join(""); + else if (state.buffer.length === 1) + ret = state.buffer.first(); + else + ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + ret = state.buffer.consume(n9, state.decoder); + } + return ret; + } + function endReadable(stream2) { + var state = stream2._readableState; + debug("endReadable", state.endEmitted); + if (!state.endEmitted) { + state.ended = true; + process$1.nextTick(endReadableNT, state, stream2); + } + } + function endReadableNT(state, stream2) { + debug("endReadableNT", state.endEmitted, state.length); + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream2.readable = false; + stream2.emit("end"); + if (state.autoDestroy) { + var wState = stream2._writableState; + if (!wState || wState.autoDestroy && wState.finished) { + stream2.destroy(); + } + } + } + } + if (typeof Symbol === "function") { + Readable2.from = function(iterable, opts) { + if (from18 === void 0) { + from18 = dew$4(); + } + return from18(Readable2, iterable, opts); + }; + } + function indexOf2(xs, x5) { + for (var i8 = 0, l8 = xs.length; i8 < l8; i8++) { + if (xs[i8] === x5) + return i8; + } + return -1; + } + return exports$32; + } + function dew$22() { + if (_dewExec$22) + return exports$22; + _dewExec$22 = true; + exports$22 = Transform2; + var _require$codes = dew$b().codes, ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; + var Duplex2 = dew$7(); + dew$f()(Transform2, Duplex2); + function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + var cb = ts.writecb; + if (cb === null) { + return this.emit("error", new ERR_MULTIPLE_CALLBACK()); + } + ts.writechunk = null; + ts.writecb = null; + if (data != null) + this.push(data); + cb(er); + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } + } + function Transform2(options) { + if (!(this instanceof Transform2)) + return new Transform2(options); + Duplex2.call(this, options); + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; + this._readableState.needReadable = true; + this._readableState.sync = false; + if (options) { + if (typeof options.transform === "function") + this._transform = options.transform; + if (typeof options.flush === "function") + this._flush = options.flush; + } + this.on("prefinish", prefinish); + } + function prefinish() { + var _this = this; + if (typeof this._flush === "function" && !this._readableState.destroyed) { + this._flush(function(er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } + } + Transform2.prototype.push = function(chunk, encoding) { + this._transformState.needTransform = false; + return Duplex2.prototype.push.call(this, chunk, encoding); + }; + Transform2.prototype._transform = function(chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED("_transform()")); + }; + Transform2.prototype._write = function(chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) + this._read(rs.highWaterMark); + } + }; + Transform2.prototype._read = function(n9) { + var ts = this._transformState; + if (ts.writechunk !== null && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + ts.needTransform = true; + } + }; + Transform2.prototype._destroy = function(err, cb) { + Duplex2.prototype._destroy.call(this, err, function(err2) { + cb(err2); + }); + }; + function done(stream2, er, data) { + if (er) + return stream2.emit("error", er); + if (data != null) + stream2.push(data); + if (stream2._writableState.length) + throw new ERR_TRANSFORM_WITH_LENGTH_0(); + if (stream2._transformState.transforming) + throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); + return stream2.push(null); + } + return exports$22; + } + function dew$12() { + if (_dewExec$12) + return exports$12; + _dewExec$12 = true; + exports$12 = PassThrough2; + var Transform2 = dew$22(); + dew$f()(PassThrough2, Transform2); + function PassThrough2(options) { + if (!(this instanceof PassThrough2)) + return new PassThrough2(options); + Transform2.call(this, options); + } + PassThrough2.prototype._transform = function(chunk, encoding, cb) { + cb(null, chunk); + }; + return exports$12; + } + function dew3() { + if (_dewExec3) + return exports4; + _dewExec3 = true; + var eos; + function once2(callback) { + var called = false; + return function() { + if (called) + return; + called = true; + callback.apply(void 0, arguments); + }; + } + var _require$codes = dew$b().codes, ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; + function noop2(err) { + if (err) + throw err; + } + function isRequest(stream2) { + return stream2.setHeader && typeof stream2.abort === "function"; + } + function destroyer(stream2, reading, writing, callback) { + callback = once2(callback); + var closed = false; + stream2.on("close", function() { + closed = true; + }); + if (eos === void 0) + eos = dew$6(); + eos(stream2, { + readable: reading, + writable: writing + }, function(err) { + if (err) + return callback(err); + closed = true; + callback(); + }); + var destroyed = false; + return function(err) { + if (closed) + return; + if (destroyed) + return; + destroyed = true; + if (isRequest(stream2)) + return stream2.abort(); + if (typeof stream2.destroy === "function") + return stream2.destroy(); + callback(err || new ERR_STREAM_DESTROYED("pipe")); + }; + } + function call(fn) { + fn(); + } + function pipe2(from18, to) { + return from18.pipe(to); + } + function popCallback(streams) { + if (!streams.length) + return noop2; + if (typeof streams[streams.length - 1] !== "function") + return noop2; + return streams.pop(); + } + function pipeline2() { + for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { + streams[_key] = arguments[_key]; + } + var callback = popCallback(streams); + if (Array.isArray(streams[0])) + streams = streams[0]; + if (streams.length < 2) { + throw new ERR_MISSING_ARGS("streams"); + } + var error7; + var destroys = streams.map(function(stream2, i8) { + var reading = i8 < streams.length - 1; + var writing = i8 > 0; + return destroyer(stream2, reading, writing, function(err) { + if (!error7) + error7 = err; + if (err) + destroys.forEach(call); + if (reading) + return; + destroys.forEach(call); + callback(error7); + }); + }); + return streams.reduce(pipe2); + } + exports4 = pipeline2; + return exports4; + } + var exports$2$1, _dewExec$2$1, exports$1$1, _dewExec$1$1, exports$g, _dewExec$g, buffer3, exports$f, _dewExec$f, exports$e, _dewExec$e, exports$d, _dewExec$d, exports$c, _dewExec$c, exports$b, _dewExec$b, exports$a, _dewExec$a, exports$9, _dewExec$9, _global$2, exports$8, _dewExec$8, _global$1, exports$7, _dewExec$7, exports$6, _dewExec$6, exports$5, _dewExec$5, exports$4, _dewExec$4, exports$32, _dewExec$3, _global2, exports$22, _dewExec$22, exports$12, _dewExec$12, exports4, _dewExec3; + var init_chunk_44e51b61 = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-44e51b61.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_4bd36a8f(); + init_chunk_ce0fbc82(); + init_chunk_b4205b57(); + init_chunk_2eac56ff(); + init_chunk_4ccc3a29(); + exports$2$1 = {}; + _dewExec$2$1 = false; + exports$1$1 = {}; + _dewExec$1$1 = false; + exports$g = {}; + _dewExec$g = false; + buffer3 = dew$g(); + buffer3.Buffer; + buffer3.INSPECT_MAX_BYTES; + buffer3.kMaxLength; + exports$f = {}; + _dewExec$f = false; + exports$e = {}; + _dewExec$e = false; + exports$d = {}; + _dewExec$d = false; + exports$c = {}; + _dewExec$c = false; + exports$b = {}; + _dewExec$b = false; + exports$a = {}; + _dewExec$a = false; + exports$9 = {}; + _dewExec$9 = false; + _global$2 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + exports$8 = {}; + _dewExec$8 = false; + _global$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + exports$7 = {}; + _dewExec$7 = false; + exports$6 = {}; + _dewExec$6 = false; + exports$5 = {}; + _dewExec$5 = false; + exports$4 = {}; + _dewExec$4 = false; + exports$32 = {}; + _dewExec$3 = false; + _global2 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + exports$22 = {}; + _dewExec$22 = false; + exports$12 = {}; + _dewExec$12 = false; + exports4 = {}; + _dewExec3 = false; + } + }); + + // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js + var require_retry_operation = __commonJS({ + "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports12, module3) { + init_dirname(); + init_buffer2(); + init_process(); + function RetryOperation(timeouts, options) { + if (typeof options === "boolean") { + options = { forever: options }; + } + this._originalTimeouts = JSON.parse(JSON.stringify(timeouts)); + this._timeouts = timeouts; + this._options = options || {}; + this._maxRetryTime = options && options.maxRetryTime || Infinity; + this._fn = null; + this._errors = []; + this._attempts = 1; + this._operationTimeout = null; + this._operationTimeoutCb = null; + this._timeout = null; + this._operationStart = null; + this._timer = null; + if (this._options.forever) { + this._cachedTimeouts = this._timeouts.slice(0); + } + } + module3.exports = RetryOperation; + RetryOperation.prototype.reset = function() { + this._attempts = 1; + this._timeouts = this._originalTimeouts.slice(0); + }; + RetryOperation.prototype.stop = function() { + if (this._timeout) { + clearTimeout(this._timeout); + } + if (this._timer) { + clearTimeout(this._timer); + } + this._timeouts = []; + this._cachedTimeouts = null; + }; + RetryOperation.prototype.retry = function(err) { + if (this._timeout) { + clearTimeout(this._timeout); + } + if (!err) { + return false; + } + var currentTime = (/* @__PURE__ */ new Date()).getTime(); + if (err && currentTime - this._operationStart >= this._maxRetryTime) { + this._errors.push(err); + this._errors.unshift(new Error("RetryOperation timeout occurred")); + return false; + } + this._errors.push(err); + var timeout = this._timeouts.shift(); + if (timeout === void 0) { + if (this._cachedTimeouts) { + this._errors.splice(0, this._errors.length - 1); + timeout = this._cachedTimeouts.slice(-1); + } else { + return false; + } + } + var self2 = this; + this._timer = setTimeout(function() { + self2._attempts++; + if (self2._operationTimeoutCb) { + self2._timeout = setTimeout(function() { + self2._operationTimeoutCb(self2._attempts); + }, self2._operationTimeout); + if (self2._options.unref) { + self2._timeout.unref(); + } + } + self2._fn(self2._attempts); + }, timeout); + if (this._options.unref) { + this._timer.unref(); + } + return true; + }; + RetryOperation.prototype.attempt = function(fn, timeoutOps) { + this._fn = fn; + if (timeoutOps) { + if (timeoutOps.timeout) { + this._operationTimeout = timeoutOps.timeout; + } + if (timeoutOps.cb) { + this._operationTimeoutCb = timeoutOps.cb; + } + } + var self2 = this; + if (this._operationTimeoutCb) { + this._timeout = setTimeout(function() { + self2._operationTimeoutCb(); + }, self2._operationTimeout); + } + this._operationStart = (/* @__PURE__ */ new Date()).getTime(); + this._fn(this._attempts); + }; + RetryOperation.prototype.try = function(fn) { + console.log("Using RetryOperation.try() is deprecated"); + this.attempt(fn); + }; + RetryOperation.prototype.start = function(fn) { + console.log("Using RetryOperation.start() is deprecated"); + this.attempt(fn); + }; + RetryOperation.prototype.start = RetryOperation.prototype.try; + RetryOperation.prototype.errors = function() { + return this._errors; + }; + RetryOperation.prototype.attempts = function() { + return this._attempts; + }; + RetryOperation.prototype.mainError = function() { + if (this._errors.length === 0) { + return null; + } + var counts = {}; + var mainError = null; + var mainErrorCount = 0; + for (var i8 = 0; i8 < this._errors.length; i8++) { + var error7 = this._errors[i8]; + var message2 = error7.message; + var count = (counts[message2] || 0) + 1; + counts[message2] = count; + if (count >= mainErrorCount) { + mainError = error7; + mainErrorCount = count; + } + } + return mainError; + }; + } + }); + + // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js + var require_retry = __commonJS({ + "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports12) { + init_dirname(); + init_buffer2(); + init_process(); + var RetryOperation = require_retry_operation(); + exports12.operation = function(options) { + var timeouts = exports12.timeouts(options); + return new RetryOperation(timeouts, { + forever: options && (options.forever || options.retries === Infinity), + unref: options && options.unref, + maxRetryTime: options && options.maxRetryTime + }); + }; + exports12.timeouts = function(options) { + if (options instanceof Array) { + return [].concat(options); + } + var opts = { + retries: 10, + factor: 2, + minTimeout: 1 * 1e3, + maxTimeout: Infinity, + randomize: false + }; + for (var key in options) { + opts[key] = options[key]; + } + if (opts.minTimeout > opts.maxTimeout) { + throw new Error("minTimeout is greater than maxTimeout"); + } + var timeouts = []; + for (var i8 = 0; i8 < opts.retries; i8++) { + timeouts.push(this.createTimeout(i8, opts)); + } + if (options && options.forever && !timeouts.length) { + timeouts.push(this.createTimeout(i8, opts)); + } + timeouts.sort(function(a8, b6) { + return a8 - b6; + }); + return timeouts; + }; + exports12.createTimeout = function(attempt, opts) { + var random = opts.randomize ? Math.random() + 1 : 1; + var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt)); + timeout = Math.min(timeout, opts.maxTimeout); + return timeout; + }; + exports12.wrap = function(obj, options, methods2) { + if (options instanceof Array) { + methods2 = options; + options = null; + } + if (!methods2) { + methods2 = []; + for (var key in obj) { + if (typeof obj[key] === "function") { + methods2.push(key); + } + } + } + for (var i8 = 0; i8 < methods2.length; i8++) { + var method = methods2[i8]; + var original = obj[method]; + obj[method] = function retryWrapper(original2) { + var op = exports12.operation(options); + var args = Array.prototype.slice.call(arguments, 1); + var callback = args.pop(); + args.push(function(err) { + if (op.retry(err)) { + return; + } + if (err) { + arguments[0] = op.mainError(); + } + callback.apply(this, arguments); + }); + op.attempt(function() { + original2.apply(obj, args); + }); + }.bind(obj, original); + obj[method].options = options; + } + }; + } + }); + + // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js + var require_retry2 = __commonJS({ + "../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports12, module3) { + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = require_retry(); + } + }); + + // ../../node_modules/.pnpm/ipfs-utils@9.0.14/node_modules/ipfs-utils/src/http/error.js + var require_error = __commonJS({ + "../../node_modules/.pnpm/ipfs-utils@9.0.14/node_modules/ipfs-utils/src/http/error.js"(exports12) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + var TimeoutError3 = class extends Error { + constructor(message2 = "Request timed out") { + super(message2); + this.name = "TimeoutError"; + } + }; + exports12.TimeoutError = TimeoutError3; + var AbortError7 = class extends Error { + constructor(message2 = "The operation was aborted.") { + super(message2); + this.name = "AbortError"; + } + }; + exports12.AbortError = AbortError7; + var HTTPError3 = class extends Error { + /** + * @param {Response} response + */ + constructor(response) { + super(response.statusText); + this.name = "HTTPError"; + this.response = response; + } + }; + exports12.HTTPError = HTTPError3; + } + }); + + // ../../node_modules/.pnpm/node-fetch@2.6.12/node_modules/node-fetch/browser.js + var require_browser = __commonJS({ + "../../node_modules/.pnpm/node-fetch@2.6.12/node_modules/node-fetch/browser.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + var getGlobal = function() { + if (typeof self !== "undefined") { + return self; + } + if (typeof window !== "undefined") { + return window; + } + if (typeof global !== "undefined") { + return global; + } + throw new Error("unable to locate global object"); + }; + var globalObject = getGlobal(); + module3.exports = exports12 = globalObject.fetch; + if (globalObject.fetch) { + exports12.default = globalObject.fetch.bind(globalObject); + } + exports12.Headers = globalObject.Headers; + exports12.Request = globalObject.Request; + exports12.Response = globalObject.Response; + } + }); + + // ../../node_modules/.pnpm/native-fetch@3.0.0_node-fetch@2.6.12/node_modules/native-fetch/src/index.js + var require_src = __commonJS({ + "../../node_modules/.pnpm/native-fetch@3.0.0_node-fetch@2.6.12/node_modules/native-fetch/src/index.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + if (globalThis.fetch && globalThis.Headers && globalThis.Request && globalThis.Response) { + module3.exports = { + default: globalThis.fetch, + Headers: globalThis.Headers, + Request: globalThis.Request, + Response: globalThis.Response + }; + } else { + module3.exports = { + default: require_browser().default, + Headers: require_browser().Headers, + Request: require_browser().Request, + Response: require_browser().Response + }; + } + } + }); + + // ../../node_modules/.pnpm/ipfs-utils@9.0.14/node_modules/ipfs-utils/src/fetch.browser.js + var require_fetch_browser = __commonJS({ + "../../node_modules/.pnpm/ipfs-utils@9.0.14/node_modules/ipfs-utils/src/fetch.browser.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = require_src(); + } + }); + + // ../../node_modules/.pnpm/ipfs-utils@9.0.14/node_modules/ipfs-utils/src/http/fetch.browser.js + var require_fetch_browser2 = __commonJS({ + "../../node_modules/.pnpm/ipfs-utils@9.0.14/node_modules/ipfs-utils/src/http/fetch.browser.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + var { TimeoutError: TimeoutError3, AbortError: AbortError7 } = require_error(); + var { Response, Request, Headers, default: fetch4 } = require_fetch_browser(); + var fetchWithProgress = (url, options = {}) => { + const request = new XMLHttpRequest(); + request.open(options.method || "GET", url.toString(), true); + const { timeout, headers } = options; + if (timeout && timeout > 0 && timeout < Infinity) { + request.timeout = timeout; + } + if (options.overrideMimeType != null) { + request.overrideMimeType(options.overrideMimeType); + } + if (headers) { + for (const [name15, value] of new Headers(headers)) { + request.setRequestHeader(name15, value); + } + } + if (options.signal) { + options.signal.onabort = () => request.abort(); + } + if (options.onUploadProgress) { + request.upload.onprogress = options.onUploadProgress; + } + request.responseType = "arraybuffer"; + return new Promise((resolve7, reject) => { + const handleEvent = (event) => { + switch (event.type) { + case "error": { + resolve7(Response.error()); + break; + } + case "load": { + resolve7( + new ResponseWithURL(request.responseURL, request.response, { + status: request.status, + statusText: request.statusText, + headers: parseHeaders(request.getAllResponseHeaders()) + }) + ); + break; + } + case "timeout": { + reject(new TimeoutError3()); + break; + } + case "abort": { + reject(new AbortError7()); + break; + } + default: { + break; + } + } + }; + request.onerror = handleEvent; + request.onload = handleEvent; + request.ontimeout = handleEvent; + request.onabort = handleEvent; + request.send(options.body); + }); + }; + var fetchWithStreaming = fetch4; + var fetchWith = (url, options = {}) => options.onUploadProgress != null ? fetchWithProgress(url, options) : fetchWithStreaming(url, options); + var parseHeaders = (input) => { + const headers = new Headers(); + for (const line of input.trim().split(/[\r\n]+/)) { + const index2 = line.indexOf(": "); + if (index2 > 0) { + headers.set(line.slice(0, index2), line.slice(index2 + 1)); + } + } + return headers; + }; + var ResponseWithURL = class extends Response { + /** + * @param {string} url + * @param {BodyInit} body + * @param {ResponseInit} options + */ + constructor(url, body, options) { + super(body, options); + Object.defineProperty(this, "url", { value: url }); + } + }; + module3.exports = { + fetch: fetchWith, + Request, + Headers + }; + } + }); + + // ../../node_modules/.pnpm/@protobufjs+aspromise@1.1.2/node_modules/@protobufjs/aspromise/index.js + var require_aspromise = __commonJS({ + "../../node_modules/.pnpm/@protobufjs+aspromise@1.1.2/node_modules/@protobufjs/aspromise/index.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = asPromise; + function asPromise(fn, ctx) { + var params = new Array(arguments.length - 1), offset2 = 0, index2 = 2, pending = true; + while (index2 < arguments.length) + params[offset2++] = arguments[index2++]; + return new Promise(function executor(resolve7, reject) { + params[offset2] = function callback(err) { + if (pending) { + pending = false; + if (err) + reject(err); + else { + var params2 = new Array(arguments.length - 1), offset3 = 0; + while (offset3 < params2.length) + params2[offset3++] = arguments[offset3]; + resolve7.apply(null, params2); + } + } + }; + try { + fn.apply(ctx || null, params); + } catch (err) { + if (pending) { + pending = false; + reject(err); + } + } + }); + } + } + }); + + // ../../node_modules/.pnpm/@protobufjs+base64@1.1.2/node_modules/@protobufjs/base64/index.js + var require_base64 = __commonJS({ + "../../node_modules/.pnpm/@protobufjs+base64@1.1.2/node_modules/@protobufjs/base64/index.js"(exports12) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + var base643 = exports12; + base643.length = function length3(string4) { + var p8 = string4.length; + if (!p8) + return 0; + var n9 = 0; + while (--p8 % 4 > 1 && string4.charAt(p8) === "=") + ++n9; + return Math.ceil(string4.length * 3) / 4 - n9; + }; + var b64 = new Array(64); + var s64 = new Array(123); + for (i8 = 0; i8 < 64; ) + s64[b64[i8] = i8 < 26 ? i8 + 65 : i8 < 52 ? i8 + 71 : i8 < 62 ? i8 - 4 : i8 - 59 | 43] = i8++; + var i8; + base643.encode = function encode41(buffer4, start, end) { + var parts = null, chunk = []; + var i9 = 0, j5 = 0, t9; + while (start < end) { + var b6 = buffer4[start++]; + switch (j5) { + case 0: + chunk[i9++] = b64[b6 >> 2]; + t9 = (b6 & 3) << 4; + j5 = 1; + break; + case 1: + chunk[i9++] = b64[t9 | b6 >> 4]; + t9 = (b6 & 15) << 2; + j5 = 2; + break; + case 2: + chunk[i9++] = b64[t9 | b6 >> 6]; + chunk[i9++] = b64[b6 & 63]; + j5 = 0; + break; + } + if (i9 > 8191) { + (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk)); + i9 = 0; + } + } + if (j5) { + chunk[i9++] = b64[t9]; + chunk[i9++] = 61; + if (j5 === 1) + chunk[i9++] = 61; + } + if (parts) { + if (i9) + parts.push(String.fromCharCode.apply(String, chunk.slice(0, i9))); + return parts.join(""); + } + return String.fromCharCode.apply(String, chunk.slice(0, i9)); + }; + var invalidEncoding = "invalid encoding"; + base643.decode = function decode46(string4, buffer4, offset2) { + var start = offset2; + var j5 = 0, t9; + for (var i9 = 0; i9 < string4.length; ) { + var c8 = string4.charCodeAt(i9++); + if (c8 === 61 && j5 > 1) + break; + if ((c8 = s64[c8]) === void 0) + throw Error(invalidEncoding); + switch (j5) { + case 0: + t9 = c8; + j5 = 1; + break; + case 1: + buffer4[offset2++] = t9 << 2 | (c8 & 48) >> 4; + t9 = c8; + j5 = 2; + break; + case 2: + buffer4[offset2++] = (t9 & 15) << 4 | (c8 & 60) >> 2; + t9 = c8; + j5 = 3; + break; + case 3: + buffer4[offset2++] = (t9 & 3) << 6 | c8; + j5 = 0; + break; + } + } + if (j5 === 1) + throw Error(invalidEncoding); + return offset2 - start; + }; + base643.test = function test(string4) { + return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string4); + }; + } + }); + + // ../../node_modules/.pnpm/@protobufjs+eventemitter@1.1.0/node_modules/@protobufjs/eventemitter/index.js + var require_eventemitter = __commonJS({ + "../../node_modules/.pnpm/@protobufjs+eventemitter@1.1.0/node_modules/@protobufjs/eventemitter/index.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = EventEmitter3; + function EventEmitter3() { + this._listeners = {}; + } + EventEmitter3.prototype.on = function on2(evt, fn, ctx) { + (this._listeners[evt] || (this._listeners[evt] = [])).push({ + fn, + ctx: ctx || this + }); + return this; + }; + EventEmitter3.prototype.off = function off(evt, fn) { + if (evt === void 0) + this._listeners = {}; + else { + if (fn === void 0) + this._listeners[evt] = []; + else { + var listeners = this._listeners[evt]; + for (var i8 = 0; i8 < listeners.length; ) + if (listeners[i8].fn === fn) + listeners.splice(i8, 1); + else + ++i8; + } + } + return this; + }; + EventEmitter3.prototype.emit = function emit(evt) { + var listeners = this._listeners[evt]; + if (listeners) { + var args = [], i8 = 1; + for (; i8 < arguments.length; ) + args.push(arguments[i8++]); + for (i8 = 0; i8 < listeners.length; ) + listeners[i8].fn.apply(listeners[i8++].ctx, args); + } + return this; + }; + } + }); + + // ../../node_modules/.pnpm/@protobufjs+float@1.0.2/node_modules/@protobufjs/float/index.js + var require_float = __commonJS({ + "../../node_modules/.pnpm/@protobufjs+float@1.0.2/node_modules/@protobufjs/float/index.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = factory(factory); + function factory(exports13) { + if (typeof Float32Array !== "undefined") + (function() { + var f32 = new Float32Array([-0]), f8b = new Uint8Array(f32.buffer), le3 = f8b[3] === 128; + function writeFloat_f32_cpy(val, buf3, pos) { + f32[0] = val; + buf3[pos] = f8b[0]; + buf3[pos + 1] = f8b[1]; + buf3[pos + 2] = f8b[2]; + buf3[pos + 3] = f8b[3]; + } + function writeFloat_f32_rev(val, buf3, pos) { + f32[0] = val; + buf3[pos] = f8b[3]; + buf3[pos + 1] = f8b[2]; + buf3[pos + 2] = f8b[1]; + buf3[pos + 3] = f8b[0]; + } + exports13.writeFloatLE = le3 ? writeFloat_f32_cpy : writeFloat_f32_rev; + exports13.writeFloatBE = le3 ? writeFloat_f32_rev : writeFloat_f32_cpy; + function readFloat_f32_cpy(buf3, pos) { + f8b[0] = buf3[pos]; + f8b[1] = buf3[pos + 1]; + f8b[2] = buf3[pos + 2]; + f8b[3] = buf3[pos + 3]; + return f32[0]; + } + function readFloat_f32_rev(buf3, pos) { + f8b[3] = buf3[pos]; + f8b[2] = buf3[pos + 1]; + f8b[1] = buf3[pos + 2]; + f8b[0] = buf3[pos + 3]; + return f32[0]; + } + exports13.readFloatLE = le3 ? readFloat_f32_cpy : readFloat_f32_rev; + exports13.readFloatBE = le3 ? readFloat_f32_rev : readFloat_f32_cpy; + })(); + else + (function() { + function writeFloat_ieee754(writeUint, val, buf3, pos) { + var sign2 = val < 0 ? 1 : 0; + if (sign2) + val = -val; + if (val === 0) + writeUint(1 / val > 0 ? ( + /* positive */ + 0 + ) : ( + /* negative 0 */ + 2147483648 + ), buf3, pos); + else if (isNaN(val)) + writeUint(2143289344, buf3, pos); + else if (val > 34028234663852886e22) + writeUint((sign2 << 31 | 2139095040) >>> 0, buf3, pos); + else if (val < 11754943508222875e-54) + writeUint((sign2 << 31 | Math.round(val / 1401298464324817e-60)) >>> 0, buf3, pos); + else { + var exponent = Math.floor(Math.log(val) / Math.LN2), mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607; + writeUint((sign2 << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf3, pos); + } + } + exports13.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE); + exports13.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE); + function readFloat_ieee754(readUint, buf3, pos) { + var uint = readUint(buf3, pos), sign2 = (uint >> 31) * 2 + 1, exponent = uint >>> 23 & 255, mantissa = uint & 8388607; + return exponent === 255 ? mantissa ? NaN : sign2 * Infinity : exponent === 0 ? sign2 * 1401298464324817e-60 * mantissa : sign2 * Math.pow(2, exponent - 150) * (mantissa + 8388608); + } + exports13.readFloatLE = readFloat_ieee754.bind(null, readUintLE); + exports13.readFloatBE = readFloat_ieee754.bind(null, readUintBE); + })(); + if (typeof Float64Array !== "undefined") + (function() { + var f64 = new Float64Array([-0]), f8b = new Uint8Array(f64.buffer), le3 = f8b[7] === 128; + function writeDouble_f64_cpy(val, buf3, pos) { + f64[0] = val; + buf3[pos] = f8b[0]; + buf3[pos + 1] = f8b[1]; + buf3[pos + 2] = f8b[2]; + buf3[pos + 3] = f8b[3]; + buf3[pos + 4] = f8b[4]; + buf3[pos + 5] = f8b[5]; + buf3[pos + 6] = f8b[6]; + buf3[pos + 7] = f8b[7]; + } + function writeDouble_f64_rev(val, buf3, pos) { + f64[0] = val; + buf3[pos] = f8b[7]; + buf3[pos + 1] = f8b[6]; + buf3[pos + 2] = f8b[5]; + buf3[pos + 3] = f8b[4]; + buf3[pos + 4] = f8b[3]; + buf3[pos + 5] = f8b[2]; + buf3[pos + 6] = f8b[1]; + buf3[pos + 7] = f8b[0]; + } + exports13.writeDoubleLE = le3 ? writeDouble_f64_cpy : writeDouble_f64_rev; + exports13.writeDoubleBE = le3 ? writeDouble_f64_rev : writeDouble_f64_cpy; + function readDouble_f64_cpy(buf3, pos) { + f8b[0] = buf3[pos]; + f8b[1] = buf3[pos + 1]; + f8b[2] = buf3[pos + 2]; + f8b[3] = buf3[pos + 3]; + f8b[4] = buf3[pos + 4]; + f8b[5] = buf3[pos + 5]; + f8b[6] = buf3[pos + 6]; + f8b[7] = buf3[pos + 7]; + return f64[0]; + } + function readDouble_f64_rev(buf3, pos) { + f8b[7] = buf3[pos]; + f8b[6] = buf3[pos + 1]; + f8b[5] = buf3[pos + 2]; + f8b[4] = buf3[pos + 3]; + f8b[3] = buf3[pos + 4]; + f8b[2] = buf3[pos + 5]; + f8b[1] = buf3[pos + 6]; + f8b[0] = buf3[pos + 7]; + return f64[0]; + } + exports13.readDoubleLE = le3 ? readDouble_f64_cpy : readDouble_f64_rev; + exports13.readDoubleBE = le3 ? readDouble_f64_rev : readDouble_f64_cpy; + })(); + else + (function() { + function writeDouble_ieee754(writeUint, off0, off1, val, buf3, pos) { + var sign2 = val < 0 ? 1 : 0; + if (sign2) + val = -val; + if (val === 0) { + writeUint(0, buf3, pos + off0); + writeUint(1 / val > 0 ? ( + /* positive */ + 0 + ) : ( + /* negative 0 */ + 2147483648 + ), buf3, pos + off1); + } else if (isNaN(val)) { + writeUint(0, buf3, pos + off0); + writeUint(2146959360, buf3, pos + off1); + } else if (val > 17976931348623157e292) { + writeUint(0, buf3, pos + off0); + writeUint((sign2 << 31 | 2146435072) >>> 0, buf3, pos + off1); + } else { + var mantissa; + if (val < 22250738585072014e-324) { + mantissa = val / 5e-324; + writeUint(mantissa >>> 0, buf3, pos + off0); + writeUint((sign2 << 31 | mantissa / 4294967296) >>> 0, buf3, pos + off1); + } else { + var exponent = Math.floor(Math.log(val) / Math.LN2); + if (exponent === 1024) + exponent = 1023; + mantissa = val * Math.pow(2, -exponent); + writeUint(mantissa * 4503599627370496 >>> 0, buf3, pos + off0); + writeUint((sign2 << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf3, pos + off1); + } + } + } + exports13.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4); + exports13.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0); + function readDouble_ieee754(readUint, off0, off1, buf3, pos) { + var lo = readUint(buf3, pos + off0), hi = readUint(buf3, pos + off1); + var sign2 = (hi >> 31) * 2 + 1, exponent = hi >>> 20 & 2047, mantissa = 4294967296 * (hi & 1048575) + lo; + return exponent === 2047 ? mantissa ? NaN : sign2 * Infinity : exponent === 0 ? sign2 * 5e-324 * mantissa : sign2 * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496); + } + exports13.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4); + exports13.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0); + })(); + return exports13; + } + function writeUintLE(val, buf3, pos) { + buf3[pos] = val & 255; + buf3[pos + 1] = val >>> 8 & 255; + buf3[pos + 2] = val >>> 16 & 255; + buf3[pos + 3] = val >>> 24; + } + function writeUintBE(val, buf3, pos) { + buf3[pos] = val >>> 24; + buf3[pos + 1] = val >>> 16 & 255; + buf3[pos + 2] = val >>> 8 & 255; + buf3[pos + 3] = val & 255; + } + function readUintLE(buf3, pos) { + return (buf3[pos] | buf3[pos + 1] << 8 | buf3[pos + 2] << 16 | buf3[pos + 3] << 24) >>> 0; + } + function readUintBE(buf3, pos) { + return (buf3[pos] << 24 | buf3[pos + 1] << 16 | buf3[pos + 2] << 8 | buf3[pos + 3]) >>> 0; + } + } + }); + + // ../../node_modules/.pnpm/@protobufjs+inquire@1.1.0/node_modules/@protobufjs/inquire/index.js + var require_inquire = __commonJS({ + "../../node_modules/.pnpm/@protobufjs+inquire@1.1.0/node_modules/@protobufjs/inquire/index.js"(exports, module) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module.exports = inquire; + function inquire(moduleName) { + try { + var mod = eval("quire".replace(/^/, "re"))(moduleName); + if (mod && (mod.length || Object.keys(mod).length)) + return mod; + } catch (e12) { + } + return null; + } + } + }); + + // ../../node_modules/.pnpm/@protobufjs+utf8@1.1.0/node_modules/@protobufjs/utf8/index.js + var require_utf8 = __commonJS({ + "../../node_modules/.pnpm/@protobufjs+utf8@1.1.0/node_modules/@protobufjs/utf8/index.js"(exports12) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + var utf84 = exports12; + utf84.length = function utf8_length(string4) { + var len = 0, c8 = 0; + for (var i8 = 0; i8 < string4.length; ++i8) { + c8 = string4.charCodeAt(i8); + if (c8 < 128) + len += 1; + else if (c8 < 2048) + len += 2; + else if ((c8 & 64512) === 55296 && (string4.charCodeAt(i8 + 1) & 64512) === 56320) { + ++i8; + len += 4; + } else + len += 3; + } + return len; + }; + utf84.read = function utf8_read(buffer4, start, end) { + var len = end - start; + if (len < 1) + return ""; + var parts = null, chunk = [], i8 = 0, t9; + while (start < end) { + t9 = buffer4[start++]; + if (t9 < 128) + chunk[i8++] = t9; + else if (t9 > 191 && t9 < 224) + chunk[i8++] = (t9 & 31) << 6 | buffer4[start++] & 63; + else if (t9 > 239 && t9 < 365) { + t9 = ((t9 & 7) << 18 | (buffer4[start++] & 63) << 12 | (buffer4[start++] & 63) << 6 | buffer4[start++] & 63) - 65536; + chunk[i8++] = 55296 + (t9 >> 10); + chunk[i8++] = 56320 + (t9 & 1023); + } else + chunk[i8++] = (t9 & 15) << 12 | (buffer4[start++] & 63) << 6 | buffer4[start++] & 63; + if (i8 > 8191) { + (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk)); + i8 = 0; + } + } + if (parts) { + if (i8) + parts.push(String.fromCharCode.apply(String, chunk.slice(0, i8))); + return parts.join(""); + } + return String.fromCharCode.apply(String, chunk.slice(0, i8)); + }; + utf84.write = function utf8_write(string4, buffer4, offset2) { + var start = offset2, c1, c22; + for (var i8 = 0; i8 < string4.length; ++i8) { + c1 = string4.charCodeAt(i8); + if (c1 < 128) { + buffer4[offset2++] = c1; + } else if (c1 < 2048) { + buffer4[offset2++] = c1 >> 6 | 192; + buffer4[offset2++] = c1 & 63 | 128; + } else if ((c1 & 64512) === 55296 && ((c22 = string4.charCodeAt(i8 + 1)) & 64512) === 56320) { + c1 = 65536 + ((c1 & 1023) << 10) + (c22 & 1023); + ++i8; + buffer4[offset2++] = c1 >> 18 | 240; + buffer4[offset2++] = c1 >> 12 & 63 | 128; + buffer4[offset2++] = c1 >> 6 & 63 | 128; + buffer4[offset2++] = c1 & 63 | 128; + } else { + buffer4[offset2++] = c1 >> 12 | 224; + buffer4[offset2++] = c1 >> 6 & 63 | 128; + buffer4[offset2++] = c1 & 63 | 128; + } + } + return offset2 - start; + }; + } + }); + + // ../../node_modules/.pnpm/@protobufjs+pool@1.1.0/node_modules/@protobufjs/pool/index.js + var require_pool = __commonJS({ + "../../node_modules/.pnpm/@protobufjs+pool@1.1.0/node_modules/@protobufjs/pool/index.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = pool; + function pool(alloc3, slice4, size4) { + var SIZE3 = size4 || 8192; + var MAX = SIZE3 >>> 1; + var slab = null; + var offset2 = SIZE3; + return function pool_alloc(size5) { + if (size5 < 1 || size5 > MAX) + return alloc3(size5); + if (offset2 + size5 > SIZE3) { + slab = alloc3(SIZE3); + offset2 = 0; + } + var buf3 = slice4.call(slab, offset2, offset2 += size5); + if (offset2 & 7) + offset2 = (offset2 | 7) + 1; + return buf3; + }; + } + } + }); + + // ../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/util/longbits.js + var require_longbits = __commonJS({ + "../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/util/longbits.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = LongBits; + var util3 = require_minimal(); + function LongBits(lo, hi) { + this.lo = lo >>> 0; + this.hi = hi >>> 0; + } + var zero2 = LongBits.zero = new LongBits(0, 0); + zero2.toNumber = function() { + return 0; + }; + zero2.zzEncode = zero2.zzDecode = function() { + return this; + }; + zero2.length = function() { + return 1; + }; + var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0"; + LongBits.fromNumber = function fromNumber(value) { + if (value === 0) + return zero2; + var sign2 = value < 0; + if (sign2) + value = -value; + var lo = value >>> 0, hi = (value - lo) / 4294967296 >>> 0; + if (sign2) { + hi = ~hi >>> 0; + lo = ~lo >>> 0; + if (++lo > 4294967295) { + lo = 0; + if (++hi > 4294967295) + hi = 0; + } + } + return new LongBits(lo, hi); + }; + LongBits.from = function from18(value) { + if (typeof value === "number") + return LongBits.fromNumber(value); + if (util3.isString(value)) { + if (util3.Long) + value = util3.Long.fromString(value); + else + return LongBits.fromNumber(parseInt(value, 10)); + } + return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero2; + }; + LongBits.prototype.toNumber = function toNumber(unsigned) { + if (!unsigned && this.hi >>> 31) { + var lo = ~this.lo + 1 >>> 0, hi = ~this.hi >>> 0; + if (!lo) + hi = hi + 1 >>> 0; + return -(lo + hi * 4294967296); + } + return this.lo + this.hi * 4294967296; + }; + LongBits.prototype.toLong = function toLong(unsigned) { + return util3.Long ? new util3.Long(this.lo | 0, this.hi | 0, Boolean(unsigned)) : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) }; + }; + var charCodeAt = String.prototype.charCodeAt; + LongBits.fromHash = function fromHash(hash) { + if (hash === zeroHash) + return zero2; + return new LongBits( + (charCodeAt.call(hash, 0) | charCodeAt.call(hash, 1) << 8 | charCodeAt.call(hash, 2) << 16 | charCodeAt.call(hash, 3) << 24) >>> 0, + (charCodeAt.call(hash, 4) | charCodeAt.call(hash, 5) << 8 | charCodeAt.call(hash, 6) << 16 | charCodeAt.call(hash, 7) << 24) >>> 0 + ); + }; + LongBits.prototype.toHash = function toHash() { + return String.fromCharCode( + this.lo & 255, + this.lo >>> 8 & 255, + this.lo >>> 16 & 255, + this.lo >>> 24, + this.hi & 255, + this.hi >>> 8 & 255, + this.hi >>> 16 & 255, + this.hi >>> 24 + ); + }; + LongBits.prototype.zzEncode = function zzEncode() { + var mask2 = this.hi >> 31; + this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask2) >>> 0; + this.lo = (this.lo << 1 ^ mask2) >>> 0; + return this; + }; + LongBits.prototype.zzDecode = function zzDecode() { + var mask2 = -(this.lo & 1); + this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask2) >>> 0; + this.hi = (this.hi >>> 1 ^ mask2) >>> 0; + return this; + }; + LongBits.prototype.length = function length3() { + var part0 = this.lo, part1 = (this.lo >>> 28 | this.hi << 4) >>> 0, part2 = this.hi >>> 24; + return part2 === 0 ? part1 === 0 ? part0 < 16384 ? part0 < 128 ? 1 : 2 : part0 < 2097152 ? 3 : 4 : part1 < 16384 ? part1 < 128 ? 5 : 6 : part1 < 2097152 ? 7 : 8 : part2 < 128 ? 9 : 10; + }; + } + }); + + // ../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/util/minimal.js + var require_minimal = __commonJS({ + "../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/util/minimal.js"(exports12) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + var util3 = exports12; + util3.asPromise = require_aspromise(); + util3.base64 = require_base64(); + util3.EventEmitter = require_eventemitter(); + util3.float = require_float(); + util3.inquire = require_inquire(); + util3.utf8 = require_utf8(); + util3.pool = require_pool(); + util3.LongBits = require_longbits(); + util3.isNode = Boolean(typeof global !== "undefined" && global && global.process && global.process.versions && global.process.versions.node); + util3.global = util3.isNode && global || typeof window !== "undefined" && window || typeof self !== "undefined" && self || exports12; + util3.emptyArray = Object.freeze ? Object.freeze([]) : ( + /* istanbul ignore next */ + [] + ); + util3.emptyObject = Object.freeze ? Object.freeze({}) : ( + /* istanbul ignore next */ + {} + ); + util3.isInteger = Number.isInteger || /* istanbul ignore next */ + function isInteger(value) { + return typeof value === "number" && isFinite(value) && Math.floor(value) === value; + }; + util3.isString = function isString3(value) { + return typeof value === "string" || value instanceof String; + }; + util3.isObject = function isObject3(value) { + return value && typeof value === "object"; + }; + util3.isset = /** + * Checks if a property on a message is considered to be present. + * @param {Object} obj Plain object or message instance + * @param {string} prop Property name + * @returns {boolean} `true` if considered to be present, otherwise `false` + */ + util3.isSet = function isSet(obj, prop) { + var value = obj[prop]; + if (value != null && obj.hasOwnProperty(prop)) + return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0; + return false; + }; + util3.Buffer = function() { + try { + var Buffer2 = util3.inquire("buffer").Buffer; + return Buffer2.prototype.utf8Write ? Buffer2 : ( + /* istanbul ignore next */ + null + ); + } catch (e12) { + return null; + } + }(); + util3._Buffer_from = null; + util3._Buffer_allocUnsafe = null; + util3.newBuffer = function newBuffer(sizeOrArray) { + return typeof sizeOrArray === "number" ? util3.Buffer ? util3._Buffer_allocUnsafe(sizeOrArray) : new util3.Array(sizeOrArray) : util3.Buffer ? util3._Buffer_from(sizeOrArray) : typeof Uint8Array === "undefined" ? sizeOrArray : new Uint8Array(sizeOrArray); + }; + util3.Array = typeof Uint8Array !== "undefined" ? Uint8Array : Array; + util3.Long = /* istanbul ignore next */ + util3.global.dcodeIO && /* istanbul ignore next */ + util3.global.dcodeIO.Long || /* istanbul ignore next */ + util3.global.Long || util3.inquire("long"); + util3.key2Re = /^true|false|0|1$/; + util3.key32Re = /^-?(?:0|[1-9][0-9]*)$/; + util3.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/; + util3.longToHash = function longToHash(value) { + return value ? util3.LongBits.from(value).toHash() : util3.LongBits.zeroHash; + }; + util3.longFromHash = function longFromHash(hash, unsigned) { + var bits = util3.LongBits.fromHash(hash); + if (util3.Long) + return util3.Long.fromBits(bits.lo, bits.hi, unsigned); + return bits.toNumber(Boolean(unsigned)); + }; + function merge2(dst, src3, ifNotSet) { + for (var keys2 = Object.keys(src3), i8 = 0; i8 < keys2.length; ++i8) + if (dst[keys2[i8]] === void 0 || !ifNotSet) + dst[keys2[i8]] = src3[keys2[i8]]; + return dst; + } + util3.merge = merge2; + util3.lcFirst = function lcFirst(str) { + return str.charAt(0).toLowerCase() + str.substring(1); + }; + function newError(name15) { + function CustomError(message2, properties) { + if (!(this instanceof CustomError)) + return new CustomError(message2, properties); + Object.defineProperty(this, "message", { get: function() { + return message2; + } }); + if (Error.captureStackTrace) + Error.captureStackTrace(this, CustomError); + else + Object.defineProperty(this, "stack", { value: new Error().stack || "" }); + if (properties) + merge2(this, properties); + } + CustomError.prototype = Object.create(Error.prototype, { + constructor: { + value: CustomError, + writable: true, + enumerable: false, + configurable: true + }, + name: { + get: function get17() { + return name15; + }, + set: void 0, + enumerable: false, + // configurable: false would accurately preserve the behavior of + // the original, but I'm guessing that was not intentional. + // For an actual error subclass, this property would + // be configurable. + configurable: true + }, + toString: { + value: function value() { + return this.name + ": " + this.message; + }, + writable: true, + enumerable: false, + configurable: true + } + }); + return CustomError; + } + util3.newError = newError; + util3.ProtocolError = newError("ProtocolError"); + util3.oneOfGetter = function getOneOf(fieldNames) { + var fieldMap = {}; + for (var i8 = 0; i8 < fieldNames.length; ++i8) + fieldMap[fieldNames[i8]] = 1; + return function() { + for (var keys2 = Object.keys(this), i9 = keys2.length - 1; i9 > -1; --i9) + if (fieldMap[keys2[i9]] === 1 && this[keys2[i9]] !== void 0 && this[keys2[i9]] !== null) + return keys2[i9]; + }; + }; + util3.oneOfSetter = function setOneOf(fieldNames) { + return function(name15) { + for (var i8 = 0; i8 < fieldNames.length; ++i8) + if (fieldNames[i8] !== name15) + delete this[fieldNames[i8]]; + }; + }; + util3.toJSONOptions = { + longs: String, + enums: String, + bytes: String, + json: true + }; + util3._configure = function() { + var Buffer2 = util3.Buffer; + if (!Buffer2) { + util3._Buffer_from = util3._Buffer_allocUnsafe = null; + return; + } + util3._Buffer_from = Buffer2.from !== Uint8Array.from && Buffer2.from || /* istanbul ignore next */ + function Buffer_from(value, encoding) { + return new Buffer2(value, encoding); + }; + util3._Buffer_allocUnsafe = Buffer2.allocUnsafe || /* istanbul ignore next */ + function Buffer_allocUnsafe(size4) { + return new Buffer2(size4); + }; + }; + } + }); + + // ../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/writer.js + var require_writer = __commonJS({ + "../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/writer.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = Writer3; + var util3 = require_minimal(); + var BufferWriter; + var LongBits = util3.LongBits; + var base643 = util3.base64; + var utf84 = util3.utf8; + function Op(fn, len, val) { + this.fn = fn; + this.len = len; + this.next = void 0; + this.val = val; + } + function noop2() { + } + function State(writer2) { + this.head = writer2.head; + this.tail = writer2.tail; + this.len = writer2.len; + this.next = writer2.states; + } + function Writer3() { + this.len = 0; + this.head = new Op(noop2, 0, 0); + this.tail = this.head; + this.states = null; + } + var create21 = function create22() { + return util3.Buffer ? function create_buffer_setup() { + return (Writer3.create = function create_buffer() { + return new BufferWriter(); + })(); + } : function create_array() { + return new Writer3(); + }; + }; + Writer3.create = create21(); + Writer3.alloc = function alloc3(size4) { + return new util3.Array(size4); + }; + if (util3.Array !== Array) + Writer3.alloc = util3.pool(Writer3.alloc, util3.Array.prototype.subarray); + Writer3.prototype._push = function push2(fn, len, val) { + this.tail = this.tail.next = new Op(fn, len, val); + this.len += len; + return this; + }; + function writeByte(val, buf3, pos) { + buf3[pos] = val & 255; + } + function writeVarint32(val, buf3, pos) { + while (val > 127) { + buf3[pos++] = val & 127 | 128; + val >>>= 7; + } + buf3[pos] = val; + } + function VarintOp(len, val) { + this.len = len; + this.next = void 0; + this.val = val; + } + VarintOp.prototype = Object.create(Op.prototype); + VarintOp.prototype.fn = writeVarint32; + Writer3.prototype.uint32 = function write_uint32(value) { + this.len += (this.tail = this.tail.next = new VarintOp( + (value = value >>> 0) < 128 ? 1 : value < 16384 ? 2 : value < 2097152 ? 3 : value < 268435456 ? 4 : 5, + value + )).len; + return this; + }; + Writer3.prototype.int32 = function write_int32(value) { + return value < 0 ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) : this.uint32(value); + }; + Writer3.prototype.sint32 = function write_sint32(value) { + return this.uint32((value << 1 ^ value >> 31) >>> 0); + }; + function writeVarint64(val, buf3, pos) { + while (val.hi) { + buf3[pos++] = val.lo & 127 | 128; + val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0; + val.hi >>>= 7; + } + while (val.lo > 127) { + buf3[pos++] = val.lo & 127 | 128; + val.lo = val.lo >>> 7; + } + buf3[pos++] = val.lo; + } + Writer3.prototype.uint64 = function write_uint64(value) { + var bits = LongBits.from(value); + return this._push(writeVarint64, bits.length(), bits); + }; + Writer3.prototype.int64 = Writer3.prototype.uint64; + Writer3.prototype.sint64 = function write_sint64(value) { + var bits = LongBits.from(value).zzEncode(); + return this._push(writeVarint64, bits.length(), bits); + }; + Writer3.prototype.bool = function write_bool(value) { + return this._push(writeByte, 1, value ? 1 : 0); + }; + function writeFixed32(val, buf3, pos) { + buf3[pos] = val & 255; + buf3[pos + 1] = val >>> 8 & 255; + buf3[pos + 2] = val >>> 16 & 255; + buf3[pos + 3] = val >>> 24; + } + Writer3.prototype.fixed32 = function write_fixed32(value) { + return this._push(writeFixed32, 4, value >>> 0); + }; + Writer3.prototype.sfixed32 = Writer3.prototype.fixed32; + Writer3.prototype.fixed64 = function write_fixed64(value) { + var bits = LongBits.from(value); + return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi); + }; + Writer3.prototype.sfixed64 = Writer3.prototype.fixed64; + Writer3.prototype.float = function write_float(value) { + return this._push(util3.float.writeFloatLE, 4, value); + }; + Writer3.prototype.double = function write_double(value) { + return this._push(util3.float.writeDoubleLE, 8, value); + }; + var writeBytes2 = util3.Array.prototype.set ? function writeBytes_set(val, buf3, pos) { + buf3.set(val, pos); + } : function writeBytes_for(val, buf3, pos) { + for (var i8 = 0; i8 < val.length; ++i8) + buf3[pos + i8] = val[i8]; + }; + Writer3.prototype.bytes = function write_bytes(value) { + var len = value.length >>> 0; + if (!len) + return this._push(writeByte, 1, 0); + if (util3.isString(value)) { + var buf3 = Writer3.alloc(len = base643.length(value)); + base643.decode(value, buf3, 0); + value = buf3; + } + return this.uint32(len)._push(writeBytes2, len, value); + }; + Writer3.prototype.string = function write_string(value) { + var len = utf84.length(value); + return len ? this.uint32(len)._push(utf84.write, len, value) : this._push(writeByte, 1, 0); + }; + Writer3.prototype.fork = function fork5() { + this.states = new State(this); + this.head = this.tail = new Op(noop2, 0, 0); + this.len = 0; + return this; + }; + Writer3.prototype.reset = function reset() { + if (this.states) { + this.head = this.states.head; + this.tail = this.states.tail; + this.len = this.states.len; + this.states = this.states.next; + } else { + this.head = this.tail = new Op(noop2, 0, 0); + this.len = 0; + } + return this; + }; + Writer3.prototype.ldelim = function ldelim() { + var head2 = this.head, tail = this.tail, len = this.len; + this.reset().uint32(len); + if (len) { + this.tail.next = head2.next; + this.tail = tail; + this.len += len; + } + return this; + }; + Writer3.prototype.finish = function finish() { + var head2 = this.head.next, buf3 = this.constructor.alloc(this.len), pos = 0; + while (head2) { + head2.fn(head2.val, buf3, pos); + pos += head2.len; + head2 = head2.next; + } + return buf3; + }; + Writer3._configure = function(BufferWriter_) { + BufferWriter = BufferWriter_; + Writer3.create = create21(); + BufferWriter._configure(); + }; + } + }); + + // ../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/writer_buffer.js + var require_writer_buffer = __commonJS({ + "../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/writer_buffer.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = BufferWriter; + var Writer3 = require_writer(); + (BufferWriter.prototype = Object.create(Writer3.prototype)).constructor = BufferWriter; + var util3 = require_minimal(); + function BufferWriter() { + Writer3.call(this); + } + BufferWriter._configure = function() { + BufferWriter.alloc = util3._Buffer_allocUnsafe; + BufferWriter.writeBytesBuffer = util3.Buffer && util3.Buffer.prototype instanceof Uint8Array && util3.Buffer.prototype.set.name === "set" ? function writeBytesBuffer_set(val, buf3, pos) { + buf3.set(val, pos); + } : function writeBytesBuffer_copy(val, buf3, pos) { + if (val.copy) + val.copy(buf3, pos, 0, val.length); + else + for (var i8 = 0; i8 < val.length; ) + buf3[pos++] = val[i8++]; + }; + }; + BufferWriter.prototype.bytes = function write_bytes_buffer(value) { + if (util3.isString(value)) + value = util3._Buffer_from(value, "base64"); + var len = value.length >>> 0; + this.uint32(len); + if (len) + this._push(BufferWriter.writeBytesBuffer, len, value); + return this; + }; + function writeStringBuffer(val, buf3, pos) { + if (val.length < 40) + util3.utf8.write(val, buf3, pos); + else if (buf3.utf8Write) + buf3.utf8Write(val, pos); + else + buf3.write(val, pos); + } + BufferWriter.prototype.string = function write_string_buffer(value) { + var len = util3.Buffer.byteLength(value); + this.uint32(len); + if (len) + this._push(writeStringBuffer, len, value); + return this; + }; + BufferWriter._configure(); + } + }); + + // ../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/reader.js + var require_reader = __commonJS({ + "../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/reader.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = Reader; + var util3 = require_minimal(); + var BufferReader; + var LongBits = util3.LongBits; + var utf84 = util3.utf8; + function indexOutOfRange(reader2, writeLength) { + return RangeError("index out of range: " + reader2.pos + " + " + (writeLength || 1) + " > " + reader2.len); + } + function Reader(buffer4) { + this.buf = buffer4; + this.pos = 0; + this.len = buffer4.length; + } + var create_array = typeof Uint8Array !== "undefined" ? function create_typed_array(buffer4) { + if (buffer4 instanceof Uint8Array || Array.isArray(buffer4)) + return new Reader(buffer4); + throw Error("illegal buffer"); + } : function create_array2(buffer4) { + if (Array.isArray(buffer4)) + return new Reader(buffer4); + throw Error("illegal buffer"); + }; + var create21 = function create22() { + return util3.Buffer ? function create_buffer_setup(buffer4) { + return (Reader.create = function create_buffer(buffer5) { + return util3.Buffer.isBuffer(buffer5) ? new BufferReader(buffer5) : create_array(buffer5); + })(buffer4); + } : create_array; + }; + Reader.create = create21(); + Reader.prototype._slice = util3.Array.prototype.subarray || /* istanbul ignore next */ + util3.Array.prototype.slice; + Reader.prototype.uint32 = function read_uint32_setup() { + var value = 4294967295; + return function read_uint32() { + value = (this.buf[this.pos] & 127) >>> 0; + if (this.buf[this.pos++] < 128) + return value; + value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; + if (this.buf[this.pos++] < 128) + return value; + value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; + if (this.buf[this.pos++] < 128) + return value; + value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; + if (this.buf[this.pos++] < 128) + return value; + value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; + if (this.buf[this.pos++] < 128) + return value; + if ((this.pos += 5) > this.len) { + this.pos = this.len; + throw indexOutOfRange(this, 10); + } + return value; + }; + }(); + Reader.prototype.int32 = function read_int32() { + return this.uint32() | 0; + }; + Reader.prototype.sint32 = function read_sint32() { + var value = this.uint32(); + return value >>> 1 ^ -(value & 1) | 0; + }; + function readLongVarint() { + var bits = new LongBits(0, 0); + var i8 = 0; + if (this.len - this.pos > 4) { + for (; i8 < 4; ++i8) { + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i8 * 7) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0; + bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + i8 = 0; + } else { + for (; i8 < 3; ++i8) { + if (this.pos >= this.len) + throw indexOutOfRange(this); + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i8 * 7) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i8 * 7) >>> 0; + return bits; + } + if (this.len - this.pos > 4) { + for (; i8 < 5; ++i8) { + bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i8 * 7 + 3) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + } else { + for (; i8 < 5; ++i8) { + if (this.pos >= this.len) + throw indexOutOfRange(this); + bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i8 * 7 + 3) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + } + throw Error("invalid varint encoding"); + } + Reader.prototype.bool = function read_bool() { + return this.uint32() !== 0; + }; + function readFixed32_end(buf3, end) { + return (buf3[end - 4] | buf3[end - 3] << 8 | buf3[end - 2] << 16 | buf3[end - 1] << 24) >>> 0; + } + Reader.prototype.fixed32 = function read_fixed32() { + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + return readFixed32_end(this.buf, this.pos += 4); + }; + Reader.prototype.sfixed32 = function read_sfixed32() { + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + return readFixed32_end(this.buf, this.pos += 4) | 0; + }; + function readFixed64() { + if (this.pos + 8 > this.len) + throw indexOutOfRange(this, 8); + return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4)); + } + Reader.prototype.float = function read_float() { + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + var value = util3.float.readFloatLE(this.buf, this.pos); + this.pos += 4; + return value; + }; + Reader.prototype.double = function read_double() { + if (this.pos + 8 > this.len) + throw indexOutOfRange(this, 4); + var value = util3.float.readDoubleLE(this.buf, this.pos); + this.pos += 8; + return value; + }; + Reader.prototype.bytes = function read_bytes() { + var length3 = this.uint32(), start = this.pos, end = this.pos + length3; + if (end > this.len) + throw indexOutOfRange(this, length3); + this.pos += length3; + if (Array.isArray(this.buf)) + return this.buf.slice(start, end); + return start === end ? new this.buf.constructor(0) : this._slice.call(this.buf, start, end); + }; + Reader.prototype.string = function read_string() { + var bytes2 = this.bytes(); + return utf84.read(bytes2, 0, bytes2.length); + }; + Reader.prototype.skip = function skip2(length3) { + if (typeof length3 === "number") { + if (this.pos + length3 > this.len) + throw indexOutOfRange(this, length3); + this.pos += length3; + } else { + do { + if (this.pos >= this.len) + throw indexOutOfRange(this); + } while (this.buf[this.pos++] & 128); + } + return this; + }; + Reader.prototype.skipType = function(wireType) { + switch (wireType) { + case 0: + this.skip(); + break; + case 1: + this.skip(8); + break; + case 2: + this.skip(this.uint32()); + break; + case 3: + while ((wireType = this.uint32() & 7) !== 4) { + this.skipType(wireType); + } + break; + case 5: + this.skip(4); + break; + default: + throw Error("invalid wire type " + wireType + " at offset " + this.pos); + } + return this; + }; + Reader._configure = function(BufferReader_) { + BufferReader = BufferReader_; + Reader.create = create21(); + BufferReader._configure(); + var fn = util3.Long ? "toLong" : ( + /* istanbul ignore next */ + "toNumber" + ); + util3.merge(Reader.prototype, { + int64: function read_int64() { + return readLongVarint.call(this)[fn](false); + }, + uint64: function read_uint64() { + return readLongVarint.call(this)[fn](true); + }, + sint64: function read_sint64() { + return readLongVarint.call(this).zzDecode()[fn](false); + }, + fixed64: function read_fixed64() { + return readFixed64.call(this)[fn](true); + }, + sfixed64: function read_sfixed64() { + return readFixed64.call(this)[fn](false); + } + }); + }; + } + }); + + // ../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/reader_buffer.js + var require_reader_buffer = __commonJS({ + "../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/reader_buffer.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = BufferReader; + var Reader = require_reader(); + (BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader; + var util3 = require_minimal(); + function BufferReader(buffer4) { + Reader.call(this, buffer4); + } + BufferReader._configure = function() { + if (util3.Buffer) + BufferReader.prototype._slice = util3.Buffer.prototype.slice; + }; + BufferReader.prototype.string = function read_string_buffer() { + var len = this.uint32(); + return this.buf.utf8Slice ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len)) : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + len, this.len)); + }; + BufferReader._configure(); + } + }); + + // ../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/rpc/service.js + var require_service = __commonJS({ + "../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/rpc/service.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = Service2; + var util3 = require_minimal(); + (Service2.prototype = Object.create(util3.EventEmitter.prototype)).constructor = Service2; + function Service2(rpcImpl, requestDelimited, responseDelimited) { + if (typeof rpcImpl !== "function") + throw TypeError("rpcImpl must be a function"); + util3.EventEmitter.call(this); + this.rpcImpl = rpcImpl; + this.requestDelimited = Boolean(requestDelimited); + this.responseDelimited = Boolean(responseDelimited); + } + Service2.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) { + if (!request) + throw TypeError("request must be specified"); + var self2 = this; + if (!callback) + return util3.asPromise(rpcCall, self2, method, requestCtor, responseCtor, request); + if (!self2.rpcImpl) { + setTimeout(function() { + callback(Error("already ended")); + }, 0); + return void 0; + } + try { + return self2.rpcImpl( + method, + requestCtor[self2.requestDelimited ? "encodeDelimited" : "encode"](request).finish(), + function rpcCallback(err, response) { + if (err) { + self2.emit("error", err, method); + return callback(err); + } + if (response === null) { + self2.end( + /* endedByRPC */ + true + ); + return void 0; + } + if (!(response instanceof responseCtor)) { + try { + response = responseCtor[self2.responseDelimited ? "decodeDelimited" : "decode"](response); + } catch (err2) { + self2.emit("error", err2, method); + return callback(err2); + } + } + self2.emit("data", response, method); + return callback(null, response); + } + ); + } catch (err) { + self2.emit("error", err, method); + setTimeout(function() { + callback(err); + }, 0); + return void 0; + } + }; + Service2.prototype.end = function end(endedByRPC) { + if (this.rpcImpl) { + if (!endedByRPC) + this.rpcImpl(null, null, null); + this.rpcImpl = null; + this.emit("end").off(); + } + return this; + }; + } + }); + + // ../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/rpc.js + var require_rpc = __commonJS({ + "../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/rpc.js"(exports12) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + var rpc = exports12; + rpc.Service = require_service(); + } + }); + + // ../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/roots.js + var require_roots = __commonJS({ + "../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/roots.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = {}; + } + }); + + // ../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/index-minimal.js + var require_index_minimal = __commonJS({ + "../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/src/index-minimal.js"(exports12) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + var protobuf = exports12; + protobuf.build = "minimal"; + protobuf.Writer = require_writer(); + protobuf.BufferWriter = require_writer_buffer(); + protobuf.Reader = require_reader(); + protobuf.BufferReader = require_reader_buffer(); + protobuf.util = require_minimal(); + protobuf.rpc = require_rpc(); + protobuf.roots = require_roots(); + protobuf.configure = configure7; + function configure7() { + protobuf.util._configure(); + protobuf.Writer._configure(protobuf.BufferWriter); + protobuf.Reader._configure(protobuf.BufferReader); + } + configure7(); + } + }); + + // ../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/minimal.js + var require_minimal2 = __commonJS({ + "../../node_modules/.pnpm/protobufjs@7.2.2/node_modules/protobufjs/minimal.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = require_index_minimal(); + } + }); + + // ../../node_modules/.pnpm/murmurhash3js-revisited@3.0.0/node_modules/murmurhash3js-revisited/lib/murmurHash3js.js + var require_murmurHash3js = __commonJS({ + "../../node_modules/.pnpm/murmurhash3js-revisited@3.0.0/node_modules/murmurhash3js-revisited/lib/murmurHash3js.js"(exports12, module3) { + init_dirname(); + init_buffer2(); + init_process(); + (function(root3, undefined2) { + "use strict"; + var library = { + "version": "3.0.0", + "x86": {}, + "x64": {}, + "inputValidation": true + }; + function _validBytes(bytes2) { + if (!Array.isArray(bytes2) && !ArrayBuffer.isView(bytes2)) { + return false; + } + for (var i8 = 0; i8 < bytes2.length; i8++) { + if (!Number.isInteger(bytes2[i8]) || bytes2[i8] < 0 || bytes2[i8] > 255) { + return false; + } + } + return true; + } + function _x86Multiply(m7, n9) { + return (m7 & 65535) * n9 + (((m7 >>> 16) * n9 & 65535) << 16); + } + function _x86Rotl(m7, n9) { + return m7 << n9 | m7 >>> 32 - n9; + } + function _x86Fmix(h9) { + h9 ^= h9 >>> 16; + h9 = _x86Multiply(h9, 2246822507); + h9 ^= h9 >>> 13; + h9 = _x86Multiply(h9, 3266489909); + h9 ^= h9 >>> 16; + return h9; + } + function _x64Add(m7, n9) { + m7 = [m7[0] >>> 16, m7[0] & 65535, m7[1] >>> 16, m7[1] & 65535]; + n9 = [n9[0] >>> 16, n9[0] & 65535, n9[1] >>> 16, n9[1] & 65535]; + var o9 = [0, 0, 0, 0]; + o9[3] += m7[3] + n9[3]; + o9[2] += o9[3] >>> 16; + o9[3] &= 65535; + o9[2] += m7[2] + n9[2]; + o9[1] += o9[2] >>> 16; + o9[2] &= 65535; + o9[1] += m7[1] + n9[1]; + o9[0] += o9[1] >>> 16; + o9[1] &= 65535; + o9[0] += m7[0] + n9[0]; + o9[0] &= 65535; + return [o9[0] << 16 | o9[1], o9[2] << 16 | o9[3]]; + } + function _x64Multiply(m7, n9) { + m7 = [m7[0] >>> 16, m7[0] & 65535, m7[1] >>> 16, m7[1] & 65535]; + n9 = [n9[0] >>> 16, n9[0] & 65535, n9[1] >>> 16, n9[1] & 65535]; + var o9 = [0, 0, 0, 0]; + o9[3] += m7[3] * n9[3]; + o9[2] += o9[3] >>> 16; + o9[3] &= 65535; + o9[2] += m7[2] * n9[3]; + o9[1] += o9[2] >>> 16; + o9[2] &= 65535; + o9[2] += m7[3] * n9[2]; + o9[1] += o9[2] >>> 16; + o9[2] &= 65535; + o9[1] += m7[1] * n9[3]; + o9[0] += o9[1] >>> 16; + o9[1] &= 65535; + o9[1] += m7[2] * n9[2]; + o9[0] += o9[1] >>> 16; + o9[1] &= 65535; + o9[1] += m7[3] * n9[1]; + o9[0] += o9[1] >>> 16; + o9[1] &= 65535; + o9[0] += m7[0] * n9[3] + m7[1] * n9[2] + m7[2] * n9[1] + m7[3] * n9[0]; + o9[0] &= 65535; + return [o9[0] << 16 | o9[1], o9[2] << 16 | o9[3]]; + } + function _x64Rotl(m7, n9) { + n9 %= 64; + if (n9 === 32) { + return [m7[1], m7[0]]; + } else if (n9 < 32) { + return [m7[0] << n9 | m7[1] >>> 32 - n9, m7[1] << n9 | m7[0] >>> 32 - n9]; + } else { + n9 -= 32; + return [m7[1] << n9 | m7[0] >>> 32 - n9, m7[0] << n9 | m7[1] >>> 32 - n9]; + } + } + function _x64LeftShift(m7, n9) { + n9 %= 64; + if (n9 === 0) { + return m7; + } else if (n9 < 32) { + return [m7[0] << n9 | m7[1] >>> 32 - n9, m7[1] << n9]; + } else { + return [m7[1] << n9 - 32, 0]; + } + } + function _x64Xor(m7, n9) { + return [m7[0] ^ n9[0], m7[1] ^ n9[1]]; + } + function _x64Fmix(h9) { + h9 = _x64Xor(h9, [0, h9[0] >>> 1]); + h9 = _x64Multiply(h9, [4283543511, 3981806797]); + h9 = _x64Xor(h9, [0, h9[0] >>> 1]); + h9 = _x64Multiply(h9, [3301882366, 444984403]); + h9 = _x64Xor(h9, [0, h9[0] >>> 1]); + return h9; + } + library.x86.hash32 = function(bytes2, seed) { + if (library.inputValidation && !_validBytes(bytes2)) { + return undefined2; + } + seed = seed || 0; + var remainder = bytes2.length % 4; + var blocks = bytes2.length - remainder; + var h1 = seed; + var k1 = 0; + var c1 = 3432918353; + var c22 = 461845907; + for (var i8 = 0; i8 < blocks; i8 = i8 + 4) { + k1 = bytes2[i8] | bytes2[i8 + 1] << 8 | bytes2[i8 + 2] << 16 | bytes2[i8 + 3] << 24; + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c22); + h1 ^= k1; + h1 = _x86Rotl(h1, 13); + h1 = _x86Multiply(h1, 5) + 3864292196; + } + k1 = 0; + switch (remainder) { + case 3: + k1 ^= bytes2[i8 + 2] << 16; + case 2: + k1 ^= bytes2[i8 + 1] << 8; + case 1: + k1 ^= bytes2[i8]; + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c22); + h1 ^= k1; + } + h1 ^= bytes2.length; + h1 = _x86Fmix(h1); + return h1 >>> 0; + }; + library.x86.hash128 = function(bytes2, seed) { + if (library.inputValidation && !_validBytes(bytes2)) { + return undefined2; + } + seed = seed || 0; + var remainder = bytes2.length % 16; + var blocks = bytes2.length - remainder; + var h1 = seed; + var h22 = seed; + var h32 = seed; + var h42 = seed; + var k1 = 0; + var k22 = 0; + var k32 = 0; + var k42 = 0; + var c1 = 597399067; + var c22 = 2869860233; + var c32 = 951274213; + var c42 = 2716044179; + for (var i8 = 0; i8 < blocks; i8 = i8 + 16) { + k1 = bytes2[i8] | bytes2[i8 + 1] << 8 | bytes2[i8 + 2] << 16 | bytes2[i8 + 3] << 24; + k22 = bytes2[i8 + 4] | bytes2[i8 + 5] << 8 | bytes2[i8 + 6] << 16 | bytes2[i8 + 7] << 24; + k32 = bytes2[i8 + 8] | bytes2[i8 + 9] << 8 | bytes2[i8 + 10] << 16 | bytes2[i8 + 11] << 24; + k42 = bytes2[i8 + 12] | bytes2[i8 + 13] << 8 | bytes2[i8 + 14] << 16 | bytes2[i8 + 15] << 24; + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c22); + h1 ^= k1; + h1 = _x86Rotl(h1, 19); + h1 += h22; + h1 = _x86Multiply(h1, 5) + 1444728091; + k22 = _x86Multiply(k22, c22); + k22 = _x86Rotl(k22, 16); + k22 = _x86Multiply(k22, c32); + h22 ^= k22; + h22 = _x86Rotl(h22, 17); + h22 += h32; + h22 = _x86Multiply(h22, 5) + 197830471; + k32 = _x86Multiply(k32, c32); + k32 = _x86Rotl(k32, 17); + k32 = _x86Multiply(k32, c42); + h32 ^= k32; + h32 = _x86Rotl(h32, 15); + h32 += h42; + h32 = _x86Multiply(h32, 5) + 2530024501; + k42 = _x86Multiply(k42, c42); + k42 = _x86Rotl(k42, 18); + k42 = _x86Multiply(k42, c1); + h42 ^= k42; + h42 = _x86Rotl(h42, 13); + h42 += h1; + h42 = _x86Multiply(h42, 5) + 850148119; + } + k1 = 0; + k22 = 0; + k32 = 0; + k42 = 0; + switch (remainder) { + case 15: + k42 ^= bytes2[i8 + 14] << 16; + case 14: + k42 ^= bytes2[i8 + 13] << 8; + case 13: + k42 ^= bytes2[i8 + 12]; + k42 = _x86Multiply(k42, c42); + k42 = _x86Rotl(k42, 18); + k42 = _x86Multiply(k42, c1); + h42 ^= k42; + case 12: + k32 ^= bytes2[i8 + 11] << 24; + case 11: + k32 ^= bytes2[i8 + 10] << 16; + case 10: + k32 ^= bytes2[i8 + 9] << 8; + case 9: + k32 ^= bytes2[i8 + 8]; + k32 = _x86Multiply(k32, c32); + k32 = _x86Rotl(k32, 17); + k32 = _x86Multiply(k32, c42); + h32 ^= k32; + case 8: + k22 ^= bytes2[i8 + 7] << 24; + case 7: + k22 ^= bytes2[i8 + 6] << 16; + case 6: + k22 ^= bytes2[i8 + 5] << 8; + case 5: + k22 ^= bytes2[i8 + 4]; + k22 = _x86Multiply(k22, c22); + k22 = _x86Rotl(k22, 16); + k22 = _x86Multiply(k22, c32); + h22 ^= k22; + case 4: + k1 ^= bytes2[i8 + 3] << 24; + case 3: + k1 ^= bytes2[i8 + 2] << 16; + case 2: + k1 ^= bytes2[i8 + 1] << 8; + case 1: + k1 ^= bytes2[i8]; + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c22); + h1 ^= k1; + } + h1 ^= bytes2.length; + h22 ^= bytes2.length; + h32 ^= bytes2.length; + h42 ^= bytes2.length; + h1 += h22; + h1 += h32; + h1 += h42; + h22 += h1; + h32 += h1; + h42 += h1; + h1 = _x86Fmix(h1); + h22 = _x86Fmix(h22); + h32 = _x86Fmix(h32); + h42 = _x86Fmix(h42); + h1 += h22; + h1 += h32; + h1 += h42; + h22 += h1; + h32 += h1; + h42 += h1; + return ("00000000" + (h1 >>> 0).toString(16)).slice(-8) + ("00000000" + (h22 >>> 0).toString(16)).slice(-8) + ("00000000" + (h32 >>> 0).toString(16)).slice(-8) + ("00000000" + (h42 >>> 0).toString(16)).slice(-8); + }; + library.x64.hash128 = function(bytes2, seed) { + if (library.inputValidation && !_validBytes(bytes2)) { + return undefined2; + } + seed = seed || 0; + var remainder = bytes2.length % 16; + var blocks = bytes2.length - remainder; + var h1 = [0, seed]; + var h22 = [0, seed]; + var k1 = [0, 0]; + var k22 = [0, 0]; + var c1 = [2277735313, 289559509]; + var c22 = [1291169091, 658871167]; + for (var i8 = 0; i8 < blocks; i8 = i8 + 16) { + k1 = [bytes2[i8 + 4] | bytes2[i8 + 5] << 8 | bytes2[i8 + 6] << 16 | bytes2[i8 + 7] << 24, bytes2[i8] | bytes2[i8 + 1] << 8 | bytes2[i8 + 2] << 16 | bytes2[i8 + 3] << 24]; + k22 = [bytes2[i8 + 12] | bytes2[i8 + 13] << 8 | bytes2[i8 + 14] << 16 | bytes2[i8 + 15] << 24, bytes2[i8 + 8] | bytes2[i8 + 9] << 8 | bytes2[i8 + 10] << 16 | bytes2[i8 + 11] << 24]; + k1 = _x64Multiply(k1, c1); + k1 = _x64Rotl(k1, 31); + k1 = _x64Multiply(k1, c22); + h1 = _x64Xor(h1, k1); + h1 = _x64Rotl(h1, 27); + h1 = _x64Add(h1, h22); + h1 = _x64Add(_x64Multiply(h1, [0, 5]), [0, 1390208809]); + k22 = _x64Multiply(k22, c22); + k22 = _x64Rotl(k22, 33); + k22 = _x64Multiply(k22, c1); + h22 = _x64Xor(h22, k22); + h22 = _x64Rotl(h22, 31); + h22 = _x64Add(h22, h1); + h22 = _x64Add(_x64Multiply(h22, [0, 5]), [0, 944331445]); + } + k1 = [0, 0]; + k22 = [0, 0]; + switch (remainder) { + case 15: + k22 = _x64Xor(k22, _x64LeftShift([0, bytes2[i8 + 14]], 48)); + case 14: + k22 = _x64Xor(k22, _x64LeftShift([0, bytes2[i8 + 13]], 40)); + case 13: + k22 = _x64Xor(k22, _x64LeftShift([0, bytes2[i8 + 12]], 32)); + case 12: + k22 = _x64Xor(k22, _x64LeftShift([0, bytes2[i8 + 11]], 24)); + case 11: + k22 = _x64Xor(k22, _x64LeftShift([0, bytes2[i8 + 10]], 16)); + case 10: + k22 = _x64Xor(k22, _x64LeftShift([0, bytes2[i8 + 9]], 8)); + case 9: + k22 = _x64Xor(k22, [0, bytes2[i8 + 8]]); + k22 = _x64Multiply(k22, c22); + k22 = _x64Rotl(k22, 33); + k22 = _x64Multiply(k22, c1); + h22 = _x64Xor(h22, k22); + case 8: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes2[i8 + 7]], 56)); + case 7: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes2[i8 + 6]], 48)); + case 6: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes2[i8 + 5]], 40)); + case 5: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes2[i8 + 4]], 32)); + case 4: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes2[i8 + 3]], 24)); + case 3: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes2[i8 + 2]], 16)); + case 2: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes2[i8 + 1]], 8)); + case 1: + k1 = _x64Xor(k1, [0, bytes2[i8]]); + k1 = _x64Multiply(k1, c1); + k1 = _x64Rotl(k1, 31); + k1 = _x64Multiply(k1, c22); + h1 = _x64Xor(h1, k1); + } + h1 = _x64Xor(h1, [0, bytes2.length]); + h22 = _x64Xor(h22, [0, bytes2.length]); + h1 = _x64Add(h1, h22); + h22 = _x64Add(h22, h1); + h1 = _x64Fmix(h1); + h22 = _x64Fmix(h22); + h1 = _x64Add(h1, h22); + h22 = _x64Add(h22, h1); + return ("00000000" + (h1[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h1[1] >>> 0).toString(16)).slice(-8) + ("00000000" + (h22[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h22[1] >>> 0).toString(16)).slice(-8); + }; + if (typeof exports12 !== "undefined") { + if (typeof module3 !== "undefined" && module3.exports) { + exports12 = module3.exports = library; + } + exports12.murmurHash3 = library; + } else if (typeof define === "function" && define.amd) { + define([], function() { + return library; + }); + } else { + library._murmurHash3 = root3.murmurHash3; + library.noConflict = function() { + root3.murmurHash3 = library._murmurHash3; + library._murmurHash3 = undefined2; + library.noConflict = undefined2; + return library; + }; + root3.murmurHash3 = library; + } + })(exports12); + } + }); + + // ../../node_modules/.pnpm/murmurhash3js-revisited@3.0.0/node_modules/murmurhash3js-revisited/index.js + var require_murmurhash3js_revisited = __commonJS({ + "../../node_modules/.pnpm/murmurhash3js-revisited@3.0.0/node_modules/murmurhash3js-revisited/index.js"(exports12, module3) { + init_dirname(); + init_buffer2(); + init_process(); + module3.exports = require_murmurHash3js(); + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/assert.js + function e8(e12, r10) { + if (null == e12) + throw new TypeError("Cannot convert first argument to object"); + for (var t9 = Object(e12), n9 = 1; n9 < arguments.length; n9++) { + var o9 = arguments[n9]; + if (null != o9) + for (var a8 = Object.keys(Object(o9)), l8 = 0, i8 = a8.length; l8 < i8; l8++) { + var c8 = a8[l8], b6 = Object.getOwnPropertyDescriptor(o9, c8); + void 0 !== b6 && b6.enumerable && (t9[c8] = o9[c8]); + } + } + return t9; + } + function i$52() { + if (a$62) + return c$42; + function e12(t9) { + return (e12 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t10) { + return typeof t10; + } : function(t10) { + return t10 && "function" == typeof Symbol && t10.constructor === Symbol && t10 !== Symbol.prototype ? "symbol" : typeof t10; + })(t9); + } + function n9(t9, n10) { + return !n10 || "object" !== e12(n10) && "function" != typeof n10 ? function(t10) { + if (void 0 === t10) + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return t10; + }(t9) : n10; + } + function r10(t9) { + return (r10 = Object.setPrototypeOf ? Object.getPrototypeOf : function(t10) { + return t10.__proto__ || Object.getPrototypeOf(t10); + })(t9); + } + function o9(t9, e13) { + return (o9 = Object.setPrototypeOf || function(t10, e14) { + return t10.__proto__ = e14, t10; + })(t9, e13); + } + a$62 = true; + var i8, u8, l8 = {}; + function f9(t9, e13, c8) { + c8 || (c8 = Error); + var a8 = function(c9) { + function a9(o10, c10, i9) { + var u9; + return !function(t10, e14) { + if (!(t10 instanceof e14)) + throw new TypeError("Cannot call a class as a function"); + }(this, a9), (u9 = n9(this, r10(a9).call(this, function(t10, n10, r11) { + return "string" == typeof e13 ? e13 : e13(t10, n10, r11); + }(o10, c10, i9)))).code = t9, u9; + } + return !function(t10, e14) { + if ("function" != typeof e14 && null !== e14) + throw new TypeError("Super expression must either be null or a function"); + t10.prototype = Object.create(e14 && e14.prototype, { constructor: { value: t10, writable: true, configurable: true } }), e14 && o9(t10, e14); + }(a9, c9), a9; + }(c8); + l8[t9] = a8; + } + function s7(t9, e13) { + if (Array.isArray(t9)) { + var n10 = t9.length; + return t9 = t9.map(function(t10) { + return String(t10); + }), n10 > 2 ? "one of ".concat(e13, " ").concat(t9.slice(0, n10 - 1).join(", "), ", or ") + t9[n10 - 1] : 2 === n10 ? "one of ".concat(e13, " ").concat(t9[0], " or ").concat(t9[1]) : "of ".concat(e13, " ").concat(t9[0]); + } + return "of ".concat(e13, " ").concat(String(t9)); + } + return f9("ERR_AMBIGUOUS_ARGUMENT", 'The "%s" argument is ambiguous. %s', TypeError), f9("ERR_INVALID_ARG_TYPE", function(t9, n10, r11) { + var o10, c8, u9; + if (void 0 === i8 && (i8 = tt2()), i8("string" == typeof t9, "'name' must be a string"), "string" == typeof n10 && (c8 = "not ", n10.substr(0, c8.length) === c8) ? (o10 = "must not be", n10 = n10.replace(/^not /, "")) : o10 = "must be", function(t10, e13, n11) { + return (void 0 === n11 || n11 > t10.length) && (n11 = t10.length), t10.substring(n11 - e13.length, n11) === e13; + }(t9, " argument")) + u9 = "The ".concat(t9, " ").concat(o10, " ").concat(s7(n10, "type")); + else { + var l9 = function(t10, e13, n11) { + return "number" != typeof n11 && (n11 = 0), !(n11 + e13.length > t10.length) && -1 !== t10.indexOf(e13, n11); + }(t9, ".") ? "property" : "argument"; + u9 = 'The "'.concat(t9, '" ').concat(l9, " ").concat(o10, " ").concat(s7(n10, "type")); + } + return u9 += ". Received type ".concat(e12(r11)); + }, TypeError), f9("ERR_INVALID_ARG_VALUE", function(e13, n10) { + var r11 = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "is invalid"; + void 0 === u8 && (u8 = X); + var o10 = u8.inspect(n10); + return o10.length > 128 && (o10 = "".concat(o10.slice(0, 128), "...")), "The argument '".concat(e13, "' ").concat(r11, ". Received ").concat(o10); + }, TypeError), f9("ERR_INVALID_RETURN_VALUE", function(t9, n10, r11) { + var o10; + return o10 = r11 && r11.constructor && r11.constructor.name ? "instance of ".concat(r11.constructor.name) : "type ".concat(e12(r11)), "Expected ".concat(t9, ' to be returned from the "').concat(n10, '"') + " function but got ".concat(o10, "."); + }, TypeError), f9("ERR_MISSING_ARGS", function() { + for (var t9 = arguments.length, e13 = new Array(t9), n10 = 0; n10 < t9; n10++) + e13[n10] = arguments[n10]; + void 0 === i8 && (i8 = tt2()), i8(e13.length > 0, "At least one arg needs to be specified"); + var r11 = "The ", o10 = e13.length; + switch (e13 = e13.map(function(t10) { + return '"'.concat(t10, '"'); + }), o10) { + case 1: + r11 += "".concat(e13[0], " argument"); + break; + case 2: + r11 += "".concat(e13[0], " and ").concat(e13[1], " arguments"); + break; + default: + r11 += e13.slice(0, o10 - 1).join(", "), r11 += ", and ".concat(e13[o10 - 1], " arguments"); + } + return "".concat(r11, " must be specified"); + }, TypeError), c$42.codes = l8, c$42; + } + function f$62() { + if (l$62) + return u$52; + l$62 = true; + var n9 = T; + function r10(t9, e12, n10) { + return e12 in t9 ? Object.defineProperty(t9, e12, { value: n10, enumerable: true, configurable: true, writable: true }) : t9[e12] = n10, t9; + } + function o9(t9, e12) { + for (var n10 = 0; n10 < e12.length; n10++) { + var r11 = e12[n10]; + r11.enumerable = r11.enumerable || false, r11.configurable = true, "value" in r11 && (r11.writable = true), Object.defineProperty(t9, r11.key, r11); + } + } + function c8(t9, e12) { + return !e12 || "object" !== y7(e12) && "function" != typeof e12 ? a8(t9) : e12; + } + function a8(t9) { + if (void 0 === t9) + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return t9; + } + function f9(t9) { + var e12 = "function" == typeof Map ? /* @__PURE__ */ new Map() : void 0; + return (f9 = function(t10) { + if (null === t10 || (n10 = t10, -1 === Function.toString.call(n10).indexOf("[native code]"))) + return t10; + var n10; + if ("function" != typeof t10) + throw new TypeError("Super expression must either be null or a function"); + if (void 0 !== e12) { + if (e12.has(t10)) + return e12.get(t10); + e12.set(t10, r11); + } + function r11() { + return p8(t10, arguments, h9(this).constructor); + } + return r11.prototype = Object.create(t10.prototype, { constructor: { value: r11, enumerable: false, writable: true, configurable: true } }), g6(r11, t10); + })(t9); + } + function s7() { + if ("undefined" == typeof Reflect || !Reflect.construct) + return false; + if (Reflect.construct.sham) + return false; + if ("function" == typeof Proxy) + return true; + try { + return Date.prototype.toString.call(Reflect.construct(Date, [], function() { + })), true; + } catch (t9) { + return false; + } + } + function p8(t9, e12, n10) { + return (p8 = s7() ? Reflect.construct : function(t10, e13, n11) { + var r11 = [null]; + r11.push.apply(r11, e13); + var o10 = new (Function.bind.apply(t10, r11))(); + return n11 && g6(o10, n11.prototype), o10; + }).apply(null, arguments); + } + function g6(t9, e12) { + return (g6 = Object.setPrototypeOf || function(t10, e13) { + return t10.__proto__ = e13, t10; + })(t9, e12); + } + function h9(t9) { + return (h9 = Object.setPrototypeOf ? Object.getPrototypeOf : function(t10) { + return t10.__proto__ || Object.getPrototypeOf(t10); + })(t9); + } + function y7(t9) { + return (y7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t10) { + return typeof t10; + } : function(t10) { + return t10 && "function" == typeof Symbol && t10.constructor === Symbol && t10 !== Symbol.prototype ? "symbol" : typeof t10; + })(t9); + } + var b6 = X.inspect, v7 = i$52().codes.ERR_INVALID_ARG_TYPE; + function d7(t9, e12, n10) { + return (void 0 === n10 || n10 > t9.length) && (n10 = t9.length), t9.substring(n10 - e12.length, n10) === e12; + } + var m7 = "", E5 = "", w5 = "", S5 = "", j5 = { deepStrictEqual: "Expected values to be strictly deep-equal:", strictEqual: "Expected values to be strictly equal:", strictEqualObject: 'Expected "actual" to be reference-equal to "expected":', deepEqual: "Expected values to be loosely deep-equal:", equal: "Expected values to be loosely equal:", notDeepStrictEqual: 'Expected "actual" not to be strictly deep-equal to:', notStrictEqual: 'Expected "actual" to be strictly unequal to:', notStrictEqualObject: 'Expected "actual" not to be reference-equal to "expected":', notDeepEqual: 'Expected "actual" not to be loosely deep-equal to:', notEqual: 'Expected "actual" to be loosely unequal to:', notIdentical: "Values identical but not reference-equal:" }; + function O6(t9) { + var e12 = Object.keys(t9), n10 = Object.create(Object.getPrototypeOf(t9)); + return e12.forEach(function(e13) { + n10[e13] = t9[e13]; + }), Object.defineProperty(n10, "message", { value: t9.message }), n10; + } + function x5(t9) { + return b6(t9, { compact: false, customInspect: false, depth: 1e3, maxArrayLength: 1 / 0, showHidden: false, breakLength: 1 / 0, showProxy: false, sorted: true, getters: true }); + } + function q4(t9, e12, r11) { + var o10 = "", c9 = "", a9 = 0, i8 = "", u8 = false, l8 = x5(t9), f10 = l8.split("\n"), s8 = x5(e12).split("\n"), p9 = 0, g7 = ""; + if ("strictEqual" === r11 && "object" === y7(t9) && "object" === y7(e12) && null !== t9 && null !== e12 && (r11 = "strictEqualObject"), 1 === f10.length && 1 === s8.length && f10[0] !== s8[0]) { + var h10 = f10[0].length + s8[0].length; + if (h10 <= 10) { + if (!("object" === y7(t9) && null !== t9 || "object" === y7(e12) && null !== e12 || 0 === t9 && 0 === e12)) + return "".concat(j5[r11], "\n\n") + "".concat(f10[0], " !== ").concat(s8[0], "\n"); + } else if ("strictEqualObject" !== r11) { + if (h10 < (n9.stderr && n9.stderr.isTTY ? n9.stderr.columns : 80)) { + for (; f10[0][p9] === s8[0][p9]; ) + p9++; + p9 > 2 && (g7 = "\n ".concat(function(t10, e13) { + if (e13 = Math.floor(e13), 0 == t10.length || 0 == e13) + return ""; + var n10 = t10.length * e13; + for (e13 = Math.floor(Math.log(e13) / Math.log(2)); e13; ) + t10 += t10, e13--; + return t10 += t10.substring(0, n10 - t10.length); + }(" ", p9), "^"), p9 = 0); + } + } + } + for (var b7 = f10[f10.length - 1], v8 = s8[s8.length - 1]; b7 === v8 && (p9++ < 2 ? i8 = "\n ".concat(b7).concat(i8) : o10 = b7, f10.pop(), s8.pop(), 0 !== f10.length && 0 !== s8.length); ) + b7 = f10[f10.length - 1], v8 = s8[s8.length - 1]; + var O7 = Math.max(f10.length, s8.length); + if (0 === O7) { + var q5 = l8.split("\n"); + if (q5.length > 30) + for (q5[26] = "".concat(m7, "...").concat(S5); q5.length > 27; ) + q5.pop(); + return "".concat(j5.notIdentical, "\n\n").concat(q5.join("\n"), "\n"); + } + p9 > 3 && (i8 = "\n".concat(m7, "...").concat(S5).concat(i8), u8 = true), "" !== o10 && (i8 = "\n ".concat(o10).concat(i8), o10 = ""); + var R6 = 0, A5 = j5[r11] + "\n".concat(E5, "+ actual").concat(S5, " ").concat(w5, "- expected").concat(S5), k5 = " ".concat(m7, "...").concat(S5, " Lines skipped"); + for (p9 = 0; p9 < O7; p9++) { + var _5 = p9 - a9; + if (f10.length < p9 + 1) + _5 > 1 && p9 > 2 && (_5 > 4 ? (c9 += "\n".concat(m7, "...").concat(S5), u8 = true) : _5 > 3 && (c9 += "\n ".concat(s8[p9 - 2]), R6++), c9 += "\n ".concat(s8[p9 - 1]), R6++), a9 = p9, o10 += "\n".concat(w5, "-").concat(S5, " ").concat(s8[p9]), R6++; + else if (s8.length < p9 + 1) + _5 > 1 && p9 > 2 && (_5 > 4 ? (c9 += "\n".concat(m7, "...").concat(S5), u8 = true) : _5 > 3 && (c9 += "\n ".concat(f10[p9 - 2]), R6++), c9 += "\n ".concat(f10[p9 - 1]), R6++), a9 = p9, c9 += "\n".concat(E5, "+").concat(S5, " ").concat(f10[p9]), R6++; + else { + var T6 = s8[p9], P5 = f10[p9], I5 = P5 !== T6 && (!d7(P5, ",") || P5.slice(0, -1) !== T6); + I5 && d7(T6, ",") && T6.slice(0, -1) === P5 && (I5 = false, P5 += ","), I5 ? (_5 > 1 && p9 > 2 && (_5 > 4 ? (c9 += "\n".concat(m7, "...").concat(S5), u8 = true) : _5 > 3 && (c9 += "\n ".concat(f10[p9 - 2]), R6++), c9 += "\n ".concat(f10[p9 - 1]), R6++), a9 = p9, c9 += "\n".concat(E5, "+").concat(S5, " ").concat(P5), o10 += "\n".concat(w5, "-").concat(S5, " ").concat(T6), R6 += 2) : (c9 += o10, o10 = "", 1 !== _5 && 0 !== p9 || (c9 += "\n ".concat(P5), R6++)); + } + if (R6 > 20 && p9 < O7 - 2) + return "".concat(A5).concat(k5, "\n").concat(c9, "\n").concat(m7, "...").concat(S5).concat(o10, "\n") + "".concat(m7, "...").concat(S5); + } + return "".concat(A5).concat(u8 ? k5 : "", "\n").concat(c9).concat(o10).concat(i8).concat(g7); + } + var R5 = function(t9) { + function e12(t10) { + var r11; + if (!function(t11, e13) { + if (!(t11 instanceof e13)) + throw new TypeError("Cannot call a class as a function"); + }(this, e12), "object" !== y7(t10) || null === t10) + throw new v7("options", "Object", t10); + var o10 = t10.message, i9 = t10.operator, u9 = t10.stackStartFn, l8 = t10.actual, f10 = t10.expected, s8 = Error.stackTraceLimit; + if (Error.stackTraceLimit = 0, null != o10) + r11 = c8(this, h9(e12).call(this, String(o10))); + else if (n9.stderr && n9.stderr.isTTY && (n9.stderr && n9.stderr.getColorDepth && 1 !== n9.stderr.getColorDepth() ? (m7 = "\x1B[34m", E5 = "\x1B[32m", S5 = "\x1B[39m", w5 = "\x1B[31m") : (m7 = "", E5 = "", S5 = "", w5 = "")), "object" === y7(l8) && null !== l8 && "object" === y7(f10) && null !== f10 && "stack" in l8 && l8 instanceof Error && "stack" in f10 && f10 instanceof Error && (l8 = O6(l8), f10 = O6(f10)), "deepStrictEqual" === i9 || "strictEqual" === i9) + r11 = c8(this, h9(e12).call(this, q4(l8, f10, i9))); + else if ("notDeepStrictEqual" === i9 || "notStrictEqual" === i9) { + var p9 = j5[i9], g7 = x5(l8).split("\n"); + if ("notStrictEqual" === i9 && "object" === y7(l8) && null !== l8 && (p9 = j5.notStrictEqualObject), g7.length > 30) + for (g7[26] = "".concat(m7, "...").concat(S5); g7.length > 27; ) + g7.pop(); + r11 = 1 === g7.length ? c8(this, h9(e12).call(this, "".concat(p9, " ").concat(g7[0]))) : c8(this, h9(e12).call(this, "".concat(p9, "\n\n").concat(g7.join("\n"), "\n"))); + } else { + var b7 = x5(l8), d8 = "", R6 = j5[i9]; + "notDeepEqual" === i9 || "notEqual" === i9 ? (b7 = "".concat(j5[i9], "\n\n").concat(b7)).length > 1024 && (b7 = "".concat(b7.slice(0, 1021), "...")) : (d8 = "".concat(x5(f10)), b7.length > 512 && (b7 = "".concat(b7.slice(0, 509), "...")), d8.length > 512 && (d8 = "".concat(d8.slice(0, 509), "...")), "deepEqual" === i9 || "equal" === i9 ? b7 = "".concat(R6, "\n\n").concat(b7, "\n\nshould equal\n\n") : d8 = " ".concat(i9, " ").concat(d8)), r11 = c8(this, h9(e12).call(this, "".concat(b7).concat(d8))); + } + return Error.stackTraceLimit = s8, r11.generatedMessage = !o10, Object.defineProperty(a8(r11), "name", { value: "AssertionError [ERR_ASSERTION]", enumerable: false, writable: true, configurable: true }), r11.code = "ERR_ASSERTION", r11.actual = l8, r11.expected = f10, r11.operator = i9, Error.captureStackTrace && Error.captureStackTrace(a8(r11), u9), r11.stack, r11.name = "AssertionError", c8(r11); + } + var i8, u8; + return !function(t10, e13) { + if ("function" != typeof e13 && null !== e13) + throw new TypeError("Super expression must either be null or a function"); + t10.prototype = Object.create(e13 && e13.prototype, { constructor: { value: t10, writable: true, configurable: true } }), e13 && g6(t10, e13); + }(e12, t9), i8 = e12, (u8 = [{ key: "toString", value: function() { + return "".concat(this.name, " [").concat(this.code, "]: ").concat(this.message); + } }, { key: b6.custom, value: function(t10, e13) { + return b6(this, function(t11) { + for (var e14 = 1; e14 < arguments.length; e14++) { + var n10 = null != arguments[e14] ? arguments[e14] : {}, o10 = Object.keys(n10); + "function" == typeof Object.getOwnPropertySymbols && (o10 = o10.concat(Object.getOwnPropertySymbols(n10).filter(function(t12) { + return Object.getOwnPropertyDescriptor(n10, t12).enumerable; + }))), o10.forEach(function(e15) { + r10(t11, e15, n10[e15]); + }); + } + return t11; + }({}, e13, { customInspect: false, depth: 0 })); + } }]) && o9(i8.prototype, u8), e12; + }(f9(Error)); + return u$52 = R5; + } + function s$32(t9, e12) { + return function(t10) { + if (Array.isArray(t10)) + return t10; + }(t9) || function(t10, e13) { + var n9 = [], r10 = true, o9 = false, c8 = void 0; + try { + for (var a8, i8 = t10[Symbol.iterator](); !(r10 = (a8 = i8.next()).done) && (n9.push(a8.value), !e13 || n9.length !== e13); r10 = true) + ; + } catch (t11) { + o9 = true, c8 = t11; + } finally { + try { + r10 || null == i8.return || i8.return(); + } finally { + if (o9) + throw c8; + } + } + return n9; + }(t9, e12) || function() { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + }(); + } + function p$32(t9) { + return (p$32 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t10) { + return typeof t10; + } : function(t10) { + return t10 && "function" == typeof Symbol && t10.constructor === Symbol && t10 !== Symbol.prototype ? "symbol" : typeof t10; + })(t9); + } + function m$22(t9) { + return t9.call.bind(t9); + } + function U4(t9) { + if (0 === t9.length || t9.length > 10) + return true; + for (var e12 = 0; e12 < t9.length; e12++) { + var n9 = t9.charCodeAt(e12); + if (n9 < 48 || n9 > 57) + return true; + } + return 10 === t9.length && t9 >= Math.pow(2, 32); + } + function G3(t9) { + return Object.keys(t9).filter(U4).concat(v$12(t9).filter(Object.prototype.propertyIsEnumerable.bind(t9))); + } + function V3(t9, e12) { + if (t9 === e12) + return 0; + for (var n9 = t9.length, r10 = e12.length, o9 = 0, c8 = Math.min(n9, r10); o9 < c8; ++o9) + if (t9[o9] !== e12[o9]) { + n9 = t9[o9], r10 = e12[o9]; + break; + } + return n9 < r10 ? -1 : r10 < n9 ? 1 : 0; + } + function B4(t9, e12, n9, r10) { + if (t9 === e12) + return 0 !== t9 || (!n9 || b$12(t9, e12)); + if (n9) { + if ("object" !== p$32(t9)) + return "number" == typeof t9 && d$12(t9) && d$12(e12); + if ("object" !== p$32(e12) || null === t9 || null === e12) + return false; + if (Object.getPrototypeOf(t9) !== Object.getPrototypeOf(e12)) + return false; + } else { + if (null === t9 || "object" !== p$32(t9)) + return (null === e12 || "object" !== p$32(e12)) && t9 == e12; + if (null === e12 || "object" !== p$32(e12)) + return false; + } + var o9, c8, a8, i8, u8 = S4(t9); + if (u8 !== S4(e12)) + return false; + if (Array.isArray(t9)) { + if (t9.length !== e12.length) + return false; + var l8 = G3(t9), f9 = G3(e12); + return l8.length === f9.length && C4(t9, e12, n9, r10, 1, l8); + } + if ("[object Object]" === u8 && (!R4(t9) && R4(e12) || !k4(t9) && k4(e12))) + return false; + if (q3(t9)) { + if (!q3(e12) || Date.prototype.getTime.call(t9) !== Date.prototype.getTime.call(e12)) + return false; + } else if (A$12(t9)) { + if (!A$12(e12) || (a8 = t9, i8 = e12, !(g$12 ? a8.source === i8.source && a8.flags === i8.flags : RegExp.prototype.toString.call(a8) === RegExp.prototype.toString.call(i8)))) + return false; + } else if (_4(t9) || t9 instanceof Error) { + if (t9.message !== e12.message || t9.name !== e12.name) + return false; + } else { + if (x4(t9)) { + if (n9 || !L4(t9) && !M4(t9)) { + if (!function(t10, e13) { + return t10.byteLength === e13.byteLength && 0 === V3(new Uint8Array(t10.buffer, t10.byteOffset, t10.byteLength), new Uint8Array(e13.buffer, e13.byteOffset, e13.byteLength)); + }(t9, e12)) + return false; + } else if (!function(t10, e13) { + if (t10.byteLength !== e13.byteLength) + return false; + for (var n10 = 0; n10 < t10.byteLength; n10++) + if (t10[n10] !== e13[n10]) + return false; + return true; + }(t9, e12)) + return false; + var s7 = G3(t9), h9 = G3(e12); + return s7.length === h9.length && C4(t9, e12, n9, r10, 0, s7); + } + if (k4(t9)) + return !(!k4(e12) || t9.size !== e12.size) && C4(t9, e12, n9, r10, 2); + if (R4(t9)) + return !(!R4(e12) || t9.size !== e12.size) && C4(t9, e12, n9, r10, 3); + if (O4(t9)) { + if (c8 = e12, (o9 = t9).byteLength !== c8.byteLength || 0 !== V3(new Uint8Array(o9), new Uint8Array(c8))) + return false; + } else if (T5(t9) && !function(t10, e13) { + return P$12(t10) ? P$12(e13) && b$12(Number.prototype.valueOf.call(t10), Number.prototype.valueOf.call(e13)) : I4(t10) ? I4(e13) && String.prototype.valueOf.call(t10) === String.prototype.valueOf.call(e13) : D4(t10) ? D4(e13) && Boolean.prototype.valueOf.call(t10) === Boolean.prototype.valueOf.call(e13) : F4(t10) ? F4(e13) && BigInt.prototype.valueOf.call(t10) === BigInt.prototype.valueOf.call(e13) : N$12(e13) && Symbol.prototype.valueOf.call(t10) === Symbol.prototype.valueOf.call(e13); + }(t9, e12)) + return false; + } + return C4(t9, e12, n9, r10, 0); + } + function z5(t9, e12) { + return e12.filter(function(e13) { + return w$12(t9, e13); + }); + } + function C4(t9, e12, n9, r10, o9, c8) { + if (5 === arguments.length) { + c8 = Object.keys(t9); + var a8 = Object.keys(e12); + if (c8.length !== a8.length) + return false; + } + for (var i8 = 0; i8 < c8.length; i8++) + if (!E4(e12, c8[i8])) + return false; + if (n9 && 5 === arguments.length) { + var u8 = v$12(t9); + if (0 !== u8.length) { + var l8 = 0; + for (i8 = 0; i8 < u8.length; i8++) { + var f9 = u8[i8]; + if (w$12(t9, f9)) { + if (!w$12(e12, f9)) + return false; + c8.push(f9), l8++; + } else if (w$12(e12, f9)) + return false; + } + var s7 = v$12(e12); + if (u8.length !== s7.length && z5(e12, s7).length !== l8) + return false; + } else { + var p8 = v$12(e12); + if (0 !== p8.length && 0 !== z5(e12, p8).length) + return false; + } + } + if (0 === c8.length && (0 === o9 || 1 === o9 && 0 === t9.length || 0 === t9.size)) + return true; + if (void 0 === r10) + r10 = { val1: /* @__PURE__ */ new Map(), val2: /* @__PURE__ */ new Map(), position: 0 }; + else { + var g6 = r10.val1.get(t9); + if (void 0 !== g6) { + var h9 = r10.val2.get(e12); + if (void 0 !== h9) + return g6 === h9; + } + r10.position++; + } + r10.val1.set(t9, r10.position), r10.val2.set(e12, r10.position); + var y7 = Q3(t9, e12, n9, c8, r10, o9); + return r10.val1.delete(t9), r10.val2.delete(e12), y7; + } + function Y4(t9, e12, n9, r10) { + for (var o9 = h$12(t9), c8 = 0; c8 < o9.length; c8++) { + var a8 = o9[c8]; + if (B4(e12, a8, n9, r10)) + return t9.delete(a8), true; + } + return false; + } + function W3(t9) { + switch (p$32(t9)) { + case "undefined": + return null; + case "object": + return; + case "symbol": + return false; + case "string": + t9 = +t9; + case "number": + if (d$12(t9)) + return false; + } + return true; + } + function H3(t9, e12, n9) { + var r10 = W3(n9); + return null != r10 ? r10 : e12.has(r10) && !t9.has(r10); + } + function J3(t9, e12, n9, r10, o9) { + var c8 = W3(n9); + if (null != c8) + return c8; + var a8 = e12.get(c8); + return !(void 0 === a8 && !e12.has(c8) || !B4(r10, a8, false, o9)) && (!t9.has(c8) && B4(r10, a8, false, o9)); + } + function K3(t9, e12, n9, r10, o9, c8) { + for (var a8 = h$12(t9), i8 = 0; i8 < a8.length; i8++) { + var u8 = a8[i8]; + if (B4(n9, u8, o9, c8) && B4(r10, e12.get(u8), o9, c8)) + return t9.delete(u8), true; + } + return false; + } + function Q3(t9, e12, n9, r10, o9, c8) { + var a8 = 0; + if (2 === c8) { + if (!function(t10, e13, n10, r11) { + for (var o10 = null, c9 = h$12(t10), a9 = 0; a9 < c9.length; a9++) { + var i9 = c9[a9]; + if ("object" === p$32(i9) && null !== i9) + null === o10 && (o10 = /* @__PURE__ */ new Set()), o10.add(i9); + else if (!e13.has(i9)) { + if (n10) + return false; + if (!H3(t10, e13, i9)) + return false; + null === o10 && (o10 = /* @__PURE__ */ new Set()), o10.add(i9); + } + } + if (null !== o10) { + for (var u9 = h$12(e13), l9 = 0; l9 < u9.length; l9++) { + var f9 = u9[l9]; + if ("object" === p$32(f9) && null !== f9) { + if (!Y4(o10, f9, n10, r11)) + return false; + } else if (!n10 && !t10.has(f9) && !Y4(o10, f9, n10, r11)) + return false; + } + return 0 === o10.size; + } + return true; + }(t9, e12, n9, o9)) + return false; + } else if (3 === c8) { + if (!function(t10, e13, n10, r11) { + for (var o10 = null, c9 = y$22(t10), a9 = 0; a9 < c9.length; a9++) { + var i9 = s$32(c9[a9], 2), u9 = i9[0], l9 = i9[1]; + if ("object" === p$32(u9) && null !== u9) + null === o10 && (o10 = /* @__PURE__ */ new Set()), o10.add(u9); + else { + var f9 = e13.get(u9); + if (void 0 === f9 && !e13.has(u9) || !B4(l9, f9, n10, r11)) { + if (n10) + return false; + if (!J3(t10, e13, u9, l9, r11)) + return false; + null === o10 && (o10 = /* @__PURE__ */ new Set()), o10.add(u9); + } + } + } + if (null !== o10) { + for (var g6 = y$22(e13), h9 = 0; h9 < g6.length; h9++) { + var b6 = s$32(g6[h9], 2), v7 = (u9 = b6[0], b6[1]); + if ("object" === p$32(u9) && null !== u9) { + if (!K3(o10, t10, u9, v7, n10, r11)) + return false; + } else if (!(n10 || t10.has(u9) && B4(t10.get(u9), v7, false, r11) || K3(o10, t10, u9, v7, false, r11))) + return false; + } + return 0 === o10.size; + } + return true; + }(t9, e12, n9, o9)) + return false; + } else if (1 === c8) + for (; a8 < t9.length; a8++) { + if (!E4(t9, a8)) { + if (E4(e12, a8)) + return false; + for (var i8 = Object.keys(t9); a8 < i8.length; a8++) { + var u8 = i8[a8]; + if (!E4(e12, u8) || !B4(t9[u8], e12[u8], n9, o9)) + return false; + } + return i8.length === Object.keys(e12).length; + } + if (!E4(e12, a8) || !B4(t9[a8], e12[a8], n9, o9)) + return false; + } + for (a8 = 0; a8 < r10.length; a8++) { + var l8 = r10[a8]; + if (!B4(t9[l8], e12[l8], n9, o9)) + return false; + } + return true; + } + function tt2() { + if ($$12) + return Z3; + $$12 = true; + var o9 = T; + function c8(t9) { + return (c8 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t10) { + return typeof t10; + } : function(t10) { + return t10 && "function" == typeof Symbol && t10.constructor === Symbol && t10 !== Symbol.prototype ? "symbol" : typeof t10; + })(t9); + } + var a8, u8, l8 = i$52().codes, s7 = l8.ERR_AMBIGUOUS_ARGUMENT, p8 = l8.ERR_INVALID_ARG_TYPE, g6 = l8.ERR_INVALID_ARG_VALUE, h9 = l8.ERR_INVALID_RETURN_VALUE, y7 = l8.ERR_MISSING_ARGS, b6 = f$62(), v7 = X.inspect, d7 = X.types, m$13 = d7.isPromise, E5 = d7.isRegExp, w5 = Object.assign ? Object.assign : r6.assign, S5 = Object.is ? Object.is : m5; + function j5() { + a8 = X3.isDeepEqual, u8 = X3.isDeepStrictEqual; + } + var O6 = false, x5 = Z3 = k5, q4 = {}; + function R5(t9) { + if (t9.message instanceof Error) + throw t9.message; + throw new b6(t9); + } + function A5(t9, e12, n9, r10) { + if (!n9) { + var o10 = false; + if (0 === e12) + o10 = true, r10 = "No value argument passed to `assert.ok()`"; + else if (r10 instanceof Error) + throw r10; + var c9 = new b6({ actual: n9, expected: true, message: r10, operator: "==", stackStartFn: t9 }); + throw c9.generatedMessage = o10, c9; + } + } + function k5() { + for (var t9 = arguments.length, e12 = new Array(t9), n9 = 0; n9 < t9; n9++) + e12[n9] = arguments[n9]; + A5.apply(void 0, [k5, e12.length].concat(e12)); + } + x5.fail = function t9(e12, n9, r10, c9, a9) { + var i8, u9 = arguments.length; + if (0 === u9) + i8 = "Failed"; + else if (1 === u9) + r10 = e12, e12 = void 0; + else { + if (false === O6) { + O6 = true; + var l9 = o9.emitWarning ? o9.emitWarning : console.warn.bind(console); + l9("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.", "DeprecationWarning", "DEP0094"); + } + 2 === u9 && (c9 = "!="); + } + if (r10 instanceof Error) + throw r10; + var f9 = { actual: e12, expected: n9, operator: void 0 === c9 ? "fail" : c9, stackStartFn: a9 || t9 }; + void 0 !== r10 && (f9.message = r10); + var s8 = new b6(f9); + throw i8 && (s8.message = i8, s8.generatedMessage = true), s8; + }, x5.AssertionError = b6, x5.ok = k5, x5.equal = function t9(e12, n9, r10) { + if (arguments.length < 2) + throw new y7("actual", "expected"); + e12 != n9 && R5({ actual: e12, expected: n9, message: r10, operator: "==", stackStartFn: t9 }); + }, x5.notEqual = function t9(e12, n9, r10) { + if (arguments.length < 2) + throw new y7("actual", "expected"); + e12 == n9 && R5({ actual: e12, expected: n9, message: r10, operator: "!=", stackStartFn: t9 }); + }, x5.deepEqual = function t9(e12, n9, r10) { + if (arguments.length < 2) + throw new y7("actual", "expected"); + void 0 === a8 && j5(), a8(e12, n9) || R5({ actual: e12, expected: n9, message: r10, operator: "deepEqual", stackStartFn: t9 }); + }, x5.notDeepEqual = function t9(e12, n9, r10) { + if (arguments.length < 2) + throw new y7("actual", "expected"); + void 0 === a8 && j5(), a8(e12, n9) && R5({ actual: e12, expected: n9, message: r10, operator: "notDeepEqual", stackStartFn: t9 }); + }, x5.deepStrictEqual = function t9(e12, n9, r10) { + if (arguments.length < 2) + throw new y7("actual", "expected"); + void 0 === a8 && j5(), u8(e12, n9) || R5({ actual: e12, expected: n9, message: r10, operator: "deepStrictEqual", stackStartFn: t9 }); + }, x5.notDeepStrictEqual = function t9(e12, n9, r10) { + if (arguments.length < 2) + throw new y7("actual", "expected"); + void 0 === a8 && j5(); + u8(e12, n9) && R5({ actual: e12, expected: n9, message: r10, operator: "notDeepStrictEqual", stackStartFn: t9 }); + }, x5.strictEqual = function t9(e12, n9, r10) { + if (arguments.length < 2) + throw new y7("actual", "expected"); + S5(e12, n9) || R5({ actual: e12, expected: n9, message: r10, operator: "strictEqual", stackStartFn: t9 }); + }, x5.notStrictEqual = function t9(e12, n9, r10) { + if (arguments.length < 2) + throw new y7("actual", "expected"); + S5(e12, n9) && R5({ actual: e12, expected: n9, message: r10, operator: "notStrictEqual", stackStartFn: t9 }); + }; + var _5 = function t9(e12, n9, r10) { + var o10 = this; + !function(t10, e13) { + if (!(t10 instanceof e13)) + throw new TypeError("Cannot call a class as a function"); + }(this, t9), n9.forEach(function(t10) { + t10 in e12 && (void 0 !== r10 && "string" == typeof r10[t10] && E5(e12[t10]) && e12[t10].test(r10[t10]) ? o10[t10] = r10[t10] : o10[t10] = e12[t10]); + }); + }; + function T6(t9, e12, n9, r10, o10, c9) { + if (!(n9 in t9) || !u8(t9[n9], e12[n9])) { + if (!r10) { + var a9 = new _5(t9, o10), i8 = new _5(e12, o10, t9), l9 = new b6({ actual: a9, expected: i8, operator: "deepStrictEqual", stackStartFn: c9 }); + throw l9.actual = t9, l9.expected = e12, l9.operator = c9.name, l9; + } + R5({ actual: t9, expected: e12, message: r10, operator: c9.name, stackStartFn: c9 }); + } + } + function P5(t9, e12, n9, r10) { + if ("function" != typeof e12) { + if (E5(e12)) + return e12.test(t9); + if (2 === arguments.length) + throw new p8("expected", ["Function", "RegExp"], e12); + if ("object" !== c8(t9) || null === t9) { + var o10 = new b6({ actual: t9, expected: e12, message: n9, operator: "deepStrictEqual", stackStartFn: r10 }); + throw o10.operator = r10.name, o10; + } + var i8 = Object.keys(e12); + if (e12 instanceof Error) + i8.push("name", "message"); + else if (0 === i8.length) + throw new g6("error", e12, "may not be an empty object"); + return void 0 === a8 && j5(), i8.forEach(function(o11) { + "string" == typeof t9[o11] && E5(e12[o11]) && e12[o11].test(t9[o11]) || T6(t9, e12, o11, n9, i8, r10); + }), true; + } + return void 0 !== e12.prototype && t9 instanceof e12 || !Error.isPrototypeOf(e12) && true === e12.call({}, t9); + } + function I5(t9) { + if ("function" != typeof t9) + throw new p8("fn", "Function", t9); + try { + t9(); + } catch (t10) { + return t10; + } + return q4; + } + function D5(t9) { + return m$13(t9) || null !== t9 && "object" === c8(t9) && "function" == typeof t9.then && "function" == typeof t9.catch; + } + function F5(t9) { + return Promise.resolve().then(function() { + var e12; + if ("function" == typeof t9) { + if (!D5(e12 = t9())) + throw new h9("instance of Promise", "promiseFn", e12); + } else { + if (!D5(t9)) + throw new p8("promiseFn", ["Function", "Promise"], t9); + e12 = t9; + } + return Promise.resolve().then(function() { + return e12; + }).then(function() { + return q4; + }).catch(function(t10) { + return t10; + }); + }); + } + function N14(t9, e12, n9, r10) { + if ("string" == typeof n9) { + if (4 === arguments.length) + throw new p8("error", ["Object", "Error", "Function", "RegExp"], n9); + if ("object" === c8(e12) && null !== e12) { + if (e12.message === n9) + throw new s7("error/message", 'The error message "'.concat(e12.message, '" is identical to the message.')); + } else if (e12 === n9) + throw new s7("error/message", 'The error "'.concat(e12, '" is identical to the message.')); + r10 = n9, n9 = void 0; + } else if (null != n9 && "object" !== c8(n9) && "function" != typeof n9) + throw new p8("error", ["Object", "Error", "Function", "RegExp"], n9); + if (e12 === q4) { + var o10 = ""; + n9 && n9.name && (o10 += " (".concat(n9.name, ")")), o10 += r10 ? ": ".concat(r10) : "."; + var a9 = "rejects" === t9.name ? "rejection" : "exception"; + R5({ actual: void 0, expected: n9, operator: t9.name, message: "Missing expected ".concat(a9).concat(o10), stackStartFn: t9 }); + } + if (n9 && !P5(e12, n9, r10, t9)) + throw e12; + } + function L5(t9, e12, n9, r10) { + if (e12 !== q4) { + if ("string" == typeof n9 && (r10 = n9, n9 = void 0), !n9 || P5(e12, n9)) { + var o10 = r10 ? ": ".concat(r10) : ".", c9 = "doesNotReject" === t9.name ? "rejection" : "exception"; + R5({ actual: e12, expected: n9, operator: t9.name, message: "Got unwanted ".concat(c9).concat(o10, "\n") + 'Actual message: "'.concat(e12 && e12.message, '"'), stackStartFn: t9 }); + } + throw e12; + } + } + function M5() { + for (var t9 = arguments.length, e12 = new Array(t9), n9 = 0; n9 < t9; n9++) + e12[n9] = arguments[n9]; + A5.apply(void 0, [M5, e12.length].concat(e12)); + } + return x5.throws = function t9(e12) { + for (var n9 = arguments.length, r10 = new Array(n9 > 1 ? n9 - 1 : 0), o10 = 1; o10 < n9; o10++) + r10[o10 - 1] = arguments[o10]; + N14.apply(void 0, [t9, I5(e12)].concat(r10)); + }, x5.rejects = function t9(e12) { + for (var n9 = arguments.length, r10 = new Array(n9 > 1 ? n9 - 1 : 0), o10 = 1; o10 < n9; o10++) + r10[o10 - 1] = arguments[o10]; + return F5(e12).then(function(e13) { + return N14.apply(void 0, [t9, e13].concat(r10)); + }); + }, x5.doesNotThrow = function t9(e12) { + for (var n9 = arguments.length, r10 = new Array(n9 > 1 ? n9 - 1 : 0), o10 = 1; o10 < n9; o10++) + r10[o10 - 1] = arguments[o10]; + L5.apply(void 0, [t9, I5(e12)].concat(r10)); + }, x5.doesNotReject = function t9(e12) { + for (var n9 = arguments.length, r10 = new Array(n9 > 1 ? n9 - 1 : 0), o10 = 1; o10 < n9; o10++) + r10[o10 - 1] = arguments[o10]; + return F5(e12).then(function(e13) { + return L5.apply(void 0, [t9, e13].concat(r10)); + }); + }, x5.ifError = function t9(e12) { + if (null != e12) { + var n9 = "ifError got unwanted exception: "; + "object" === c8(e12) && "string" == typeof e12.message ? 0 === e12.message.length && e12.constructor ? n9 += e12.constructor.name : n9 += e12.message : n9 += v7(e12); + var r10 = new b6({ actual: e12, expected: null, operator: "ifError", message: n9, stackStartFn: t9 }), o10 = e12.stack; + if ("string" == typeof o10) { + var a9 = o10.split("\n"); + a9.shift(); + for (var i8 = r10.stack.split("\n"), u9 = 0; u9 < a9.length; u9++) { + var l9 = i8.indexOf(a9[u9]); + if (-1 !== l9) { + i8 = i8.slice(0, l9); + break; + } + } + r10.stack = "".concat(i8.join("\n"), "\n").concat(a9.join("\n")); + } + throw r10; + } + }, x5.strict = w5(M5, x5, { equal: x5.strictEqual, deepEqual: x5.deepStrictEqual, notEqual: x5.notStrictEqual, notDeepEqual: x5.notDeepStrictEqual }), x5.strict.strict = x5.strict, Z3; + } + var r6, t6, e$14, r$13, n9, o9, c8, l8, i8, a8, u8, f9, p8, s7, y5, b4, g4, h6, $3, j4, w4, r$22, e$22, o$14, n$14, a$12, c$14, l$14, u$14, f$13, t$13, f$23, e$32, l$22, t$23, n$22, o$23, r$32, e$42, o$32, t$32, n$32, y$12, a$23, i$14, d5, f$32, u$23, A4, l$32, v5, P4, c$22, t$42, p$12, o$42, i$22, a$32, l$42, r$42, n$42, i$32, o$52, c$32, f$42, u$32, s$13, a$42, l$52, p$22, m5, N13, e$52, i$42, n$52, t$52, u$42, a$52, m$12, o$62, s$22, f$52, c$42, a$62, u$52, l$62, g$12, h$12, y$22, b$12, v$12, d$12, E4, w$12, S4, j$12, O4, x4, q3, R4, A$12, k4, _4, T5, P$12, I4, D4, F4, N$12, L4, M4, X3, Z3, $$12, et2, AssertionError, deepEqual, deepStrictEqual, doesNotReject, doesNotThrow, equal3, fail3, ifError, notDeepEqual, notDeepStrictEqual, notEqual, notStrictEqual, ok2, rejects, strict, strictEqual, throws; + var init_assert = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/assert.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_b4205b57(); + init_chunk_5decc758(); + r6 = { assign: e8, polyfill: function() { + Object.assign || Object.defineProperty(Object, "assign", { enumerable: false, configurable: true, writable: true, value: e8 }); + } }; + e$14 = Object.prototype.toString; + r$13 = function(t9) { + var r10 = e$14.call(t9), n9 = "[object Arguments]" === r10; + return n9 || (n9 = "[object Array]" !== r10 && null !== t9 && "object" == typeof t9 && "number" == typeof t9.length && t9.length >= 0 && "[object Function]" === e$14.call(t9.callee)), n9; + }; + if (!Object.keys) { + n9 = Object.prototype.hasOwnProperty, o9 = Object.prototype.toString, c8 = r$13, l8 = Object.prototype.propertyIsEnumerable, i8 = !l8.call({ toString: null }, "toString"), a8 = l8.call(function() { + }, "prototype"), u8 = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"], f9 = function(t9) { + var e12 = t9.constructor; + return e12 && e12.prototype === t9; + }, p8 = { $applicationCache: true, $console: true, $external: true, $frame: true, $frameElement: true, $frames: true, $innerHeight: true, $innerWidth: true, $onmozfullscreenchange: true, $onmozfullscreenerror: true, $outerHeight: true, $outerWidth: true, $pageXOffset: true, $pageYOffset: true, $parent: true, $scrollLeft: true, $scrollTop: true, $scrollX: true, $scrollY: true, $self: true, $webkitIndexedDB: true, $webkitStorageInfo: true, $window: true }, s7 = function() { + if ("undefined" == typeof window) + return false; + for (var t9 in window) + try { + if (!p8["$" + t9] && n9.call(window, t9) && null !== window[t9] && "object" == typeof window[t9]) + try { + f9(window[t9]); + } catch (t10) { + return true; + } + } catch (t10) { + return true; + } + return false; + }(); + t6 = function(t9) { + var e12 = null !== t9 && "object" == typeof t9, r10 = "[object Function]" === o9.call(t9), l9 = c8(t9), p9 = e12 && "[object String]" === o9.call(t9), y7 = []; + if (!e12 && !r10 && !l9) + throw new TypeError("Object.keys called on a non-object"); + var b6 = a8 && r10; + if (p9 && t9.length > 0 && !n9.call(t9, 0)) + for (var g6 = 0; g6 < t9.length; ++g6) + y7.push(String(g6)); + if (l9 && t9.length > 0) + for (var h9 = 0; h9 < t9.length; ++h9) + y7.push(String(h9)); + else + for (var $4 in t9) + b6 && "prototype" === $4 || !n9.call(t9, $4) || y7.push(String($4)); + if (i8) + for (var j5 = function(t10) { + if ("undefined" == typeof window || !s7) + return f9(t10); + try { + return f9(t10); + } catch (t11) { + return false; + } + }(t9), w5 = 0; w5 < u8.length; ++w5) + j5 && "constructor" === u8[w5] || !n9.call(t9, u8[w5]) || y7.push(u8[w5]); + return y7; + }; + } + y5 = t6; + b4 = Array.prototype.slice; + g4 = r$13; + h6 = Object.keys; + $3 = h6 ? function(t9) { + return h6(t9); + } : y5; + j4 = Object.keys; + $3.shim = function() { + Object.keys ? function() { + var t9 = Object.keys(arguments); + return t9 && t9.length === arguments.length; + }(1, 2) || (Object.keys = function(t9) { + return g4(t9) ? j4(b4.call(t9)) : j4(t9); + }) : Object.keys = $3; + return Object.keys || $3; + }; + w4 = $3; + r$22 = w4; + e$22 = "function" == typeof Symbol && "symbol" == typeof Symbol("foo"); + o$14 = Object.prototype.toString; + n$14 = Array.prototype.concat; + a$12 = Object.defineProperty; + c$14 = a$12 && function() { + var t9 = {}; + try { + for (var r10 in a$12(t9, "x", { enumerable: false, value: t9 }), t9) + return false; + return t9.x === t9; + } catch (t10) { + return false; + } + }(); + l$14 = function(t9, r10, e12, n9) { + var l8; + (!(r10 in t9) || "function" == typeof (l8 = n9) && "[object Function]" === o$14.call(l8) && n9()) && (c$14 ? a$12(t9, r10, { configurable: true, enumerable: false, value: e12, writable: true }) : t9[r10] = e12); + }; + u$14 = function(t9, o9) { + var a8 = arguments.length > 2 ? arguments[2] : {}, c8 = r$22(o9); + e$22 && (c8 = n$14.call(c8, Object.getOwnPropertySymbols(o9))); + for (var u8 = 0; u8 < c8.length; u8 += 1) + l$14(t9, c8[u8], o9[c8[u8]], a8[c8[u8]]); + }; + u$14.supportsDescriptors = !!c$14; + f$13 = u$14; + t$13 = function() { + if ("function" != typeof Symbol || "function" != typeof Object.getOwnPropertySymbols) + return false; + if ("symbol" == typeof Symbol.iterator) + return true; + var t9 = {}, e12 = Symbol("test"), r10 = Object(e12); + if ("string" == typeof e12) + return false; + if ("[object Symbol]" !== Object.prototype.toString.call(e12)) + return false; + if ("[object Symbol]" !== Object.prototype.toString.call(r10)) + return false; + for (e12 in t9[e12] = 42, t9) + return false; + if ("function" == typeof Object.keys && 0 !== Object.keys(t9).length) + return false; + if ("function" == typeof Object.getOwnPropertyNames && 0 !== Object.getOwnPropertyNames(t9).length) + return false; + var o9 = Object.getOwnPropertySymbols(t9); + if (1 !== o9.length || o9[0] !== e12) + return false; + if (!Object.prototype.propertyIsEnumerable.call(t9, e12)) + return false; + if ("function" == typeof Object.getOwnPropertyDescriptor) { + var n9 = Object.getOwnPropertyDescriptor(t9, e12); + if (42 !== n9.value || true !== n9.enumerable) + return false; + } + return true; + }; + f$23 = ("undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global).Symbol; + e$32 = t$13; + l$22 = function() { + return "function" == typeof f$23 && ("function" == typeof Symbol && ("symbol" == typeof f$23("foo") && ("symbol" == typeof Symbol("bar") && e$32()))); + }; + t$23 = "Function.prototype.bind called on incompatible "; + n$22 = Array.prototype.slice; + o$23 = Object.prototype.toString; + r$32 = function(r10) { + var e12 = this; + if ("function" != typeof e12 || "[object Function]" !== o$23.call(e12)) + throw new TypeError(t$23 + e12); + for (var p8, i8 = n$22.call(arguments, 1), c8 = function() { + if (this instanceof p8) { + var t9 = e12.apply(this, i8.concat(n$22.call(arguments))); + return Object(t9) === t9 ? t9 : this; + } + return e12.apply(r10, i8.concat(n$22.call(arguments))); + }, a8 = Math.max(0, e12.length - i8.length), l8 = [], u8 = 0; u8 < a8; u8++) + l8.push("$" + u8); + if (p8 = Function("binder", "return function (" + l8.join(",") + "){ return binder.apply(this,arguments); }")(c8), e12.prototype) { + var y7 = function() { + }; + y7.prototype = e12.prototype, p8.prototype = new y7(), y7.prototype = null; + } + return p8; + }; + e$42 = Function.prototype.bind || r$32; + o$32 = TypeError; + t$32 = Object.getOwnPropertyDescriptor; + if (t$32) + try { + t$32({}, ""); + } catch (r10) { + t$32 = null; + } + n$32 = function() { + throw new o$32(); + }; + y$12 = t$32 ? function() { + try { + return arguments.callee, n$32; + } catch (r10) { + try { + return t$32(arguments, "callee").get; + } catch (r11) { + return n$32; + } + } + }() : n$32; + a$23 = l$22(); + i$14 = Object.getPrototypeOf || function(r10) { + return r10.__proto__; + }; + d5 = "undefined" == typeof Uint8Array ? void 0 : i$14(Uint8Array); + f$32 = { "%Array%": Array, "%ArrayBuffer%": "undefined" == typeof ArrayBuffer ? void 0 : ArrayBuffer, "%ArrayBufferPrototype%": "undefined" == typeof ArrayBuffer ? void 0 : ArrayBuffer.prototype, "%ArrayIteratorPrototype%": a$23 ? i$14([][Symbol.iterator]()) : void 0, "%ArrayPrototype%": Array.prototype, "%ArrayProto_entries%": Array.prototype.entries, "%ArrayProto_forEach%": Array.prototype.forEach, "%ArrayProto_keys%": Array.prototype.keys, "%ArrayProto_values%": Array.prototype.values, "%AsyncFromSyncIteratorPrototype%": void 0, "%AsyncFunction%": void 0, "%AsyncFunctionPrototype%": void 0, "%AsyncGenerator%": void 0, "%AsyncGeneratorFunction%": void 0, "%AsyncGeneratorPrototype%": void 0, "%AsyncIteratorPrototype%": void 0, "%Atomics%": "undefined" == typeof Atomics ? void 0 : Atomics, "%Boolean%": Boolean, "%BooleanPrototype%": Boolean.prototype, "%DataView%": "undefined" == typeof DataView ? void 0 : DataView, "%DataViewPrototype%": "undefined" == typeof DataView ? void 0 : DataView.prototype, "%Date%": Date, "%DatePrototype%": Date.prototype, "%decodeURI%": decodeURI, "%decodeURIComponent%": decodeURIComponent, "%encodeURI%": encodeURI, "%encodeURIComponent%": encodeURIComponent, "%Error%": Error, "%ErrorPrototype%": Error.prototype, "%eval%": eval, "%EvalError%": EvalError, "%EvalErrorPrototype%": EvalError.prototype, "%Float32Array%": "undefined" == typeof Float32Array ? void 0 : Float32Array, "%Float32ArrayPrototype%": "undefined" == typeof Float32Array ? void 0 : Float32Array.prototype, "%Float64Array%": "undefined" == typeof Float64Array ? void 0 : Float64Array, "%Float64ArrayPrototype%": "undefined" == typeof Float64Array ? void 0 : Float64Array.prototype, "%Function%": Function, "%FunctionPrototype%": Function.prototype, "%Generator%": void 0, "%GeneratorFunction%": void 0, "%GeneratorPrototype%": void 0, "%Int8Array%": "undefined" == typeof Int8Array ? void 0 : Int8Array, "%Int8ArrayPrototype%": "undefined" == typeof Int8Array ? void 0 : Int8Array.prototype, "%Int16Array%": "undefined" == typeof Int16Array ? void 0 : Int16Array, "%Int16ArrayPrototype%": "undefined" == typeof Int16Array ? void 0 : Int8Array.prototype, "%Int32Array%": "undefined" == typeof Int32Array ? void 0 : Int32Array, "%Int32ArrayPrototype%": "undefined" == typeof Int32Array ? void 0 : Int32Array.prototype, "%isFinite%": isFinite, "%isNaN%": isNaN, "%IteratorPrototype%": a$23 ? i$14(i$14([][Symbol.iterator]())) : void 0, "%JSON%": "object" == typeof JSON ? JSON : void 0, "%JSONParse%": "object" == typeof JSON ? JSON.parse : void 0, "%Map%": "undefined" == typeof Map ? void 0 : Map, "%MapIteratorPrototype%": "undefined" != typeof Map && a$23 ? i$14((/* @__PURE__ */ new Map())[Symbol.iterator]()) : void 0, "%MapPrototype%": "undefined" == typeof Map ? void 0 : Map.prototype, "%Math%": Math, "%Number%": Number, "%NumberPrototype%": Number.prototype, "%Object%": Object, "%ObjectPrototype%": Object.prototype, "%ObjProto_toString%": Object.prototype.toString, "%ObjProto_valueOf%": Object.prototype.valueOf, "%parseFloat%": parseFloat, "%parseInt%": parseInt, "%Promise%": "undefined" == typeof Promise ? void 0 : Promise, "%PromisePrototype%": "undefined" == typeof Promise ? void 0 : Promise.prototype, "%PromiseProto_then%": "undefined" == typeof Promise ? void 0 : Promise.prototype.then, "%Promise_all%": "undefined" == typeof Promise ? void 0 : Promise.all, "%Promise_reject%": "undefined" == typeof Promise ? void 0 : Promise.reject, "%Promise_resolve%": "undefined" == typeof Promise ? void 0 : Promise.resolve, "%Proxy%": "undefined" == typeof Proxy ? void 0 : Proxy, "%RangeError%": RangeError, "%RangeErrorPrototype%": RangeError.prototype, "%ReferenceError%": ReferenceError, "%ReferenceErrorPrototype%": ReferenceError.prototype, "%Reflect%": "undefined" == typeof Reflect ? void 0 : Reflect, "%RegExp%": RegExp, "%RegExpPrototype%": RegExp.prototype, "%Set%": "undefined" == typeof Set ? void 0 : Set, "%SetIteratorPrototype%": "undefined" != typeof Set && a$23 ? i$14((/* @__PURE__ */ new Set())[Symbol.iterator]()) : void 0, "%SetPrototype%": "undefined" == typeof Set ? void 0 : Set.prototype, "%SharedArrayBuffer%": "undefined" == typeof SharedArrayBuffer ? void 0 : SharedArrayBuffer, "%SharedArrayBufferPrototype%": "undefined" == typeof SharedArrayBuffer ? void 0 : SharedArrayBuffer.prototype, "%String%": String, "%StringIteratorPrototype%": a$23 ? i$14(""[Symbol.iterator]()) : void 0, "%StringPrototype%": String.prototype, "%Symbol%": a$23 ? Symbol : void 0, "%SymbolPrototype%": a$23 ? Symbol.prototype : void 0, "%SyntaxError%": SyntaxError, "%SyntaxErrorPrototype%": SyntaxError.prototype, "%ThrowTypeError%": y$12, "%TypedArray%": d5, "%TypedArrayPrototype%": d5 ? d5.prototype : void 0, "%TypeError%": o$32, "%TypeErrorPrototype%": o$32.prototype, "%Uint8Array%": "undefined" == typeof Uint8Array ? void 0 : Uint8Array, "%Uint8ArrayPrototype%": "undefined" == typeof Uint8Array ? void 0 : Uint8Array.prototype, "%Uint8ClampedArray%": "undefined" == typeof Uint8ClampedArray ? void 0 : Uint8ClampedArray, "%Uint8ClampedArrayPrototype%": "undefined" == typeof Uint8ClampedArray ? void 0 : Uint8ClampedArray.prototype, "%Uint16Array%": "undefined" == typeof Uint16Array ? void 0 : Uint16Array, "%Uint16ArrayPrototype%": "undefined" == typeof Uint16Array ? void 0 : Uint16Array.prototype, "%Uint32Array%": "undefined" == typeof Uint32Array ? void 0 : Uint32Array, "%Uint32ArrayPrototype%": "undefined" == typeof Uint32Array ? void 0 : Uint32Array.prototype, "%URIError%": URIError, "%URIErrorPrototype%": URIError.prototype, "%WeakMap%": "undefined" == typeof WeakMap ? void 0 : WeakMap, "%WeakMapPrototype%": "undefined" == typeof WeakMap ? void 0 : WeakMap.prototype, "%WeakSet%": "undefined" == typeof WeakSet ? void 0 : WeakSet, "%WeakSetPrototype%": "undefined" == typeof WeakSet ? void 0 : WeakSet.prototype }; + u$23 = e$42.call(Function.call, String.prototype.replace); + A4 = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g; + l$32 = /\\(\\)?/g; + v5 = function(r10) { + var e12 = []; + return u$23(r10, A4, function(r11, o9, t9, n9) { + e12[e12.length] = t9 ? u$23(n9, l$32, "$1") : o9 || r11; + }), e12; + }; + P4 = function(r10, e12) { + if (!(r10 in f$32)) + throw new SyntaxError("intrinsic " + r10 + " does not exist!"); + if (void 0 === f$32[r10] && !e12) + throw new o$32("intrinsic " + r10 + " exists, but is not available. Please file an issue!"); + return f$32[r10]; + }; + c$22 = function(r10, e12) { + if ("string" != typeof r10 || 0 === r10.length) + throw new TypeError("intrinsic name must be a non-empty string"); + if (arguments.length > 1 && "boolean" != typeof e12) + throw new TypeError('"allowMissing" argument must be a boolean'); + for (var n9 = v5(r10), y7 = P4("%" + (n9.length > 0 ? n9[0] : "") + "%", e12), a8 = 1; a8 < n9.length; a8 += 1) + if (null != y7) + if (t$32 && a8 + 1 >= n9.length) { + var i8 = t$32(y7, n9[a8]); + if (!e12 && !(n9[a8] in y7)) + throw new o$32("base intrinsic for " + r10 + " exists, but the property is not available."); + y7 = i8 ? i8.get || i8.value : y7[n9[a8]]; + } else + y7 = y7[n9[a8]]; + return y7; + }; + p$12 = e$42; + o$42 = c$22("%Function%"); + i$22 = o$42.apply; + a$32 = o$42.call; + (t$42 = function() { + return p$12.apply(a$32, arguments); + }).apply = function() { + return p$12.apply(i$22, arguments); + }; + l$42 = t$42; + i$32 = function(t9) { + return t9 != t9; + }; + o$52 = (r$42 = function(t9, e12) { + return 0 === t9 && 0 === e12 ? 1 / t9 == 1 / e12 : t9 === e12 || !(!i$32(t9) || !i$32(e12)); + }, r$42); + c$32 = (n$42 = function() { + return "function" == typeof Object.is ? Object.is : o$52; + }, n$42); + f$42 = f$13; + u$32 = f$13; + s$13 = r$42; + a$42 = n$42; + l$52 = function() { + var t9 = c$32(); + return f$42(Object, { is: t9 }, { is: function() { + return Object.is !== t9; + } }), t9; + }; + p$22 = l$42(a$42(), Object); + u$32(p$22, { getPolyfill: a$42, implementation: s$13, shim: l$52 }); + m5 = p$22; + N13 = function(r10) { + return r10 != r10; + }; + i$42 = N13; + n$52 = (e$52 = function() { + return Number.isNaN && Number.isNaN(NaN) && !Number.isNaN("a") ? Number.isNaN : i$42; + }, f$13); + t$52 = e$52; + u$42 = f$13; + a$52 = N13; + m$12 = e$52; + o$62 = function() { + var r10 = t$52(); + return n$52(Number, { isNaN: r10 }, { isNaN: function() { + return Number.isNaN !== r10; + } }), r10; + }; + s$22 = m$12(); + u$42(s$22, { getPolyfill: m$12, implementation: a$52, shim: o$62 }); + f$52 = s$22; + c$42 = {}; + a$62 = false; + u$52 = {}; + l$62 = false; + g$12 = void 0 !== /a/g.flags; + h$12 = function(t9) { + var e12 = []; + return t9.forEach(function(t10) { + return e12.push(t10); + }), e12; + }; + y$22 = function(t9) { + var e12 = []; + return t9.forEach(function(t10, n9) { + return e12.push([n9, t10]); + }), e12; + }; + b$12 = Object.is ? Object.is : m5; + v$12 = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols : function() { + return []; + }; + d$12 = Number.isNaN ? Number.isNaN : f$52; + E4 = m$22(Object.prototype.hasOwnProperty); + w$12 = m$22(Object.prototype.propertyIsEnumerable); + S4 = m$22(Object.prototype.toString); + j$12 = X.types; + O4 = j$12.isAnyArrayBuffer; + x4 = j$12.isArrayBufferView; + q3 = j$12.isDate; + R4 = j$12.isMap; + A$12 = j$12.isRegExp; + k4 = j$12.isSet; + _4 = j$12.isNativeError; + T5 = j$12.isBoxedPrimitive; + P$12 = j$12.isNumberObject; + I4 = j$12.isStringObject; + D4 = j$12.isBooleanObject; + F4 = j$12.isBigIntObject; + N$12 = j$12.isSymbolObject; + L4 = j$12.isFloat32Array; + M4 = j$12.isFloat64Array; + X3 = { isDeepEqual: function(t9, e12) { + return B4(t9, e12, false); + }, isDeepStrictEqual: function(t9, e12) { + return B4(t9, e12, true); + } }; + Z3 = {}; + $$12 = false; + et2 = tt2(); + et2.AssertionError; + et2.deepEqual; + et2.deepStrictEqual; + et2.doesNotReject; + et2.doesNotThrow; + et2.equal; + et2.fail; + et2.ifError; + et2.notDeepEqual; + et2.notDeepStrictEqual; + et2.notEqual; + et2.notStrictEqual; + et2.ok; + et2.rejects; + et2.strict; + et2.strictEqual; + et2.throws; + et2.AssertionError; + et2.deepEqual; + et2.deepStrictEqual; + et2.doesNotReject; + et2.doesNotThrow; + et2.equal; + et2.fail; + et2.ifError; + et2.notDeepEqual; + et2.notDeepStrictEqual; + et2.notEqual; + et2.notStrictEqual; + et2.ok; + et2.rejects; + et2.strict; + et2.strictEqual; + et2.throws; + AssertionError = et2.AssertionError; + deepEqual = et2.deepEqual; + deepStrictEqual = et2.deepStrictEqual; + doesNotReject = et2.doesNotReject; + doesNotThrow = et2.doesNotThrow; + equal3 = et2.equal; + fail3 = et2.fail; + ifError = et2.ifError; + notDeepEqual = et2.notDeepEqual; + notDeepStrictEqual = et2.notDeepStrictEqual; + notEqual = et2.notEqual; + notStrictEqual = et2.notStrictEqual; + ok2 = et2.ok; + rejects = et2.rejects; + strict = et2.strict; + strictEqual = et2.strictEqual; + throws = et2.throws; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/util.js + var _extend2, callbackify2, debuglog2, deprecate2, format12, inherits2, inspect2, isArray2, isBoolean2, isBuffer6, isDate2, isError2, isFunction2, isNull2, isNullOrUndefined2, isNumber2, isObject2, isPrimitive2, isRegExp2, isString2, isSymbol2, isUndefined2, log3, promisify2, types2, TextEncoder3, TextDecoder3; + var init_util = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/util.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_ce0fbc82(); + init_chunk_b4205b57(); + init_chunk_b4205b57(); + init_chunk_5decc758(); + _extend2 = X._extend; + callbackify2 = X.callbackify; + debuglog2 = X.debuglog; + deprecate2 = X.deprecate; + format12 = X.format; + inherits2 = X.inherits; + inspect2 = X.inspect; + isArray2 = X.isArray; + isBoolean2 = X.isBoolean; + isBuffer6 = X.isBuffer; + isDate2 = X.isDate; + isError2 = X.isError; + isFunction2 = X.isFunction; + isNull2 = X.isNull; + isNullOrUndefined2 = X.isNullOrUndefined; + isNumber2 = X.isNumber; + isObject2 = X.isObject; + isPrimitive2 = X.isPrimitive; + isRegExp2 = X.isRegExp; + isString2 = X.isString; + isSymbol2 = X.isSymbol; + isUndefined2 = X.isUndefined; + log3 = X.log; + promisify2 = X.promisify; + types2 = X.types; + TextEncoder3 = X.TextEncoder = globalThis.TextEncoder; + TextDecoder3 = X.TextDecoder = globalThis.TextDecoder; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-23dbec7b.js + function dew6() { + if (_dewExec6) + return exports$111; + _dewExec6 = true; + var process$1 = process2; + function assertPath(path2) { + if (typeof path2 !== "string") { + throw new TypeError("Path must be a string. Received " + JSON.stringify(path2)); + } + } + function normalizeStringPosix(path2, allowAboveRoot) { + var res = ""; + var lastSegmentLength = 0; + var lastSlash = -1; + var dots = 0; + var code15; + for (var i8 = 0; i8 <= path2.length; ++i8) { + if (i8 < path2.length) + code15 = path2.charCodeAt(i8); + else if (code15 === 47) + break; + else + code15 = 47; + if (code15 === 47) { + if (lastSlash === i8 - 1 || dots === 1) + ; + else if (lastSlash !== i8 - 1 && dots === 2) { + if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) { + if (res.length > 2) { + var lastSlashIndex = res.lastIndexOf("/"); + if (lastSlashIndex !== res.length - 1) { + if (lastSlashIndex === -1) { + res = ""; + lastSegmentLength = 0; + } else { + res = res.slice(0, lastSlashIndex); + lastSegmentLength = res.length - 1 - res.lastIndexOf("/"); + } + lastSlash = i8; + dots = 0; + continue; + } + } else if (res.length === 2 || res.length === 1) { + res = ""; + lastSegmentLength = 0; + lastSlash = i8; + dots = 0; + continue; + } + } + if (allowAboveRoot) { + if (res.length > 0) + res += "/.."; + else + res = ".."; + lastSegmentLength = 2; + } + } else { + if (res.length > 0) + res += "/" + path2.slice(lastSlash + 1, i8); + else + res = path2.slice(lastSlash + 1, i8); + lastSegmentLength = i8 - lastSlash - 1; + } + lastSlash = i8; + dots = 0; + } else if (code15 === 46 && dots !== -1) { + ++dots; + } else { + dots = -1; + } + } + return res; + } + function _format(sep2, pathObject) { + var dir = pathObject.dir || pathObject.root; + var base3 = pathObject.base || (pathObject.name || "") + (pathObject.ext || ""); + if (!dir) { + return base3; + } + if (dir === pathObject.root) { + return dir + base3; + } + return dir + sep2 + base3; + } + var posix2 = { + // path.resolve([from ...], to) + resolve: function resolve7() { + var resolvedPath = ""; + var resolvedAbsolute = false; + var cwd; + for (var i8 = arguments.length - 1; i8 >= -1 && !resolvedAbsolute; i8--) { + var path2; + if (i8 >= 0) + path2 = arguments[i8]; + else { + if (cwd === void 0) + cwd = process$1.cwd(); + path2 = cwd; + } + assertPath(path2); + if (path2.length === 0) { + continue; + } + resolvedPath = path2 + "/" + resolvedPath; + resolvedAbsolute = path2.charCodeAt(0) === 47; + } + resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); + if (resolvedAbsolute) { + if (resolvedPath.length > 0) + return "/" + resolvedPath; + else + return "/"; + } else if (resolvedPath.length > 0) { + return resolvedPath; + } else { + return "."; + } + }, + normalize: function normalize2(path2) { + assertPath(path2); + if (path2.length === 0) + return "."; + var isAbsolute2 = path2.charCodeAt(0) === 47; + var trailingSeparator = path2.charCodeAt(path2.length - 1) === 47; + path2 = normalizeStringPosix(path2, !isAbsolute2); + if (path2.length === 0 && !isAbsolute2) + path2 = "."; + if (path2.length > 0 && trailingSeparator) + path2 += "/"; + if (isAbsolute2) + return "/" + path2; + return path2; + }, + isAbsolute: function isAbsolute2(path2) { + assertPath(path2); + return path2.length > 0 && path2.charCodeAt(0) === 47; + }, + join: function join3() { + if (arguments.length === 0) + return "."; + var joined; + for (var i8 = 0; i8 < arguments.length; ++i8) { + var arg = arguments[i8]; + assertPath(arg); + if (arg.length > 0) { + if (joined === void 0) + joined = arg; + else + joined += "/" + arg; + } + } + if (joined === void 0) + return "."; + return posix2.normalize(joined); + }, + relative: function relative2(from18, to) { + assertPath(from18); + assertPath(to); + if (from18 === to) + return ""; + from18 = posix2.resolve(from18); + to = posix2.resolve(to); + if (from18 === to) + return ""; + var fromStart = 1; + for (; fromStart < from18.length; ++fromStart) { + if (from18.charCodeAt(fromStart) !== 47) + break; + } + var fromEnd = from18.length; + var fromLen = fromEnd - fromStart; + var toStart = 1; + for (; toStart < to.length; ++toStart) { + if (to.charCodeAt(toStart) !== 47) + break; + } + var toEnd = to.length; + var toLen = toEnd - toStart; + var length3 = fromLen < toLen ? fromLen : toLen; + var lastCommonSep = -1; + var i8 = 0; + for (; i8 <= length3; ++i8) { + if (i8 === length3) { + if (toLen > length3) { + if (to.charCodeAt(toStart + i8) === 47) { + return to.slice(toStart + i8 + 1); + } else if (i8 === 0) { + return to.slice(toStart + i8); + } + } else if (fromLen > length3) { + if (from18.charCodeAt(fromStart + i8) === 47) { + lastCommonSep = i8; + } else if (i8 === 0) { + lastCommonSep = 0; + } + } + break; + } + var fromCode = from18.charCodeAt(fromStart + i8); + var toCode = to.charCodeAt(toStart + i8); + if (fromCode !== toCode) + break; + else if (fromCode === 47) + lastCommonSep = i8; + } + var out = ""; + for (i8 = fromStart + lastCommonSep + 1; i8 <= fromEnd; ++i8) { + if (i8 === fromEnd || from18.charCodeAt(i8) === 47) { + if (out.length === 0) + out += ".."; + else + out += "/.."; + } + } + if (out.length > 0) + return out + to.slice(toStart + lastCommonSep); + else { + toStart += lastCommonSep; + if (to.charCodeAt(toStart) === 47) + ++toStart; + return to.slice(toStart); + } + }, + _makeLong: function _makeLong2(path2) { + return path2; + }, + dirname: function dirname2(path2) { + assertPath(path2); + if (path2.length === 0) + return "."; + var code15 = path2.charCodeAt(0); + var hasRoot = code15 === 47; + var end = -1; + var matchedSlash = true; + for (var i8 = path2.length - 1; i8 >= 1; --i8) { + code15 = path2.charCodeAt(i8); + if (code15 === 47) { + if (!matchedSlash) { + end = i8; + break; + } + } else { + matchedSlash = false; + } + } + if (end === -1) + return hasRoot ? "/" : "."; + if (hasRoot && end === 1) + return "//"; + return path2.slice(0, end); + }, + basename: function basename2(path2, ext) { + if (ext !== void 0 && typeof ext !== "string") + throw new TypeError('"ext" argument must be a string'); + assertPath(path2); + var start = 0; + var end = -1; + var matchedSlash = true; + var i8; + if (ext !== void 0 && ext.length > 0 && ext.length <= path2.length) { + if (ext.length === path2.length && ext === path2) + return ""; + var extIdx = ext.length - 1; + var firstNonSlashEnd = -1; + for (i8 = path2.length - 1; i8 >= 0; --i8) { + var code15 = path2.charCodeAt(i8); + if (code15 === 47) { + if (!matchedSlash) { + start = i8 + 1; + break; + } + } else { + if (firstNonSlashEnd === -1) { + matchedSlash = false; + firstNonSlashEnd = i8 + 1; + } + if (extIdx >= 0) { + if (code15 === ext.charCodeAt(extIdx)) { + if (--extIdx === -1) { + end = i8; + } + } else { + extIdx = -1; + end = firstNonSlashEnd; + } + } + } + } + if (start === end) + end = firstNonSlashEnd; + else if (end === -1) + end = path2.length; + return path2.slice(start, end); + } else { + for (i8 = path2.length - 1; i8 >= 0; --i8) { + if (path2.charCodeAt(i8) === 47) { + if (!matchedSlash) { + start = i8 + 1; + break; + } + } else if (end === -1) { + matchedSlash = false; + end = i8 + 1; + } + } + if (end === -1) + return ""; + return path2.slice(start, end); + } + }, + extname: function extname2(path2) { + assertPath(path2); + var startDot = -1; + var startPart = 0; + var end = -1; + var matchedSlash = true; + var preDotState = 0; + for (var i8 = path2.length - 1; i8 >= 0; --i8) { + var code15 = path2.charCodeAt(i8); + if (code15 === 47) { + if (!matchedSlash) { + startPart = i8 + 1; + break; + } + continue; + } + if (end === -1) { + matchedSlash = false; + end = i8 + 1; + } + if (code15 === 46) { + if (startDot === -1) + startDot = i8; + else if (preDotState !== 1) + preDotState = 1; + } else if (startDot !== -1) { + preDotState = -1; + } + } + if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot + preDotState === 0 || // The (right-most) trimmed path component is exactly '..' + preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + return ""; + } + return path2.slice(startDot, end); + }, + format: function format16(pathObject) { + if (pathObject === null || typeof pathObject !== "object") { + throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); + } + return _format("/", pathObject); + }, + parse: function parse10(path2) { + assertPath(path2); + var ret = { + root: "", + dir: "", + base: "", + ext: "", + name: "" + }; + if (path2.length === 0) + return ret; + var code15 = path2.charCodeAt(0); + var isAbsolute2 = code15 === 47; + var start; + if (isAbsolute2) { + ret.root = "/"; + start = 1; + } else { + start = 0; + } + var startDot = -1; + var startPart = 0; + var end = -1; + var matchedSlash = true; + var i8 = path2.length - 1; + var preDotState = 0; + for (; i8 >= start; --i8) { + code15 = path2.charCodeAt(i8); + if (code15 === 47) { + if (!matchedSlash) { + startPart = i8 + 1; + break; + } + continue; + } + if (end === -1) { + matchedSlash = false; + end = i8 + 1; + } + if (code15 === 46) { + if (startDot === -1) + startDot = i8; + else if (preDotState !== 1) + preDotState = 1; + } else if (startDot !== -1) { + preDotState = -1; + } + } + if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot + preDotState === 0 || // The (right-most) trimmed path component is exactly '..' + preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + if (end !== -1) { + if (startPart === 0 && isAbsolute2) + ret.base = ret.name = path2.slice(1, end); + else + ret.base = ret.name = path2.slice(startPart, end); + } + } else { + if (startPart === 0 && isAbsolute2) { + ret.name = path2.slice(1, startDot); + ret.base = path2.slice(1, end); + } else { + ret.name = path2.slice(startPart, startDot); + ret.base = path2.slice(startPart, end); + } + ret.ext = path2.slice(startDot, end); + } + if (startPart > 0) + ret.dir = path2.slice(0, startPart - 1); + else if (isAbsolute2) + ret.dir = "/"; + return ret; + }, + sep: "/", + delimiter: ":", + win32: null, + posix: null + }; + posix2.posix = posix2; + exports$111 = posix2; + return exports$111; + } + var exports$111, _dewExec6, exports7; + var init_chunk_23dbec7b = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-23dbec7b.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_2eac56ff(); + exports$111 = {}; + _dewExec6 = false; + exports7 = dew6(); + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/path.js + var _makeLong, basename, delimiter, dirname, extname, format13, isAbsolute, join2, normalize, parse8, posix, relative, resolve, sep, win32; + var init_path = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/path.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_23dbec7b(); + init_chunk_23dbec7b(); + init_chunk_2eac56ff(); + _makeLong = exports7._makeLong; + basename = exports7.basename; + delimiter = exports7.delimiter; + dirname = exports7.dirname; + extname = exports7.extname; + format13 = exports7.format; + isAbsolute = exports7.isAbsolute; + join2 = exports7.join; + normalize = exports7.normalize; + parse8 = exports7.parse; + posix = exports7.posix; + relative = exports7.relative; + resolve = exports7.resolve; + sep = exports7.sep; + win32 = exports7.win32; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/events.js + var EventEmitter, defaultMaxListeners, init2, listenerCount, on, once; + var init_events = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/events.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_4bd36a8f(); + init_chunk_4bd36a8f(); + y.once = function(emitter, event) { + return new Promise((resolve7, reject) => { + function eventListener(...args) { + if (errorListener !== void 0) { + emitter.removeListener("error", errorListener); + } + resolve7(args); + } + let errorListener; + if (event !== "error") { + errorListener = (err) => { + emitter.removeListener(name, eventListener); + reject(err); + }; + emitter.once("error", errorListener); + } + emitter.once(event, eventListener); + }); + }; + y.on = function(emitter, event) { + const unconsumedEventValues = []; + const unconsumedPromises = []; + let error7 = null; + let finished2 = false; + const iterator = { + async next() { + const value = unconsumedEventValues.shift(); + if (value) { + return createIterResult(value, false); + } + if (error7) { + const p8 = Promise.reject(error7); + error7 = null; + return p8; + } + if (finished2) { + return createIterResult(void 0, true); + } + return new Promise((resolve7, reject) => unconsumedPromises.push({ resolve: resolve7, reject })); + }, + async return() { + emitter.removeListener(event, eventHandler); + emitter.removeListener("error", errorHandler); + finished2 = true; + for (const promise of unconsumedPromises) { + promise.resolve(createIterResult(void 0, true)); + } + return createIterResult(void 0, true); + }, + throw(err) { + error7 = err; + emitter.removeListener(event, eventHandler); + emitter.removeListener("error", errorHandler); + }, + [Symbol.asyncIterator]() { + return this; + } + }; + emitter.on(event, eventHandler); + emitter.on("error", errorHandler); + return iterator; + function eventHandler(...args) { + const promise = unconsumedPromises.shift(); + if (promise) { + promise.resolve(createIterResult(args, false)); + } else { + unconsumedEventValues.push(args); + } + } + function errorHandler(err) { + finished2 = true; + const toError = unconsumedPromises.shift(); + if (toError) { + toError.reject(err); + } else { + error7 = err; + } + iterator.return(); + } + }; + ({ + EventEmitter, + defaultMaxListeners, + init: init2, + listenerCount, + on, + once + } = y); + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-6c718bbe.js + function dew7() { + if (_dewExec7) + return exports$112; + _dewExec7 = true; + exports$112 = Stream2; + var EE = y.EventEmitter; + var inherits3 = dew$f(); + inherits3(Stream2, EE); + Stream2.Readable = dew$3(); + Stream2.Writable = dew$8(); + Stream2.Duplex = dew$7(); + Stream2.Transform = dew$22(); + Stream2.PassThrough = dew$12(); + Stream2.finished = dew$6(); + Stream2.pipeline = dew3(); + Stream2.Stream = Stream2; + function Stream2() { + EE.call(this || _global4); + } + Stream2.prototype.pipe = function(dest, options) { + var source = this || _global4; + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } + source.on("data", ondata); + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } + dest.on("drain", ondrain); + if (!dest._isStdio && (!options || options.end !== false)) { + source.on("end", onend); + source.on("close", onclose); + } + var didOnEnd = false; + function onend() { + if (didOnEnd) + return; + didOnEnd = true; + dest.end(); + } + function onclose() { + if (didOnEnd) + return; + didOnEnd = true; + if (typeof dest.destroy === "function") + dest.destroy(); + } + function onerror(er) { + cleanup(); + if (EE.listenerCount(this || _global4, "error") === 0) { + throw er; + } + } + source.on("error", onerror); + dest.on("error", onerror); + function cleanup() { + source.removeListener("data", ondata); + dest.removeListener("drain", ondrain); + source.removeListener("end", onend); + source.removeListener("close", onclose); + source.removeListener("error", onerror); + dest.removeListener("error", onerror); + source.removeListener("end", cleanup); + source.removeListener("close", cleanup); + dest.removeListener("close", cleanup); + } + source.on("end", cleanup); + source.on("close", cleanup); + dest.on("close", cleanup); + dest.emit("pipe", source); + return dest; + }; + return exports$112; + } + var exports$112, _dewExec7, _global4, exports8; + var init_chunk_6c718bbe = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-6c718bbe.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_events(); + init_chunk_44e51b61(); + init_chunk_4bd36a8f(); + exports$112 = {}; + _dewExec7 = false; + _global4 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + exports8 = dew7(); + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/stream.js + var Readable, Writable, Duplex, Transform, PassThrough, finished, pipeline, Stream, promises; + var init_stream = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/stream.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_6c718bbe(); + init_chunk_6c718bbe(); + init_util(); + init_events(); + init_chunk_4bd36a8f(); + init_chunk_44e51b61(); + init_chunk_ce0fbc82(); + init_chunk_b4205b57(); + init_chunk_5decc758(); + init_chunk_2eac56ff(); + init_chunk_4ccc3a29(); + Readable = exports8.Readable; + Readable.wrap = function(src3, options) { + options = Object.assign({ objectMode: src3.readableObjectMode != null || src3.objectMode != null || true }, options); + options.destroy = function(err, callback) { + src3.destroy(err); + callback(err); + }; + return new Readable(options).wrap(src3); + }; + Writable = exports8.Writable; + Duplex = exports8.Duplex; + Transform = exports8.Transform; + PassThrough = exports8.PassThrough; + finished = exports8.finished; + pipeline = exports8.pipeline; + Stream = exports8.Stream; + promises = { + finished: promisify2(exports8.finished), + pipeline: promisify2(exports8.pipeline) + }; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-924bb2e1.js + function i6(t9) { + throw new RangeError(r7[t9]); + } + function f7(t9, o9) { + const n9 = t9.split("@"); + let r10 = ""; + n9.length > 1 && (r10 = n9[0] + "@", t9 = n9[1]); + const c8 = function(t10, o10) { + const n10 = []; + let e12 = t10.length; + for (; e12--; ) + n10[e12] = o10(t10[e12]); + return n10; + }((t9 = t9.replace(e9, ".")).split("."), o9).join("."); + return r10 + c8; + } + function l6(t9) { + const o9 = []; + let n9 = 0; + const e12 = t9.length; + for (; n9 < e12; ) { + const r10 = t9.charCodeAt(n9++); + if (r10 >= 55296 && r10 <= 56319 && n9 < e12) { + const e13 = t9.charCodeAt(n9++); + 56320 == (64512 & e13) ? o9.push(((1023 & r10) << 10) + (1023 & e13) + 65536) : (o9.push(r10), n9--); + } else + o9.push(r10); + } + return o9; + } + var t7, o6, n6, e9, r7, c6, s6, u6, a6, d6, h7, p6; + var init_chunk_924bb2e1 = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-924bb2e1.js"() { + init_dirname(); + init_buffer2(); + init_process(); + t7 = 2147483647; + o6 = /^xn--/; + n6 = /[^\0-\x7E]/; + e9 = /[\x2E\u3002\uFF0E\uFF61]/g; + r7 = { overflow: "Overflow: input needs wider integers to process", "not-basic": "Illegal input >= 0x80 (not a basic code point)", "invalid-input": "Invalid input" }; + c6 = Math.floor; + s6 = String.fromCharCode; + u6 = function(t9, o9) { + return t9 + 22 + 75 * (t9 < 26) - ((0 != o9) << 5); + }; + a6 = function(t9, o9, n9) { + let e12 = 0; + for (t9 = n9 ? c6(t9 / 700) : t9 >> 1, t9 += c6(t9 / o9); t9 > 455; e12 += 36) + t9 = c6(t9 / 35); + return c6(e12 + 36 * t9 / (t9 + 38)); + }; + d6 = function(o9) { + const n9 = [], e12 = o9.length; + let r10 = 0, s7 = 128, f9 = 72, l8 = o9.lastIndexOf("-"); + l8 < 0 && (l8 = 0); + for (let t9 = 0; t9 < l8; ++t9) + o9.charCodeAt(t9) >= 128 && i6("not-basic"), n9.push(o9.charCodeAt(t9)); + for (let d7 = l8 > 0 ? l8 + 1 : 0; d7 < e12; ) { + let l9 = r10; + for (let n10 = 1, s8 = 36; ; s8 += 36) { + d7 >= e12 && i6("invalid-input"); + const l10 = (u8 = o9.charCodeAt(d7++)) - 48 < 10 ? u8 - 22 : u8 - 65 < 26 ? u8 - 65 : u8 - 97 < 26 ? u8 - 97 : 36; + (l10 >= 36 || l10 > c6((t7 - r10) / n10)) && i6("overflow"), r10 += l10 * n10; + const a8 = s8 <= f9 ? 1 : s8 >= f9 + 26 ? 26 : s8 - f9; + if (l10 < a8) + break; + const h10 = 36 - a8; + n10 > c6(t7 / h10) && i6("overflow"), n10 *= h10; + } + const h9 = n9.length + 1; + f9 = a6(r10 - l9, h9, 0 == l9), c6(r10 / h9) > t7 - s7 && i6("overflow"), s7 += c6(r10 / h9), r10 %= h9, n9.splice(r10++, 0, s7); + } + var u8; + return String.fromCodePoint(...n9); + }; + h7 = function(o9) { + const n9 = []; + let e12 = (o9 = l6(o9)).length, r10 = 128, f9 = 0, d7 = 72; + for (const t9 of o9) + t9 < 128 && n9.push(s6(t9)); + let h9 = n9.length, p8 = h9; + for (h9 && n9.push("-"); p8 < e12; ) { + let e13 = t7; + for (const t9 of o9) + t9 >= r10 && t9 < e13 && (e13 = t9); + const l8 = p8 + 1; + e13 - r10 > c6((t7 - f9) / l8) && i6("overflow"), f9 += (e13 - r10) * l8, r10 = e13; + for (const e14 of o9) + if (e14 < r10 && ++f9 > t7 && i6("overflow"), e14 == r10) { + let t9 = f9; + for (let o10 = 36; ; o10 += 36) { + const e15 = o10 <= d7 ? 1 : o10 >= d7 + 26 ? 26 : o10 - d7; + if (t9 < e15) + break; + const r11 = t9 - e15, i8 = 36 - e15; + n9.push(s6(u6(e15 + r11 % i8, 0))), t9 = c6(r11 / i8); + } + n9.push(s6(u6(t9, 0))), d7 = a6(f9, l8, p8 == h9), f9 = 0, ++p8; + } + ++f9, ++r10; + } + return n9.join(""); + }; + p6 = { version: "2.1.0", ucs2: { decode: l6, encode: (t9) => String.fromCodePoint(...t9) }, decode: d6, encode: h7, toASCII: function(t9) { + return f7(t9, function(t10) { + return n6.test(t10) ? "xn--" + h7(t10) : t10; + }); + }, toUnicode: function(t9) { + return f7(t9, function(t10) { + return o6.test(t10) ? d6(t10.slice(4).toLowerCase()) : t10; + }); + } }; + p6.decode; + p6.encode; + p6.toASCII; + p6.toUnicode; + p6.ucs2; + p6.version; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-b04e620d.js + function e10(e12, n9) { + return Object.prototype.hasOwnProperty.call(e12, n9); + } + var n7, r8, t8, o7; + var init_chunk_b04e620d = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-b04e620d.js"() { + init_dirname(); + init_buffer2(); + init_process(); + n7 = function(n9, r10, t9, o9) { + r10 = r10 || "&", t9 = t9 || "="; + var a8 = {}; + if ("string" != typeof n9 || 0 === n9.length) + return a8; + var u8 = /\+/g; + n9 = n9.split(r10); + var c8 = 1e3; + o9 && "number" == typeof o9.maxKeys && (c8 = o9.maxKeys); + var i8 = n9.length; + c8 > 0 && i8 > c8 && (i8 = c8); + for (var s7 = 0; s7 < i8; ++s7) { + var p8, f9, d7, y7, m7 = n9[s7].replace(u8, "%20"), l8 = m7.indexOf(t9); + l8 >= 0 ? (p8 = m7.substr(0, l8), f9 = m7.substr(l8 + 1)) : (p8 = m7, f9 = ""), d7 = decodeURIComponent(p8), y7 = decodeURIComponent(f9), e10(a8, d7) ? Array.isArray(a8[d7]) ? a8[d7].push(y7) : a8[d7] = [a8[d7], y7] : a8[d7] = y7; + } + return a8; + }; + r8 = function(e12) { + switch (typeof e12) { + case "string": + return e12; + case "boolean": + return e12 ? "true" : "false"; + case "number": + return isFinite(e12) ? e12 : ""; + default: + return ""; + } + }; + t8 = function(e12, n9, t9, o9) { + return n9 = n9 || "&", t9 = t9 || "=", null === e12 && (e12 = void 0), "object" == typeof e12 ? Object.keys(e12).map(function(o10) { + var a8 = encodeURIComponent(r8(o10)) + t9; + return Array.isArray(e12[o10]) ? e12[o10].map(function(e13) { + return a8 + encodeURIComponent(r8(e13)); + }).join(n9) : a8 + encodeURIComponent(r8(e12[o10])); + }).join(n9) : o9 ? encodeURIComponent(r8(o9)) + t9 + encodeURIComponent(r8(e12)) : ""; + }; + o7 = {}; + o7.decode = o7.parse = n7, o7.encode = o7.stringify = t8; + o7.decode; + o7.encode; + o7.parse; + o7.stringify; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/url.js + function r9() { + this.protocol = null, this.slashes = null, this.auth = null, this.host = null, this.port = null, this.hostname = null, this.hash = null, this.search = null, this.query = null, this.pathname = null, this.path = null, this.href = null; + } + function O5(t9, s7, h9) { + if (t9 && a7.isObject(t9) && t9 instanceof r9) + return t9; + var e12 = new r9(); + return e12.parse(t9, s7, h9), e12; + } + function dew8() { + if (_dewExec8) + return exports9; + _dewExec8 = true; + var process3 = T; + function assertPath(path2) { + if (typeof path2 !== "string") { + throw new TypeError("Path must be a string. Received " + JSON.stringify(path2)); + } + } + function normalizeStringPosix(path2, allowAboveRoot) { + var res = ""; + var lastSegmentLength = 0; + var lastSlash = -1; + var dots = 0; + var code15; + for (var i8 = 0; i8 <= path2.length; ++i8) { + if (i8 < path2.length) + code15 = path2.charCodeAt(i8); + else if (code15 === 47) + break; + else + code15 = 47; + if (code15 === 47) { + if (lastSlash === i8 - 1 || dots === 1) + ; + else if (lastSlash !== i8 - 1 && dots === 2) { + if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) { + if (res.length > 2) { + var lastSlashIndex = res.lastIndexOf("/"); + if (lastSlashIndex !== res.length - 1) { + if (lastSlashIndex === -1) { + res = ""; + lastSegmentLength = 0; + } else { + res = res.slice(0, lastSlashIndex); + lastSegmentLength = res.length - 1 - res.lastIndexOf("/"); + } + lastSlash = i8; + dots = 0; + continue; + } + } else if (res.length === 2 || res.length === 1) { + res = ""; + lastSegmentLength = 0; + lastSlash = i8; + dots = 0; + continue; + } + } + if (allowAboveRoot) { + if (res.length > 0) + res += "/.."; + else + res = ".."; + lastSegmentLength = 2; + } + } else { + if (res.length > 0) + res += "/" + path2.slice(lastSlash + 1, i8); + else + res = path2.slice(lastSlash + 1, i8); + lastSegmentLength = i8 - lastSlash - 1; + } + lastSlash = i8; + dots = 0; + } else if (code15 === 46 && dots !== -1) { + ++dots; + } else { + dots = -1; + } + } + return res; + } + function _format(sep2, pathObject) { + var dir = pathObject.dir || pathObject.root; + var base3 = pathObject.base || (pathObject.name || "") + (pathObject.ext || ""); + if (!dir) { + return base3; + } + if (dir === pathObject.root) { + return dir + base3; + } + return dir + sep2 + base3; + } + var posix2 = { + // path.resolve([from ...], to) + resolve: function resolve7() { + var resolvedPath = ""; + var resolvedAbsolute = false; + var cwd; + for (var i8 = arguments.length - 1; i8 >= -1 && !resolvedAbsolute; i8--) { + var path2; + if (i8 >= 0) + path2 = arguments[i8]; + else { + if (cwd === void 0) + cwd = process3.cwd(); + path2 = cwd; + } + assertPath(path2); + if (path2.length === 0) { + continue; + } + resolvedPath = path2 + "/" + resolvedPath; + resolvedAbsolute = path2.charCodeAt(0) === 47; + } + resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); + if (resolvedAbsolute) { + if (resolvedPath.length > 0) + return "/" + resolvedPath; + else + return "/"; + } else if (resolvedPath.length > 0) { + return resolvedPath; + } else { + return "."; + } + }, + normalize: function normalize2(path2) { + assertPath(path2); + if (path2.length === 0) + return "."; + var isAbsolute2 = path2.charCodeAt(0) === 47; + var trailingSeparator = path2.charCodeAt(path2.length - 1) === 47; + path2 = normalizeStringPosix(path2, !isAbsolute2); + if (path2.length === 0 && !isAbsolute2) + path2 = "."; + if (path2.length > 0 && trailingSeparator) + path2 += "/"; + if (isAbsolute2) + return "/" + path2; + return path2; + }, + isAbsolute: function isAbsolute2(path2) { + assertPath(path2); + return path2.length > 0 && path2.charCodeAt(0) === 47; + }, + join: function join3() { + if (arguments.length === 0) + return "."; + var joined; + for (var i8 = 0; i8 < arguments.length; ++i8) { + var arg = arguments[i8]; + assertPath(arg); + if (arg.length > 0) { + if (joined === void 0) + joined = arg; + else + joined += "/" + arg; + } + } + if (joined === void 0) + return "."; + return posix2.normalize(joined); + }, + relative: function relative2(from18, to) { + assertPath(from18); + assertPath(to); + if (from18 === to) + return ""; + from18 = posix2.resolve(from18); + to = posix2.resolve(to); + if (from18 === to) + return ""; + var fromStart = 1; + for (; fromStart < from18.length; ++fromStart) { + if (from18.charCodeAt(fromStart) !== 47) + break; + } + var fromEnd = from18.length; + var fromLen = fromEnd - fromStart; + var toStart = 1; + for (; toStart < to.length; ++toStart) { + if (to.charCodeAt(toStart) !== 47) + break; + } + var toEnd = to.length; + var toLen = toEnd - toStart; + var length3 = fromLen < toLen ? fromLen : toLen; + var lastCommonSep = -1; + var i8 = 0; + for (; i8 <= length3; ++i8) { + if (i8 === length3) { + if (toLen > length3) { + if (to.charCodeAt(toStart + i8) === 47) { + return to.slice(toStart + i8 + 1); + } else if (i8 === 0) { + return to.slice(toStart + i8); + } + } else if (fromLen > length3) { + if (from18.charCodeAt(fromStart + i8) === 47) { + lastCommonSep = i8; + } else if (i8 === 0) { + lastCommonSep = 0; + } + } + break; + } + var fromCode = from18.charCodeAt(fromStart + i8); + var toCode = to.charCodeAt(toStart + i8); + if (fromCode !== toCode) + break; + else if (fromCode === 47) + lastCommonSep = i8; + } + var out = ""; + for (i8 = fromStart + lastCommonSep + 1; i8 <= fromEnd; ++i8) { + if (i8 === fromEnd || from18.charCodeAt(i8) === 47) { + if (out.length === 0) + out += ".."; + else + out += "/.."; + } + } + if (out.length > 0) + return out + to.slice(toStart + lastCommonSep); + else { + toStart += lastCommonSep; + if (to.charCodeAt(toStart) === 47) + ++toStart; + return to.slice(toStart); + } + }, + _makeLong: function _makeLong2(path2) { + return path2; + }, + dirname: function dirname2(path2) { + assertPath(path2); + if (path2.length === 0) + return "."; + var code15 = path2.charCodeAt(0); + var hasRoot = code15 === 47; + var end = -1; + var matchedSlash = true; + for (var i8 = path2.length - 1; i8 >= 1; --i8) { + code15 = path2.charCodeAt(i8); + if (code15 === 47) { + if (!matchedSlash) { + end = i8; + break; + } + } else { + matchedSlash = false; + } + } + if (end === -1) + return hasRoot ? "/" : "."; + if (hasRoot && end === 1) + return "//"; + return path2.slice(0, end); + }, + basename: function basename2(path2, ext) { + if (ext !== void 0 && typeof ext !== "string") + throw new TypeError('"ext" argument must be a string'); + assertPath(path2); + var start = 0; + var end = -1; + var matchedSlash = true; + var i8; + if (ext !== void 0 && ext.length > 0 && ext.length <= path2.length) { + if (ext.length === path2.length && ext === path2) + return ""; + var extIdx = ext.length - 1; + var firstNonSlashEnd = -1; + for (i8 = path2.length - 1; i8 >= 0; --i8) { + var code15 = path2.charCodeAt(i8); + if (code15 === 47) { + if (!matchedSlash) { + start = i8 + 1; + break; + } + } else { + if (firstNonSlashEnd === -1) { + matchedSlash = false; + firstNonSlashEnd = i8 + 1; + } + if (extIdx >= 0) { + if (code15 === ext.charCodeAt(extIdx)) { + if (--extIdx === -1) { + end = i8; + } + } else { + extIdx = -1; + end = firstNonSlashEnd; + } + } + } + } + if (start === end) + end = firstNonSlashEnd; + else if (end === -1) + end = path2.length; + return path2.slice(start, end); + } else { + for (i8 = path2.length - 1; i8 >= 0; --i8) { + if (path2.charCodeAt(i8) === 47) { + if (!matchedSlash) { + start = i8 + 1; + break; + } + } else if (end === -1) { + matchedSlash = false; + end = i8 + 1; + } + } + if (end === -1) + return ""; + return path2.slice(start, end); + } + }, + extname: function extname2(path2) { + assertPath(path2); + var startDot = -1; + var startPart = 0; + var end = -1; + var matchedSlash = true; + var preDotState = 0; + for (var i8 = path2.length - 1; i8 >= 0; --i8) { + var code15 = path2.charCodeAt(i8); + if (code15 === 47) { + if (!matchedSlash) { + startPart = i8 + 1; + break; + } + continue; + } + if (end === -1) { + matchedSlash = false; + end = i8 + 1; + } + if (code15 === 46) { + if (startDot === -1) + startDot = i8; + else if (preDotState !== 1) + preDotState = 1; + } else if (startDot !== -1) { + preDotState = -1; + } + } + if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot + preDotState === 0 || // The (right-most) trimmed path component is exactly '..' + preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + return ""; + } + return path2.slice(startDot, end); + }, + format: function format16(pathObject) { + if (pathObject === null || typeof pathObject !== "object") { + throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); + } + return _format("/", pathObject); + }, + parse: function parse10(path2) { + assertPath(path2); + var ret = { + root: "", + dir: "", + base: "", + ext: "", + name: "" + }; + if (path2.length === 0) + return ret; + var code15 = path2.charCodeAt(0); + var isAbsolute2 = code15 === 47; + var start; + if (isAbsolute2) { + ret.root = "/"; + start = 1; + } else { + start = 0; + } + var startDot = -1; + var startPart = 0; + var end = -1; + var matchedSlash = true; + var i8 = path2.length - 1; + var preDotState = 0; + for (; i8 >= start; --i8) { + code15 = path2.charCodeAt(i8); + if (code15 === 47) { + if (!matchedSlash) { + startPart = i8 + 1; + break; + } + continue; + } + if (end === -1) { + matchedSlash = false; + end = i8 + 1; + } + if (code15 === 46) { + if (startDot === -1) + startDot = i8; + else if (preDotState !== 1) + preDotState = 1; + } else if (startDot !== -1) { + preDotState = -1; + } + } + if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot + preDotState === 0 || // The (right-most) trimmed path component is exactly '..' + preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + if (end !== -1) { + if (startPart === 0 && isAbsolute2) + ret.base = ret.name = path2.slice(1, end); + else + ret.base = ret.name = path2.slice(startPart, end); + } + } else { + if (startPart === 0 && isAbsolute2) { + ret.name = path2.slice(1, startDot); + ret.base = path2.slice(1, end); + } else { + ret.name = path2.slice(startPart, startDot); + ret.base = path2.slice(startPart, end); + } + ret.ext = path2.slice(startDot, end); + } + if (startPart > 0) + ret.dir = path2.slice(0, startPart - 1); + else if (isAbsolute2) + ret.dir = "/"; + return ret; + }, + sep: "/", + delimiter: ":", + win32: null, + posix: null + }; + posix2.posix = posix2; + exports9 = posix2; + return exports9; + } + function fileURLToPath$1(path2) { + if (typeof path2 === "string") + path2 = new URL(path2); + else if (!(path2 instanceof URL)) { + throw new Deno.errors.InvalidData( + "invalid argument path , must be a string or URL" + ); + } + if (path2.protocol !== "file:") { + throw new Deno.errors.InvalidData("invalid url scheme"); + } + return isWindows$1 ? getPathFromURLWin$1(path2) : getPathFromURLPosix$1(path2); + } + function getPathFromURLWin$1(url) { + const hostname2 = url.hostname; + let pathname = url.pathname; + for (let n9 = 0; n9 < pathname.length; n9++) { + if (pathname[n9] === "%") { + const third = pathname.codePointAt(n9 + 2) || 32; + if (pathname[n9 + 1] === "2" && third === 102 || // 2f 2F / + pathname[n9 + 1] === "5" && third === 99) { + throw new Deno.errors.InvalidData( + "must not include encoded \\ or / characters" + ); + } + } + } + pathname = pathname.replace(forwardSlashRegEx$1, "\\"); + pathname = decodeURIComponent(pathname); + if (hostname2 !== "") { + return `\\\\${hostname2}${pathname}`; + } else { + const letter = pathname.codePointAt(1) | 32; + const sep2 = pathname[2]; + if (letter < CHAR_LOWERCASE_A$1 || letter > CHAR_LOWERCASE_Z$1 || // a..z A..Z + sep2 !== ":") { + throw new Deno.errors.InvalidData("file url path must be absolute"); + } + return pathname.slice(1); + } + } + function getPathFromURLPosix$1(url) { + if (url.hostname !== "") { + throw new Deno.errors.InvalidData("invalid file url hostname"); + } + const pathname = url.pathname; + for (let n9 = 0; n9 < pathname.length; n9++) { + if (pathname[n9] === "%") { + const third = pathname.codePointAt(n9 + 2) || 32; + if (pathname[n9 + 1] === "2" && third === 102) { + throw new Deno.errors.InvalidData( + "must not include encoded / characters" + ); + } + } + } + return decodeURIComponent(pathname); + } + function pathToFileURL$1(filepath) { + let resolved = path.resolve(filepath); + const filePathLast = filepath.charCodeAt(filepath.length - 1); + if ((filePathLast === CHAR_FORWARD_SLASH$1 || isWindows$1 && filePathLast === CHAR_BACKWARD_SLASH$1) && resolved[resolved.length - 1] !== path.sep) { + resolved += "/"; + } + const outURL = new URL("file://"); + if (resolved.includes("%")) + resolved = resolved.replace(percentRegEx$1, "%25"); + if (!isWindows$1 && resolved.includes("\\")) { + resolved = resolved.replace(backslashRegEx$1, "%5C"); + } + if (resolved.includes("\n")) + resolved = resolved.replace(newlineRegEx$1, "%0A"); + if (resolved.includes("\r")) { + resolved = resolved.replace(carriageReturnRegEx$1, "%0D"); + } + if (resolved.includes(" ")) + resolved = resolved.replace(tabRegEx$1, "%09"); + outURL.pathname = resolved; + return outURL; + } + function fileURLToPath(path2) { + if (typeof path2 === "string") + path2 = new URL(path2); + else if (!(path2 instanceof URL)) { + throw new Deno.errors.InvalidData( + "invalid argument path , must be a string or URL" + ); + } + if (path2.protocol !== "file:") { + throw new Deno.errors.InvalidData("invalid url scheme"); + } + return isWindows ? getPathFromURLWin(path2) : getPathFromURLPosix(path2); + } + function getPathFromURLWin(url) { + const hostname2 = url.hostname; + let pathname = url.pathname; + for (let n9 = 0; n9 < pathname.length; n9++) { + if (pathname[n9] === "%") { + const third = pathname.codePointAt(n9 + 2) || 32; + if (pathname[n9 + 1] === "2" && third === 102 || // 2f 2F / + pathname[n9 + 1] === "5" && third === 99) { + throw new Deno.errors.InvalidData( + "must not include encoded \\ or / characters" + ); + } + } + } + pathname = pathname.replace(forwardSlashRegEx, "\\"); + pathname = decodeURIComponent(pathname); + if (hostname2 !== "") { + return `\\\\${hostname2}${pathname}`; + } else { + const letter = pathname.codePointAt(1) | 32; + const sep2 = pathname[2]; + if (letter < CHAR_LOWERCASE_A || letter > CHAR_LOWERCASE_Z || // a..z A..Z + sep2 !== ":") { + throw new Deno.errors.InvalidData("file url path must be absolute"); + } + return pathname.slice(1); + } + } + function getPathFromURLPosix(url) { + if (url.hostname !== "") { + throw new Deno.errors.InvalidData("invalid file url hostname"); + } + const pathname = url.pathname; + for (let n9 = 0; n9 < pathname.length; n9++) { + if (pathname[n9] === "%") { + const third = pathname.codePointAt(n9 + 2) || 32; + if (pathname[n9 + 1] === "2" && third === 102) { + throw new Deno.errors.InvalidData( + "must not include encoded / characters" + ); + } + } + } + return decodeURIComponent(pathname); + } + function pathToFileURL(filepath) { + let resolved = exports7.resolve(filepath); + const filePathLast = filepath.charCodeAt(filepath.length - 1); + if ((filePathLast === CHAR_FORWARD_SLASH || isWindows && filePathLast === CHAR_BACKWARD_SLASH) && resolved[resolved.length - 1] !== exports7.sep) { + resolved += "/"; + } + const outURL = new URL("file://"); + if (resolved.includes("%")) + resolved = resolved.replace(percentRegEx, "%25"); + if (!isWindows && resolved.includes("\\")) { + resolved = resolved.replace(backslashRegEx, "%5C"); + } + if (resolved.includes("\n")) + resolved = resolved.replace(newlineRegEx, "%0A"); + if (resolved.includes("\r")) { + resolved = resolved.replace(carriageReturnRegEx, "%0D"); + } + if (resolved.includes(" ")) + resolved = resolved.replace(tabRegEx, "%09"); + outURL.pathname = resolved; + return outURL; + } + var h8, e11, a7, o8, n8, i7, l7, p7, c7, u7, f8, m6, v6, g5, y6, b5, exports9, _dewExec8, path, processPlatform$1, CHAR_BACKWARD_SLASH$1, CHAR_FORWARD_SLASH$1, CHAR_LOWERCASE_A$1, CHAR_LOWERCASE_Z$1, isWindows$1, forwardSlashRegEx$1, percentRegEx$1, backslashRegEx$1, newlineRegEx$1, carriageReturnRegEx$1, tabRegEx$1, processPlatform, Url, format14, resolve2, resolveObject, parse9, _URL, CHAR_BACKWARD_SLASH, CHAR_FORWARD_SLASH, CHAR_LOWERCASE_A, CHAR_LOWERCASE_Z, isWindows, forwardSlashRegEx, percentRegEx, backslashRegEx, newlineRegEx, carriageReturnRegEx, tabRegEx; + var init_url = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/url.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_924bb2e1(); + init_chunk_b04e620d(); + init_chunk_5decc758(); + init_chunk_23dbec7b(); + init_chunk_2eac56ff(); + h8 = {}; + e11 = p6; + a7 = { isString: function(t9) { + return "string" == typeof t9; + }, isObject: function(t9) { + return "object" == typeof t9 && null !== t9; + }, isNull: function(t9) { + return null === t9; + }, isNullOrUndefined: function(t9) { + return null == t9; + } }; + h8.parse = O5, h8.resolve = function(t9, s7) { + return O5(t9, false, true).resolve(s7); + }, h8.resolveObject = function(t9, s7) { + return t9 ? O5(t9, false, true).resolveObject(s7) : s7; + }, h8.format = function(t9) { + a7.isString(t9) && (t9 = O5(t9)); + return t9 instanceof r9 ? t9.format() : r9.prototype.format.call(t9); + }, h8.Url = r9; + o8 = /^([a-z0-9.+-]+:)/i; + n8 = /:[0-9]*$/; + i7 = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/; + l7 = ["{", "}", "|", "\\", "^", "`"].concat(["<", ">", '"', "`", " ", "\r", "\n", " "]); + p7 = ["'"].concat(l7); + c7 = ["%", "/", "?", ";", "#"].concat(p7); + u7 = ["/", "?", "#"]; + f8 = /^[+a-z0-9A-Z_-]{0,63}$/; + m6 = /^([+a-z0-9A-Z_-]{0,63})(.*)$/; + v6 = { javascript: true, "javascript:": true }; + g5 = { javascript: true, "javascript:": true }; + y6 = { http: true, https: true, ftp: true, gopher: true, file: true, "http:": true, "https:": true, "ftp:": true, "gopher:": true, "file:": true }; + b5 = o7; + r9.prototype.parse = function(t9, s7, h9) { + if (!a7.isString(t9)) + throw new TypeError("Parameter 'url' must be a string, not " + typeof t9); + var r10 = t9.indexOf("?"), n9 = -1 !== r10 && r10 < t9.indexOf("#") ? "?" : "#", l8 = t9.split(n9); + l8[0] = l8[0].replace(/\\/g, "/"); + var O6 = t9 = l8.join(n9); + if (O6 = O6.trim(), !h9 && 1 === t9.split("#").length) { + var d7 = i7.exec(O6); + if (d7) + return this.path = O6, this.href = O6, this.pathname = d7[1], d7[2] ? (this.search = d7[2], this.query = s7 ? b5.parse(this.search.substr(1)) : this.search.substr(1)) : s7 && (this.search = "", this.query = {}), this; + } + var j5 = o8.exec(O6); + if (j5) { + var q4 = (j5 = j5[0]).toLowerCase(); + this.protocol = q4, O6 = O6.substr(j5.length); + } + if (h9 || j5 || O6.match(/^\/\/[^@\/]+@[^@\/]+/)) { + var x5 = "//" === O6.substr(0, 2); + !x5 || j5 && g5[j5] || (O6 = O6.substr(2), this.slashes = true); + } + if (!g5[j5] && (x5 || j5 && !y6[j5])) { + for (var A5, C5, I5 = -1, w5 = 0; w5 < u7.length; w5++) { + -1 !== (N14 = O6.indexOf(u7[w5])) && (-1 === I5 || N14 < I5) && (I5 = N14); + } + -1 !== (C5 = -1 === I5 ? O6.lastIndexOf("@") : O6.lastIndexOf("@", I5)) && (A5 = O6.slice(0, C5), O6 = O6.slice(C5 + 1), this.auth = decodeURIComponent(A5)), I5 = -1; + for (w5 = 0; w5 < c7.length; w5++) { + var N14; + -1 !== (N14 = O6.indexOf(c7[w5])) && (-1 === I5 || N14 < I5) && (I5 = N14); + } + -1 === I5 && (I5 = O6.length), this.host = O6.slice(0, I5), O6 = O6.slice(I5), this.parseHost(), this.hostname = this.hostname || ""; + var U5 = "[" === this.hostname[0] && "]" === this.hostname[this.hostname.length - 1]; + if (!U5) + for (var k5 = this.hostname.split(/\./), S5 = (w5 = 0, k5.length); w5 < S5; w5++) { + var R5 = k5[w5]; + if (R5 && !R5.match(f8)) { + for (var $4 = "", z6 = 0, H4 = R5.length; z6 < H4; z6++) + R5.charCodeAt(z6) > 127 ? $4 += "x" : $4 += R5[z6]; + if (!$4.match(f8)) { + var L5 = k5.slice(0, w5), Z4 = k5.slice(w5 + 1), _5 = R5.match(m6); + _5 && (L5.push(_5[1]), Z4.unshift(_5[2])), Z4.length && (O6 = "/" + Z4.join(".") + O6), this.hostname = L5.join("."); + break; + } + } + } + this.hostname.length > 255 ? this.hostname = "" : this.hostname = this.hostname.toLowerCase(), U5 || (this.hostname = e11.toASCII(this.hostname)); + var E5 = this.port ? ":" + this.port : "", P5 = this.hostname || ""; + this.host = P5 + E5, this.href += this.host, U5 && (this.hostname = this.hostname.substr(1, this.hostname.length - 2), "/" !== O6[0] && (O6 = "/" + O6)); + } + if (!v6[q4]) + for (w5 = 0, S5 = p7.length; w5 < S5; w5++) { + var T6 = p7[w5]; + if (-1 !== O6.indexOf(T6)) { + var B5 = encodeURIComponent(T6); + B5 === T6 && (B5 = escape(T6)), O6 = O6.split(T6).join(B5); + } + } + var D5 = O6.indexOf("#"); + -1 !== D5 && (this.hash = O6.substr(D5), O6 = O6.slice(0, D5)); + var F5 = O6.indexOf("?"); + if (-1 !== F5 ? (this.search = O6.substr(F5), this.query = O6.substr(F5 + 1), s7 && (this.query = b5.parse(this.query)), O6 = O6.slice(0, F5)) : s7 && (this.search = "", this.query = {}), O6 && (this.pathname = O6), y6[q4] && this.hostname && !this.pathname && (this.pathname = "/"), this.pathname || this.search) { + E5 = this.pathname || ""; + var G4 = this.search || ""; + this.path = E5 + G4; + } + return this.href = this.format(), this; + }, r9.prototype.format = function() { + var t9 = this.auth || ""; + t9 && (t9 = (t9 = encodeURIComponent(t9)).replace(/%3A/i, ":"), t9 += "@"); + var s7 = this.protocol || "", h9 = this.pathname || "", e12 = this.hash || "", r10 = false, o9 = ""; + this.host ? r10 = t9 + this.host : this.hostname && (r10 = t9 + (-1 === this.hostname.indexOf(":") ? this.hostname : "[" + this.hostname + "]"), this.port && (r10 += ":" + this.port)), this.query && a7.isObject(this.query) && Object.keys(this.query).length && (o9 = b5.stringify(this.query)); + var n9 = this.search || o9 && "?" + o9 || ""; + return s7 && ":" !== s7.substr(-1) && (s7 += ":"), this.slashes || (!s7 || y6[s7]) && false !== r10 ? (r10 = "//" + (r10 || ""), h9 && "/" !== h9.charAt(0) && (h9 = "/" + h9)) : r10 || (r10 = ""), e12 && "#" !== e12.charAt(0) && (e12 = "#" + e12), n9 && "?" !== n9.charAt(0) && (n9 = "?" + n9), s7 + r10 + (h9 = h9.replace(/[?#]/g, function(t10) { + return encodeURIComponent(t10); + })) + (n9 = n9.replace("#", "%23")) + e12; + }, r9.prototype.resolve = function(t9) { + return this.resolveObject(O5(t9, false, true)).format(); + }, r9.prototype.resolveObject = function(t9) { + if (a7.isString(t9)) { + var s7 = new r9(); + s7.parse(t9, false, true), t9 = s7; + } + for (var h9 = new r9(), e12 = Object.keys(this), o9 = 0; o9 < e12.length; o9++) { + var n9 = e12[o9]; + h9[n9] = this[n9]; + } + if (h9.hash = t9.hash, "" === t9.href) + return h9.href = h9.format(), h9; + if (t9.slashes && !t9.protocol) { + for (var i8 = Object.keys(t9), l8 = 0; l8 < i8.length; l8++) { + var p8 = i8[l8]; + "protocol" !== p8 && (h9[p8] = t9[p8]); + } + return y6[h9.protocol] && h9.hostname && !h9.pathname && (h9.path = h9.pathname = "/"), h9.href = h9.format(), h9; + } + if (t9.protocol && t9.protocol !== h9.protocol) { + if (!y6[t9.protocol]) { + for (var c8 = Object.keys(t9), u8 = 0; u8 < c8.length; u8++) { + var f9 = c8[u8]; + h9[f9] = t9[f9]; + } + return h9.href = h9.format(), h9; + } + if (h9.protocol = t9.protocol, t9.host || g5[t9.protocol]) + h9.pathname = t9.pathname; + else { + for (var m7 = (t9.pathname || "").split("/"); m7.length && !(t9.host = m7.shift()); ) + ; + t9.host || (t9.host = ""), t9.hostname || (t9.hostname = ""), "" !== m7[0] && m7.unshift(""), m7.length < 2 && m7.unshift(""), h9.pathname = m7.join("/"); + } + if (h9.search = t9.search, h9.query = t9.query, h9.host = t9.host || "", h9.auth = t9.auth, h9.hostname = t9.hostname || t9.host, h9.port = t9.port, h9.pathname || h9.search) { + var v7 = h9.pathname || "", b6 = h9.search || ""; + h9.path = v7 + b6; + } + return h9.slashes = h9.slashes || t9.slashes, h9.href = h9.format(), h9; + } + var O6 = h9.pathname && "/" === h9.pathname.charAt(0), d7 = t9.host || t9.pathname && "/" === t9.pathname.charAt(0), j5 = d7 || O6 || h9.host && t9.pathname, q4 = j5, x5 = h9.pathname && h9.pathname.split("/") || [], A5 = (m7 = t9.pathname && t9.pathname.split("/") || [], h9.protocol && !y6[h9.protocol]); + if (A5 && (h9.hostname = "", h9.port = null, h9.host && ("" === x5[0] ? x5[0] = h9.host : x5.unshift(h9.host)), h9.host = "", t9.protocol && (t9.hostname = null, t9.port = null, t9.host && ("" === m7[0] ? m7[0] = t9.host : m7.unshift(t9.host)), t9.host = null), j5 = j5 && ("" === m7[0] || "" === x5[0])), d7) + h9.host = t9.host || "" === t9.host ? t9.host : h9.host, h9.hostname = t9.hostname || "" === t9.hostname ? t9.hostname : h9.hostname, h9.search = t9.search, h9.query = t9.query, x5 = m7; + else if (m7.length) + x5 || (x5 = []), x5.pop(), x5 = x5.concat(m7), h9.search = t9.search, h9.query = t9.query; + else if (!a7.isNullOrUndefined(t9.search)) { + if (A5) + h9.hostname = h9.host = x5.shift(), (U5 = !!(h9.host && h9.host.indexOf("@") > 0) && h9.host.split("@")) && (h9.auth = U5.shift(), h9.host = h9.hostname = U5.shift()); + return h9.search = t9.search, h9.query = t9.query, a7.isNull(h9.pathname) && a7.isNull(h9.search) || (h9.path = (h9.pathname ? h9.pathname : "") + (h9.search ? h9.search : "")), h9.href = h9.format(), h9; + } + if (!x5.length) + return h9.pathname = null, h9.search ? h9.path = "/" + h9.search : h9.path = null, h9.href = h9.format(), h9; + for (var C5 = x5.slice(-1)[0], I5 = (h9.host || t9.host || x5.length > 1) && ("." === C5 || ".." === C5) || "" === C5, w5 = 0, N14 = x5.length; N14 >= 0; N14--) + "." === (C5 = x5[N14]) ? x5.splice(N14, 1) : ".." === C5 ? (x5.splice(N14, 1), w5++) : w5 && (x5.splice(N14, 1), w5--); + if (!j5 && !q4) + for (; w5--; w5) + x5.unshift(".."); + !j5 || "" === x5[0] || x5[0] && "/" === x5[0].charAt(0) || x5.unshift(""), I5 && "/" !== x5.join("/").substr(-1) && x5.push(""); + var U5, k5 = "" === x5[0] || x5[0] && "/" === x5[0].charAt(0); + A5 && (h9.hostname = h9.host = k5 ? "" : x5.length ? x5.shift() : "", (U5 = !!(h9.host && h9.host.indexOf("@") > 0) && h9.host.split("@")) && (h9.auth = U5.shift(), h9.host = h9.hostname = U5.shift())); + return (j5 = j5 || h9.host && x5.length) && !k5 && x5.unshift(""), x5.length ? h9.pathname = x5.join("/") : (h9.pathname = null, h9.path = null), a7.isNull(h9.pathname) && a7.isNull(h9.search) || (h9.path = (h9.pathname ? h9.pathname : "") + (h9.search ? h9.search : "")), h9.auth = t9.auth || h9.auth, h9.slashes = h9.slashes || t9.slashes, h9.href = h9.format(), h9; + }, r9.prototype.parseHost = function() { + var t9 = this.host, s7 = n8.exec(t9); + s7 && (":" !== (s7 = s7[0]) && (this.port = s7.substr(1)), t9 = t9.substr(0, t9.length - s7.length)), t9 && (this.hostname = t9); + }; + h8.Url; + h8.format; + h8.resolve; + h8.resolveObject; + exports9 = {}; + _dewExec8 = false; + path = dew8(); + processPlatform$1 = typeof Deno !== "undefined" ? Deno.build.os === "windows" ? "win32" : Deno.build.os : void 0; + h8.URL = typeof URL !== "undefined" ? URL : null; + h8.pathToFileURL = pathToFileURL$1; + h8.fileURLToPath = fileURLToPath$1; + h8.Url; + h8.format; + h8.resolve; + h8.resolveObject; + h8.URL; + CHAR_BACKWARD_SLASH$1 = 92; + CHAR_FORWARD_SLASH$1 = 47; + CHAR_LOWERCASE_A$1 = 97; + CHAR_LOWERCASE_Z$1 = 122; + isWindows$1 = processPlatform$1 === "win32"; + forwardSlashRegEx$1 = /\//g; + percentRegEx$1 = /%/g; + backslashRegEx$1 = /\\/g; + newlineRegEx$1 = /\n/g; + carriageReturnRegEx$1 = /\r/g; + tabRegEx$1 = /\t/g; + processPlatform = typeof Deno !== "undefined" ? Deno.build.os === "windows" ? "win32" : Deno.build.os : void 0; + h8.URL = typeof URL !== "undefined" ? URL : null; + h8.pathToFileURL = pathToFileURL; + h8.fileURLToPath = fileURLToPath; + Url = h8.Url; + format14 = h8.format; + resolve2 = h8.resolve; + resolveObject = h8.resolveObject; + parse9 = h8.parse; + _URL = h8.URL; + CHAR_BACKWARD_SLASH = 92; + CHAR_FORWARD_SLASH = 47; + CHAR_LOWERCASE_A = 97; + CHAR_LOWERCASE_Z = 122; + isWindows = processPlatform === "win32"; + forwardSlashRegEx = /\//g; + percentRegEx = /%/g; + backslashRegEx = /\\/g; + newlineRegEx = /\n/g; + carriageReturnRegEx = /\r/g; + tabRegEx = /\t/g; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/fs.js + function dew$f3() { + if (_dewExec$f3) + return exports$h2; + _dewExec$f3 = true; + Object.defineProperty(exports$h2, "__esModule", { + value: true + }); + exports$h2.constants = void 0; + exports$h2.constants = { + O_RDONLY: 0, + O_WRONLY: 1, + O_RDWR: 2, + S_IFMT: 61440, + S_IFREG: 32768, + S_IFDIR: 16384, + S_IFCHR: 8192, + S_IFBLK: 24576, + S_IFIFO: 4096, + S_IFLNK: 40960, + S_IFSOCK: 49152, + O_CREAT: 64, + O_EXCL: 128, + O_NOCTTY: 256, + O_TRUNC: 512, + O_APPEND: 1024, + O_DIRECTORY: 65536, + O_NOATIME: 262144, + O_NOFOLLOW: 131072, + O_SYNC: 1052672, + O_DIRECT: 16384, + O_NONBLOCK: 2048, + S_IRWXU: 448, + S_IRUSR: 256, + S_IWUSR: 128, + S_IXUSR: 64, + S_IRWXG: 56, + S_IRGRP: 32, + S_IWGRP: 16, + S_IXGRP: 8, + S_IRWXO: 7, + S_IROTH: 4, + S_IWOTH: 2, + S_IXOTH: 1, + F_OK: 0, + R_OK: 4, + W_OK: 2, + X_OK: 1, + UV_FS_SYMLINK_DIR: 1, + UV_FS_SYMLINK_JUNCTION: 2, + UV_FS_COPYFILE_EXCL: 1, + UV_FS_COPYFILE_FICLONE: 2, + UV_FS_COPYFILE_FICLONE_FORCE: 4, + COPYFILE_EXCL: 1, + COPYFILE_FICLONE: 2, + COPYFILE_FICLONE_FORCE: 4 + }; + return exports$h2; + } + function dew$e3() { + if (_dewExec$e3) + return exports$g3; + _dewExec$e3 = true; + if (typeof BigInt === "function") + exports$g3.default = BigInt; + else + exports$g3.default = function BigIntNotSupported() { + throw new Error("BigInt is not supported in this environment."); + }; + return exports$g3; + } + function dew$d3() { + if (_dewExec$d3) + return exports$f3; + _dewExec$d3 = true; + Object.defineProperty(exports$f3, "__esModule", { + value: true + }); + exports$f3.Stats = void 0; + var constants_1 = dew$f3(); + var getBigInt_1 = dew$e3(); + var S_IFMT = constants_1.constants.S_IFMT, S_IFDIR = constants_1.constants.S_IFDIR, S_IFREG = constants_1.constants.S_IFREG, S_IFBLK = constants_1.constants.S_IFBLK, S_IFCHR = constants_1.constants.S_IFCHR, S_IFLNK = constants_1.constants.S_IFLNK, S_IFIFO = constants_1.constants.S_IFIFO, S_IFSOCK = constants_1.constants.S_IFSOCK; + var Stats2 = function() { + function Stats3() { + } + Stats3.build = function(node, bigint) { + if (bigint === void 0) { + bigint = false; + } + var stats = new Stats3(); + var uid = node.uid, gid = node.gid, atime = node.atime, mtime = node.mtime, ctime = node.ctime; + var getStatNumber = !bigint ? function(number3) { + return number3; + } : getBigInt_1.default; + stats.uid = getStatNumber(uid); + stats.gid = getStatNumber(gid); + stats.rdev = getStatNumber(0); + stats.blksize = getStatNumber(4096); + stats.ino = getStatNumber(node.ino); + stats.size = getStatNumber(node.getSize()); + stats.blocks = getStatNumber(1); + stats.atime = atime; + stats.mtime = mtime; + stats.ctime = ctime; + stats.birthtime = ctime; + stats.atimeMs = getStatNumber(atime.getTime()); + stats.mtimeMs = getStatNumber(mtime.getTime()); + var ctimeMs = getStatNumber(ctime.getTime()); + stats.ctimeMs = ctimeMs; + stats.birthtimeMs = ctimeMs; + stats.dev = getStatNumber(0); + stats.mode = getStatNumber(node.mode); + stats.nlink = getStatNumber(node.nlink); + return stats; + }; + Stats3.prototype._checkModeProperty = function(property) { + return (Number(this.mode) & S_IFMT) === property; + }; + Stats3.prototype.isDirectory = function() { + return this._checkModeProperty(S_IFDIR); + }; + Stats3.prototype.isFile = function() { + return this._checkModeProperty(S_IFREG); + }; + Stats3.prototype.isBlockDevice = function() { + return this._checkModeProperty(S_IFBLK); + }; + Stats3.prototype.isCharacterDevice = function() { + return this._checkModeProperty(S_IFCHR); + }; + Stats3.prototype.isSymbolicLink = function() { + return this._checkModeProperty(S_IFLNK); + }; + Stats3.prototype.isFIFO = function() { + return this._checkModeProperty(S_IFIFO); + }; + Stats3.prototype.isSocket = function() { + return this._checkModeProperty(S_IFSOCK); + }; + return Stats3; + }(); + exports$f3.Stats = Stats2; + exports$f3.default = Stats2; + return exports$f3; + } + function dew$c3() { + if (_dewExec$c3) + return exports$e3; + _dewExec$c3 = true; + var __spreadArray = exports$e3 && exports$e3.__spreadArray || function(to, from18, pack) { + if (pack || arguments.length === 2) + for (var i8 = 0, l8 = from18.length, ar; i8 < l8; i8++) { + if (ar || !(i8 in from18)) { + if (!ar) + ar = Array.prototype.slice.call(from18, 0, i8); + ar[i8] = from18[i8]; + } + } + return to.concat(ar || Array.prototype.slice.call(from18)); + }; + Object.defineProperty(exports$e3, "__esModule", { + value: true + }); + exports$e3.bufferFrom = exports$e3.bufferAllocUnsafe = exports$e3.Buffer = void 0; + var buffer_1 = buffer3; + Object.defineProperty(exports$e3, "Buffer", { + enumerable: true, + get: function() { + return buffer_1.Buffer; + } + }); + function bufferV0P12Ponyfill(arg0) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + return new (buffer_1.Buffer.bind.apply(buffer_1.Buffer, __spreadArray([void 0, arg0], args, false)))(); + } + var bufferAllocUnsafe = buffer_1.Buffer.allocUnsafe || bufferV0P12Ponyfill; + exports$e3.bufferAllocUnsafe = bufferAllocUnsafe; + var bufferFrom = buffer_1.Buffer.from || bufferV0P12Ponyfill; + exports$e3.bufferFrom = bufferFrom; + return exports$e3; + } + function dew$b3() { + if (_dewExec$b3) + return exports$d3; + _dewExec$b3 = true; + var __extends = exports$d3 && exports$d3.__extends || function() { + var extendStatics = function(d7, b6) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(d8, b7) { + d8.__proto__ = b7; + } || function(d8, b7) { + for (var p8 in b7) + if (Object.prototype.hasOwnProperty.call(b7, p8)) + d8[p8] = b7[p8]; + }; + return extendStatics(d7, b6); + }; + return function(d7, b6) { + if (typeof b6 !== "function" && b6 !== null) + throw new TypeError("Class extends value " + String(b6) + " is not a constructor or null"); + extendStatics(d7, b6); + function __() { + this.constructor = d7; + } + d7.prototype = b6 === null ? Object.create(b6) : (__.prototype = b6.prototype, new __()); + }; + }(); + Object.defineProperty(exports$d3, "__esModule", { + value: true + }); + exports$d3.E = exports$d3.AssertionError = exports$d3.message = exports$d3.RangeError = exports$d3.TypeError = exports$d3.Error = void 0; + var assert = et2; + var util3 = X; + var kCode = typeof Symbol === "undefined" ? "_kCode" : Symbol("code"); + var messages = {}; + function makeNodeError(Base2) { + return function(_super) { + __extends(NodeError, _super); + function NodeError(key) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var _this = _super.call(this, message2(key, args)) || this; + _this.code = key; + _this[kCode] = key; + _this.name = _super.prototype.name + " [" + _this[kCode] + "]"; + return _this; + } + return NodeError; + }(Base2); + } + var g6 = typeof globalThis !== "undefined" ? globalThis : _global$32; + var AssertionError2 = function(_super) { + __extends(AssertionError3, _super); + function AssertionError3(options) { + var _this = this; + if (typeof options !== "object" || options === null) { + throw new exports$d3.TypeError("ERR_INVALID_ARG_TYPE", "options", "object"); + } + if (options.message) { + _this = _super.call(this, options.message) || this; + } else { + _this = _super.call(this, util3.inspect(options.actual).slice(0, 128) + " " + (options.operator + " " + util3.inspect(options.expected).slice(0, 128))) || this; + } + _this.generatedMessage = !options.message; + _this.name = "AssertionError [ERR_ASSERTION]"; + _this.code = "ERR_ASSERTION"; + _this.actual = options.actual; + _this.expected = options.expected; + _this.operator = options.operator; + exports$d3.Error.captureStackTrace(_this, options.stackStartFunction); + return _this; + } + return AssertionError3; + }(g6.Error); + exports$d3.AssertionError = AssertionError2; + function message2(key, args) { + assert.strictEqual(typeof key, "string"); + var msg = messages[key]; + assert(msg, "An invalid error message key was used: " + key + "."); + var fmt; + if (typeof msg === "function") { + fmt = msg; + } else { + fmt = util3.format; + if (args === void 0 || args.length === 0) + return msg; + args.unshift(msg); + } + return String(fmt.apply(null, args)); + } + exports$d3.message = message2; + function E5(sym, val) { + messages[sym] = typeof val === "function" ? val : String(val); + } + exports$d3.E = E5; + exports$d3.Error = makeNodeError(g6.Error); + exports$d3.TypeError = makeNodeError(g6.TypeError); + exports$d3.RangeError = makeNodeError(g6.RangeError); + E5("ERR_ARG_NOT_ITERABLE", "%s must be iterable"); + E5("ERR_ASSERTION", "%s"); + E5("ERR_BUFFER_OUT_OF_BOUNDS", bufferOutOfBounds); + E5("ERR_CHILD_CLOSED_BEFORE_REPLY", "Child closed before reply received"); + E5("ERR_CONSOLE_WRITABLE_STREAM", "Console expects a writable stream instance for %s"); + E5("ERR_CPU_USAGE", "Unable to obtain cpu usage %s"); + E5("ERR_DNS_SET_SERVERS_FAILED", function(err, servers) { + return 'c-ares failed to set servers: "' + err + '" [' + servers + "]"; + }); + E5("ERR_FALSY_VALUE_REJECTION", "Promise was rejected with falsy value"); + E5("ERR_ENCODING_NOT_SUPPORTED", function(enc) { + return 'The "' + enc + '" encoding is not supported'; + }); + E5("ERR_ENCODING_INVALID_ENCODED_DATA", function(enc) { + return "The encoded data was not valid for encoding " + enc; + }); + E5("ERR_HTTP_HEADERS_SENT", "Cannot render headers after they are sent to the client"); + E5("ERR_HTTP_INVALID_STATUS_CODE", "Invalid status code: %s"); + E5("ERR_HTTP_TRAILER_INVALID", "Trailers are invalid with this transfer encoding"); + E5("ERR_INDEX_OUT_OF_RANGE", "Index out of range"); + E5("ERR_INVALID_ARG_TYPE", invalidArgType); + E5("ERR_INVALID_ARRAY_LENGTH", function(name15, len, actual) { + assert.strictEqual(typeof actual, "number"); + return 'The array "' + name15 + '" (length ' + actual + ") must be of length " + len + "."; + }); + E5("ERR_INVALID_BUFFER_SIZE", "Buffer size must be a multiple of %s"); + E5("ERR_INVALID_CALLBACK", "Callback must be a function"); + E5("ERR_INVALID_CHAR", "Invalid character in %s"); + E5("ERR_INVALID_CURSOR_POS", "Cannot set cursor row without setting its column"); + E5("ERR_INVALID_FD", '"fd" must be a positive integer: %s'); + E5("ERR_INVALID_FILE_URL_HOST", 'File URL host must be "localhost" or empty on %s'); + E5("ERR_INVALID_FILE_URL_PATH", "File URL path %s"); + E5("ERR_INVALID_HANDLE_TYPE", "This handle type cannot be sent"); + E5("ERR_INVALID_IP_ADDRESS", "Invalid IP address: %s"); + E5("ERR_INVALID_OPT_VALUE", function(name15, value) { + return 'The value "' + String(value) + '" is invalid for option "' + name15 + '"'; + }); + E5("ERR_INVALID_OPT_VALUE_ENCODING", function(value) { + return 'The value "' + String(value) + '" is invalid for option "encoding"'; + }); + E5("ERR_INVALID_REPL_EVAL_CONFIG", 'Cannot specify both "breakEvalOnSigint" and "eval" for REPL'); + E5("ERR_INVALID_SYNC_FORK_INPUT", "Asynchronous forks do not support Buffer, Uint8Array or string input: %s"); + E5("ERR_INVALID_THIS", 'Value of "this" must be of type %s'); + E5("ERR_INVALID_TUPLE", "%s must be an iterable %s tuple"); + E5("ERR_INVALID_URL", "Invalid URL: %s"); + E5("ERR_INVALID_URL_SCHEME", function(expected) { + return "The URL must be " + oneOf(expected, "scheme"); + }); + E5("ERR_IPC_CHANNEL_CLOSED", "Channel closed"); + E5("ERR_IPC_DISCONNECTED", "IPC channel is already disconnected"); + E5("ERR_IPC_ONE_PIPE", "Child process can have only one IPC pipe"); + E5("ERR_IPC_SYNC_FORK", "IPC cannot be used with synchronous forks"); + E5("ERR_MISSING_ARGS", missingArgs); + E5("ERR_MULTIPLE_CALLBACK", "Callback called multiple times"); + E5("ERR_NAPI_CONS_FUNCTION", "Constructor must be a function"); + E5("ERR_NAPI_CONS_PROTOTYPE_OBJECT", "Constructor.prototype must be an object"); + E5("ERR_NO_CRYPTO", "Node.js is not compiled with OpenSSL crypto support"); + E5("ERR_NO_LONGER_SUPPORTED", "%s is no longer supported"); + E5("ERR_PARSE_HISTORY_DATA", "Could not parse history data in %s"); + E5("ERR_SOCKET_ALREADY_BOUND", "Socket is already bound"); + E5("ERR_SOCKET_BAD_PORT", "Port should be > 0 and < 65536"); + E5("ERR_SOCKET_BAD_TYPE", "Bad socket type specified. Valid types are: udp4, udp6"); + E5("ERR_SOCKET_CANNOT_SEND", "Unable to send data"); + E5("ERR_SOCKET_CLOSED", "Socket is closed"); + E5("ERR_SOCKET_DGRAM_NOT_RUNNING", "Not running"); + E5("ERR_STDERR_CLOSE", "process.stderr cannot be closed"); + E5("ERR_STDOUT_CLOSE", "process.stdout cannot be closed"); + E5("ERR_STREAM_WRAP", "Stream has StringDecoder set or is in objectMode"); + E5("ERR_TLS_CERT_ALTNAME_INVALID", "Hostname/IP does not match certificate's altnames: %s"); + E5("ERR_TLS_DH_PARAM_SIZE", function(size4) { + return "DH parameter size " + size4 + " is less than 2048"; + }); + E5("ERR_TLS_HANDSHAKE_TIMEOUT", "TLS handshake timeout"); + E5("ERR_TLS_RENEGOTIATION_FAILED", "Failed to renegotiate"); + E5("ERR_TLS_REQUIRED_SERVER_NAME", '"servername" is required parameter for Server.addContext'); + E5("ERR_TLS_SESSION_ATTACK", "TSL session renegotiation attack detected"); + E5("ERR_TRANSFORM_ALREADY_TRANSFORMING", "Calling transform done when still transforming"); + E5("ERR_TRANSFORM_WITH_LENGTH_0", "Calling transform done when writableState.length != 0"); + E5("ERR_UNKNOWN_ENCODING", "Unknown encoding: %s"); + E5("ERR_UNKNOWN_SIGNAL", "Unknown signal: %s"); + E5("ERR_UNKNOWN_STDIN_TYPE", "Unknown stdin file type"); + E5("ERR_UNKNOWN_STREAM_TYPE", "Unknown stream file type"); + E5("ERR_V8BREAKITERATOR", "Full ICU data not installed. See https://github.com/nodejs/node/wiki/Intl"); + function invalidArgType(name15, expected, actual) { + assert(name15, "name is required"); + var determiner; + if (expected.includes("not ")) { + determiner = "must not be"; + expected = expected.split("not ")[1]; + } else { + determiner = "must be"; + } + var msg; + if (Array.isArray(name15)) { + var names = name15.map(function(val) { + return '"' + val + '"'; + }).join(", "); + msg = "The " + names + " arguments " + determiner + " " + oneOf(expected, "type"); + } else if (name15.includes(" argument")) { + msg = "The " + name15 + " " + determiner + " " + oneOf(expected, "type"); + } else { + var type3 = name15.includes(".") ? "property" : "argument"; + msg = 'The "' + name15 + '" ' + type3 + " " + determiner + " " + oneOf(expected, "type"); + } + if (arguments.length >= 3) { + msg += ". Received type " + (actual !== null ? typeof actual : "null"); + } + return msg; + } + function missingArgs() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + assert(args.length > 0, "At least one arg needs to be specified"); + var msg = "The "; + var len = args.length; + args = args.map(function(a8) { + return '"' + a8 + '"'; + }); + switch (len) { + case 1: + msg += args[0] + " argument"; + break; + case 2: + msg += args[0] + " and " + args[1] + " arguments"; + break; + default: + msg += args.slice(0, len - 1).join(", "); + msg += ", and " + args[len - 1] + " arguments"; + break; + } + return msg + " must be specified"; + } + function oneOf(expected, thing) { + assert(expected, "expected is required"); + assert(typeof thing === "string", "thing is required"); + if (Array.isArray(expected)) { + var len = expected.length; + assert(len > 0, "At least one expected value needs to be specified"); + expected = expected.map(function(i8) { + return String(i8); + }); + if (len > 2) { + return "one of " + thing + " " + expected.slice(0, len - 1).join(", ") + ", or " + expected[len - 1]; + } else if (len === 2) { + return "one of " + thing + " " + expected[0] + " or " + expected[1]; + } else { + return "of " + thing + " " + expected[0]; + } + } else { + return "of " + thing + " " + String(expected); + } + } + function bufferOutOfBounds(name15, isWriting) { + if (isWriting) { + return "Attempt to write outside buffer bounds"; + } else { + return '"' + name15 + '" is outside of buffer bounds'; + } + } + return exports$d3; + } + function dew$a3() { + if (_dewExec$a3) + return exports$c3; + _dewExec$a3 = true; + Object.defineProperty(exports$c3, "__esModule", { + value: true + }); + exports$c3.strToEncoding = exports$c3.assertEncoding = exports$c3.ENCODING_UTF8 = void 0; + var buffer_1 = dew$c3(); + var errors = dew$b3(); + exports$c3.ENCODING_UTF8 = "utf8"; + function assertEncoding(encoding) { + if (encoding && !buffer_1.Buffer.isEncoding(encoding)) + throw new errors.TypeError("ERR_INVALID_OPT_VALUE_ENCODING", encoding); + } + exports$c3.assertEncoding = assertEncoding; + function strToEncoding(str, encoding) { + if (!encoding || encoding === exports$c3.ENCODING_UTF8) + return str; + if (encoding === "buffer") + return new buffer_1.Buffer(str); + return new buffer_1.Buffer(str).toString(encoding); + } + exports$c3.strToEncoding = strToEncoding; + return exports$c3; + } + function dew$93() { + if (_dewExec$93) + return exports$b3; + _dewExec$93 = true; + Object.defineProperty(exports$b3, "__esModule", { + value: true + }); + exports$b3.Dirent = void 0; + var constants_1 = dew$f3(); + var encoding_1 = dew$a3(); + var S_IFMT = constants_1.constants.S_IFMT, S_IFDIR = constants_1.constants.S_IFDIR, S_IFREG = constants_1.constants.S_IFREG, S_IFBLK = constants_1.constants.S_IFBLK, S_IFCHR = constants_1.constants.S_IFCHR, S_IFLNK = constants_1.constants.S_IFLNK, S_IFIFO = constants_1.constants.S_IFIFO, S_IFSOCK = constants_1.constants.S_IFSOCK; + var Dirent2 = function() { + function Dirent3() { + this.name = ""; + this.mode = 0; + } + Dirent3.build = function(link10, encoding) { + var dirent = new Dirent3(); + var mode = link10.getNode().mode; + dirent.name = (0, encoding_1.strToEncoding)(link10.getName(), encoding); + dirent.mode = mode; + return dirent; + }; + Dirent3.prototype._checkModeProperty = function(property) { + return (this.mode & S_IFMT) === property; + }; + Dirent3.prototype.isDirectory = function() { + return this._checkModeProperty(S_IFDIR); + }; + Dirent3.prototype.isFile = function() { + return this._checkModeProperty(S_IFREG); + }; + Dirent3.prototype.isBlockDevice = function() { + return this._checkModeProperty(S_IFBLK); + }; + Dirent3.prototype.isCharacterDevice = function() { + return this._checkModeProperty(S_IFCHR); + }; + Dirent3.prototype.isSymbolicLink = function() { + return this._checkModeProperty(S_IFLNK); + }; + Dirent3.prototype.isFIFO = function() { + return this._checkModeProperty(S_IFIFO); + }; + Dirent3.prototype.isSocket = function() { + return this._checkModeProperty(S_IFSOCK); + }; + return Dirent3; + }(); + exports$b3.Dirent = Dirent2; + exports$b3.default = Dirent2; + return exports$b3; + } + function dew$83() { + if (_dewExec$83) + return exports$a3; + _dewExec$83 = true; + var process$1 = process2; + Object.defineProperty(exports$a3, "__esModule", { + value: true + }); + var _setImmediate; + if (typeof process$1.nextTick === "function") + _setImmediate = process$1.nextTick.bind(typeof globalThis !== "undefined" ? globalThis : _global$23); + else + _setImmediate = setTimeout.bind(typeof globalThis !== "undefined" ? globalThis : _global$23); + exports$a3.default = _setImmediate; + return exports$a3; + } + function dew$73() { + if (_dewExec$73) + return exports$93; + _dewExec$73 = true; + var process$1 = process2; + Object.defineProperty(exports$93, "__esModule", { + value: true + }); + exports$93.createProcess = void 0; + var maybeReturnProcess = function() { + if (typeof process$1 !== "undefined") { + return process$1; + } + try { + return process2; + } catch (_a2) { + return void 0; + } + }; + function createProcess() { + var p8 = maybeReturnProcess() || {}; + if (!p8.getuid) + p8.getuid = function() { + return 0; + }; + if (!p8.getgid) + p8.getgid = function() { + return 0; + }; + if (!p8.cwd) + p8.cwd = function() { + return "/"; + }; + if (!p8.nextTick) + p8.nextTick = dew$83().default; + if (!p8.emitWarning) + p8.emitWarning = function(message2, type3) { + console.warn("" + type3 + (type3 ? ": " : "") + message2); + }; + if (!p8.env) + p8.env = {}; + return p8; + } + exports$93.createProcess = createProcess; + exports$93.default = createProcess(); + return exports$93; + } + function dew$63() { + if (_dewExec$63) + return exports$83; + _dewExec$63 = true; + var __extends = exports$83 && exports$83.__extends || function() { + var extendStatics = function(d7, b6) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(d8, b7) { + d8.__proto__ = b7; + } || function(d8, b7) { + for (var p8 in b7) + if (Object.prototype.hasOwnProperty.call(b7, p8)) + d8[p8] = b7[p8]; + }; + return extendStatics(d7, b6); + }; + return function(d7, b6) { + if (typeof b6 !== "function" && b6 !== null) + throw new TypeError("Class extends value " + String(b6) + " is not a constructor or null"); + extendStatics(d7, b6); + function __() { + this.constructor = d7; + } + d7.prototype = b6 === null ? Object.create(b6) : (__.prototype = b6.prototype, new __()); + }; + }(); + Object.defineProperty(exports$83, "__esModule", { + value: true + }); + exports$83.File = exports$83.Link = exports$83.Node = exports$83.SEP = void 0; + var process_1 = dew$73(); + var buffer_1 = dew$c3(); + var constants_1 = dew$f3(); + var events_1 = y; + var Stats_1 = dew$d3(); + var S_IFMT = constants_1.constants.S_IFMT, S_IFDIR = constants_1.constants.S_IFDIR, S_IFREG = constants_1.constants.S_IFREG, S_IFLNK = constants_1.constants.S_IFLNK, O_APPEND = constants_1.constants.O_APPEND; + exports$83.SEP = "/"; + var Node3 = function(_super) { + __extends(Node4, _super); + function Node4(ino, perm) { + if (perm === void 0) { + perm = 438; + } + var _this = _super.call(this) || this; + _this.uid = process_1.default.getuid(); + _this.gid = process_1.default.getgid(); + _this.atime = /* @__PURE__ */ new Date(); + _this.mtime = /* @__PURE__ */ new Date(); + _this.ctime = /* @__PURE__ */ new Date(); + _this.perm = 438; + _this.mode = S_IFREG; + _this.nlink = 1; + _this.perm = perm; + _this.mode |= perm; + _this.ino = ino; + return _this; + } + Node4.prototype.getString = function(encoding) { + if (encoding === void 0) { + encoding = "utf8"; + } + return this.getBuffer().toString(encoding); + }; + Node4.prototype.setString = function(str) { + this.buf = (0, buffer_1.bufferFrom)(str, "utf8"); + this.touch(); + }; + Node4.prototype.getBuffer = function() { + if (!this.buf) + this.setBuffer((0, buffer_1.bufferAllocUnsafe)(0)); + return (0, buffer_1.bufferFrom)(this.buf); + }; + Node4.prototype.setBuffer = function(buf3) { + this.buf = (0, buffer_1.bufferFrom)(buf3); + this.touch(); + }; + Node4.prototype.getSize = function() { + return this.buf ? this.buf.length : 0; + }; + Node4.prototype.setModeProperty = function(property) { + this.mode = this.mode & ~S_IFMT | property; + }; + Node4.prototype.setIsFile = function() { + this.setModeProperty(S_IFREG); + }; + Node4.prototype.setIsDirectory = function() { + this.setModeProperty(S_IFDIR); + }; + Node4.prototype.setIsSymlink = function() { + this.setModeProperty(S_IFLNK); + }; + Node4.prototype.isFile = function() { + return (this.mode & S_IFMT) === S_IFREG; + }; + Node4.prototype.isDirectory = function() { + return (this.mode & S_IFMT) === S_IFDIR; + }; + Node4.prototype.isSymlink = function() { + return (this.mode & S_IFMT) === S_IFLNK; + }; + Node4.prototype.makeSymlink = function(steps) { + this.symlink = steps; + this.setIsSymlink(); + }; + Node4.prototype.write = function(buf3, off, len, pos) { + if (off === void 0) { + off = 0; + } + if (len === void 0) { + len = buf3.length; + } + if (pos === void 0) { + pos = 0; + } + if (!this.buf) + this.buf = (0, buffer_1.bufferAllocUnsafe)(0); + if (pos + len > this.buf.length) { + var newBuf = (0, buffer_1.bufferAllocUnsafe)(pos + len); + this.buf.copy(newBuf, 0, 0, this.buf.length); + this.buf = newBuf; + } + buf3.copy(this.buf, pos, off, off + len); + this.touch(); + return len; + }; + Node4.prototype.read = function(buf3, off, len, pos) { + if (off === void 0) { + off = 0; + } + if (len === void 0) { + len = buf3.byteLength; + } + if (pos === void 0) { + pos = 0; + } + if (!this.buf) + this.buf = (0, buffer_1.bufferAllocUnsafe)(0); + var actualLen = len; + if (actualLen > buf3.byteLength) { + actualLen = buf3.byteLength; + } + if (actualLen + pos > this.buf.length) { + actualLen = this.buf.length - pos; + } + this.buf.copy(buf3, off, pos, pos + actualLen); + return actualLen; + }; + Node4.prototype.truncate = function(len) { + if (len === void 0) { + len = 0; + } + if (!len) + this.buf = (0, buffer_1.bufferAllocUnsafe)(0); + else { + if (!this.buf) + this.buf = (0, buffer_1.bufferAllocUnsafe)(0); + if (len <= this.buf.length) { + this.buf = this.buf.slice(0, len); + } else { + var buf3 = (0, buffer_1.bufferAllocUnsafe)(0); + this.buf.copy(buf3); + buf3.fill(0, len); + } + } + this.touch(); + }; + Node4.prototype.chmod = function(perm) { + this.perm = perm; + this.mode = this.mode & ~511 | perm; + this.touch(); + }; + Node4.prototype.chown = function(uid, gid) { + this.uid = uid; + this.gid = gid; + this.touch(); + }; + Node4.prototype.touch = function() { + this.mtime = /* @__PURE__ */ new Date(); + this.emit("change", this); + }; + Node4.prototype.canRead = function(uid, gid) { + if (uid === void 0) { + uid = process_1.default.getuid(); + } + if (gid === void 0) { + gid = process_1.default.getgid(); + } + if (this.perm & 4) { + return true; + } + if (gid === this.gid) { + if (this.perm & 32) { + return true; + } + } + if (uid === this.uid) { + if (this.perm & 256) { + return true; + } + } + return false; + }; + Node4.prototype.canWrite = function(uid, gid) { + if (uid === void 0) { + uid = process_1.default.getuid(); + } + if (gid === void 0) { + gid = process_1.default.getgid(); + } + if (this.perm & 2) { + return true; + } + if (gid === this.gid) { + if (this.perm & 16) { + return true; + } + } + if (uid === this.uid) { + if (this.perm & 128) { + return true; + } + } + return false; + }; + Node4.prototype.del = function() { + this.emit("delete", this); + }; + Node4.prototype.toJSON = function() { + return { + ino: this.ino, + uid: this.uid, + gid: this.gid, + atime: this.atime.getTime(), + mtime: this.mtime.getTime(), + ctime: this.ctime.getTime(), + perm: this.perm, + mode: this.mode, + nlink: this.nlink, + symlink: this.symlink, + data: this.getString() + }; + }; + return Node4; + }(events_1.EventEmitter); + exports$83.Node = Node3; + var Link = function(_super) { + __extends(Link2, _super); + function Link2(vol2, parent, name15) { + var _this = _super.call(this) || this; + _this.children = {}; + _this.steps = []; + _this.ino = 0; + _this.length = 0; + _this.vol = vol2; + _this.parent = parent; + _this.steps = parent ? parent.steps.concat([name15]) : [name15]; + return _this; + } + Link2.prototype.setNode = function(node) { + this.node = node; + this.ino = node.ino; + }; + Link2.prototype.getNode = function() { + return this.node; + }; + Link2.prototype.createChild = function(name15, node) { + if (node === void 0) { + node = this.vol.createNode(); + } + var link10 = new Link2(this.vol, this, name15); + link10.setNode(node); + if (node.isDirectory()) + ; + this.setChild(name15, link10); + return link10; + }; + Link2.prototype.setChild = function(name15, link10) { + if (link10 === void 0) { + link10 = new Link2(this.vol, this, name15); + } + this.children[name15] = link10; + link10.parent = this; + this.length++; + this.emit("child:add", link10, this); + return link10; + }; + Link2.prototype.deleteChild = function(link10) { + delete this.children[link10.getName()]; + this.length--; + this.emit("child:delete", link10, this); + }; + Link2.prototype.getChild = function(name15) { + if (Object.hasOwnProperty.call(this.children, name15)) { + return this.children[name15]; + } + }; + Link2.prototype.getPath = function() { + return this.steps.join(exports$83.SEP); + }; + Link2.prototype.getName = function() { + return this.steps[this.steps.length - 1]; + }; + Link2.prototype.walk = function(steps, stop, i8) { + if (stop === void 0) { + stop = steps.length; + } + if (i8 === void 0) { + i8 = 0; + } + if (i8 >= steps.length) + return this; + if (i8 >= stop) + return this; + var step2 = steps[i8]; + var link10 = this.getChild(step2); + if (!link10) + return null; + return link10.walk(steps, stop, i8 + 1); + }; + Link2.prototype.toJSON = function() { + return { + steps: this.steps, + ino: this.ino, + children: Object.keys(this.children) + }; + }; + return Link2; + }(events_1.EventEmitter); + exports$83.Link = Link; + var File2 = function() { + function File3(link10, node, flags, fd) { + this.position = 0; + this.link = link10; + this.node = node; + this.flags = flags; + this.fd = fd; + } + File3.prototype.getString = function(encoding) { + return this.node.getString(); + }; + File3.prototype.setString = function(str) { + this.node.setString(str); + }; + File3.prototype.getBuffer = function() { + return this.node.getBuffer(); + }; + File3.prototype.setBuffer = function(buf3) { + this.node.setBuffer(buf3); + }; + File3.prototype.getSize = function() { + return this.node.getSize(); + }; + File3.prototype.truncate = function(len) { + this.node.truncate(len); + }; + File3.prototype.seekTo = function(position) { + this.position = position; + }; + File3.prototype.stats = function() { + return Stats_1.default.build(this.node); + }; + File3.prototype.write = function(buf3, offset2, length3, position) { + if (offset2 === void 0) { + offset2 = 0; + } + if (length3 === void 0) { + length3 = buf3.length; + } + if (typeof position !== "number") + position = this.position; + if (this.flags & O_APPEND) + position = this.getSize(); + var bytes2 = this.node.write(buf3, offset2, length3, position); + this.position = position + bytes2; + return bytes2; + }; + File3.prototype.read = function(buf3, offset2, length3, position) { + if (offset2 === void 0) { + offset2 = 0; + } + if (length3 === void 0) { + length3 = buf3.byteLength; + } + if (typeof position !== "number") + position = this.position; + var bytes2 = this.node.read(buf3, offset2, length3, position); + this.position = position + bytes2; + return bytes2; + }; + File3.prototype.chmod = function(perm) { + this.node.chmod(perm); + }; + File3.prototype.chown = function(uid, gid) { + this.node.chown(uid, gid); + }; + return File3; + }(); + exports$83.File = File2; + return exports$83; + } + function dew$53() { + if (_dewExec$53) + return exports$73; + _dewExec$53 = true; + Object.defineProperty(exports$73, "__esModule", { + value: true + }); + function setTimeoutUnref(callback, time, args) { + var ref = setTimeout.apply(typeof globalThis !== "undefined" ? globalThis : _global$13, arguments); + if (ref && typeof ref === "object" && typeof ref.unref === "function") + ref.unref(); + return ref; + } + exports$73.default = setTimeoutUnref; + return exports$73; + } + function dew$43() { + if (_dewExec$43) + return exports$63; + _dewExec$43 = true; + var __spreadArray = exports$63 && exports$63.__spreadArray || function(to, from18, pack) { + if (pack || arguments.length === 2) + for (var i8 = 0, l8 = from18.length, ar; i8 < l8; i8++) { + if (ar || !(i8 in from18)) { + if (!ar) + ar = Array.prototype.slice.call(from18, 0, i8); + ar[i8] = from18[i8]; + } + } + return to.concat(ar || Array.prototype.slice.call(from18)); + }; + Object.defineProperty(exports$63, "__esModule", { + value: true + }); + exports$63.FileHandle = void 0; + function promisify3(vol2, fn, getResult) { + if (getResult === void 0) { + getResult = function(input) { + return input; + }; + } + return function() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return new Promise(function(resolve7, reject) { + vol2[fn].bind(vol2).apply(void 0, __spreadArray(__spreadArray([], args, false), [function(error7, result) { + if (error7) + return reject(error7); + return resolve7(getResult(result)); + }], false)); + }); + }; + } + var FileHandle = function() { + function FileHandle2(vol2, fd) { + this.vol = vol2; + this.fd = fd; + } + FileHandle2.prototype.appendFile = function(data, options) { + return promisify3(this.vol, "appendFile")(this.fd, data, options); + }; + FileHandle2.prototype.chmod = function(mode) { + return promisify3(this.vol, "fchmod")(this.fd, mode); + }; + FileHandle2.prototype.chown = function(uid, gid) { + return promisify3(this.vol, "fchown")(this.fd, uid, gid); + }; + FileHandle2.prototype.close = function() { + return promisify3(this.vol, "close")(this.fd); + }; + FileHandle2.prototype.datasync = function() { + return promisify3(this.vol, "fdatasync")(this.fd); + }; + FileHandle2.prototype.read = function(buffer4, offset2, length3, position) { + return promisify3(this.vol, "read", function(bytesRead) { + return { + bytesRead, + buffer: buffer4 + }; + })(this.fd, buffer4, offset2, length3, position); + }; + FileHandle2.prototype.readFile = function(options) { + return promisify3(this.vol, "readFile")(this.fd, options); + }; + FileHandle2.prototype.stat = function(options) { + return promisify3(this.vol, "fstat")(this.fd, options); + }; + FileHandle2.prototype.sync = function() { + return promisify3(this.vol, "fsync")(this.fd); + }; + FileHandle2.prototype.truncate = function(len) { + return promisify3(this.vol, "ftruncate")(this.fd, len); + }; + FileHandle2.prototype.utimes = function(atime, mtime) { + return promisify3(this.vol, "futimes")(this.fd, atime, mtime); + }; + FileHandle2.prototype.write = function(buffer4, offset2, length3, position) { + return promisify3(this.vol, "write", function(bytesWritten) { + return { + bytesWritten, + buffer: buffer4 + }; + })(this.fd, buffer4, offset2, length3, position); + }; + FileHandle2.prototype.writeFile = function(data, options) { + return promisify3(this.vol, "writeFile")(this.fd, data, options); + }; + return FileHandle2; + }(); + exports$63.FileHandle = FileHandle; + function createPromisesApi(vol2) { + if (typeof Promise === "undefined") + return null; + return { + FileHandle, + access: function(path2, mode) { + return promisify3(vol2, "access")(path2, mode); + }, + appendFile: function(path2, data, options) { + return promisify3(vol2, "appendFile")(path2 instanceof FileHandle ? path2.fd : path2, data, options); + }, + chmod: function(path2, mode) { + return promisify3(vol2, "chmod")(path2, mode); + }, + chown: function(path2, uid, gid) { + return promisify3(vol2, "chown")(path2, uid, gid); + }, + copyFile: function(src3, dest, flags) { + return promisify3(vol2, "copyFile")(src3, dest, flags); + }, + lchmod: function(path2, mode) { + return promisify3(vol2, "lchmod")(path2, mode); + }, + lchown: function(path2, uid, gid) { + return promisify3(vol2, "lchown")(path2, uid, gid); + }, + link: function(existingPath, newPath) { + return promisify3(vol2, "link")(existingPath, newPath); + }, + lstat: function(path2, options) { + return promisify3(vol2, "lstat")(path2, options); + }, + mkdir: function(path2, options) { + return promisify3(vol2, "mkdir")(path2, options); + }, + mkdtemp: function(prefix, options) { + return promisify3(vol2, "mkdtemp")(prefix, options); + }, + open: function(path2, flags, mode) { + return promisify3(vol2, "open", function(fd) { + return new FileHandle(vol2, fd); + })(path2, flags, mode); + }, + readdir: function(path2, options) { + return promisify3(vol2, "readdir")(path2, options); + }, + readFile: function(id, options) { + return promisify3(vol2, "readFile")(id instanceof FileHandle ? id.fd : id, options); + }, + readlink: function(path2, options) { + return promisify3(vol2, "readlink")(path2, options); + }, + realpath: function(path2, options) { + return promisify3(vol2, "realpath")(path2, options); + }, + rename: function(oldPath, newPath) { + return promisify3(vol2, "rename")(oldPath, newPath); + }, + rmdir: function(path2) { + return promisify3(vol2, "rmdir")(path2); + }, + stat: function(path2, options) { + return promisify3(vol2, "stat")(path2, options); + }, + symlink: function(target, path2, type3) { + return promisify3(vol2, "symlink")(target, path2, type3); + }, + truncate: function(path2, len) { + return promisify3(vol2, "truncate")(path2, len); + }, + unlink: function(path2) { + return promisify3(vol2, "unlink")(path2); + }, + utimes: function(path2, atime, mtime) { + return promisify3(vol2, "utimes")(path2, atime, mtime); + }, + writeFile: function(id, data, options) { + return promisify3(vol2, "writeFile")(id instanceof FileHandle ? id.fd : id, data, options); + } + }; + } + exports$63.default = createPromisesApi; + return exports$63; + } + function dew$33() { + if (_dewExec$33) + return exports$53; + _dewExec$33 = true; + var process$1 = process2; + Object.defineProperty(exports$53, "__esModule", { + value: true + }); + exports$53.unixify = unixify; + exports$53.correctPath = correctPath; + var isWin = process$1.platform === "win32"; + function removeTrailingSeparator(str) { + var i8 = str.length - 1; + if (i8 < 2) { + return str; + } + while (isSeparator(str, i8)) { + i8--; + } + return str.substr(0, i8 + 1); + } + function isSeparator(str, i8) { + var _char = str[i8]; + return i8 > 0 && (_char === "/" || isWin && _char === "\\"); + } + function normalizePath(str, stripTrailing) { + if (typeof str !== "string") { + throw new TypeError("expected a string"); + } + str = str.replace(/[\\\/]+/g, "/"); + if (stripTrailing !== false) { + str = removeTrailingSeparator(str); + } + return str; + } + function unixify(filepath) { + var stripTrailing = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true; + if (isWin) { + filepath = normalizePath(filepath, stripTrailing); + return filepath.replace(/^([a-zA-Z]+:|\.\/)/, ""); + } + return filepath; + } + function correctPath(filepath) { + return unixify(filepath.replace(/^\\\\\?\\.:\\/, "\\")); + } + return exports$53; + } + function dew$211() { + if (_dewExec$211) + return exports$43; + _dewExec$211 = true; + var __extends = exports$43 && exports$43.__extends || function() { + var extendStatics = function(d7, b6) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function(d8, b7) { + d8.__proto__ = b7; + } || function(d8, b7) { + for (var p8 in b7) + if (Object.prototype.hasOwnProperty.call(b7, p8)) + d8[p8] = b7[p8]; + }; + return extendStatics(d7, b6); + }; + return function(d7, b6) { + if (typeof b6 !== "function" && b6 !== null) + throw new TypeError("Class extends value " + String(b6) + " is not a constructor or null"); + extendStatics(d7, b6); + function __() { + this.constructor = d7; + } + d7.prototype = b6 === null ? Object.create(b6) : (__.prototype = b6.prototype, new __()); + }; + }(); + var __spreadArray = exports$43 && exports$43.__spreadArray || function(to, from18, pack) { + if (pack || arguments.length === 2) + for (var i8 = 0, l8 = from18.length, ar; i8 < l8; i8++) { + if (ar || !(i8 in from18)) { + if (!ar) + ar = Array.prototype.slice.call(from18, 0, i8); + ar[i8] = from18[i8]; + } + } + return to.concat(ar || Array.prototype.slice.call(from18)); + }; + Object.defineProperty(exports$43, "__esModule", { + value: true + }); + exports$43.FSWatcher = exports$43.StatWatcher = exports$43.Volume = exports$43.toUnixTimestamp = exports$43.bufferToEncoding = exports$43.dataToBuffer = exports$43.dataToStr = exports$43.pathToSteps = exports$43.filenameToSteps = exports$43.pathToFilename = exports$43.flagsToNumber = exports$43.FLAGS = void 0; + var pathModule = exports7; + var node_1 = dew$63(); + var Stats_1 = dew$d3(); + var Dirent_1 = dew$93(); + var buffer_1 = dew$c3(); + var setImmediate_1 = dew$83(); + var process_1 = dew$73(); + var setTimeoutUnref_1 = dew$53(); + var stream_1 = exports8; + var constants_1 = dew$f3(); + var events_1 = y; + var encoding_1 = dew$a3(); + var errors = dew$b3(); + var util3 = X; + var promises_1 = dew$43(); + var resolveCrossPlatform = pathModule.resolve; + var O_RDONLY = constants_1.constants.O_RDONLY, O_WRONLY = constants_1.constants.O_WRONLY, O_RDWR = constants_1.constants.O_RDWR, O_CREAT = constants_1.constants.O_CREAT, O_EXCL = constants_1.constants.O_EXCL, O_TRUNC = constants_1.constants.O_TRUNC, O_APPEND = constants_1.constants.O_APPEND, O_SYNC = constants_1.constants.O_SYNC, O_DIRECTORY = constants_1.constants.O_DIRECTORY, F_OK2 = constants_1.constants.F_OK, COPYFILE_EXCL = constants_1.constants.COPYFILE_EXCL, COPYFILE_FICLONE_FORCE = constants_1.constants.COPYFILE_FICLONE_FORCE; + var _a2 = pathModule.posix ? pathModule.posix : pathModule, sep2 = _a2.sep, relative2 = _a2.relative, join3 = _a2.join, dirname2 = _a2.dirname; + var isWin = process_1.default.platform === "win32"; + var kMinPoolSpace = 128; + var ERRSTR = { + PATH_STR: "path must be a string or Buffer", + // FD: 'file descriptor must be a unsigned 32-bit integer', + FD: "fd must be a file descriptor", + MODE_INT: "mode must be an int", + CB: "callback must be a function", + UID: "uid must be an unsigned int", + GID: "gid must be an unsigned int", + LEN: "len must be an integer", + ATIME: "atime must be an integer", + MTIME: "mtime must be an integer", + PREFIX: "filename prefix is required", + BUFFER: "buffer must be an instance of Buffer or StaticBuffer", + OFFSET: "offset must be an integer", + LENGTH: "length must be an integer", + POSITION: "position must be an integer" + }; + var ERRSTR_OPTS = function(tipeof) { + return "Expected options to be either an object or a string, but got " + tipeof + " instead"; + }; + var ENOENT = "ENOENT"; + var EBADF = "EBADF"; + var EINVAL = "EINVAL"; + var EPERM = "EPERM"; + var EPROTO = "EPROTO"; + var EEXIST = "EEXIST"; + var ENOTDIR = "ENOTDIR"; + var EMFILE = "EMFILE"; + var EACCES = "EACCES"; + var EISDIR = "EISDIR"; + var ENOTEMPTY = "ENOTEMPTY"; + var ENOSYS = "ENOSYS"; + function formatError(errorCode, func, path2, path22) { + if (func === void 0) { + func = ""; + } + if (path2 === void 0) { + path2 = ""; + } + if (path22 === void 0) { + path22 = ""; + } + var pathFormatted = ""; + if (path2) + pathFormatted = " '" + path2 + "'"; + if (path22) + pathFormatted += " -> '" + path22 + "'"; + switch (errorCode) { + case ENOENT: + return "ENOENT: no such file or directory, " + func + pathFormatted; + case EBADF: + return "EBADF: bad file descriptor, " + func + pathFormatted; + case EINVAL: + return "EINVAL: invalid argument, " + func + pathFormatted; + case EPERM: + return "EPERM: operation not permitted, " + func + pathFormatted; + case EPROTO: + return "EPROTO: protocol error, " + func + pathFormatted; + case EEXIST: + return "EEXIST: file already exists, " + func + pathFormatted; + case ENOTDIR: + return "ENOTDIR: not a directory, " + func + pathFormatted; + case EISDIR: + return "EISDIR: illegal operation on a directory, " + func + pathFormatted; + case EACCES: + return "EACCES: permission denied, " + func + pathFormatted; + case ENOTEMPTY: + return "ENOTEMPTY: directory not empty, " + func + pathFormatted; + case EMFILE: + return "EMFILE: too many open files, " + func + pathFormatted; + case ENOSYS: + return "ENOSYS: function not implemented, " + func + pathFormatted; + default: + return errorCode + ": error occurred, " + func + pathFormatted; + } + } + function createError(errorCode, func, path2, path22, Constructor) { + if (func === void 0) { + func = ""; + } + if (path2 === void 0) { + path2 = ""; + } + if (path22 === void 0) { + path22 = ""; + } + if (Constructor === void 0) { + Constructor = Error; + } + var error7 = new Constructor(formatError(errorCode, func, path2, path22)); + error7.code = errorCode; + return error7; + } + var FLAGS; + (function(FLAGS2) { + FLAGS2[FLAGS2["r"] = O_RDONLY] = "r"; + FLAGS2[FLAGS2["r+"] = O_RDWR] = "r+"; + FLAGS2[FLAGS2["rs"] = O_RDONLY | O_SYNC] = "rs"; + FLAGS2[FLAGS2["sr"] = FLAGS2.rs] = "sr"; + FLAGS2[FLAGS2["rs+"] = O_RDWR | O_SYNC] = "rs+"; + FLAGS2[FLAGS2["sr+"] = FLAGS2["rs+"]] = "sr+"; + FLAGS2[FLAGS2["w"] = O_WRONLY | O_CREAT | O_TRUNC] = "w"; + FLAGS2[FLAGS2["wx"] = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL] = "wx"; + FLAGS2[FLAGS2["xw"] = FLAGS2.wx] = "xw"; + FLAGS2[FLAGS2["w+"] = O_RDWR | O_CREAT | O_TRUNC] = "w+"; + FLAGS2[FLAGS2["wx+"] = O_RDWR | O_CREAT | O_TRUNC | O_EXCL] = "wx+"; + FLAGS2[FLAGS2["xw+"] = FLAGS2["wx+"]] = "xw+"; + FLAGS2[FLAGS2["a"] = O_WRONLY | O_APPEND | O_CREAT] = "a"; + FLAGS2[FLAGS2["ax"] = O_WRONLY | O_APPEND | O_CREAT | O_EXCL] = "ax"; + FLAGS2[FLAGS2["xa"] = FLAGS2.ax] = "xa"; + FLAGS2[FLAGS2["a+"] = O_RDWR | O_APPEND | O_CREAT] = "a+"; + FLAGS2[FLAGS2["ax+"] = O_RDWR | O_APPEND | O_CREAT | O_EXCL] = "ax+"; + FLAGS2[FLAGS2["xa+"] = FLAGS2["ax+"]] = "xa+"; + })(FLAGS = exports$43.FLAGS || (exports$43.FLAGS = {})); + function flagsToNumber(flags) { + if (typeof flags === "number") + return flags; + if (typeof flags === "string") { + var flagsNum = FLAGS[flags]; + if (typeof flagsNum !== "undefined") + return flagsNum; + } + throw new errors.TypeError("ERR_INVALID_OPT_VALUE", "flags", flags); + } + exports$43.flagsToNumber = flagsToNumber; + function getOptions(defaults6, options) { + var opts; + if (!options) + return defaults6; + else { + var tipeof = typeof options; + switch (tipeof) { + case "string": + opts = Object.assign({}, defaults6, { + encoding: options + }); + break; + case "object": + opts = Object.assign({}, defaults6, options); + break; + default: + throw TypeError(ERRSTR_OPTS(tipeof)); + } + } + if (opts.encoding !== "buffer") + (0, encoding_1.assertEncoding)(opts.encoding); + return opts; + } + function optsGenerator(defaults6) { + return function(options) { + return getOptions(defaults6, options); + }; + } + function validateCallback(callback) { + if (typeof callback !== "function") + throw TypeError(ERRSTR.CB); + return callback; + } + function optsAndCbGenerator(getOpts) { + return function(options, callback) { + return typeof options === "function" ? [getOpts(), options] : [getOpts(options), validateCallback(callback)]; + }; + } + var optsDefaults = { + encoding: "utf8" + }; + var getDefaultOpts = optsGenerator(optsDefaults); + var getDefaultOptsAndCb = optsAndCbGenerator(getDefaultOpts); + var readFileOptsDefaults = { + flag: "r" + }; + var getReadFileOptions = optsGenerator(readFileOptsDefaults); + var writeFileDefaults = { + encoding: "utf8", + mode: 438, + flag: FLAGS[FLAGS.w] + }; + var getWriteFileOptions = optsGenerator(writeFileDefaults); + var appendFileDefaults = { + encoding: "utf8", + mode: 438, + flag: FLAGS[FLAGS.a] + }; + var getAppendFileOpts = optsGenerator(appendFileDefaults); + var getAppendFileOptsAndCb = optsAndCbGenerator(getAppendFileOpts); + var realpathDefaults = optsDefaults; + var getRealpathOptions = optsGenerator(realpathDefaults); + var getRealpathOptsAndCb = optsAndCbGenerator(getRealpathOptions); + var mkdirDefaults = { + mode: 511, + recursive: false + }; + var getMkdirOptions = function(options) { + if (typeof options === "number") + return Object.assign({}, mkdirDefaults, { + mode: options + }); + return Object.assign({}, mkdirDefaults, options); + }; + var rmdirDefaults = { + recursive: false + }; + var getRmdirOptions = function(options) { + return Object.assign({}, rmdirDefaults, options); + }; + var readdirDefaults = { + encoding: "utf8", + withFileTypes: false + }; + var getReaddirOptions = optsGenerator(readdirDefaults); + var getReaddirOptsAndCb = optsAndCbGenerator(getReaddirOptions); + var statDefaults = { + bigint: false + }; + var getStatOptions = function(options) { + if (options === void 0) { + options = {}; + } + return Object.assign({}, statDefaults, options); + }; + var getStatOptsAndCb = function(options, callback) { + return typeof options === "function" ? [getStatOptions(), options] : [getStatOptions(options), validateCallback(callback)]; + }; + function getPathFromURLPosix2(url) { + if (url.hostname !== "") { + throw new errors.TypeError("ERR_INVALID_FILE_URL_HOST", process_1.default.platform); + } + var pathname = url.pathname; + for (var n9 = 0; n9 < pathname.length; n9++) { + if (pathname[n9] === "%") { + var third = pathname.codePointAt(n9 + 2) | 32; + if (pathname[n9 + 1] === "2" && third === 102) { + throw new errors.TypeError("ERR_INVALID_FILE_URL_PATH", "must not include encoded / characters"); + } + } + } + return decodeURIComponent(pathname); + } + function pathToFilename(path2) { + if (typeof path2 !== "string" && !buffer_1.Buffer.isBuffer(path2)) { + try { + if (!(path2 instanceof h8.URL)) + throw new TypeError(ERRSTR.PATH_STR); + } catch (err) { + throw new TypeError(ERRSTR.PATH_STR); + } + path2 = getPathFromURLPosix2(path2); + } + var pathString = String(path2); + nullCheck(pathString); + return pathString; + } + exports$43.pathToFilename = pathToFilename; + var resolve7 = function(filename, base3) { + if (base3 === void 0) { + base3 = process_1.default.cwd(); + } + return resolveCrossPlatform(base3, filename); + }; + if (isWin) { + var _resolve_1 = resolve7; + var unixify_1 = dew$33().unixify; + resolve7 = function(filename, base3) { + return unixify_1(_resolve_1(filename, base3)); + }; + } + function filenameToSteps(filename, base3) { + var fullPath = resolve7(filename, base3); + var fullPathSansSlash = fullPath.substr(1); + if (!fullPathSansSlash) + return []; + return fullPathSansSlash.split(sep2); + } + exports$43.filenameToSteps = filenameToSteps; + function pathToSteps(path2) { + return filenameToSteps(pathToFilename(path2)); + } + exports$43.pathToSteps = pathToSteps; + function dataToStr(data, encoding) { + if (encoding === void 0) { + encoding = encoding_1.ENCODING_UTF8; + } + if (buffer_1.Buffer.isBuffer(data)) + return data.toString(encoding); + else if (data instanceof Uint8Array) + return (0, buffer_1.bufferFrom)(data).toString(encoding); + else + return String(data); + } + exports$43.dataToStr = dataToStr; + function dataToBuffer(data, encoding) { + if (encoding === void 0) { + encoding = encoding_1.ENCODING_UTF8; + } + if (buffer_1.Buffer.isBuffer(data)) + return data; + else if (data instanceof Uint8Array) + return (0, buffer_1.bufferFrom)(data); + else + return (0, buffer_1.bufferFrom)(String(data), encoding); + } + exports$43.dataToBuffer = dataToBuffer; + function bufferToEncoding(buffer4, encoding) { + if (!encoding || encoding === "buffer") + return buffer4; + else + return buffer4.toString(encoding); + } + exports$43.bufferToEncoding = bufferToEncoding; + function nullCheck(path2, callback) { + if (("" + path2).indexOf("\0") !== -1) { + var er = new Error("Path must be a string without null bytes"); + er.code = ENOENT; + if (typeof callback !== "function") + throw er; + process_1.default.nextTick(callback, er); + return false; + } + return true; + } + function _modeToNumber(mode, def) { + if (typeof mode === "number") + return mode; + if (typeof mode === "string") + return parseInt(mode, 8); + if (def) + return modeToNumber(def); + return void 0; + } + function modeToNumber(mode, def) { + var result = _modeToNumber(mode, def); + if (typeof result !== "number" || isNaN(result)) + throw new TypeError(ERRSTR.MODE_INT); + return result; + } + function isFd(path2) { + return path2 >>> 0 === path2; + } + function validateFd(fd) { + if (!isFd(fd)) + throw TypeError(ERRSTR.FD); + } + function toUnixTimestamp(time) { + if (typeof time === "string" && +time == time) { + return +time; + } + if (time instanceof Date) { + return time.getTime() / 1e3; + } + if (isFinite(time)) { + if (time < 0) { + return Date.now() / 1e3; + } + return time; + } + throw new Error("Cannot parse time: " + time); + } + exports$43.toUnixTimestamp = toUnixTimestamp; + function validateUid(uid) { + if (typeof uid !== "number") + throw TypeError(ERRSTR.UID); + } + function validateGid(gid) { + if (typeof gid !== "number") + throw TypeError(ERRSTR.GID); + } + function flattenJSON(nestedJSON) { + var flatJSON = {}; + function flatten(pathPrefix, node) { + for (var path2 in node) { + var contentOrNode = node[path2]; + var joinedPath = join3(pathPrefix, path2); + if (typeof contentOrNode === "string") { + flatJSON[joinedPath] = contentOrNode; + } else if (typeof contentOrNode === "object" && contentOrNode !== null && Object.keys(contentOrNode).length > 0) { + flatten(joinedPath, contentOrNode); + } else { + flatJSON[joinedPath] = null; + } + } + } + flatten("", nestedJSON); + return flatJSON; + } + var Volume = function() { + function Volume2(props) { + if (props === void 0) { + props = {}; + } + this.ino = 0; + this.inodes = {}; + this.releasedInos = []; + this.fds = {}; + this.releasedFds = []; + this.maxFiles = 1e4; + this.openFiles = 0; + this.promisesApi = (0, promises_1.default)(this); + this.statWatchers = {}; + this.props = Object.assign({ + Node: node_1.Node, + Link: node_1.Link, + File: node_1.File + }, props); + var root3 = this.createLink(); + root3.setNode(this.createNode(true)); + var self2 = this; + this.StatWatcher = function(_super) { + __extends(StatWatcher2, _super); + function StatWatcher2() { + return _super.call(this, self2) || this; + } + return StatWatcher2; + }(StatWatcher); + var _ReadStream = FsReadStream; + this.ReadStream = function(_super) { + __extends(class_1, _super); + function class_1() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return _super.apply(this, __spreadArray([self2], args, false)) || this; + } + return class_1; + }(_ReadStream); + var _WriteStream = FsWriteStream; + this.WriteStream = function(_super) { + __extends(class_2, _super); + function class_2() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return _super.apply(this, __spreadArray([self2], args, false)) || this; + } + return class_2; + }(_WriteStream); + this.FSWatcher = function(_super) { + __extends(FSWatcher2, _super); + function FSWatcher2() { + return _super.call(this, self2) || this; + } + return FSWatcher2; + }(FSWatcher); + this.root = root3; + } + Volume2.fromJSON = function(json, cwd) { + var vol2 = new Volume2(); + vol2.fromJSON(json, cwd); + return vol2; + }; + Volume2.fromNestedJSON = function(json, cwd) { + var vol2 = new Volume2(); + vol2.fromNestedJSON(json, cwd); + return vol2; + }; + Object.defineProperty(Volume2.prototype, "promises", { + get: function() { + if (this.promisesApi === null) + throw new Error("Promise is not supported in this environment."); + return this.promisesApi; + }, + enumerable: false, + configurable: true + }); + Volume2.prototype.createLink = function(parent, name15, isDirectory, perm) { + if (isDirectory === void 0) { + isDirectory = false; + } + if (!parent) { + return new this.props.Link(this, null, ""); + } + if (!name15) { + throw new Error("createLink: name cannot be empty"); + } + return parent.createChild(name15, this.createNode(isDirectory, perm)); + }; + Volume2.prototype.deleteLink = function(link10) { + var parent = link10.parent; + if (parent) { + parent.deleteChild(link10); + return true; + } + return false; + }; + Volume2.prototype.newInoNumber = function() { + var releasedFd = this.releasedInos.pop(); + if (releasedFd) + return releasedFd; + else { + this.ino = (this.ino + 1) % 4294967295; + return this.ino; + } + }; + Volume2.prototype.newFdNumber = function() { + var releasedFd = this.releasedFds.pop(); + return typeof releasedFd === "number" ? releasedFd : Volume2.fd--; + }; + Volume2.prototype.createNode = function(isDirectory, perm) { + if (isDirectory === void 0) { + isDirectory = false; + } + var node = new this.props.Node(this.newInoNumber(), perm); + if (isDirectory) + node.setIsDirectory(); + this.inodes[node.ino] = node; + return node; + }; + Volume2.prototype.getNode = function(ino) { + return this.inodes[ino]; + }; + Volume2.prototype.deleteNode = function(node) { + node.del(); + delete this.inodes[node.ino]; + this.releasedInos.push(node.ino); + }; + Volume2.prototype.genRndStr = function() { + var str = (Math.random() + 1).toString(36).substr(2, 6); + if (str.length === 6) + return str; + else + return this.genRndStr(); + }; + Volume2.prototype.getLink = function(steps) { + return this.root.walk(steps); + }; + Volume2.prototype.getLinkOrThrow = function(filename, funcName) { + var steps = filenameToSteps(filename); + var link10 = this.getLink(steps); + if (!link10) + throw createError(ENOENT, funcName, filename); + return link10; + }; + Volume2.prototype.getResolvedLink = function(filenameOrSteps) { + var steps = typeof filenameOrSteps === "string" ? filenameToSteps(filenameOrSteps) : filenameOrSteps; + var link10 = this.root; + var i8 = 0; + while (i8 < steps.length) { + var step2 = steps[i8]; + link10 = link10.getChild(step2); + if (!link10) + return null; + var node = link10.getNode(); + if (node.isSymlink()) { + steps = node.symlink.concat(steps.slice(i8 + 1)); + link10 = this.root; + i8 = 0; + continue; + } + i8++; + } + return link10; + }; + Volume2.prototype.getResolvedLinkOrThrow = function(filename, funcName) { + var link10 = this.getResolvedLink(filename); + if (!link10) + throw createError(ENOENT, funcName, filename); + return link10; + }; + Volume2.prototype.resolveSymlinks = function(link10) { + return this.getResolvedLink(link10.steps.slice(1)); + }; + Volume2.prototype.getLinkAsDirOrThrow = function(filename, funcName) { + var link10 = this.getLinkOrThrow(filename, funcName); + if (!link10.getNode().isDirectory()) + throw createError(ENOTDIR, funcName, filename); + return link10; + }; + Volume2.prototype.getLinkParent = function(steps) { + return this.root.walk(steps, steps.length - 1); + }; + Volume2.prototype.getLinkParentAsDirOrThrow = function(filenameOrSteps, funcName) { + var steps = filenameOrSteps instanceof Array ? filenameOrSteps : filenameToSteps(filenameOrSteps); + var link10 = this.getLinkParent(steps); + if (!link10) + throw createError(ENOENT, funcName, sep2 + steps.join(sep2)); + if (!link10.getNode().isDirectory()) + throw createError(ENOTDIR, funcName, sep2 + steps.join(sep2)); + return link10; + }; + Volume2.prototype.getFileByFd = function(fd) { + return this.fds[String(fd)]; + }; + Volume2.prototype.getFileByFdOrThrow = function(fd, funcName) { + if (!isFd(fd)) + throw TypeError(ERRSTR.FD); + var file = this.getFileByFd(fd); + if (!file) + throw createError(EBADF, funcName); + return file; + }; + Volume2.prototype.getNodeByIdOrCreate = function(id, flags, perm) { + if (typeof id === "number") { + var file = this.getFileByFd(id); + if (!file) + throw Error("File nto found"); + return file.node; + } else { + var steps = pathToSteps(id); + var link10 = this.getLink(steps); + if (link10) + return link10.getNode(); + if (flags & O_CREAT) { + var dirLink = this.getLinkParent(steps); + if (dirLink) { + var name_1 = steps[steps.length - 1]; + link10 = this.createLink(dirLink, name_1, false, perm); + return link10.getNode(); + } + } + throw createError(ENOENT, "getNodeByIdOrCreate", pathToFilename(id)); + } + }; + Volume2.prototype.wrapAsync = function(method, args, callback) { + var _this = this; + validateCallback(callback); + (0, setImmediate_1.default)(function() { + var result; + try { + result = method.apply(_this, args); + } catch (err) { + callback(err); + return; + } + callback(null, result); + }); + }; + Volume2.prototype._toJSON = function(link10, json, path2) { + var _a3; + if (link10 === void 0) { + link10 = this.root; + } + if (json === void 0) { + json = {}; + } + var isEmpty3 = true; + var children = link10.children; + if (link10.getNode().isFile()) { + children = (_a3 = {}, _a3[link10.getName()] = link10.parent.getChild(link10.getName()), _a3); + link10 = link10.parent; + } + for (var name_2 in children) { + isEmpty3 = false; + var child = link10.getChild(name_2); + if (!child) { + throw new Error("_toJSON: unexpected undefined"); + } + var node = child.getNode(); + if (node.isFile()) { + var filename = child.getPath(); + if (path2) + filename = relative2(path2, filename); + json[filename] = node.getString(); + } else if (node.isDirectory()) { + this._toJSON(child, json, path2); + } + } + var dirPath = link10.getPath(); + if (path2) + dirPath = relative2(path2, dirPath); + if (dirPath && isEmpty3) { + json[dirPath] = null; + } + return json; + }; + Volume2.prototype.toJSON = function(paths, json, isRelative) { + if (json === void 0) { + json = {}; + } + if (isRelative === void 0) { + isRelative = false; + } + var links4 = []; + if (paths) { + if (!(paths instanceof Array)) + paths = [paths]; + for (var _i = 0, paths_1 = paths; _i < paths_1.length; _i++) { + var path2 = paths_1[_i]; + var filename = pathToFilename(path2); + var link10 = this.getResolvedLink(filename); + if (!link10) + continue; + links4.push(link10); + } + } else { + links4.push(this.root); + } + if (!links4.length) + return json; + for (var _a3 = 0, links_1 = links4; _a3 < links_1.length; _a3++) { + var link10 = links_1[_a3]; + this._toJSON(link10, json, isRelative ? link10.getPath() : ""); + } + return json; + }; + Volume2.prototype.fromJSON = function(json, cwd) { + if (cwd === void 0) { + cwd = process_1.default.cwd(); + } + for (var filename in json) { + var data = json[filename]; + filename = resolve7(filename, cwd); + if (typeof data === "string") { + var dir = dirname2(filename); + this.mkdirpBase( + dir, + 511 + /* DIR */ + ); + this.writeFileSync(filename, data); + } else { + this.mkdirpBase( + filename, + 511 + /* DIR */ + ); + } + } + }; + Volume2.prototype.fromNestedJSON = function(json, cwd) { + this.fromJSON(flattenJSON(json), cwd); + }; + Volume2.prototype.reset = function() { + this.ino = 0; + this.inodes = {}; + this.releasedInos = []; + this.fds = {}; + this.releasedFds = []; + this.openFiles = 0; + this.root = this.createLink(); + this.root.setNode(this.createNode(true)); + }; + Volume2.prototype.mountSync = function(mountpoint, json) { + this.fromJSON(json, mountpoint); + }; + Volume2.prototype.openLink = function(link10, flagsNum, resolveSymlinks) { + if (resolveSymlinks === void 0) { + resolveSymlinks = true; + } + if (this.openFiles >= this.maxFiles) { + throw createError(EMFILE, "open", link10.getPath()); + } + var realLink = link10; + if (resolveSymlinks) + realLink = this.resolveSymlinks(link10); + if (!realLink) + throw createError(ENOENT, "open", link10.getPath()); + var node = realLink.getNode(); + if (node.isDirectory()) { + if ((flagsNum & (O_RDONLY | O_RDWR | O_WRONLY)) !== O_RDONLY) + throw createError(EISDIR, "open", link10.getPath()); + } else { + if (flagsNum & O_DIRECTORY) + throw createError(ENOTDIR, "open", link10.getPath()); + } + if (!(flagsNum & O_WRONLY)) { + if (!node.canRead()) { + throw createError(EACCES, "open", link10.getPath()); + } + } + var file = new this.props.File(link10, node, flagsNum, this.newFdNumber()); + this.fds[file.fd] = file; + this.openFiles++; + if (flagsNum & O_TRUNC) + file.truncate(); + return file; + }; + Volume2.prototype.openFile = function(filename, flagsNum, modeNum, resolveSymlinks) { + if (resolveSymlinks === void 0) { + resolveSymlinks = true; + } + var steps = filenameToSteps(filename); + var link10 = resolveSymlinks ? this.getResolvedLink(steps) : this.getLink(steps); + if (!link10 && flagsNum & O_CREAT) { + var dirLink = this.getResolvedLink(steps.slice(0, steps.length - 1)); + if (!dirLink) + throw createError(ENOENT, "open", sep2 + steps.join(sep2)); + if (flagsNum & O_CREAT && typeof modeNum === "number") { + link10 = this.createLink(dirLink, steps[steps.length - 1], false, modeNum); + } + } + if (link10) + return this.openLink(link10, flagsNum, resolveSymlinks); + throw createError(ENOENT, "open", filename); + }; + Volume2.prototype.openBase = function(filename, flagsNum, modeNum, resolveSymlinks) { + if (resolveSymlinks === void 0) { + resolveSymlinks = true; + } + var file = this.openFile(filename, flagsNum, modeNum, resolveSymlinks); + if (!file) + throw createError(ENOENT, "open", filename); + return file.fd; + }; + Volume2.prototype.openSync = function(path2, flags, mode) { + if (mode === void 0) { + mode = 438; + } + var modeNum = modeToNumber(mode); + var fileName = pathToFilename(path2); + var flagsNum = flagsToNumber(flags); + return this.openBase(fileName, flagsNum, modeNum); + }; + Volume2.prototype.open = function(path2, flags, a8, b6) { + var mode = a8; + var callback = b6; + if (typeof a8 === "function") { + mode = 438; + callback = a8; + } + mode = mode || 438; + var modeNum = modeToNumber(mode); + var fileName = pathToFilename(path2); + var flagsNum = flagsToNumber(flags); + this.wrapAsync(this.openBase, [fileName, flagsNum, modeNum], callback); + }; + Volume2.prototype.closeFile = function(file) { + if (!this.fds[file.fd]) + return; + this.openFiles--; + delete this.fds[file.fd]; + this.releasedFds.push(file.fd); + }; + Volume2.prototype.closeSync = function(fd) { + validateFd(fd); + var file = this.getFileByFdOrThrow(fd, "close"); + this.closeFile(file); + }; + Volume2.prototype.close = function(fd, callback) { + validateFd(fd); + this.wrapAsync(this.closeSync, [fd], callback); + }; + Volume2.prototype.openFileOrGetById = function(id, flagsNum, modeNum) { + if (typeof id === "number") { + var file = this.fds[id]; + if (!file) + throw createError(ENOENT); + return file; + } else { + return this.openFile(pathToFilename(id), flagsNum, modeNum); + } + }; + Volume2.prototype.readBase = function(fd, buffer4, offset2, length3, position) { + var file = this.getFileByFdOrThrow(fd); + return file.read(buffer4, Number(offset2), Number(length3), position); + }; + Volume2.prototype.readSync = function(fd, buffer4, offset2, length3, position) { + validateFd(fd); + return this.readBase(fd, buffer4, offset2, length3, position); + }; + Volume2.prototype.read = function(fd, buffer4, offset2, length3, position, callback) { + var _this = this; + validateCallback(callback); + if (length3 === 0) { + return process_1.default.nextTick(function() { + if (callback) + callback(null, 0, buffer4); + }); + } + (0, setImmediate_1.default)(function() { + try { + var bytes2 = _this.readBase(fd, buffer4, offset2, length3, position); + callback(null, bytes2, buffer4); + } catch (err) { + callback(err); + } + }); + }; + Volume2.prototype.readFileBase = function(id, flagsNum, encoding) { + var result; + var isUserFd = typeof id === "number"; + var userOwnsFd = isUserFd && isFd(id); + var fd; + if (userOwnsFd) + fd = id; + else { + var filename = pathToFilename(id); + var steps = filenameToSteps(filename); + var link10 = this.getResolvedLink(steps); + if (link10) { + var node = link10.getNode(); + if (node.isDirectory()) + throw createError(EISDIR, "open", link10.getPath()); + } + fd = this.openSync(id, flagsNum); + } + try { + result = bufferToEncoding(this.getFileByFdOrThrow(fd).getBuffer(), encoding); + } finally { + if (!userOwnsFd) { + this.closeSync(fd); + } + } + return result; + }; + Volume2.prototype.readFileSync = function(file, options) { + var opts = getReadFileOptions(options); + var flagsNum = flagsToNumber(opts.flag); + return this.readFileBase(file, flagsNum, opts.encoding); + }; + Volume2.prototype.readFile = function(id, a8, b6) { + var _a3 = optsAndCbGenerator(getReadFileOptions)(a8, b6), opts = _a3[0], callback = _a3[1]; + var flagsNum = flagsToNumber(opts.flag); + this.wrapAsync(this.readFileBase, [id, flagsNum, opts.encoding], callback); + }; + Volume2.prototype.writeBase = function(fd, buf3, offset2, length3, position) { + var file = this.getFileByFdOrThrow(fd, "write"); + return file.write(buf3, offset2, length3, position); + }; + Volume2.prototype.writeSync = function(fd, a8, b6, c8, d7) { + validateFd(fd); + var encoding; + var offset2; + var length3; + var position; + var isBuffer7 = typeof a8 !== "string"; + if (isBuffer7) { + offset2 = (b6 || 0) | 0; + length3 = c8; + position = d7; + } else { + position = b6; + encoding = c8; + } + var buf3 = dataToBuffer(a8, encoding); + if (isBuffer7) { + if (typeof length3 === "undefined") { + length3 = buf3.length; + } + } else { + offset2 = 0; + length3 = buf3.length; + } + return this.writeBase(fd, buf3, offset2, length3, position); + }; + Volume2.prototype.write = function(fd, a8, b6, c8, d7, e12) { + var _this = this; + validateFd(fd); + var offset2; + var length3; + var position; + var encoding; + var callback; + var tipa = typeof a8; + var tipb = typeof b6; + var tipc = typeof c8; + var tipd = typeof d7; + if (tipa !== "string") { + if (tipb === "function") { + callback = b6; + } else if (tipc === "function") { + offset2 = b6 | 0; + callback = c8; + } else if (tipd === "function") { + offset2 = b6 | 0; + length3 = c8; + callback = d7; + } else { + offset2 = b6 | 0; + length3 = c8; + position = d7; + callback = e12; + } + } else { + if (tipb === "function") { + callback = b6; + } else if (tipc === "function") { + position = b6; + callback = c8; + } else if (tipd === "function") { + position = b6; + encoding = c8; + callback = d7; + } + } + var buf3 = dataToBuffer(a8, encoding); + if (tipa !== "string") { + if (typeof length3 === "undefined") + length3 = buf3.length; + } else { + offset2 = 0; + length3 = buf3.length; + } + var cb = validateCallback(callback); + (0, setImmediate_1.default)(function() { + try { + var bytes2 = _this.writeBase(fd, buf3, offset2, length3, position); + if (tipa !== "string") { + cb(null, bytes2, buf3); + } else { + cb(null, bytes2, a8); + } + } catch (err) { + cb(err); + } + }); + }; + Volume2.prototype.writeFileBase = function(id, buf3, flagsNum, modeNum) { + var isUserFd = typeof id === "number"; + var fd; + if (isUserFd) + fd = id; + else { + fd = this.openBase(pathToFilename(id), flagsNum, modeNum); + } + var offset2 = 0; + var length3 = buf3.length; + var position = flagsNum & O_APPEND ? void 0 : 0; + try { + while (length3 > 0) { + var written = this.writeSync(fd, buf3, offset2, length3, position); + offset2 += written; + length3 -= written; + if (position !== void 0) + position += written; + } + } finally { + if (!isUserFd) + this.closeSync(fd); + } + }; + Volume2.prototype.writeFileSync = function(id, data, options) { + var opts = getWriteFileOptions(options); + var flagsNum = flagsToNumber(opts.flag); + var modeNum = modeToNumber(opts.mode); + var buf3 = dataToBuffer(data, opts.encoding); + this.writeFileBase(id, buf3, flagsNum, modeNum); + }; + Volume2.prototype.writeFile = function(id, data, a8, b6) { + var options = a8; + var callback = b6; + if (typeof a8 === "function") { + options = writeFileDefaults; + callback = a8; + } + var cb = validateCallback(callback); + var opts = getWriteFileOptions(options); + var flagsNum = flagsToNumber(opts.flag); + var modeNum = modeToNumber(opts.mode); + var buf3 = dataToBuffer(data, opts.encoding); + this.wrapAsync(this.writeFileBase, [id, buf3, flagsNum, modeNum], cb); + }; + Volume2.prototype.linkBase = function(filename1, filename2) { + var steps1 = filenameToSteps(filename1); + var link1 = this.getLink(steps1); + if (!link1) + throw createError(ENOENT, "link", filename1, filename2); + var steps2 = filenameToSteps(filename2); + var dir2 = this.getLinkParent(steps2); + if (!dir2) + throw createError(ENOENT, "link", filename1, filename2); + var name15 = steps2[steps2.length - 1]; + if (dir2.getChild(name15)) + throw createError(EEXIST, "link", filename1, filename2); + var node = link1.getNode(); + node.nlink++; + dir2.createChild(name15, node); + }; + Volume2.prototype.copyFileBase = function(src3, dest, flags) { + var buf3 = this.readFileSync(src3); + if (flags & COPYFILE_EXCL) { + if (this.existsSync(dest)) { + throw createError(EEXIST, "copyFile", src3, dest); + } + } + if (flags & COPYFILE_FICLONE_FORCE) { + throw createError(ENOSYS, "copyFile", src3, dest); + } + this.writeFileBase( + dest, + buf3, + FLAGS.w, + 438 + /* DEFAULT */ + ); + }; + Volume2.prototype.copyFileSync = function(src3, dest, flags) { + var srcFilename = pathToFilename(src3); + var destFilename = pathToFilename(dest); + return this.copyFileBase(srcFilename, destFilename, (flags || 0) | 0); + }; + Volume2.prototype.copyFile = function(src3, dest, a8, b6) { + var srcFilename = pathToFilename(src3); + var destFilename = pathToFilename(dest); + var flags; + var callback; + if (typeof a8 === "function") { + flags = 0; + callback = a8; + } else { + flags = a8; + callback = b6; + } + validateCallback(callback); + this.wrapAsync(this.copyFileBase, [srcFilename, destFilename, flags], callback); + }; + Volume2.prototype.linkSync = function(existingPath, newPath) { + var existingPathFilename = pathToFilename(existingPath); + var newPathFilename = pathToFilename(newPath); + this.linkBase(existingPathFilename, newPathFilename); + }; + Volume2.prototype.link = function(existingPath, newPath, callback) { + var existingPathFilename = pathToFilename(existingPath); + var newPathFilename = pathToFilename(newPath); + this.wrapAsync(this.linkBase, [existingPathFilename, newPathFilename], callback); + }; + Volume2.prototype.unlinkBase = function(filename) { + var steps = filenameToSteps(filename); + var link10 = this.getLink(steps); + if (!link10) + throw createError(ENOENT, "unlink", filename); + if (link10.length) + throw Error("Dir not empty..."); + this.deleteLink(link10); + var node = link10.getNode(); + node.nlink--; + if (node.nlink <= 0) { + this.deleteNode(node); + } + }; + Volume2.prototype.unlinkSync = function(path2) { + var filename = pathToFilename(path2); + this.unlinkBase(filename); + }; + Volume2.prototype.unlink = function(path2, callback) { + var filename = pathToFilename(path2); + this.wrapAsync(this.unlinkBase, [filename], callback); + }; + Volume2.prototype.symlinkBase = function(targetFilename, pathFilename) { + var pathSteps = filenameToSteps(pathFilename); + var dirLink = this.getLinkParent(pathSteps); + if (!dirLink) + throw createError(ENOENT, "symlink", targetFilename, pathFilename); + var name15 = pathSteps[pathSteps.length - 1]; + if (dirLink.getChild(name15)) + throw createError(EEXIST, "symlink", targetFilename, pathFilename); + var symlink3 = dirLink.createChild(name15); + symlink3.getNode().makeSymlink(filenameToSteps(targetFilename)); + return symlink3; + }; + Volume2.prototype.symlinkSync = function(target, path2, type3) { + var targetFilename = pathToFilename(target); + var pathFilename = pathToFilename(path2); + this.symlinkBase(targetFilename, pathFilename); + }; + Volume2.prototype.symlink = function(target, path2, a8, b6) { + var callback = validateCallback(typeof a8 === "function" ? a8 : b6); + var targetFilename = pathToFilename(target); + var pathFilename = pathToFilename(path2); + this.wrapAsync(this.symlinkBase, [targetFilename, pathFilename], callback); + }; + Volume2.prototype.realpathBase = function(filename, encoding) { + var steps = filenameToSteps(filename); + var realLink = this.getResolvedLink(steps); + if (!realLink) + throw createError(ENOENT, "realpath", filename); + return (0, encoding_1.strToEncoding)(realLink.getPath(), encoding); + }; + Volume2.prototype.realpathSync = function(path2, options) { + return this.realpathBase(pathToFilename(path2), getRealpathOptions(options).encoding); + }; + Volume2.prototype.realpath = function(path2, a8, b6) { + var _a3 = getRealpathOptsAndCb(a8, b6), opts = _a3[0], callback = _a3[1]; + var pathFilename = pathToFilename(path2); + this.wrapAsync(this.realpathBase, [pathFilename, opts.encoding], callback); + }; + Volume2.prototype.lstatBase = function(filename, bigint) { + if (bigint === void 0) { + bigint = false; + } + var link10 = this.getLink(filenameToSteps(filename)); + if (!link10) + throw createError(ENOENT, "lstat", filename); + return Stats_1.default.build(link10.getNode(), bigint); + }; + Volume2.prototype.lstatSync = function(path2, options) { + return this.lstatBase(pathToFilename(path2), getStatOptions(options).bigint); + }; + Volume2.prototype.lstat = function(path2, a8, b6) { + var _a3 = getStatOptsAndCb(a8, b6), opts = _a3[0], callback = _a3[1]; + this.wrapAsync(this.lstatBase, [pathToFilename(path2), opts.bigint], callback); + }; + Volume2.prototype.statBase = function(filename, bigint) { + if (bigint === void 0) { + bigint = false; + } + var link10 = this.getResolvedLink(filenameToSteps(filename)); + if (!link10) + throw createError(ENOENT, "stat", filename); + return Stats_1.default.build(link10.getNode(), bigint); + }; + Volume2.prototype.statSync = function(path2, options) { + return this.statBase(pathToFilename(path2), getStatOptions(options).bigint); + }; + Volume2.prototype.stat = function(path2, a8, b6) { + var _a3 = getStatOptsAndCb(a8, b6), opts = _a3[0], callback = _a3[1]; + this.wrapAsync(this.statBase, [pathToFilename(path2), opts.bigint], callback); + }; + Volume2.prototype.fstatBase = function(fd, bigint) { + if (bigint === void 0) { + bigint = false; + } + var file = this.getFileByFd(fd); + if (!file) + throw createError(EBADF, "fstat"); + return Stats_1.default.build(file.node, bigint); + }; + Volume2.prototype.fstatSync = function(fd, options) { + return this.fstatBase(fd, getStatOptions(options).bigint); + }; + Volume2.prototype.fstat = function(fd, a8, b6) { + var _a3 = getStatOptsAndCb(a8, b6), opts = _a3[0], callback = _a3[1]; + this.wrapAsync(this.fstatBase, [fd, opts.bigint], callback); + }; + Volume2.prototype.renameBase = function(oldPathFilename, newPathFilename) { + var link10 = this.getLink(filenameToSteps(oldPathFilename)); + if (!link10) + throw createError(ENOENT, "rename", oldPathFilename, newPathFilename); + var newPathSteps = filenameToSteps(newPathFilename); + var newPathDirLink = this.getLinkParent(newPathSteps); + if (!newPathDirLink) + throw createError(ENOENT, "rename", oldPathFilename, newPathFilename); + var oldLinkParent = link10.parent; + if (oldLinkParent) { + oldLinkParent.deleteChild(link10); + } + var name15 = newPathSteps[newPathSteps.length - 1]; + link10.steps = __spreadArray(__spreadArray([], newPathDirLink.steps, true), [name15], false); + newPathDirLink.setChild(link10.getName(), link10); + }; + Volume2.prototype.renameSync = function(oldPath, newPath) { + var oldPathFilename = pathToFilename(oldPath); + var newPathFilename = pathToFilename(newPath); + this.renameBase(oldPathFilename, newPathFilename); + }; + Volume2.prototype.rename = function(oldPath, newPath, callback) { + var oldPathFilename = pathToFilename(oldPath); + var newPathFilename = pathToFilename(newPath); + this.wrapAsync(this.renameBase, [oldPathFilename, newPathFilename], callback); + }; + Volume2.prototype.existsBase = function(filename) { + return !!this.statBase(filename); + }; + Volume2.prototype.existsSync = function(path2) { + try { + return this.existsBase(pathToFilename(path2)); + } catch (err) { + return false; + } + }; + Volume2.prototype.exists = function(path2, callback) { + var _this = this; + var filename = pathToFilename(path2); + if (typeof callback !== "function") + throw Error(ERRSTR.CB); + (0, setImmediate_1.default)(function() { + try { + callback(_this.existsBase(filename)); + } catch (err) { + callback(false); + } + }); + }; + Volume2.prototype.accessBase = function(filename, mode) { + this.getLinkOrThrow(filename, "access"); + }; + Volume2.prototype.accessSync = function(path2, mode) { + if (mode === void 0) { + mode = F_OK2; + } + var filename = pathToFilename(path2); + mode = mode | 0; + this.accessBase(filename, mode); + }; + Volume2.prototype.access = function(path2, a8, b6) { + var mode = F_OK2; + var callback; + if (typeof a8 !== "function") { + mode = a8 | 0; + callback = validateCallback(b6); + } else { + callback = a8; + } + var filename = pathToFilename(path2); + this.wrapAsync(this.accessBase, [filename, mode], callback); + }; + Volume2.prototype.appendFileSync = function(id, data, options) { + if (options === void 0) { + options = appendFileDefaults; + } + var opts = getAppendFileOpts(options); + if (!opts.flag || isFd(id)) + opts.flag = "a"; + this.writeFileSync(id, data, opts); + }; + Volume2.prototype.appendFile = function(id, data, a8, b6) { + var _a3 = getAppendFileOptsAndCb(a8, b6), opts = _a3[0], callback = _a3[1]; + if (!opts.flag || isFd(id)) + opts.flag = "a"; + this.writeFile(id, data, opts, callback); + }; + Volume2.prototype.readdirBase = function(filename, options) { + var steps = filenameToSteps(filename); + var link10 = this.getResolvedLink(steps); + if (!link10) + throw createError(ENOENT, "readdir", filename); + var node = link10.getNode(); + if (!node.isDirectory()) + throw createError(ENOTDIR, "scandir", filename); + if (options.withFileTypes) { + var list_1 = []; + for (var name_3 in link10.children) { + var child = link10.getChild(name_3); + if (!child) { + continue; + } + list_1.push(Dirent_1.default.build(child, options.encoding)); + } + if (!isWin && options.encoding !== "buffer") + list_1.sort(function(a8, b6) { + if (a8.name < b6.name) + return -1; + if (a8.name > b6.name) + return 1; + return 0; + }); + return list_1; + } + var list10 = []; + for (var name_4 in link10.children) { + list10.push((0, encoding_1.strToEncoding)(name_4, options.encoding)); + } + if (!isWin && options.encoding !== "buffer") + list10.sort(); + return list10; + }; + Volume2.prototype.readdirSync = function(path2, options) { + var opts = getReaddirOptions(options); + var filename = pathToFilename(path2); + return this.readdirBase(filename, opts); + }; + Volume2.prototype.readdir = function(path2, a8, b6) { + var _a3 = getReaddirOptsAndCb(a8, b6), options = _a3[0], callback = _a3[1]; + var filename = pathToFilename(path2); + this.wrapAsync(this.readdirBase, [filename, options], callback); + }; + Volume2.prototype.readlinkBase = function(filename, encoding) { + var link10 = this.getLinkOrThrow(filename, "readlink"); + var node = link10.getNode(); + if (!node.isSymlink()) + throw createError(EINVAL, "readlink", filename); + var str = sep2 + node.symlink.join(sep2); + return (0, encoding_1.strToEncoding)(str, encoding); + }; + Volume2.prototype.readlinkSync = function(path2, options) { + var opts = getDefaultOpts(options); + var filename = pathToFilename(path2); + return this.readlinkBase(filename, opts.encoding); + }; + Volume2.prototype.readlink = function(path2, a8, b6) { + var _a3 = getDefaultOptsAndCb(a8, b6), opts = _a3[0], callback = _a3[1]; + var filename = pathToFilename(path2); + this.wrapAsync(this.readlinkBase, [filename, opts.encoding], callback); + }; + Volume2.prototype.fsyncBase = function(fd) { + this.getFileByFdOrThrow(fd, "fsync"); + }; + Volume2.prototype.fsyncSync = function(fd) { + this.fsyncBase(fd); + }; + Volume2.prototype.fsync = function(fd, callback) { + this.wrapAsync(this.fsyncBase, [fd], callback); + }; + Volume2.prototype.fdatasyncBase = function(fd) { + this.getFileByFdOrThrow(fd, "fdatasync"); + }; + Volume2.prototype.fdatasyncSync = function(fd) { + this.fdatasyncBase(fd); + }; + Volume2.prototype.fdatasync = function(fd, callback) { + this.wrapAsync(this.fdatasyncBase, [fd], callback); + }; + Volume2.prototype.ftruncateBase = function(fd, len) { + var file = this.getFileByFdOrThrow(fd, "ftruncate"); + file.truncate(len); + }; + Volume2.prototype.ftruncateSync = function(fd, len) { + this.ftruncateBase(fd, len); + }; + Volume2.prototype.ftruncate = function(fd, a8, b6) { + var len = typeof a8 === "number" ? a8 : 0; + var callback = validateCallback(typeof a8 === "number" ? b6 : a8); + this.wrapAsync(this.ftruncateBase, [fd, len], callback); + }; + Volume2.prototype.truncateBase = function(path2, len) { + var fd = this.openSync(path2, "r+"); + try { + this.ftruncateSync(fd, len); + } finally { + this.closeSync(fd); + } + }; + Volume2.prototype.truncateSync = function(id, len) { + if (isFd(id)) + return this.ftruncateSync(id, len); + this.truncateBase(id, len); + }; + Volume2.prototype.truncate = function(id, a8, b6) { + var len = typeof a8 === "number" ? a8 : 0; + var callback = validateCallback(typeof a8 === "number" ? b6 : a8); + if (isFd(id)) + return this.ftruncate(id, len, callback); + this.wrapAsync(this.truncateBase, [id, len], callback); + }; + Volume2.prototype.futimesBase = function(fd, atime, mtime) { + var file = this.getFileByFdOrThrow(fd, "futimes"); + var node = file.node; + node.atime = new Date(atime * 1e3); + node.mtime = new Date(mtime * 1e3); + }; + Volume2.prototype.futimesSync = function(fd, atime, mtime) { + this.futimesBase(fd, toUnixTimestamp(atime), toUnixTimestamp(mtime)); + }; + Volume2.prototype.futimes = function(fd, atime, mtime, callback) { + this.wrapAsync(this.futimesBase, [fd, toUnixTimestamp(atime), toUnixTimestamp(mtime)], callback); + }; + Volume2.prototype.utimesBase = function(filename, atime, mtime) { + var fd = this.openSync(filename, "r+"); + try { + this.futimesBase(fd, atime, mtime); + } finally { + this.closeSync(fd); + } + }; + Volume2.prototype.utimesSync = function(path2, atime, mtime) { + this.utimesBase(pathToFilename(path2), toUnixTimestamp(atime), toUnixTimestamp(mtime)); + }; + Volume2.prototype.utimes = function(path2, atime, mtime, callback) { + this.wrapAsync(this.utimesBase, [pathToFilename(path2), toUnixTimestamp(atime), toUnixTimestamp(mtime)], callback); + }; + Volume2.prototype.mkdirBase = function(filename, modeNum) { + var steps = filenameToSteps(filename); + if (!steps.length) { + throw createError(EEXIST, "mkdir", filename); + } + var dir = this.getLinkParentAsDirOrThrow(filename, "mkdir"); + var name15 = steps[steps.length - 1]; + if (dir.getChild(name15)) + throw createError(EEXIST, "mkdir", filename); + dir.createChild(name15, this.createNode(true, modeNum)); + }; + Volume2.prototype.mkdirpBase = function(filename, modeNum) { + var steps = filenameToSteps(filename); + var link10 = this.root; + for (var i8 = 0; i8 < steps.length; i8++) { + var step2 = steps[i8]; + if (!link10.getNode().isDirectory()) + throw createError(ENOTDIR, "mkdir", link10.getPath()); + var child = link10.getChild(step2); + if (child) { + if (child.getNode().isDirectory()) + link10 = child; + else + throw createError(ENOTDIR, "mkdir", child.getPath()); + } else { + link10 = link10.createChild(step2, this.createNode(true, modeNum)); + } + } + }; + Volume2.prototype.mkdirSync = function(path2, options) { + var opts = getMkdirOptions(options); + var modeNum = modeToNumber(opts.mode, 511); + var filename = pathToFilename(path2); + if (opts.recursive) + this.mkdirpBase(filename, modeNum); + else + this.mkdirBase(filename, modeNum); + }; + Volume2.prototype.mkdir = function(path2, a8, b6) { + var opts = getMkdirOptions(a8); + var callback = validateCallback(typeof a8 === "function" ? a8 : b6); + var modeNum = modeToNumber(opts.mode, 511); + var filename = pathToFilename(path2); + if (opts.recursive) + this.wrapAsync(this.mkdirpBase, [filename, modeNum], callback); + else + this.wrapAsync(this.mkdirBase, [filename, modeNum], callback); + }; + Volume2.prototype.mkdirpSync = function(path2, mode) { + this.mkdirSync(path2, { + mode, + recursive: true + }); + }; + Volume2.prototype.mkdirp = function(path2, a8, b6) { + var mode = typeof a8 === "function" ? void 0 : a8; + var callback = validateCallback(typeof a8 === "function" ? a8 : b6); + this.mkdir(path2, { + mode, + recursive: true + }, callback); + }; + Volume2.prototype.mkdtempBase = function(prefix, encoding, retry2) { + if (retry2 === void 0) { + retry2 = 5; + } + var filename = prefix + this.genRndStr(); + try { + this.mkdirBase( + filename, + 511 + /* DIR */ + ); + return (0, encoding_1.strToEncoding)(filename, encoding); + } catch (err) { + if (err.code === EEXIST) { + if (retry2 > 1) + return this.mkdtempBase(prefix, encoding, retry2 - 1); + else + throw Error("Could not create temp dir."); + } else + throw err; + } + }; + Volume2.prototype.mkdtempSync = function(prefix, options) { + var encoding = getDefaultOpts(options).encoding; + if (!prefix || typeof prefix !== "string") + throw new TypeError("filename prefix is required"); + nullCheck(prefix); + return this.mkdtempBase(prefix, encoding); + }; + Volume2.prototype.mkdtemp = function(prefix, a8, b6) { + var _a3 = getDefaultOptsAndCb(a8, b6), encoding = _a3[0].encoding, callback = _a3[1]; + if (!prefix || typeof prefix !== "string") + throw new TypeError("filename prefix is required"); + if (!nullCheck(prefix)) + return; + this.wrapAsync(this.mkdtempBase, [prefix, encoding], callback); + }; + Volume2.prototype.rmdirBase = function(filename, options) { + var opts = getRmdirOptions(options); + var link10 = this.getLinkAsDirOrThrow(filename, "rmdir"); + if (link10.length && !opts.recursive) + throw createError(ENOTEMPTY, "rmdir", filename); + this.deleteLink(link10); + }; + Volume2.prototype.rmdirSync = function(path2, options) { + this.rmdirBase(pathToFilename(path2), options); + }; + Volume2.prototype.rmdir = function(path2, a8, b6) { + var opts = getRmdirOptions(a8); + var callback = validateCallback(typeof a8 === "function" ? a8 : b6); + this.wrapAsync(this.rmdirBase, [pathToFilename(path2), opts], callback); + }; + Volume2.prototype.fchmodBase = function(fd, modeNum) { + var file = this.getFileByFdOrThrow(fd, "fchmod"); + file.chmod(modeNum); + }; + Volume2.prototype.fchmodSync = function(fd, mode) { + this.fchmodBase(fd, modeToNumber(mode)); + }; + Volume2.prototype.fchmod = function(fd, mode, callback) { + this.wrapAsync(this.fchmodBase, [fd, modeToNumber(mode)], callback); + }; + Volume2.prototype.chmodBase = function(filename, modeNum) { + var fd = this.openSync(filename, "r+"); + try { + this.fchmodBase(fd, modeNum); + } finally { + this.closeSync(fd); + } + }; + Volume2.prototype.chmodSync = function(path2, mode) { + var modeNum = modeToNumber(mode); + var filename = pathToFilename(path2); + this.chmodBase(filename, modeNum); + }; + Volume2.prototype.chmod = function(path2, mode, callback) { + var modeNum = modeToNumber(mode); + var filename = pathToFilename(path2); + this.wrapAsync(this.chmodBase, [filename, modeNum], callback); + }; + Volume2.prototype.lchmodBase = function(filename, modeNum) { + var fd = this.openBase(filename, O_RDWR, 0, false); + try { + this.fchmodBase(fd, modeNum); + } finally { + this.closeSync(fd); + } + }; + Volume2.prototype.lchmodSync = function(path2, mode) { + var modeNum = modeToNumber(mode); + var filename = pathToFilename(path2); + this.lchmodBase(filename, modeNum); + }; + Volume2.prototype.lchmod = function(path2, mode, callback) { + var modeNum = modeToNumber(mode); + var filename = pathToFilename(path2); + this.wrapAsync(this.lchmodBase, [filename, modeNum], callback); + }; + Volume2.prototype.fchownBase = function(fd, uid, gid) { + this.getFileByFdOrThrow(fd, "fchown").chown(uid, gid); + }; + Volume2.prototype.fchownSync = function(fd, uid, gid) { + validateUid(uid); + validateGid(gid); + this.fchownBase(fd, uid, gid); + }; + Volume2.prototype.fchown = function(fd, uid, gid, callback) { + validateUid(uid); + validateGid(gid); + this.wrapAsync(this.fchownBase, [fd, uid, gid], callback); + }; + Volume2.prototype.chownBase = function(filename, uid, gid) { + var link10 = this.getResolvedLinkOrThrow(filename, "chown"); + var node = link10.getNode(); + node.chown(uid, gid); + }; + Volume2.prototype.chownSync = function(path2, uid, gid) { + validateUid(uid); + validateGid(gid); + this.chownBase(pathToFilename(path2), uid, gid); + }; + Volume2.prototype.chown = function(path2, uid, gid, callback) { + validateUid(uid); + validateGid(gid); + this.wrapAsync(this.chownBase, [pathToFilename(path2), uid, gid], callback); + }; + Volume2.prototype.lchownBase = function(filename, uid, gid) { + this.getLinkOrThrow(filename, "lchown").getNode().chown(uid, gid); + }; + Volume2.prototype.lchownSync = function(path2, uid, gid) { + validateUid(uid); + validateGid(gid); + this.lchownBase(pathToFilename(path2), uid, gid); + }; + Volume2.prototype.lchown = function(path2, uid, gid, callback) { + validateUid(uid); + validateGid(gid); + this.wrapAsync(this.lchownBase, [pathToFilename(path2), uid, gid], callback); + }; + Volume2.prototype.watchFile = function(path2, a8, b6) { + var filename = pathToFilename(path2); + var options = a8; + var listener = b6; + if (typeof options === "function") { + listener = a8; + options = null; + } + if (typeof listener !== "function") { + throw Error('"watchFile()" requires a listener function'); + } + var interval = 5007; + var persistent = true; + if (options && typeof options === "object") { + if (typeof options.interval === "number") + interval = options.interval; + if (typeof options.persistent === "boolean") + persistent = options.persistent; + } + var watcher = this.statWatchers[filename]; + if (!watcher) { + watcher = new this.StatWatcher(); + watcher.start(filename, persistent, interval); + this.statWatchers[filename] = watcher; + } + watcher.addListener("change", listener); + return watcher; + }; + Volume2.prototype.unwatchFile = function(path2, listener) { + var filename = pathToFilename(path2); + var watcher = this.statWatchers[filename]; + if (!watcher) + return; + if (typeof listener === "function") { + watcher.removeListener("change", listener); + } else { + watcher.removeAllListeners("change"); + } + if (watcher.listenerCount("change") === 0) { + watcher.stop(); + delete this.statWatchers[filename]; + } + }; + Volume2.prototype.createReadStream = function(path2, options) { + return new this.ReadStream(path2, options); + }; + Volume2.prototype.createWriteStream = function(path2, options) { + return new this.WriteStream(path2, options); + }; + Volume2.prototype.watch = function(path2, options, listener) { + var filename = pathToFilename(path2); + var givenOptions = options; + if (typeof options === "function") { + listener = options; + givenOptions = null; + } + var _a3 = getDefaultOpts(givenOptions), persistent = _a3.persistent, recursive = _a3.recursive, encoding = _a3.encoding; + if (persistent === void 0) + persistent = true; + if (recursive === void 0) + recursive = false; + var watcher = new this.FSWatcher(); + watcher.start(filename, persistent, recursive, encoding); + if (listener) { + watcher.addListener("change", listener); + } + return watcher; + }; + Volume2.fd = 2147483647; + return Volume2; + }(); + exports$43.Volume = Volume; + function emitStop(self2) { + self2.emit("stop"); + } + var StatWatcher = function(_super) { + __extends(StatWatcher2, _super); + function StatWatcher2(vol2) { + var _this = _super.call(this) || this; + _this.onInterval = function() { + try { + var stats = _this.vol.statSync(_this.filename); + if (_this.hasChanged(stats)) { + _this.emit("change", stats, _this.prev); + _this.prev = stats; + } + } finally { + _this.loop(); + } + }; + _this.vol = vol2; + return _this; + } + StatWatcher2.prototype.loop = function() { + this.timeoutRef = this.setTimeout(this.onInterval, this.interval); + }; + StatWatcher2.prototype.hasChanged = function(stats) { + if (stats.mtimeMs > this.prev.mtimeMs) + return true; + if (stats.nlink !== this.prev.nlink) + return true; + return false; + }; + StatWatcher2.prototype.start = function(path2, persistent, interval) { + if (persistent === void 0) { + persistent = true; + } + if (interval === void 0) { + interval = 5007; + } + this.filename = pathToFilename(path2); + this.setTimeout = persistent ? setTimeout.bind(typeof globalThis !== "undefined" ? globalThis : _global5) : setTimeoutUnref_1.default; + this.interval = interval; + this.prev = this.vol.statSync(this.filename); + this.loop(); + }; + StatWatcher2.prototype.stop = function() { + clearTimeout(this.timeoutRef); + process_1.default.nextTick(emitStop, this); + }; + return StatWatcher2; + }(events_1.EventEmitter); + exports$43.StatWatcher = StatWatcher; + var pool; + function allocNewPool(poolSize) { + pool = (0, buffer_1.bufferAllocUnsafe)(poolSize); + pool.used = 0; + } + util3.inherits(FsReadStream, stream_1.Readable); + exports$43.ReadStream = FsReadStream; + function FsReadStream(vol2, path2, options) { + if (!(this instanceof FsReadStream)) + return new FsReadStream(vol2, path2, options); + this._vol = vol2; + options = Object.assign({}, getOptions(options, {})); + if (options.highWaterMark === void 0) + options.highWaterMark = 64 * 1024; + stream_1.Readable.call(this, options); + this.path = pathToFilename(path2); + this.fd = options.fd === void 0 ? null : options.fd; + this.flags = options.flags === void 0 ? "r" : options.flags; + this.mode = options.mode === void 0 ? 438 : options.mode; + this.start = options.start; + this.end = options.end; + this.autoClose = options.autoClose === void 0 ? true : options.autoClose; + this.pos = void 0; + this.bytesRead = 0; + if (this.start !== void 0) { + if (typeof this.start !== "number") { + throw new TypeError('"start" option must be a Number'); + } + if (this.end === void 0) { + this.end = Infinity; + } else if (typeof this.end !== "number") { + throw new TypeError('"end" option must be a Number'); + } + if (this.start > this.end) { + throw new Error('"start" option must be <= "end" option'); + } + this.pos = this.start; + } + if (typeof this.fd !== "number") + this.open(); + this.on("end", function() { + if (this.autoClose) { + if (this.destroy) + this.destroy(); + } + }); + } + FsReadStream.prototype.open = function() { + var self2 = this; + this._vol.open(this.path, this.flags, this.mode, function(er, fd) { + if (er) { + if (self2.autoClose) { + if (self2.destroy) + self2.destroy(); + } + self2.emit("error", er); + return; + } + self2.fd = fd; + self2.emit("open", fd); + self2.read(); + }); + }; + FsReadStream.prototype._read = function(n9) { + if (typeof this.fd !== "number") { + return this.once("open", function() { + this._read(n9); + }); + } + if (this.destroyed) + return; + if (!pool || pool.length - pool.used < kMinPoolSpace) { + allocNewPool(this._readableState.highWaterMark); + } + var thisPool = pool; + var toRead = Math.min(pool.length - pool.used, n9); + var start = pool.used; + if (this.pos !== void 0) + toRead = Math.min(this.end - this.pos + 1, toRead); + if (toRead <= 0) + return this.push(null); + var self2 = this; + this._vol.read(this.fd, pool, pool.used, toRead, this.pos, onread); + if (this.pos !== void 0) + this.pos += toRead; + pool.used += toRead; + function onread(er, bytesRead) { + if (er) { + if (self2.autoClose && self2.destroy) { + self2.destroy(); + } + self2.emit("error", er); + } else { + var b6 = null; + if (bytesRead > 0) { + self2.bytesRead += bytesRead; + b6 = thisPool.slice(start, start + bytesRead); + } + self2.push(b6); + } + } + }; + FsReadStream.prototype._destroy = function(err, cb) { + this.close(function(err2) { + cb(err || err2); + }); + }; + FsReadStream.prototype.close = function(cb) { + var _this = this; + if (cb) + this.once("close", cb); + if (this.closed || typeof this.fd !== "number") { + if (typeof this.fd !== "number") { + this.once("open", closeOnOpen); + return; + } + return process_1.default.nextTick(function() { + return _this.emit("close"); + }); + } + this.closed = true; + this._vol.close(this.fd, function(er) { + if (er) + _this.emit("error", er); + else + _this.emit("close"); + }); + this.fd = null; + }; + function closeOnOpen(fd) { + this.close(); + } + util3.inherits(FsWriteStream, stream_1.Writable); + exports$43.WriteStream = FsWriteStream; + function FsWriteStream(vol2, path2, options) { + if (!(this instanceof FsWriteStream)) + return new FsWriteStream(vol2, path2, options); + this._vol = vol2; + options = Object.assign({}, getOptions(options, {})); + stream_1.Writable.call(this, options); + this.path = pathToFilename(path2); + this.fd = options.fd === void 0 ? null : options.fd; + this.flags = options.flags === void 0 ? "w" : options.flags; + this.mode = options.mode === void 0 ? 438 : options.mode; + this.start = options.start; + this.autoClose = options.autoClose === void 0 ? true : !!options.autoClose; + this.pos = void 0; + this.bytesWritten = 0; + if (this.start !== void 0) { + if (typeof this.start !== "number") { + throw new TypeError('"start" option must be a Number'); + } + if (this.start < 0) { + throw new Error('"start" must be >= zero'); + } + this.pos = this.start; + } + if (options.encoding) + this.setDefaultEncoding(options.encoding); + if (typeof this.fd !== "number") + this.open(); + this.once("finish", function() { + if (this.autoClose) { + this.close(); + } + }); + } + FsWriteStream.prototype.open = function() { + this._vol.open(this.path, this.flags, this.mode, function(er, fd) { + if (er) { + if (this.autoClose && this.destroy) { + this.destroy(); + } + this.emit("error", er); + return; + } + this.fd = fd; + this.emit("open", fd); + }.bind(this)); + }; + FsWriteStream.prototype._write = function(data, encoding, cb) { + if (!(data instanceof buffer_1.Buffer)) + return this.emit("error", new Error("Invalid data")); + if (typeof this.fd !== "number") { + return this.once("open", function() { + this._write(data, encoding, cb); + }); + } + var self2 = this; + this._vol.write(this.fd, data, 0, data.length, this.pos, function(er, bytes2) { + if (er) { + if (self2.autoClose && self2.destroy) { + self2.destroy(); + } + return cb(er); + } + self2.bytesWritten += bytes2; + cb(); + }); + if (this.pos !== void 0) + this.pos += data.length; + }; + FsWriteStream.prototype._writev = function(data, cb) { + if (typeof this.fd !== "number") { + return this.once("open", function() { + this._writev(data, cb); + }); + } + var self2 = this; + var len = data.length; + var chunks = new Array(len); + var size4 = 0; + for (var i8 = 0; i8 < len; i8++) { + var chunk = data[i8].chunk; + chunks[i8] = chunk; + size4 += chunk.length; + } + var buf3 = buffer_1.Buffer.concat(chunks); + this._vol.write(this.fd, buf3, 0, buf3.length, this.pos, function(er, bytes2) { + if (er) { + if (self2.destroy) + self2.destroy(); + return cb(er); + } + self2.bytesWritten += bytes2; + cb(); + }); + if (this.pos !== void 0) + this.pos += size4; + }; + FsWriteStream.prototype._destroy = FsReadStream.prototype._destroy; + FsWriteStream.prototype.close = FsReadStream.prototype.close; + FsWriteStream.prototype.destroySoon = FsWriteStream.prototype.end; + var FSWatcher = function(_super) { + __extends(FSWatcher2, _super); + function FSWatcher2(vol2) { + var _this = _super.call(this) || this; + _this._filename = ""; + _this._filenameEncoded = ""; + _this._recursive = false; + _this._encoding = encoding_1.ENCODING_UTF8; + _this._onNodeChange = function() { + _this._emit("change"); + }; + _this._onParentChild = function(link10) { + if (link10.getName() === _this._getName()) { + _this._emit("rename"); + } + }; + _this._emit = function(type3) { + _this.emit("change", type3, _this._filenameEncoded); + }; + _this._persist = function() { + _this._timer = setTimeout(_this._persist, 1e6); + }; + _this._vol = vol2; + return _this; + } + FSWatcher2.prototype._getName = function() { + return this._steps[this._steps.length - 1]; + }; + FSWatcher2.prototype.start = function(path2, persistent, recursive, encoding) { + if (persistent === void 0) { + persistent = true; + } + if (recursive === void 0) { + recursive = false; + } + if (encoding === void 0) { + encoding = encoding_1.ENCODING_UTF8; + } + this._filename = pathToFilename(path2); + this._steps = filenameToSteps(this._filename); + this._filenameEncoded = (0, encoding_1.strToEncoding)(this._filename); + this._recursive = recursive; + this._encoding = encoding; + try { + this._link = this._vol.getLinkOrThrow(this._filename, "FSWatcher"); + } catch (err) { + var error7 = new Error("watch " + this._filename + " " + err.code); + error7.code = err.code; + error7.errno = err.code; + throw error7; + } + this._link.getNode().on("change", this._onNodeChange); + this._link.on("child:add", this._onNodeChange); + this._link.on("child:delete", this._onNodeChange); + var parent = this._link.parent; + if (parent) { + parent.setMaxListeners(parent.getMaxListeners() + 1); + parent.on("child:delete", this._onParentChild); + } + if (persistent) + this._persist(); + }; + FSWatcher2.prototype.close = function() { + clearTimeout(this._timer); + this._link.getNode().removeListener("change", this._onNodeChange); + var parent = this._link.parent; + if (parent) { + parent.removeListener("child:delete", this._onParentChild); + } + }; + return FSWatcher2; + }(events_1.EventEmitter); + exports$43.FSWatcher = FSWatcher; + return exports$43; + } + function dew$111() { + if (_dewExec$111) + return exports$34; + _dewExec$111 = true; + Object.defineProperty(exports$34, "__esModule", { + value: true + }); + exports$34.fsAsyncMethods = exports$34.fsSyncMethods = exports$34.fsProps = void 0; + var fsProps = ["constants", "F_OK", "R_OK", "W_OK", "X_OK", "Stats"]; + exports$34.fsProps = fsProps; + var fsSyncMethods = ["renameSync", "ftruncateSync", "truncateSync", "chownSync", "fchownSync", "lchownSync", "chmodSync", "fchmodSync", "lchmodSync", "statSync", "lstatSync", "fstatSync", "linkSync", "symlinkSync", "readlinkSync", "realpathSync", "unlinkSync", "rmdirSync", "mkdirSync", "mkdirpSync", "readdirSync", "closeSync", "openSync", "utimesSync", "futimesSync", "fsyncSync", "writeSync", "readSync", "readFileSync", "writeFileSync", "appendFileSync", "existsSync", "accessSync", "fdatasyncSync", "mkdtempSync", "copyFileSync", "createReadStream", "createWriteStream"]; + exports$34.fsSyncMethods = fsSyncMethods; + var fsAsyncMethods = ["rename", "ftruncate", "truncate", "chown", "fchown", "lchown", "chmod", "fchmod", "lchmod", "stat", "lstat", "fstat", "link", "symlink", "readlink", "realpath", "unlink", "rmdir", "mkdir", "mkdirp", "readdir", "close", "open", "utimes", "futimes", "fsync", "write", "read", "readFile", "writeFile", "appendFile", "exists", "access", "fdatasync", "mkdtemp", "copyFile", "watchFile", "unwatchFile", "watch"]; + exports$34.fsAsyncMethods = fsAsyncMethods; + return exports$34; + } + function dew9() { + if (_dewExec9) + return exports$211; + _dewExec9 = true; + var __assign = exports$211 && exports$211.__assign || function() { + __assign = Object.assign || function(t9) { + for (var s7, i8 = 1, n9 = arguments.length; i8 < n9; i8++) { + s7 = arguments[i8]; + for (var p8 in s7) + if (Object.prototype.hasOwnProperty.call(s7, p8)) + t9[p8] = s7[p8]; + } + return t9; + }; + return __assign.apply(this, arguments); + }; + Object.defineProperty(exports$211, "__esModule", { + value: true + }); + exports$211.fs = exports$211.createFsFromVolume = exports$211.vol = exports$211.Volume = void 0; + var Stats_1 = dew$d3(); + var Dirent_1 = dew$93(); + var volume_1 = dew$211(); + var _a2 = dew$111(), fsSyncMethods = _a2.fsSyncMethods, fsAsyncMethods = _a2.fsAsyncMethods; + var constants_1 = dew$f3(); + var F_OK2 = constants_1.constants.F_OK, R_OK2 = constants_1.constants.R_OK, W_OK2 = constants_1.constants.W_OK, X_OK2 = constants_1.constants.X_OK; + exports$211.Volume = volume_1.Volume; + exports$211.vol = new volume_1.Volume(); + function createFsFromVolume2(vol2) { + var fs2 = { + F_OK: F_OK2, + R_OK: R_OK2, + W_OK: W_OK2, + X_OK: X_OK2, + constants: constants_1.constants, + Stats: Stats_1.default, + Dirent: Dirent_1.default + }; + for (var _i = 0, fsSyncMethods_1 = fsSyncMethods; _i < fsSyncMethods_1.length; _i++) { + var method = fsSyncMethods_1[_i]; + if (typeof vol2[method] === "function") + fs2[method] = vol2[method].bind(vol2); + } + for (var _a3 = 0, fsAsyncMethods_1 = fsAsyncMethods; _a3 < fsAsyncMethods_1.length; _a3++) { + var method = fsAsyncMethods_1[_a3]; + if (typeof vol2[method] === "function") + fs2[method] = vol2[method].bind(vol2); + } + fs2.StatWatcher = vol2.StatWatcher; + fs2.FSWatcher = vol2.FSWatcher; + fs2.WriteStream = vol2.WriteStream; + fs2.ReadStream = vol2.ReadStream; + fs2.promises = vol2.promises; + fs2._toUnixTimestamp = volume_1.toUnixTimestamp; + return fs2; + } + exports$211.createFsFromVolume = createFsFromVolume2; + exports$211.fs = createFsFromVolume2(exports$211.vol); + exports$211 = __assign(__assign({}, exports$211), exports$211.fs); + exports$211.semantic = true; + return exports$211; + } + function unimplemented(name15) { + throw new Error(`Node.js fs ${name15} is not supported by JSPM core in the browser`); + } + function watchStdo(path2, fd, listener) { + let oldSize = 0; + const decoder4 = new TextDecoder(); + vol.watch(path2, "utf8", () => { + const { size: size4 } = vol.fstatSync(fd); + const buf3 = Buffer.alloc(size4 - oldSize); + vol.readSync(fd, buf3, 0, buf3.length, oldSize); + oldSize = size4; + listener(decoder4.decode(buf3, { stream: true })); + }); + } + function handleFsUrl(url, isSync) { + if (url.protocol === "file:") + return fileURLToPath(url); + if (url.protocol === "https:" || url.protocol === "http:") { + const path2 = "\\\\url\\" + url.href.replaceAll(/\//g, "\\\\"); + if (existsSync(path2)) + return path2; + if (isSync) + throw new Error(`Cannot sync request URL ${url} via FS. JSPM FS support for network URLs requires using async FS methods or priming the MemFS cache first with an async request before a sync request.`); + return (async () => { + const res = await fetch(url); + if (!res.ok) + throw new Error(`Unable to fetch ${url.href}, ${res.status}`); + const buf3 = await res.arrayBuffer(); + writeFileSync(path2, Buffer.from(buf3)); + return path2; + })(); + } + throw new Error("URL " + url + " not supported in JSPM FS implementation."); + } + function wrapFsSync(fn) { + return function(path2, ...args) { + if (path2 instanceof URL) + return fn(handleFsUrl(path2, true), ...args); + return fn(path2, ...args); + }; + } + function wrapFsPromise(fn) { + return async function(path2, ...args) { + if (path2 instanceof URL) + return fn(await handleFsUrl(path2), ...args); + return fn(path2, ...args); + }; + } + function wrapFsCallback(fn) { + return function(path2, ...args) { + const cb = args[args.length - 1]; + if (path2 instanceof URL && typeof cb === "function") { + handleFsUrl(path2).then((path3) => { + fn(path3, ...args); + }, cb); + } else { + fn(path2, ...args); + } + }; + } + var exports$h2, _dewExec$f3, exports$g3, _dewExec$e3, exports$f3, _dewExec$d3, exports$e3, _dewExec$c3, exports$d3, _dewExec$b3, _global$32, exports$c3, _dewExec$a3, exports$b3, _dewExec$93, exports$a3, _dewExec$83, _global$23, exports$93, _dewExec$73, exports$83, _dewExec$63, exports$73, _dewExec$53, _global$13, exports$63, _dewExec$43, exports$53, _dewExec$33, exports$43, _dewExec$211, _global5, exports$34, _dewExec$111, exports$211, _dewExec9, exports$113, exports10, vol, createFsFromVolume, fs, appendFile, appendFileSync, access2, accessSync, chown, chownSync, chmod, chmodSync, close9, closeSync, copyFile, copyFileSync, cp, cpSync, createReadStream, createWriteStream, exists, existsSync, fchown, fchownSync, fchmod, fchmodSync, fdatasync, fdatasyncSync, fstat, fstatSync, fsync, fsyncSync, ftruncate, ftruncateSync, futimes, futimesSync, lchown, lchownSync, lchmod, lchmodSync, link5, linkSync, lstat, lstatSync, mkdir, mkdirSync, mkdtemp, mkdtempSync, open4, openSync, opendir, opendirSync, readdir, readdirSync, read8, readSync, readv, readvSync, readFile, readFileSync, readlink, readlinkSync, realpath, realpathSync, rename, renameSync, rm, rmSync, rmdir, rmdirSync, stat, statSync, symlink, symlinkSync, truncate, truncateSync, unwatchFile, unlink, unlinkSync, utimes, utimesSync, watch, watchFile, writeFile, writeFileSync, write8, writeSync, writev, writevSync, Dir, Dirent, Stats, ReadStream, WriteStream, FileReadStream, FileWriteStream, _toUnixTimestamp, F_OK, R_OK, W_OK, X_OK, constants2, promises2; + var init_fs = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/fs.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_44e51b61(); + init_assert(); + init_util(); + init_chunk_b4205b57(); + init_path(); + init_chunk_2eac56ff(); + init_events(); + init_chunk_4bd36a8f(); + init_stream(); + init_url(); + init_chunk_23dbec7b(); + init_chunk_6c718bbe(); + init_buffer(); + init_chunk_ce0fbc82(); + init_chunk_5decc758(); + init_chunk_4ccc3a29(); + init_chunk_924bb2e1(); + init_chunk_b04e620d(); + exports$h2 = {}; + _dewExec$f3 = false; + exports$g3 = {}; + _dewExec$e3 = false; + exports$f3 = {}; + _dewExec$d3 = false; + exports$e3 = {}; + _dewExec$c3 = false; + exports$d3 = {}; + _dewExec$b3 = false; + _global$32 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + exports$c3 = {}; + _dewExec$a3 = false; + exports$b3 = {}; + _dewExec$93 = false; + exports$a3 = {}; + _dewExec$83 = false; + _global$23 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + exports$93 = {}; + _dewExec$73 = false; + exports$83 = {}; + _dewExec$63 = false; + exports$73 = {}; + _dewExec$53 = false; + _global$13 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + exports$63 = {}; + _dewExec$43 = false; + exports$53 = {}; + _dewExec$33 = false; + exports$43 = {}; + _dewExec$211 = false; + _global5 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + exports$34 = {}; + _dewExec$111 = false; + exports$211 = {}; + _dewExec9 = false; + exports$113 = dew9(); + exports$113["__esModule"]; + exports$113["fs"]; + exports$113["createFsFromVolume"]; + exports$113["vol"]; + exports$113["Volume"]; + exports$113["semantic"]; + exports10 = dew$211(); + exports10["__esModule"]; + exports10["FSWatcher"]; + exports10["StatWatcher"]; + exports10["Volume"]; + exports10["toUnixTimestamp"]; + exports10["bufferToEncoding"]; + exports10["dataToBuffer"]; + exports10["dataToStr"]; + exports10["pathToSteps"]; + exports10["filenameToSteps"]; + exports10["pathToFilename"]; + exports10["flagsToNumber"]; + exports10["FLAGS"]; + exports10["ReadStream"]; + exports10["WriteStream"]; + ({ vol, createFsFromVolume } = exports$113); + vol.fromNestedJSON({ + "/dev": { stdin: "", stdout: "", stderr: "" }, + "/usr/bin": {}, + "/home": {}, + "/tmp": {} + }); + vol.releasedFds = [2, 1, 0]; + vol.openSync("/dev/stdin", "w"); + vol.openSync("/dev/stdout", "r"); + vol.openSync("/dev/stderr", "r"); + watchStdo("/dev/stdout", 1, console.log); + watchStdo("/dev/stderr", 2, console.error); + fs = createFsFromVolume(vol); + fs.opendir = () => unimplemented("opendir"); + fs.opendirSync = () => unimplemented("opendirSync"); + fs.promises.opendir = () => unimplemented("promises.opendir"); + fs.cp = () => unimplemented("cp"); + fs.cpSync = () => unimplemented("cpSync"); + fs.promises.cp = () => unimplemented("promises.cp"); + fs.readv = () => unimplemented("readv"); + fs.readvSync = () => unimplemented("readvSync"); + fs.rm = () => unimplemented("rm"); + fs.rmSync = () => unimplemented("rmSync"); + fs.promises.rm = () => unimplemented("promises.rm"); + fs.Dir = () => unimplemented("Dir"); + fs.promises.watch = () => unimplemented("promises.watch"); + fs.FileReadStream = fs.ReadStream; + fs.FileWriteStream = fs.WriteStream; + fs.promises.readFile = wrapFsPromise(fs.promises.readFile); + fs.readFile = wrapFsCallback(fs.readFile); + fs.readFileSync = wrapFsSync(fs.readFileSync); + ({ + appendFile, + appendFileSync, + access: access2, + accessSync, + chown, + chownSync, + chmod, + chmodSync, + close: close9, + closeSync, + copyFile, + copyFileSync, + cp, + cpSync, + createReadStream, + createWriteStream, + exists, + existsSync, + fchown, + fchownSync, + fchmod, + fchmodSync, + fdatasync, + fdatasyncSync, + fstat, + fstatSync, + fsync, + fsyncSync, + ftruncate, + ftruncateSync, + futimes, + futimesSync, + lchown, + lchownSync, + lchmod, + lchmodSync, + link: link5, + linkSync, + lstat, + lstatSync, + mkdir, + mkdirSync, + mkdtemp, + mkdtempSync, + open: open4, + openSync, + opendir, + opendirSync, + readdir, + readdirSync, + read: read8, + readSync, + readv, + readvSync, + readFile, + readFileSync, + readlink, + readlinkSync, + realpath, + realpathSync, + rename, + renameSync, + rm, + rmSync, + rmdir, + rmdirSync, + stat, + statSync, + symlink, + symlinkSync, + truncate, + truncateSync, + unwatchFile, + unlink, + unlinkSync, + utimes, + utimesSync, + watch, + watchFile, + writeFile, + writeFileSync, + write: write8, + writeSync, + writev, + writevSync, + Dir, + Dirent, + Stats, + ReadStream, + WriteStream, + FileReadStream, + FileWriteStream, + _toUnixTimestamp, + constants: { F_OK, R_OK, W_OK, X_OK }, + constants: constants2, + promises: promises2 + } = fs); + } + }); + + // ../../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js + var require_eventemitter3 = __commonJS({ + "../../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + var has4 = Object.prototype.hasOwnProperty; + var prefix = "~"; + function Events() { + } + if (Object.create) { + Events.prototype = /* @__PURE__ */ Object.create(null); + if (!new Events().__proto__) + prefix = false; + } + function EE(fn, context2, once2) { + this.fn = fn; + this.context = context2; + this.once = once2 || false; + } + function addListener(emitter, event, fn, context2, once2) { + if (typeof fn !== "function") { + throw new TypeError("The listener must be a function"); + } + var listener = new EE(fn, context2 || emitter, once2), evt = prefix ? prefix + event : event; + if (!emitter._events[evt]) + emitter._events[evt] = listener, emitter._eventsCount++; + else if (!emitter._events[evt].fn) + emitter._events[evt].push(listener); + else + emitter._events[evt] = [emitter._events[evt], listener]; + return emitter; + } + function clearEvent(emitter, evt) { + if (--emitter._eventsCount === 0) + emitter._events = new Events(); + else + delete emitter._events[evt]; + } + function EventEmitter3() { + this._events = new Events(); + this._eventsCount = 0; + } + EventEmitter3.prototype.eventNames = function eventNames() { + var names = [], events, name15; + if (this._eventsCount === 0) + return names; + for (name15 in events = this._events) { + if (has4.call(events, name15)) + names.push(prefix ? name15.slice(1) : name15); + } + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + return names; + }; + EventEmitter3.prototype.listeners = function listeners(event) { + var evt = prefix ? prefix + event : event, handlers = this._events[evt]; + if (!handlers) + return []; + if (handlers.fn) + return [handlers.fn]; + for (var i8 = 0, l8 = handlers.length, ee3 = new Array(l8); i8 < l8; i8++) { + ee3[i8] = handlers[i8].fn; + } + return ee3; + }; + EventEmitter3.prototype.listenerCount = function listenerCount2(event) { + var evt = prefix ? prefix + event : event, listeners = this._events[evt]; + if (!listeners) + return 0; + if (listeners.fn) + return 1; + return listeners.length; + }; + EventEmitter3.prototype.emit = function emit(event, a1, a22, a32, a42, a52) { + var evt = prefix ? prefix + event : event; + if (!this._events[evt]) + return false; + var listeners = this._events[evt], len = arguments.length, args, i8; + if (listeners.fn) { + if (listeners.once) + this.removeListener(event, listeners.fn, void 0, true); + switch (len) { + case 1: + return listeners.fn.call(listeners.context), true; + case 2: + return listeners.fn.call(listeners.context, a1), true; + case 3: + return listeners.fn.call(listeners.context, a1, a22), true; + case 4: + return listeners.fn.call(listeners.context, a1, a22, a32), true; + case 5: + return listeners.fn.call(listeners.context, a1, a22, a32, a42), true; + case 6: + return listeners.fn.call(listeners.context, a1, a22, a32, a42, a52), true; + } + for (i8 = 1, args = new Array(len - 1); i8 < len; i8++) { + args[i8 - 1] = arguments[i8]; + } + listeners.fn.apply(listeners.context, args); + } else { + var length3 = listeners.length, j5; + for (i8 = 0; i8 < length3; i8++) { + if (listeners[i8].once) + this.removeListener(event, listeners[i8].fn, void 0, true); + switch (len) { + case 1: + listeners[i8].fn.call(listeners[i8].context); + break; + case 2: + listeners[i8].fn.call(listeners[i8].context, a1); + break; + case 3: + listeners[i8].fn.call(listeners[i8].context, a1, a22); + break; + case 4: + listeners[i8].fn.call(listeners[i8].context, a1, a22, a32); + break; + default: + if (!args) + for (j5 = 1, args = new Array(len - 1); j5 < len; j5++) { + args[j5 - 1] = arguments[j5]; + } + listeners[i8].fn.apply(listeners[i8].context, args); + } + } + } + return true; + }; + EventEmitter3.prototype.on = function on2(event, fn, context2) { + return addListener(this, event, fn, context2, false); + }; + EventEmitter3.prototype.once = function once2(event, fn, context2) { + return addListener(this, event, fn, context2, true); + }; + EventEmitter3.prototype.removeListener = function removeListener(event, fn, context2, once2) { + var evt = prefix ? prefix + event : event; + if (!this._events[evt]) + return this; + if (!fn) { + clearEvent(this, evt); + return this; + } + var listeners = this._events[evt]; + if (listeners.fn) { + if (listeners.fn === fn && (!once2 || listeners.once) && (!context2 || listeners.context === context2)) { + clearEvent(this, evt); + } + } else { + for (var i8 = 0, events = [], length3 = listeners.length; i8 < length3; i8++) { + if (listeners[i8].fn !== fn || once2 && !listeners[i8].once || context2 && listeners[i8].context !== context2) { + events.push(listeners[i8]); + } + } + if (events.length) + this._events[evt] = events.length === 1 ? events[0] : events; + else + clearEvent(this, evt); + } + return this; + }; + EventEmitter3.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) + clearEvent(this, evt); + } else { + this._events = new Events(); + this._eventsCount = 0; + } + return this; + }; + EventEmitter3.prototype.off = EventEmitter3.prototype.removeListener; + EventEmitter3.prototype.addListener = EventEmitter3.prototype.on; + EventEmitter3.prefixed = prefix; + EventEmitter3.EventEmitter = EventEmitter3; + if ("undefined" !== typeof module3) { + module3.exports = EventEmitter3; + } + } + }); + + // ../../node_modules/.pnpm/pvtsutils@1.3.3/node_modules/pvtsutils/build/index.js + var require_build = __commonJS({ + "../../node_modules/.pnpm/pvtsutils@1.3.3/node_modules/pvtsutils/build/index.js"(exports12) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + var ARRAY_BUFFER_NAME = "[object ArrayBuffer]"; + var BufferSourceConverter8 = class _BufferSourceConverter { + static isArrayBuffer(data) { + return Object.prototype.toString.call(data) === ARRAY_BUFFER_NAME; + } + static toArrayBuffer(data) { + if (this.isArrayBuffer(data)) { + return data; + } + if (data.byteLength === data.buffer.byteLength) { + return data.buffer; + } + if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) { + return data.buffer; + } + return this.toUint8Array(data).slice().buffer; + } + static toUint8Array(data) { + return this.toView(data, Uint8Array); + } + static toView(data, type3) { + if (data instanceof type3) { + return data; + } + if (this.isArrayBuffer(data)) { + return new type3(data); + } + if (this.isArrayBufferView(data)) { + return new type3(data.buffer, data.byteOffset, data.byteLength); + } + throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'"); + } + static isBufferSource(data) { + return this.isArrayBufferView(data) || this.isArrayBuffer(data); + } + static isArrayBufferView(data) { + return ArrayBuffer.isView(data) || data && this.isArrayBuffer(data.buffer); + } + static isEqual(a8, b6) { + const aView = _BufferSourceConverter.toUint8Array(a8); + const bView = _BufferSourceConverter.toUint8Array(b6); + if (aView.length !== bView.byteLength) { + return false; + } + for (let i8 = 0; i8 < aView.length; i8++) { + if (aView[i8] !== bView[i8]) { + return false; + } + } + return true; + } + static concat(...args) { + let buffers; + if (Array.isArray(args[0]) && !(args[1] instanceof Function)) { + buffers = args[0]; + } else if (Array.isArray(args[0]) && args[1] instanceof Function) { + buffers = args[0]; + } else { + if (args[args.length - 1] instanceof Function) { + buffers = args.slice(0, args.length - 1); + } else { + buffers = args; + } + } + let size4 = 0; + for (const buffer4 of buffers) { + size4 += buffer4.byteLength; + } + const res = new Uint8Array(size4); + let offset2 = 0; + for (const buffer4 of buffers) { + const view10 = this.toUint8Array(buffer4); + res.set(view10, offset2); + offset2 += view10.length; + } + if (args[args.length - 1] instanceof Function) { + return this.toView(res, args[args.length - 1]); + } + return res.buffer; + } + }; + var STRING_TYPE = "string"; + var HEX_REGEX = /^[0-9a-f]+$/i; + var BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/; + var BASE64URL_REGEX = /^[a-zA-Z0-9-_]+$/; + var Utf8Converter = class { + static fromString(text3) { + const s7 = unescape(encodeURIComponent(text3)); + const uintArray = new Uint8Array(s7.length); + for (let i8 = 0; i8 < s7.length; i8++) { + uintArray[i8] = s7.charCodeAt(i8); + } + return uintArray.buffer; + } + static toString(buffer4) { + const buf3 = BufferSourceConverter8.toUint8Array(buffer4); + let encodedString = ""; + for (let i8 = 0; i8 < buf3.length; i8++) { + encodedString += String.fromCharCode(buf3[i8]); + } + const decodedString = decodeURIComponent(escape(encodedString)); + return decodedString; + } + }; + var Utf16Converter = class { + static toString(buffer4, littleEndian = false) { + const arrayBuffer = BufferSourceConverter8.toArrayBuffer(buffer4); + const dataView3 = new DataView(arrayBuffer); + let res = ""; + for (let i8 = 0; i8 < arrayBuffer.byteLength; i8 += 2) { + const code15 = dataView3.getUint16(i8, littleEndian); + res += String.fromCharCode(code15); + } + return res; + } + static fromString(text3, littleEndian = false) { + const res = new ArrayBuffer(text3.length * 2); + const dataView3 = new DataView(res); + for (let i8 = 0; i8 < text3.length; i8++) { + dataView3.setUint16(i8 * 2, text3.charCodeAt(i8), littleEndian); + } + return res; + } + }; + var Convert4 = class _Convert { + static isHex(data) { + return typeof data === STRING_TYPE && HEX_REGEX.test(data); + } + static isBase64(data) { + return typeof data === STRING_TYPE && BASE64_REGEX.test(data); + } + static isBase64Url(data) { + return typeof data === STRING_TYPE && BASE64URL_REGEX.test(data); + } + static ToString(buffer4, enc = "utf8") { + const buf3 = BufferSourceConverter8.toUint8Array(buffer4); + switch (enc.toLowerCase()) { + case "utf8": + return this.ToUtf8String(buf3); + case "binary": + return this.ToBinary(buf3); + case "hex": + return this.ToHex(buf3); + case "base64": + return this.ToBase64(buf3); + case "base64url": + return this.ToBase64Url(buf3); + case "utf16le": + return Utf16Converter.toString(buf3, true); + case "utf16": + case "utf16be": + return Utf16Converter.toString(buf3); + default: + throw new Error(`Unknown type of encoding '${enc}'`); + } + } + static FromString(str, enc = "utf8") { + if (!str) { + return new ArrayBuffer(0); + } + switch (enc.toLowerCase()) { + case "utf8": + return this.FromUtf8String(str); + case "binary": + return this.FromBinary(str); + case "hex": + return this.FromHex(str); + case "base64": + return this.FromBase64(str); + case "base64url": + return this.FromBase64Url(str); + case "utf16le": + return Utf16Converter.fromString(str, true); + case "utf16": + case "utf16be": + return Utf16Converter.fromString(str); + default: + throw new Error(`Unknown type of encoding '${enc}'`); + } + } + static ToBase64(buffer4) { + const buf3 = BufferSourceConverter8.toUint8Array(buffer4); + if (typeof btoa !== "undefined") { + const binary = this.ToString(buf3, "binary"); + return btoa(binary); + } else { + return Buffer.from(buf3).toString("base64"); + } + } + static FromBase64(base643) { + const formatted = this.formatString(base643); + if (!formatted) { + return new ArrayBuffer(0); + } + if (!_Convert.isBase64(formatted)) { + throw new TypeError("Argument 'base64Text' is not Base64 encoded"); + } + if (typeof atob !== "undefined") { + return this.FromBinary(atob(formatted)); + } else { + return new Uint8Array(Buffer.from(formatted, "base64")).buffer; + } + } + static FromBase64Url(base64url3) { + const formatted = this.formatString(base64url3); + if (!formatted) { + return new ArrayBuffer(0); + } + if (!_Convert.isBase64Url(formatted)) { + throw new TypeError("Argument 'base64url' is not Base64Url encoded"); + } + return this.FromBase64(this.Base64Padding(formatted.replace(/\-/g, "+").replace(/\_/g, "/"))); + } + static ToBase64Url(data) { + return this.ToBase64(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/\=/g, ""); + } + static FromUtf8String(text3, encoding = _Convert.DEFAULT_UTF8_ENCODING) { + switch (encoding) { + case "ascii": + return this.FromBinary(text3); + case "utf8": + return Utf8Converter.fromString(text3); + case "utf16": + case "utf16be": + return Utf16Converter.fromString(text3); + case "utf16le": + case "usc2": + return Utf16Converter.fromString(text3, true); + default: + throw new Error(`Unknown type of encoding '${encoding}'`); + } + } + static ToUtf8String(buffer4, encoding = _Convert.DEFAULT_UTF8_ENCODING) { + switch (encoding) { + case "ascii": + return this.ToBinary(buffer4); + case "utf8": + return Utf8Converter.toString(buffer4); + case "utf16": + case "utf16be": + return Utf16Converter.toString(buffer4); + case "utf16le": + case "usc2": + return Utf16Converter.toString(buffer4, true); + default: + throw new Error(`Unknown type of encoding '${encoding}'`); + } + } + static FromBinary(text3) { + const stringLength = text3.length; + const resultView = new Uint8Array(stringLength); + for (let i8 = 0; i8 < stringLength; i8++) { + resultView[i8] = text3.charCodeAt(i8); + } + return resultView.buffer; + } + static ToBinary(buffer4) { + const buf3 = BufferSourceConverter8.toUint8Array(buffer4); + let res = ""; + for (let i8 = 0; i8 < buf3.length; i8++) { + res += String.fromCharCode(buf3[i8]); + } + return res; + } + static ToHex(buffer4) { + const buf3 = BufferSourceConverter8.toUint8Array(buffer4); + let result = ""; + const len = buf3.length; + for (let i8 = 0; i8 < len; i8++) { + const byte = buf3[i8]; + if (byte < 16) { + result += "0"; + } + result += byte.toString(16); + } + return result; + } + static FromHex(hexString) { + let formatted = this.formatString(hexString); + if (!formatted) { + return new ArrayBuffer(0); + } + if (!_Convert.isHex(formatted)) { + throw new TypeError("Argument 'hexString' is not HEX encoded"); + } + if (formatted.length % 2) { + formatted = `0${formatted}`; + } + const res = new Uint8Array(formatted.length / 2); + for (let i8 = 0; i8 < formatted.length; i8 = i8 + 2) { + const c8 = formatted.slice(i8, i8 + 2); + res[i8 / 2] = parseInt(c8, 16); + } + return res.buffer; + } + static ToUtf16String(buffer4, littleEndian = false) { + return Utf16Converter.toString(buffer4, littleEndian); + } + static FromUtf16String(text3, littleEndian = false) { + return Utf16Converter.fromString(text3, littleEndian); + } + static Base64Padding(base643) { + const padCount = 4 - base643.length % 4; + if (padCount < 4) { + for (let i8 = 0; i8 < padCount; i8++) { + base643 += "="; + } + } + return base643; + } + static formatString(data) { + return (data === null || data === void 0 ? void 0 : data.replace(/[\n\r\t ]/g, "")) || ""; + } + }; + Convert4.DEFAULT_UTF8_ENCODING = "utf8"; + function assign2(target, ...sources) { + const res = arguments[0]; + for (let i8 = 1; i8 < arguments.length; i8++) { + const obj = arguments[i8]; + for (const prop in obj) { + res[prop] = obj[prop]; + } + } + return res; + } + function combine4(...buf3) { + const totalByteLength = buf3.map((item) => item.byteLength).reduce((prev, cur) => prev + cur); + const res = new Uint8Array(totalByteLength); + let currentPos = 0; + buf3.map((item) => new Uint8Array(item)).forEach((arr) => { + for (const item2 of arr) { + res[currentPos++] = item2; + } + }); + return res.buffer; + } + function isEqual(bytes1, bytes2) { + if (!(bytes1 && bytes2)) { + return false; + } + if (bytes1.byteLength !== bytes2.byteLength) { + return false; + } + const b1 = new Uint8Array(bytes1); + const b22 = new Uint8Array(bytes2); + for (let i8 = 0; i8 < bytes1.byteLength; i8++) { + if (b1[i8] !== b22[i8]) { + return false; + } + } + return true; + } + exports12.BufferSourceConverter = BufferSourceConverter8; + exports12.Convert = Convert4; + exports12.assign = assign2; + exports12.combine = combine4; + exports12.isEqual = isEqual; + } + }); + + // src/version.ts + var PACKAGE_VERSION; + var init_version = __esm({ + "src/version.ts"() { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + PACKAGE_VERSION = "0.11.21"; + } + }); + + // src/store.ts + var match9, STORAGE_VERSION, VersionedStore, MetaStore, DataStore; + var init_store = __esm({ + "src/store.ts"() { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + init_src2(); + init_version(); + match9 = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/); + if (!match9) + throw new Error("invalid version: " + PACKAGE_VERSION); + STORAGE_VERSION = match9[0]; + VersionedStore = class { + constructor(name15) { + __publicField(this, "STORAGE_VERSION", STORAGE_VERSION); + __publicField(this, "name"); + this.name = name15; + } + }; + MetaStore = class extends VersionedStore { + constructor() { + super(...arguments); + __publicField(this, "tag", "header-base"); + } + makeHeader({ car, key }) { + const encoded = format5({ car, key }); + return encoded; + } + parseHeader(headerData) { + const got = parse4(headerData); + return got; + } + }; + DataStore = class { + constructor(loader) { + __publicField(this, "tag", "car-base"); + __publicField(this, "STORAGE_VERSION", STORAGE_VERSION); + __publicField(this, "loader"); + this.loader = loader; + } + }; + } + }); + + // ../../node_modules/.pnpm/idb@7.1.1/node_modules/idb/build/wrap-idb-value.js + function getIdbProxyableTypes() { + return idbProxyableTypes || (idbProxyableTypes = [ + IDBDatabase, + IDBObjectStore, + IDBIndex, + IDBCursor, + IDBTransaction + ]); + } + function getCursorAdvanceMethods() { + return cursorAdvanceMethods || (cursorAdvanceMethods = [ + IDBCursor.prototype.advance, + IDBCursor.prototype.continue, + IDBCursor.prototype.continuePrimaryKey + ]); + } + function promisifyRequest(request) { + const promise = new Promise((resolve7, reject) => { + const unlisten = () => { + request.removeEventListener("success", success); + request.removeEventListener("error", error7); + }; + const success = () => { + resolve7(wrap(request.result)); + unlisten(); + }; + const error7 = () => { + reject(request.error); + unlisten(); + }; + request.addEventListener("success", success); + request.addEventListener("error", error7); + }); + promise.then((value) => { + if (value instanceof IDBCursor) { + cursorRequestMap.set(value, request); + } + }).catch(() => { + }); + reverseTransformCache.set(promise, request); + return promise; + } + function cacheDonePromiseForTransaction(tx) { + if (transactionDoneMap.has(tx)) + return; + const done = new Promise((resolve7, reject) => { + const unlisten = () => { + tx.removeEventListener("complete", complete); + tx.removeEventListener("error", error7); + tx.removeEventListener("abort", error7); + }; + const complete = () => { + resolve7(); + unlisten(); + }; + const error7 = () => { + reject(tx.error || new DOMException("AbortError", "AbortError")); + unlisten(); + }; + tx.addEventListener("complete", complete); + tx.addEventListener("error", error7); + tx.addEventListener("abort", error7); + }); + transactionDoneMap.set(tx, done); + } + function replaceTraps(callback) { + idbProxyTraps = callback(idbProxyTraps); + } + function wrapFunction(func) { + if (func === IDBDatabase.prototype.transaction && !("objectStoreNames" in IDBTransaction.prototype)) { + return function(storeNames, ...args) { + const tx = func.call(unwrap(this), storeNames, ...args); + transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]); + return wrap(tx); + }; + } + if (getCursorAdvanceMethods().includes(func)) { + return function(...args) { + func.apply(unwrap(this), args); + return wrap(cursorRequestMap.get(this)); + }; + } + return function(...args) { + return wrap(func.apply(unwrap(this), args)); + }; + } + function transformCachableValue(value) { + if (typeof value === "function") + return wrapFunction(value); + if (value instanceof IDBTransaction) + cacheDonePromiseForTransaction(value); + if (instanceOfAny(value, getIdbProxyableTypes())) + return new Proxy(value, idbProxyTraps); + return value; + } + function wrap(value) { + if (value instanceof IDBRequest) + return promisifyRequest(value); + if (transformCache.has(value)) + return transformCache.get(value); + const newValue = transformCachableValue(value); + if (newValue !== value) { + transformCache.set(value, newValue); + reverseTransformCache.set(newValue, value); + } + return newValue; + } + var instanceOfAny, idbProxyableTypes, cursorAdvanceMethods, cursorRequestMap, transactionDoneMap, transactionStoreNamesMap, transformCache, reverseTransformCache, idbProxyTraps, unwrap; + var init_wrap_idb_value = __esm({ + "../../node_modules/.pnpm/idb@7.1.1/node_modules/idb/build/wrap-idb-value.js"() { + init_dirname(); + init_buffer2(); + init_process(); + instanceOfAny = (object, constructors) => constructors.some((c8) => object instanceof c8); + cursorRequestMap = /* @__PURE__ */ new WeakMap(); + transactionDoneMap = /* @__PURE__ */ new WeakMap(); + transactionStoreNamesMap = /* @__PURE__ */ new WeakMap(); + transformCache = /* @__PURE__ */ new WeakMap(); + reverseTransformCache = /* @__PURE__ */ new WeakMap(); + idbProxyTraps = { + get(target, prop, receiver) { + if (target instanceof IDBTransaction) { + if (prop === "done") + return transactionDoneMap.get(target); + if (prop === "objectStoreNames") { + return target.objectStoreNames || transactionStoreNamesMap.get(target); + } + if (prop === "store") { + return receiver.objectStoreNames[1] ? void 0 : receiver.objectStore(receiver.objectStoreNames[0]); + } + } + return wrap(target[prop]); + }, + set(target, prop, value) { + target[prop] = value; + return true; + }, + has(target, prop) { + if (target instanceof IDBTransaction && (prop === "done" || prop === "store")) { + return true; + } + return prop in target; + } + }; + unwrap = (value) => reverseTransformCache.get(value); + } + }); + + // ../../node_modules/.pnpm/idb@7.1.1/node_modules/idb/build/index.js + function openDB(name15, version3, { blocked, upgrade, blocking, terminated } = {}) { + const request = indexedDB.open(name15, version3); + const openPromise = wrap(request); + if (upgrade) { + request.addEventListener("upgradeneeded", (event) => { + upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event); + }); + } + if (blocked) { + request.addEventListener("blocked", (event) => blocked( + // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405 + event.oldVersion, + event.newVersion, + event + )); + } + openPromise.then((db) => { + if (terminated) + db.addEventListener("close", () => terminated()); + if (blocking) { + db.addEventListener("versionchange", (event) => blocking(event.oldVersion, event.newVersion, event)); + } + }).catch(() => { + }); + return openPromise; + } + function getMethod(target, prop) { + if (!(target instanceof IDBDatabase && !(prop in target) && typeof prop === "string")) { + return; + } + if (cachedMethods.get(prop)) + return cachedMethods.get(prop); + const targetFuncName = prop.replace(/FromIndex$/, ""); + const useIndex = prop !== targetFuncName; + const isWrite = writeMethods.includes(targetFuncName); + if ( + // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge. + !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) || !(isWrite || readMethods.includes(targetFuncName)) + ) { + return; + } + const method = async function(storeName, ...args) { + const tx = this.transaction(storeName, isWrite ? "readwrite" : "readonly"); + let target2 = tx.store; + if (useIndex) + target2 = target2.index(args.shift()); + return (await Promise.all([ + target2[targetFuncName](...args), + isWrite && tx.done + ]))[0]; + }; + cachedMethods.set(prop, method); + return method; + } + var readMethods, writeMethods, cachedMethods; + var init_build = __esm({ + "../../node_modules/.pnpm/idb@7.1.1/node_modules/idb/build/index.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_wrap_idb_value(); + init_wrap_idb_value(); + readMethods = ["get", "getKey", "getAll", "getAllKeys", "count"]; + writeMethods = ["put", "add", "delete", "clear"]; + cachedMethods = /* @__PURE__ */ new Map(); + replaceTraps((oldTraps) => ({ + ...oldTraps, + get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver), + has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop) + })); + } + }); + + // src/store-browser.ts + var store_browser_exports = {}; + __export(store_browser_exports, { + DataStore: () => DataStore2, + MetaStore: () => MetaStore2 + }); + var DataStore2, MetaStore2; + var init_store_browser = __esm({ + "src/store-browser.ts"() { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + init_build(); + init_store(); + DataStore2 = class extends DataStore { + constructor() { + super(...arguments); + __publicField(this, "tag", "car-browser-idb"); + __publicField(this, "idb", null); + } + async _withDB(dbWorkFun) { + if (!this.idb) { + const dbName = `fp.${this.STORAGE_VERSION}.${this.loader.keyId}.${this.loader.name}`; + this.idb = await openDB(dbName, 1, { + upgrade(db) { + db.createObjectStore("cars"); + } + }); + } + return await dbWorkFun(this.idb); + } + async load(cid) { + return await this._withDB(async (db) => { + const tx = db.transaction(["cars"], "readonly"); + const bytes2 = await tx.objectStore("cars").get(cid.toString()); + if (!bytes2) + throw new Error(`missing idb block ${cid.toString()}`); + return { cid, bytes: bytes2 }; + }); + } + async save(car) { + return await this._withDB(async (db) => { + const tx = db.transaction(["cars"], "readwrite"); + await tx.objectStore("cars").put(car.bytes, car.cid.toString()); + return await tx.done; + }); + } + async remove(cid) { + return await this._withDB(async (db) => { + const tx = db.transaction(["cars"], "readwrite"); + await tx.objectStore("cars").delete(cid.toString()); + return await tx.done; + }); + } + }; + MetaStore2 = class extends MetaStore { + constructor() { + super(...arguments); + __publicField(this, "tag", "header-browser-ls"); + } + headerKey(branch) { + return `fp.${this.STORAGE_VERSION}.public.${this.name}.${branch}`; + } + // eslint-disable-next-line @typescript-eslint/require-await + async load(branch = "main") { + try { + const bytesString = localStorage.getItem(this.headerKey(branch)); + if (!bytesString) + return null; + return this.parseHeader(bytesString); + } catch (e12) { + return null; + } + } + // eslint-disable-next-line @typescript-eslint/require-await + async save(meta, branch = "main") { + try { + const headerKey = this.headerKey(branch); + const bytes2 = this.makeHeader(meta); + return localStorage.setItem(headerKey, bytes2); + } catch (e12) { + } + } + }; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/process.js + function Item(fun, array3) { + this.fun = fun; + this.array = array3; + } + function uptime() { + return _performance.now() / 1e3; + } + function hrtime(previousTimestamp) { + var baseNow = Math.floor((Date.now() - _performance.now()) * 1e-3); + var clocktime = _performance.now() * 1e-3; + var seconds = Math.floor(clocktime) + baseNow; + var nanoseconds = Math.floor(clocktime % 1 * 1e9); + if (previousTimestamp) { + seconds = seconds - previousTimestamp[0]; + nanoseconds = nanoseconds - previousTimestamp[1]; + if (nanoseconds < 0) { + seconds--; + nanoseconds += nanoPerSec; + } + } + return [seconds, nanoseconds]; + } + var env, _performance, nowOffset, nanoPerSec; + var init_process2 = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/process.js"() { + init_dirname(); + init_buffer2(); + init_process(); + Item.prototype.run = function() { + this.fun.apply(null, this.array); + }; + env = { + PATH: "/usr/bin", + LANG: navigator.language + ".UTF-8", + PWD: "/", + HOME: "/home", + TMP: "/tmp" + }; + _performance = { + now: typeof performance !== "undefined" ? performance.now.bind(performance) : void 0, + timing: typeof performance !== "undefined" ? performance.timing : void 0 + }; + if (_performance.now === void 0) { + nowOffset = Date.now(); + if (_performance.timing && _performance.timing.navigationStart) { + nowOffset = _performance.timing.navigationStart; + } + _performance.now = () => Date.now() - nowOffset; + } + nanoPerSec = 1e9; + hrtime.bigint = function(time) { + var diff = hrtime(time); + if (typeof BigInt === "undefined") { + return diff[0] * nanoPerSec + diff[1]; + } + return BigInt(diff[0] * nanoPerSec) + BigInt(diff[1]); + }; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/os.js + function dew10() { + if (_dewExec10) + return exports$114; + _dewExec10 = true; + exports$114.endianness = function() { + return "LE"; + }; + exports$114.hostname = function() { + if (typeof location !== "undefined") { + return location.hostname; + } else + return ""; + }; + exports$114.loadavg = function() { + return []; + }; + exports$114.uptime = function() { + return 0; + }; + exports$114.freemem = function() { + return Number.MAX_VALUE; + }; + exports$114.totalmem = function() { + return Number.MAX_VALUE; + }; + exports$114.cpus = function() { + return []; + }; + exports$114.type = function() { + return "Browser"; + }; + exports$114.release = function() { + if (typeof navigator !== "undefined") { + return navigator.appVersion; + } + return ""; + }; + exports$114.networkInterfaces = exports$114.getNetworkInterfaces = function() { + return {}; + }; + exports$114.arch = function() { + return "javascript"; + }; + exports$114.platform = function() { + return "browser"; + }; + exports$114.tmpdir = exports$114.tmpDir = function() { + return "/tmp"; + }; + exports$114.EOL = "\n"; + exports$114.homedir = function() { + return "/"; + }; + return exports$114; + } + var exports$114, _dewExec10, exports11, _endianness, version2, constants3, EOL, arch, cpus, endianness, freemem, getNetworkInterfaces, homedir, hostname, loadavg, networkInterfaces, platform, release, tmpDir, tmpdir, totalmem, type2; + var init_os = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/os.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_process2(); + init_process2(); + exports$114 = {}; + _dewExec10 = false; + exports11 = dew10(); + exports11["endianness"]; + exports11["hostname"]; + exports11["loadavg"]; + exports11["uptime"]; + exports11["freemem"]; + exports11["totalmem"]; + exports11["cpus"]; + exports11["type"]; + exports11["release"]; + exports11["networkInterfaces"]; + exports11["getNetworkInterfaces"]; + exports11["arch"]; + exports11["platform"]; + exports11["tmpdir"]; + exports11["tmpDir"]; + exports11["EOL"]; + exports11["homedir"]; + _endianness = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1 ? "LE" : "BE"; + exports11.endianness = function() { + return _endianness; + }; + exports11.homedir = function() { + return "/home"; + }; + exports11.version = function() { + return ""; + }; + exports11.arch = function() { + return "x64"; + }; + exports11.totalmem = function() { + return navigator.deviceMemory !== void 0 ? navigator.deviceMemory * (1 << 30) : 2 * (1 << 30); + }; + exports11.cpus = function() { + return Array(navigator.hardwareConcurrency || 0).fill({ model: "", times: {} }); + }; + exports11.uptime = uptime; + exports11.constants = {}; + version2 = exports11.version; + constants3 = exports11.constants; + EOL = exports11.EOL; + arch = exports11.arch; + cpus = exports11.cpus; + endianness = exports11.endianness; + freemem = exports11.freemem; + getNetworkInterfaces = exports11.getNetworkInterfaces; + homedir = exports11.homedir; + hostname = exports11.hostname; + loadavg = exports11.loadavg; + networkInterfaces = exports11.networkInterfaces; + platform = exports11.platform; + release = exports11.release; + tmpDir = exports11.tmpDir; + tmpdir = exports11.tmpdir; + totalmem = exports11.totalmem; + type2 = exports11.type; + } + }); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/fs/promises.js + var access4, copyFile2, cp2, open6, opendir2, rename2, truncate2, rm2, rmdir2, mkdir2, readdir2, readlink2, symlink2, lstat2, stat2, link9, unlink2, chmod2, lchmod2, lchown2, chown2, utimes2, realpath2, mkdtemp2, writeFile2, appendFile2, readFile2, watch2; + var init_promises = __esm({ + "../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/fs/promises.js"() { + init_dirname(); + init_buffer2(); + init_process(); + init_fs(); + init_fs(); + init_chunk_44e51b61(); + init_chunk_4bd36a8f(); + init_chunk_ce0fbc82(); + init_chunk_b4205b57(); + init_chunk_5decc758(); + init_chunk_2eac56ff(); + init_chunk_4ccc3a29(); + init_assert(); + init_util(); + init_path(); + init_chunk_23dbec7b(); + init_events(); + init_stream(); + init_chunk_6c718bbe(); + init_url(); + init_chunk_924bb2e1(); + init_chunk_b04e620d(); + init_buffer(); + ({ + access: access4, + copyFile: copyFile2, + cp: cp2, + open: open6, + opendir: opendir2, + rename: rename2, + truncate: truncate2, + rm: rm2, + rmdir: rmdir2, + mkdir: mkdir2, + readdir: readdir2, + readlink: readlink2, + symlink: symlink2, + lstat: lstat2, + stat: stat2, + link: link9, + unlink: unlink2, + chmod: chmod2, + lchmod: lchmod2, + lchown: lchown2, + chown: chown2, + utimes: utimes2, + realpath: realpath2, + mkdtemp: mkdtemp2, + writeFile: writeFile2, + appendFile: appendFile2, + readFile: readFile2, + watch: watch2 + } = promises2); + } + }); + + // src/store-fs.ts + var store_fs_exports = {}; + __export(store_fs_exports, { + DataStore: () => DataStore3, + MetaStore: () => MetaStore3, + testConfig: () => testConfig + }); + async function writePathFile(path2, data) { + await mkdir2(dirname(path2), { recursive: true }); + return await writeFile2(path2, data); + } + var _MetaStore, MetaStore3, testConfig, _DataStore, DataStore3; + var init_store_fs = __esm({ + "src/store-fs.ts"() { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + init_path(); + init_os(); + init_promises(); + init_store(); + _MetaStore = class _MetaStore extends MetaStore { + constructor() { + super(...arguments); + __publicField(this, "tag", "header-node-fs"); + } + filePathForBranch(branch) { + return join2(_MetaStore.dataDir, this.name, "meta", branch + ".json"); + } + async load(branch = "main") { + const filepath = this.filePathForBranch(branch); + const bytes2 = await readFile2(filepath).catch((e12) => { + if (e12.code === "ENOENT") + return null; + throw e12; + }); + return bytes2 ? this.parseHeader(bytes2.toString()) : null; + } + async save(meta, branch = "main") { + const filepath = this.filePathForBranch(branch); + const bytes2 = this.makeHeader(meta); + await writePathFile(filepath, bytes2); + } + }; + __publicField(_MetaStore, "dataDir", join2(homedir(), ".fireproof", "v" + STORAGE_VERSION)); + MetaStore3 = _MetaStore; + testConfig = { + dataDir: MetaStore3.dataDir + }; + _DataStore = class _DataStore extends DataStore { + constructor() { + super(...arguments); + __publicField(this, "tag", "car-node-fs"); + } + async save(car) { + const filepath = this.cidPath(car.cid); + await writePathFile(filepath, car.bytes); + } + cidPath(cid) { + return join2(_DataStore.dataDir, this.loader.name, "data", cid.toString() + ".car"); + } + async load(cid) { + const filepath = this.cidPath(cid); + const bytes2 = await readFile2(filepath); + return { cid, bytes: new Uint8Array(bytes2) }; + } + async remove(cid) { + const filepath = this.cidPath(cid); + await unlink2(filepath); + } + }; + __publicField(_DataStore, "dataDir", join2(homedir(), ".fireproof", "v" + STORAGE_VERSION)); + DataStore3 = _DataStore; + } + }); + + // ../../node_modules/.pnpm/charwise@3.0.1/node_modules/charwise/codec/number.js + var require_number = __commonJS({ + "../../node_modules/.pnpm/charwise@3.0.1/node_modules/charwise/codec/number.js"(exports12) { + init_dirname(); + init_buffer2(); + init_process(); + exports12.encode = function(number3) { + if (isNaN(number3)) { + return "DaN"; + } + if (number3 === 0) { + return "FE 0M0"; + } + if (number3 === Infinity) { + return "FF"; + } + if (number3 === -Infinity) { + return "DD"; + } + var splitScientificNotation = number3.toExponential().split("e"); + var exponent = Number(splitScientificNotation[1]) + 500; + var mantissa = splitScientificNotation[0] + (splitScientificNotation[0].indexOf(".") === -1 ? "." : "") + "0".repeat(20); + var encoded = "E" + padStart(String(exponent), 3) + "M" + String(mantissa); + if (number3 > 0) { + return "F" + encoded; + } else { + return "D" + flip(encoded); + } + }; + exports12.decode = function(encoded) { + if (encoded === "DaN") { + return NaN; + } + if (encoded === "FF") { + return Infinity; + } + if (encoded === "DD") { + return -Infinity; + } + var isNegative = encoded[0] === "D"; + var splitEncoded = (isNegative ? flip(encoded) : encoded).slice(2).split("M"); + return Number((isNegative ? "-" : "") + splitEncoded[1] + "e" + String(Number(splitEncoded[0]) - 500)); + }; + function flip(number3) { + var flipped = ""; + for (var i8 = 0; i8 < number3.length; i8++) { + var digit = number3[i8]; + if (isNaN(Number(digit)) || digit === " ") { + if (digit !== "-") { + flipped += digit; + } + } else { + flipped += String(9 - Number(digit)); + } + } + return flipped; + } + function padStart(str, count) { + return " ".repeat(count - str.length).substr(0, count) + str; + } + } + }); + + // ../../node_modules/.pnpm/charwise@3.0.1/node_modules/charwise/codec/object.js + var require_object = __commonJS({ + "../../node_modules/.pnpm/charwise@3.0.1/node_modules/charwise/codec/object.js"(exports12) { + init_dirname(); + init_buffer2(); + init_process(); + var dictEscape = { "?": "?@", "!": "??", '"': "?%" }; + function escape2(str) { + if (!/[!"]/.test(str)) { + return str; + } + return str.replace(/[\?!"]/g, function(match10) { + return dictEscape[match10]; + }); + } + var dictUnescape = { "?@": "?", "??": "!", "?%": '"' }; + function unescape2(str) { + if (!/\?[%\?@]/.test(str)) { + return str; + } + return str.replace(/\?[%\?@]/g, function(match10) { + return dictUnescape[match10]; + }); + } + exports12.factory = function(codec) { + return { + encode: encode41, + decode: decode46 + }; + function encode41(array3) { + if (array3 === null) { + return "A"; + } + if (!Array.isArray(array3)) { + throw new Error("can only encode arrays"); + } + var l8 = array3.length; + if (l8 == 0) { + return "K!"; + } + var s7 = encodeItem(array3[0]); + for (var i8 = 1; i8 < l8; i8++) { + s7 += '"' + encodeItem(array3[i8]); + } + return "K" + s7 + "!"; + } + function encodeItem(item) { + if (typeof item === "object") { + return encode41(item); + } + return escape2(codec.encode(item)); + } + function decode46(encoded) { + if (encoded === "A") { + return null; + } + if (encoded === "K!") { + return []; + } + var items = encoded.split('"'); + var pointers = [[]]; + var array3; + var depth = 0; + var l8 = items.length; + for (var i8 = 0; i8 < l8; i8++) { + var item = items[i8]; + var itemLength = item.length; + var open7 = 0; + while (item[open7] == "K") { + open7++; + } + var close10 = 0; + while (item[itemLength - close10 - 1] == "!") { + close10++; + } + var content = item.slice(open7, itemLength - close10); + var newdepth = depth + open7; + for (var j5 = depth; j5 < newdepth; j5++) { + pointers[j5 + 1] = []; + pointers[j5].push(pointers[j5 + 1]); + depth = newdepth; + array3 = pointers[depth]; + } + if (content.length !== 0) { + array3.push(codec.decode(unescape2(content))); + } + var newdepth = depth - close10; + for (var j5 = newdepth; j5 < depth; j5++) { + pointers[j5 + 1] = []; + depth = newdepth; + array3 = pointers[depth]; + } + } + return pointers[0][0]; + } + }; + } + }); + + // ../../node_modules/.pnpm/charwise@3.0.1/node_modules/charwise/index.js + var require_charwise = __commonJS({ + "../../node_modules/.pnpm/charwise@3.0.1/node_modules/charwise/index.js"(exports12) { + init_dirname(); + init_buffer2(); + init_process(); + var number3 = require_number(); + var object = require_object(); + var flip = exports12.flip = function(n9) { + var s7 = n9.toString(); + var f9 = ""; + for (var i8 in s7) { + f9 += s7[i8] == "." ? "." : 9 - +s7[i8]; + } + return f9; + }; + exports12.number = number3; + exports12.string = { + encode: function(s7) { + if (!/\x00|\x01/.test(s7)) + return "J" + s7; + else { + return "J" + s7.replace(/\x01/g, "").replace(/\x00/g, ""); + } + }, + decode: function(s7) { + if ("J" === s7[0]) + return s7.substring(1); + } + }; + exports12.encode = function(t9) { + return exports12[typeof t9].encode(t9); + }; + exports12.decode = function(s7) { + if (s7 === "") + return s7; + if (!decoders[s7[0]]) + throw new Error("no decoder for:" + JSON.stringify(s7)); + return decoders[s7[0]](s7); + }; + exports12.object = object.factory(exports12); + exports12.boolean = { + encode: function(b6) { + return b6 ? "C" : "B"; + }, + decode: function(b6) { + return "C" === b6; + } + }; + exports12.undefined = { + encode: function(b6) { + return "L"; + }, + decode: function() { + return void 0; + } + }; + var decoders = { + A: exports12.object.decode, + //null + B: exports12.boolean.decode, + // false + C: exports12.boolean.decode, + // true + D: exports12.number.decode, + // number + F: exports12.number.decode, + // number + // G Date + // H Date + // I Buffer + J: exports12.string.decode, + // String + K: exports12.object.decode, + // Array + L: exports12.undefined.decode + // undefined + }; + exports12.buffer = false; + exports12.type = "charwise"; + } + }); + + // ../../node_modules/.pnpm/err-code@3.0.1/node_modules/err-code/index.js + var require_err_code = __commonJS({ + "../../node_modules/.pnpm/err-code@3.0.1/node_modules/err-code/index.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + function assign2(obj, props) { + for (const key in props) { + Object.defineProperty(obj, key, { + value: props[key], + enumerable: true, + configurable: true + }); + } + return obj; + } + function createError(err, code15, props) { + if (!err || typeof err === "string") { + throw new TypeError("Please pass an Error to err-code"); + } + if (!props) { + props = {}; + } + if (typeof code15 === "object") { + props = code15; + code15 = ""; + } + if (code15) { + props.code = code15; + } + try { + return assign2(err, props); + } catch (_5) { + props.message = err.message; + props.stack = err.stack; + const ErrClass = function() { + }; + ErrClass.prototype = Object.create(Object.getPrototypeOf(err)); + const output = assign2(new ErrClass(), props); + return output; + } + } + module3.exports = createError; + } + }); + + // ../../node_modules/.pnpm/sparse-array@1.3.2/node_modules/sparse-array/index.js + var require_sparse_array = __commonJS({ + "../../node_modules/.pnpm/sparse-array@1.3.2/node_modules/sparse-array/index.js"(exports12, module3) { + "use strict"; + init_dirname(); + init_buffer2(); + init_process(); + var BITS_PER_BYTE = 7; + module3.exports = class SparseArray { + constructor() { + this._bitArrays = []; + this._data = []; + this._length = 0; + this._changedLength = false; + this._changedData = false; + } + set(index2, value) { + let pos = this._internalPositionFor(index2, false); + if (value === void 0) { + if (pos !== -1) { + this._unsetInternalPos(pos); + this._unsetBit(index2); + this._changedLength = true; + this._changedData = true; + } + } else { + let needsSort = false; + if (pos === -1) { + pos = this._data.length; + this._setBit(index2); + this._changedData = true; + } else { + needsSort = true; + } + this._setInternalPos(pos, index2, value, needsSort); + this._changedLength = true; + } + } + unset(index2) { + this.set(index2, void 0); + } + get(index2) { + this._sortData(); + const pos = this._internalPositionFor(index2, true); + if (pos === -1) { + return void 0; + } + return this._data[pos][1]; + } + push(value) { + this.set(this.length, value); + return this.length; + } + get length() { + this._sortData(); + if (this._changedLength) { + const last2 = this._data[this._data.length - 1]; + this._length = last2 ? last2[0] + 1 : 0; + this._changedLength = false; + } + return this._length; + } + forEach(iterator) { + let i8 = 0; + while (i8 < this.length) { + iterator(this.get(i8), i8, this); + i8++; + } + } + map(iterator) { + let i8 = 0; + let mapped = new Array(this.length); + while (i8 < this.length) { + mapped[i8] = iterator(this.get(i8), i8, this); + i8++; + } + return mapped; + } + reduce(reducer, initialValue) { + let i8 = 0; + let acc = initialValue; + while (i8 < this.length) { + const value = this.get(i8); + acc = reducer(acc, value, i8); + i8++; + } + return acc; + } + find(finder) { + let i8 = 0, found, last2; + while (i8 < this.length && !found) { + last2 = this.get(i8); + found = finder(last2); + i8++; + } + return found ? last2 : void 0; + } + _internalPositionFor(index2, noCreate) { + const bytePos = this._bytePosFor(index2, noCreate); + if (bytePos >= this._bitArrays.length) { + return -1; + } + const byte = this._bitArrays[bytePos]; + const bitPos = index2 - bytePos * BITS_PER_BYTE; + const exists3 = (byte & 1 << bitPos) > 0; + if (!exists3) { + return -1; + } + const previousPopCount = this._bitArrays.slice(0, bytePos).reduce(popCountReduce, 0); + const mask2 = ~(4294967295 << bitPos + 1); + const bytePopCount = popCount(byte & mask2); + const arrayPos = previousPopCount + bytePopCount - 1; + return arrayPos; + } + _bytePosFor(index2, noCreate) { + const bytePos = Math.floor(index2 / BITS_PER_BYTE); + const targetLength = bytePos + 1; + while (!noCreate && this._bitArrays.length < targetLength) { + this._bitArrays.push(0); + } + return bytePos; + } + _setBit(index2) { + const bytePos = this._bytePosFor(index2, false); + this._bitArrays[bytePos] |= 1 << index2 - bytePos * BITS_PER_BYTE; + } + _unsetBit(index2) { + const bytePos = this._bytePosFor(index2, false); + this._bitArrays[bytePos] &= ~(1 << index2 - bytePos * BITS_PER_BYTE); + } + _setInternalPos(pos, index2, value, needsSort) { + const data = this._data; + const elem = [index2, value]; + if (needsSort) { + this._sortData(); + data[pos] = elem; + } else { + if (data.length) { + if (data[data.length - 1][0] >= index2) { + data.push(elem); + } else if (data[0][0] <= index2) { + data.unshift(elem); + } else { + const randomIndex = Math.round(data.length / 2); + this._data = data.slice(0, randomIndex).concat(elem).concat(data.slice(randomIndex)); + } + } else { + this._data.push(elem); + } + this._changedData = true; + this._changedLength = true; + } + } + _unsetInternalPos(pos) { + this._data.splice(pos, 1); + } + _sortData() { + if (this._changedData) { + this._data.sort(sortInternal); + } + this._changedData = false; + } + bitField() { + const bytes2 = []; + let pendingBitsForResultingByte = 8; + let pendingBitsForNewByte = 0; + let resultingByte = 0; + let newByte; + const pending = this._bitArrays.slice(); + while (pending.length || pendingBitsForNewByte) { + if (pendingBitsForNewByte === 0) { + newByte = pending.shift(); + pendingBitsForNewByte = 7; + } + const usingBits = Math.min(pendingBitsForNewByte, pendingBitsForResultingByte); + const mask2 = ~(255 << usingBits); + const masked = newByte & mask2; + resultingByte |= masked << 8 - pendingBitsForResultingByte; + newByte = newByte >>> usingBits; + pendingBitsForNewByte -= usingBits; + pendingBitsForResultingByte -= usingBits; + if (!pendingBitsForResultingByte || !pendingBitsForNewByte && !pending.length) { + bytes2.push(resultingByte); + resultingByte = 0; + pendingBitsForResultingByte = 8; + } + } + for (var i8 = bytes2.length - 1; i8 > 0; i8--) { + const value = bytes2[i8]; + if (value === 0) { + bytes2.pop(); + } else { + break; + } + } + return bytes2; + } + compactArray() { + this._sortData(); + return this._data.map(valueOnly); + } + }; + function popCountReduce(count, byte) { + return count + popCount(byte); + } + function popCount(_v) { + let v7 = _v; + v7 = v7 - (v7 >> 1 & 1431655765); + v7 = (v7 & 858993459) + (v7 >> 2 & 858993459); + return (v7 + (v7 >> 4) & 252645135) * 16843009 >> 24; + } + function sortInternal(a8, b6) { + return a8[0] - b6[0]; + } + function valueOnly(elem) { + return elem[1]; + } + } + }); + + // src/fireproof.ts + var fireproof_exports = {}; + __export(fireproof_exports, { + Database: () => Database, + Index: () => Index, + connect: () => connect4, + fireproof: () => fireproof, + index: () => index + }); + init_dirname(); + init_buffer2(); + init_process(); + + // src/connect.ts + init_dirname(); + init_buffer2(); + init_process(); + + // src/connect-s3.ts + init_dirname(); + init_buffer2(); + init_process(); + var import_cross_fetch = __toESM(require_browser_ponyfill(), 1); + var ConnectS3 = class { + constructor(upload4, download) { + __publicField(this, "uploadUrl"); + __publicField(this, "downloadUrl"); + __publicField(this, "ready", Promise.resolve()); + this.uploadUrl = new URL(upload4); + this.downloadUrl = new URL(download); + } + async upload(bytes2, params) { + validateParams(params); + console.log("s3 uploading", params); + const fetchUploadUrl = new URL(`${this.uploadUrl.toString()}?${new URLSearchParams(params).toString()}`); + const response = await (0, import_cross_fetch.default)(fetchUploadUrl); + const { uploadURL } = await response.json(); + await (0, import_cross_fetch.default)(uploadURL, { method: "PUT", body: bytes2 }); + } + async download(params) { + validateParams(params); + console.log("s3 downloading", params); + const { type: type3, name: name15, car, branch } = params; + const fetchFromUrl = new URL(`${type3}/${name15}/${type3 === "meta" ? branch + ".json?cache=" + Math.floor(Math.random() * 1e6) : car + ".car"}`, this.downloadUrl); + const response = await (0, import_cross_fetch.default)(fetchFromUrl); + const bytes2 = new Uint8Array(await response.arrayBuffer()); + return bytes2; + } + }; + + // src/connect-web3.ts + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/agent.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+client@8.0.0/node_modules/@ucanto/client/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+client@8.0.0/node_modules/@ucanto/client/src/connection.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+interface@8.0.0/node_modules/@ucanto/interface/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/delegation.js + var delegation_exports = {}; + __export(delegation_exports, { + ArchiveSchema: () => ArchiveSchema, + Delegation: () => Delegation, + View: () => Delegation, + allows: () => allows, + archive: () => archive, + create: () => create5, + delegate: () => delegate, + exportDAG: () => exportDAG, + extract: () => extract, + importDAG: () => importDAG, + isDelegation: () => isDelegation, + isLink: () => isLink2, + view: () => view2 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/ucan.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/codec/cbor.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+dag-cbor@9.0.4/node_modules/@ipld/dag-cbor/src/index.js + var src_exports = {}; + __export(src_exports, { + code: () => code, + decode: () => decode6, + encode: () => encode4, + name: () => name2 + }); + init_dirname(); + init_buffer2(); + init_process(); + init_cborg(); + init_cid(); + var CID_CBOR_TAG = 42; + function cidEncoder(obj) { + if (obj.asCID !== obj && obj["/"] !== obj.bytes) { + return null; + } + const cid = CID.asCID(obj); + if (!cid) { + return null; + } + const bytes2 = new Uint8Array(cid.bytes.byteLength + 1); + bytes2.set(cid.bytes, 1); + return [ + new Token(Type.tag, CID_CBOR_TAG), + new Token(Type.bytes, bytes2) + ]; + } + function undefinedEncoder() { + throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded"); + } + function numberEncoder(num) { + if (Number.isNaN(num)) { + throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded"); + } + if (num === Infinity || num === -Infinity) { + throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded"); + } + return null; + } + var encodeOptions = { + float64: true, + typeEncoders: { + Object: cidEncoder, + undefined: undefinedEncoder, + number: numberEncoder + } + }; + function cidDecoder(bytes2) { + if (bytes2[0] !== 0) { + throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00"); + } + return CID.decode(bytes2.subarray(1)); + } + var decodeOptions = { + allowIndefinite: false, + coerceUndefinedToNull: true, + allowNaN: false, + allowInfinity: false, + allowBigInt: true, + // this will lead to BigInt for ints outside of + // safe-integer range, which may surprise users + strict: true, + useMaps: false, + rejectDuplicateMapKeys: true, + /** @type {import('cborg').TagDecoder[]} */ + tags: [] + }; + decodeOptions.tags[CID_CBOR_TAG] = cidDecoder; + var name2 = "dag-cbor"; + var code = 113; + var encode4 = (node) => encode(node, encodeOptions); + var decode6 = (data) => decode(data, decodeOptions); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/schema.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/utf8.js + init_dirname(); + init_buffer2(); + init_process(); + var encoder = new TextEncoder(); + var decoder = new TextDecoder(); + var encode5 = (text3) => encoder.encode(text3); + var decode7 = (bytes2) => decoder.decode(bytes2); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/link.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/link/interface.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/cid.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/varint.js + var varint_exports2 = {}; + __export(varint_exports2, { + decode: () => decode9, + encodeTo: () => encodeTo2, + encodingLength: () => encodingLength2 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/vendor/varint.js + init_dirname(); + init_buffer2(); + init_process(); + var encode_12 = encode6; + var MSB2 = 128; + var REST2 = 127; + var MSBALL2 = ~REST2; + var INT2 = Math.pow(2, 31); + function encode6(num, out, offset2) { + out = out || []; + offset2 = offset2 || 0; + var oldOffset = offset2; + while (num >= INT2) { + out[offset2++] = num & 255 | MSB2; + num /= 128; + } + while (num & MSBALL2) { + out[offset2++] = num & 255 | MSB2; + num >>>= 7; + } + out[offset2] = num | 0; + encode6.bytes = offset2 - oldOffset + 1; + return out; + } + var decode8 = read2; + var MSB$12 = 128; + var REST$12 = 127; + function read2(buf3, offset2) { + var res = 0, offset2 = offset2 || 0, shift = 0, counter = offset2, b6, l8 = buf3.length; + do { + if (counter >= l8) { + read2.bytes = 0; + throw new RangeError("Could not decode varint"); + } + b6 = buf3[counter++]; + res += shift < 28 ? (b6 & REST$12) << shift : (b6 & REST$12) * Math.pow(2, shift); + shift += 7; + } while (b6 >= MSB$12); + read2.bytes = counter - offset2; + return res; + } + var N12 = Math.pow(2, 7); + var N22 = Math.pow(2, 14); + var N32 = Math.pow(2, 21); + var N42 = Math.pow(2, 28); + var N52 = Math.pow(2, 35); + var N62 = Math.pow(2, 42); + var N72 = Math.pow(2, 49); + var N82 = Math.pow(2, 56); + var N92 = Math.pow(2, 63); + var length2 = function(value) { + return value < N12 ? 1 : value < N22 ? 2 : value < N32 ? 3 : value < N42 ? 4 : value < N52 ? 5 : value < N62 ? 6 : value < N72 ? 7 : value < N82 ? 8 : value < N92 ? 9 : 10; + }; + var varint2 = { + encode: encode_12, + decode: decode8, + encodingLength: length2 + }; + var _brrp_varint2 = varint2; + var varint_default2 = _brrp_varint2; + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/varint.js + var decode9 = (data, offset2 = 0) => { + const code15 = varint_default2.decode(data, offset2); + return [code15, varint_default2.decode.bytes]; + }; + var encodeTo2 = (int, target, offset2 = 0) => { + varint_default2.encode(int, target, offset2); + return target; + }; + var encodingLength2 = (int) => { + return varint_default2.encodingLength(int); + }; + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/hashes/digest.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bytes.js + init_dirname(); + init_buffer2(); + init_process(); + var empty2 = new Uint8Array(0); + var equals3 = (aa, bb) => { + if (aa === bb) + return true; + if (aa.byteLength !== bb.byteLength) { + return false; + } + for (let ii = 0; ii < aa.byteLength; ii++) { + if (aa[ii] !== bb[ii]) { + return false; + } + } + return true; + }; + var coerce2 = (o9) => { + if (o9 instanceof Uint8Array && o9.constructor.name === "Uint8Array") + return o9; + if (o9 instanceof ArrayBuffer) + return new Uint8Array(o9); + if (ArrayBuffer.isView(o9)) { + return new Uint8Array(o9.buffer, o9.byteOffset, o9.byteLength); + } + throw new Error("Unknown type, must be binary type"); + }; + var fromString3 = (str) => new TextEncoder().encode(str); + var toString3 = (b6) => new TextDecoder().decode(b6); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/hashes/digest.js + var create2 = (code15, digest3) => { + const size4 = digest3.byteLength; + const sizeOffset = encodingLength2(code15); + const digestOffset = sizeOffset + encodingLength2(size4); + const bytes2 = new Uint8Array(digestOffset + size4); + encodeTo2(code15, bytes2, 0); + encodeTo2(size4, bytes2, sizeOffset); + bytes2.set(digest3, digestOffset); + return new Digest2(code15, size4, digest3, bytes2); + }; + var decode10 = (multihash) => { + const bytes2 = coerce2(multihash); + const [code15, sizeOffset] = decode9(bytes2); + const [size4, digestOffset] = decode9(bytes2.subarray(sizeOffset)); + const digest3 = bytes2.subarray(sizeOffset + digestOffset); + if (digest3.byteLength !== size4) { + throw new Error("Incorrect length"); + } + return new Digest2(code15, size4, digest3, bytes2); + }; + var equals4 = (a8, b6) => { + if (a8 === b6) { + return true; + } else { + const data = ( + /** @type {{code?:unknown, size?:unknown, bytes?:unknown}} */ + b6 + ); + return a8.code === data.code && a8.size === data.size && data.bytes instanceof Uint8Array && equals3(a8.bytes, data.bytes); + } + }; + var Digest2 = class { + /** + * Creates a multihash digest. + * + * @param {Code} code + * @param {Size} size + * @param {Uint8Array} digest + * @param {Uint8Array} bytes + */ + constructor(code15, size4, digest3, bytes2) { + this.code = code15; + this.size = size4; + this.digest = digest3; + this.bytes = bytes2; + } + }; + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base58.js + var base58_exports = {}; + __export(base58_exports, { + base58btc: () => base58btc2, + base58flickr: () => base58flickr2 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/vendor/base-x.js + init_dirname(); + init_buffer2(); + init_process(); + function base2(ALPHABET, name15) { + if (ALPHABET.length >= 255) { + throw new TypeError("Alphabet too long"); + } + var BASE_MAP = new Uint8Array(256); + for (var j5 = 0; j5 < BASE_MAP.length; j5++) { + BASE_MAP[j5] = 255; + } + for (var i8 = 0; i8 < ALPHABET.length; i8++) { + var x5 = ALPHABET.charAt(i8); + var xc = x5.charCodeAt(0); + if (BASE_MAP[xc] !== 255) { + throw new TypeError(x5 + " is ambiguous"); + } + BASE_MAP[xc] = i8; + } + var BASE = ALPHABET.length; + var LEADER = ALPHABET.charAt(0); + var FACTOR = Math.log(BASE) / Math.log(256); + var iFACTOR = Math.log(256) / Math.log(BASE); + function encode41(source) { + if (source instanceof Uint8Array) + ; + else if (ArrayBuffer.isView(source)) { + source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength); + } else if (Array.isArray(source)) { + source = Uint8Array.from(source); + } + if (!(source instanceof Uint8Array)) { + throw new TypeError("Expected Uint8Array"); + } + if (source.length === 0) { + return ""; + } + var zeroes = 0; + var length3 = 0; + var pbegin = 0; + var pend = source.length; + while (pbegin !== pend && source[pbegin] === 0) { + pbegin++; + zeroes++; + } + var size4 = (pend - pbegin) * iFACTOR + 1 >>> 0; + var b58 = new Uint8Array(size4); + while (pbegin !== pend) { + var carry = source[pbegin]; + var i9 = 0; + for (var it1 = size4 - 1; (carry !== 0 || i9 < length3) && it1 !== -1; it1--, i9++) { + carry += 256 * b58[it1] >>> 0; + b58[it1] = carry % BASE >>> 0; + carry = carry / BASE >>> 0; + } + if (carry !== 0) { + throw new Error("Non-zero carry"); + } + length3 = i9; + pbegin++; + } + var it22 = size4 - length3; + while (it22 !== size4 && b58[it22] === 0) { + it22++; + } + var str = LEADER.repeat(zeroes); + for (; it22 < size4; ++it22) { + str += ALPHABET.charAt(b58[it22]); + } + return str; + } + function decodeUnsafe(source) { + if (typeof source !== "string") { + throw new TypeError("Expected String"); + } + if (source.length === 0) { + return new Uint8Array(); + } + var psz = 0; + if (source[psz] === " ") { + return; + } + var zeroes = 0; + var length3 = 0; + while (source[psz] === LEADER) { + zeroes++; + psz++; + } + var size4 = (source.length - psz) * FACTOR + 1 >>> 0; + var b256 = new Uint8Array(size4); + while (source[psz]) { + var carry = BASE_MAP[source.charCodeAt(psz)]; + if (carry === 255) { + return; + } + var i9 = 0; + for (var it32 = size4 - 1; (carry !== 0 || i9 < length3) && it32 !== -1; it32--, i9++) { + carry += BASE * b256[it32] >>> 0; + b256[it32] = carry % 256 >>> 0; + carry = carry / 256 >>> 0; + } + if (carry !== 0) { + throw new Error("Non-zero carry"); + } + length3 = i9; + psz++; + } + if (source[psz] === " ") { + return; + } + var it4 = size4 - length3; + while (it4 !== size4 && b256[it4] === 0) { + it4++; + } + var vch = new Uint8Array(zeroes + (size4 - it4)); + var j6 = zeroes; + while (it4 !== size4) { + vch[j6++] = b256[it4++]; + } + return vch; + } + function decode46(string4) { + var buffer4 = decodeUnsafe(string4); + if (buffer4) { + return buffer4; + } + throw new Error(`Non-${name15} character`); + } + return { + encode: encode41, + decodeUnsafe, + decode: decode46 + }; + } + var src2 = base2; + var _brrp__multiformats_scope_baseX2 = src2; + var base_x_default2 = _brrp__multiformats_scope_baseX2; + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/interface.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base.js + var Encoder2 = class { + /** + * @param {Base} name + * @param {Prefix} prefix + * @param {(bytes:Uint8Array) => string} baseEncode + */ + constructor(name15, prefix, baseEncode) { + this.name = name15; + this.prefix = prefix; + this.baseEncode = baseEncode; + } + /** + * @param {Uint8Array} bytes + * @returns {API.Multibase} + */ + encode(bytes2) { + if (bytes2 instanceof Uint8Array) { + return `${this.prefix}${this.baseEncode(bytes2)}`; + } else { + throw Error("Unknown type, must be binary type"); + } + } + }; + var Decoder2 = class { + /** + * @param {Base} name + * @param {Prefix} prefix + * @param {(text:string) => Uint8Array} baseDecode + */ + constructor(name15, prefix, baseDecode) { + this.name = name15; + this.prefix = prefix; + if (prefix.codePointAt(0) === void 0) { + throw new Error("Invalid prefix character"); + } + this.prefixCodePoint = /** @type {number} */ + prefix.codePointAt(0); + this.baseDecode = baseDecode; + } + /** + * @param {string} text + */ + decode(text3) { + if (typeof text3 === "string") { + if (text3.codePointAt(0) !== this.prefixCodePoint) { + throw Error(`Unable to decode multibase string ${JSON.stringify(text3)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`); + } + return this.baseDecode(text3.slice(this.prefix.length)); + } else { + throw Error("Can only multibase decode strings"); + } + } + /** + * @template {string} OtherPrefix + * @param {API.UnibaseDecoder|ComposedDecoder} decoder + * @returns {ComposedDecoder} + */ + or(decoder4) { + return or2(this, decoder4); + } + }; + var ComposedDecoder2 = class { + /** + * @param {Decoders} decoders + */ + constructor(decoders) { + this.decoders = decoders; + } + /** + * @template {string} OtherPrefix + * @param {API.UnibaseDecoder|ComposedDecoder} decoder + * @returns {ComposedDecoder} + */ + or(decoder4) { + return or2(this, decoder4); + } + /** + * @param {string} input + * @returns {Uint8Array} + */ + decode(input) { + const prefix = ( + /** @type {Prefix} */ + input[0] + ); + const decoder4 = this.decoders[prefix]; + if (decoder4) { + return decoder4.decode(input); + } else { + throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); + } + } + }; + var or2 = (left, right) => new ComposedDecoder2( + /** @type {Decoders} */ + { + ...left.decoders || { [ + /** @type API.UnibaseDecoder */ + left.prefix + ]: left }, + ...right.decoders || { [ + /** @type API.UnibaseDecoder */ + right.prefix + ]: right } + } + ); + var Codec2 = class { + /** + * @param {Base} name + * @param {Prefix} prefix + * @param {(bytes:Uint8Array) => string} baseEncode + * @param {(text:string) => Uint8Array} baseDecode + */ + constructor(name15, prefix, baseEncode, baseDecode) { + this.name = name15; + this.prefix = prefix; + this.baseEncode = baseEncode; + this.baseDecode = baseDecode; + this.encoder = new Encoder2(name15, prefix, baseEncode); + this.decoder = new Decoder2(name15, prefix, baseDecode); + } + /** + * @param {Uint8Array} input + */ + encode(input) { + return this.encoder.encode(input); + } + /** + * @param {string} input + */ + decode(input) { + return this.decoder.decode(input); + } + }; + var from2 = ({ name: name15, prefix, encode: encode41, decode: decode46 }) => new Codec2(name15, prefix, encode41, decode46); + var baseX2 = ({ prefix, name: name15, alphabet: alphabet2 }) => { + const { encode: encode41, decode: decode46 } = base_x_default2(alphabet2, name15); + return from2({ + prefix, + name: name15, + encode: encode41, + /** + * @param {string} text + */ + decode: (text3) => coerce2(decode46(text3)) + }); + }; + var decode11 = (string4, alphabet2, bitsPerChar, name15) => { + const codes = {}; + for (let i8 = 0; i8 < alphabet2.length; ++i8) { + codes[alphabet2[i8]] = i8; + } + let end = string4.length; + while (string4[end - 1] === "=") { + --end; + } + const out = new Uint8Array(end * bitsPerChar / 8 | 0); + let bits = 0; + let buffer4 = 0; + let written = 0; + for (let i8 = 0; i8 < end; ++i8) { + const value = codes[string4[i8]]; + if (value === void 0) { + throw new SyntaxError(`Non-${name15} character`); + } + buffer4 = buffer4 << bitsPerChar | value; + bits += bitsPerChar; + if (bits >= 8) { + bits -= 8; + out[written++] = 255 & buffer4 >> bits; + } + } + if (bits >= bitsPerChar || 255 & buffer4 << 8 - bits) { + throw new SyntaxError("Unexpected end of data"); + } + return out; + }; + var encode7 = (data, alphabet2, bitsPerChar) => { + const pad = alphabet2[alphabet2.length - 1] === "="; + const mask2 = (1 << bitsPerChar) - 1; + let out = ""; + let bits = 0; + let buffer4 = 0; + for (let i8 = 0; i8 < data.length; ++i8) { + buffer4 = buffer4 << 8 | data[i8]; + bits += 8; + while (bits > bitsPerChar) { + bits -= bitsPerChar; + out += alphabet2[mask2 & buffer4 >> bits]; + } + } + if (bits) { + out += alphabet2[mask2 & buffer4 << bitsPerChar - bits]; + } + if (pad) { + while (out.length * bitsPerChar & 7) { + out += "="; + } + } + return out; + }; + var rfc46482 = ({ name: name15, prefix, bitsPerChar, alphabet: alphabet2 }) => { + return from2({ + prefix, + name: name15, + encode(input) { + return encode7(input, alphabet2, bitsPerChar); + }, + decode(input) { + return decode11(input, alphabet2, bitsPerChar, name15); + } + }); + }; + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base58.js + var base58btc2 = baseX2({ + name: "base58btc", + prefix: "z", + alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" + }); + var base58flickr2 = baseX2({ + name: "base58flickr", + prefix: "Z", + alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" + }); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base32.js + var base32_exports = {}; + __export(base32_exports, { + base32: () => base322, + base32hex: () => base32hex2, + base32hexpad: () => base32hexpad2, + base32hexpadupper: () => base32hexpadupper2, + base32hexupper: () => base32hexupper2, + base32pad: () => base32pad2, + base32padupper: () => base32padupper2, + base32upper: () => base32upper2, + base32z: () => base32z2 + }); + init_dirname(); + init_buffer2(); + init_process(); + var base322 = rfc46482({ + prefix: "b", + name: "base32", + alphabet: "abcdefghijklmnopqrstuvwxyz234567", + bitsPerChar: 5 + }); + var base32upper2 = rfc46482({ + prefix: "B", + name: "base32upper", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", + bitsPerChar: 5 + }); + var base32pad2 = rfc46482({ + prefix: "c", + name: "base32pad", + alphabet: "abcdefghijklmnopqrstuvwxyz234567=", + bitsPerChar: 5 + }); + var base32padupper2 = rfc46482({ + prefix: "C", + name: "base32padupper", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", + bitsPerChar: 5 + }); + var base32hex2 = rfc46482({ + prefix: "v", + name: "base32hex", + alphabet: "0123456789abcdefghijklmnopqrstuv", + bitsPerChar: 5 + }); + var base32hexupper2 = rfc46482({ + prefix: "V", + name: "base32hexupper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", + bitsPerChar: 5 + }); + var base32hexpad2 = rfc46482({ + prefix: "t", + name: "base32hexpad", + alphabet: "0123456789abcdefghijklmnopqrstuv=", + bitsPerChar: 5 + }); + var base32hexpadupper2 = rfc46482({ + prefix: "T", + name: "base32hexpadupper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", + bitsPerChar: 5 + }); + var base32z2 = rfc46482({ + prefix: "h", + name: "base32z", + alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", + bitsPerChar: 5 + }); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/cid.js + var format2 = (link10, base3) => { + const { bytes: bytes2, version: version3 } = link10; + switch (version3) { + case 0: + return toStringV02( + bytes2, + baseCache2(link10), + /** @type {API.MultibaseEncoder<"z">} */ + base3 || base58btc2.encoder + ); + default: + return toStringV12( + bytes2, + baseCache2(link10), + /** @type {API.MultibaseEncoder} */ + base3 || base322.encoder + ); + } + }; + var cache2 = /* @__PURE__ */ new WeakMap(); + var baseCache2 = (cid) => { + const baseCache3 = cache2.get(cid); + if (baseCache3 == null) { + const baseCache4 = /* @__PURE__ */ new Map(); + cache2.set(cid, baseCache4); + return baseCache4; + } + return baseCache3; + }; + var CID2 = class _CID { + /** + * @param {Version} version - Version of the CID + * @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv + * @param {API.MultihashDigest} multihash - (Multi)hash of the of the content. + * @param {Uint8Array} bytes + * + */ + constructor(version3, code15, multihash, bytes2) { + this.code = code15; + this.version = version3; + this.multihash = multihash; + this.bytes = bytes2; + this["/"] = bytes2; + } + /** + * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes` + * please either use `CID.asCID(cid)` or switch to new signalling mechanism + * + * @deprecated + */ + get asCID() { + return this; + } + // ArrayBufferView + get byteOffset() { + return this.bytes.byteOffset; + } + // ArrayBufferView + get byteLength() { + return this.bytes.byteLength; + } + /** + * @returns {CID} + */ + toV0() { + switch (this.version) { + case 0: { + return ( + /** @type {CID} */ + this + ); + } + case 1: { + const { code: code15, multihash } = this; + if (code15 !== DAG_PB_CODE2) { + throw new Error("Cannot convert a non dag-pb CID to CIDv0"); + } + if (multihash.code !== SHA_256_CODE2) { + throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0"); + } + return ( + /** @type {CID} */ + _CID.createV0( + /** @type {API.MultihashDigest} */ + multihash + ) + ); + } + default: { + throw Error( + `Can not convert CID version ${this.version} to version 0. This is a bug please report` + ); + } + } + } + /** + * @returns {CID} + */ + toV1() { + switch (this.version) { + case 0: { + const { code: code15, digest: digest3 } = this.multihash; + const multihash = create2(code15, digest3); + return ( + /** @type {CID} */ + _CID.createV1(this.code, multihash) + ); + } + case 1: { + return ( + /** @type {CID} */ + this + ); + } + default: { + throw Error( + `Can not convert CID version ${this.version} to version 1. This is a bug please report` + ); + } + } + } + /** + * @param {unknown} other + * @returns {other is CID} + */ + equals(other) { + return _CID.equals(this, other); + } + /** + * @template {unknown} Data + * @template {number} Format + * @template {number} Alg + * @template {API.Version} Version + * @param {API.Link} self + * @param {unknown} other + * @returns {other is CID} + */ + static equals(self2, other) { + const unknown3 = ( + /** @type {{code?:unknown, version?:unknown, multihash?:unknown}} */ + other + ); + return unknown3 && self2.code === unknown3.code && self2.version === unknown3.version && equals4(self2.multihash, unknown3.multihash); + } + /** + * @param {API.MultibaseEncoder} [base] + * @returns {string} + */ + toString(base3) { + return format2(this, base3); + } + toJSON() { + return { "/": format2(this) }; + } + link() { + return this; + } + get [Symbol.toStringTag]() { + return "CID"; + } + // Legacy + [Symbol.for("nodejs.util.inspect.custom")]() { + return `CID(${this.toString()})`; + } + /** + * Takes any input `value` and returns a `CID` instance if it was + * a `CID` otherwise returns `null`. If `value` is instanceof `CID` + * it will return value back. If `value` is not instance of this CID + * class, but is compatible CID it will return new instance of this + * `CID` class. Otherwise returns null. + * + * This allows two different incompatible versions of CID library to + * co-exist and interop as long as binary interface is compatible. + * + * @template {unknown} Data + * @template {number} Format + * @template {number} Alg + * @template {API.Version} Version + * @template {unknown} U + * @param {API.Link|U} input + * @returns {CID|null} + */ + static asCID(input) { + if (input == null) { + return null; + } + const value = ( + /** @type {any} */ + input + ); + if (value instanceof _CID) { + return value; + } else if (value["/"] != null && value["/"] === value.bytes || value.asCID === value) { + const { version: version3, code: code15, multihash, bytes: bytes2 } = value; + return new _CID( + version3, + code15, + /** @type {API.MultihashDigest} */ + multihash, + bytes2 || encodeCID2(version3, code15, multihash.bytes) + ); + } else if (value[cidSymbol2] === true) { + const { version: version3, multihash, code: code15 } = value; + const digest3 = ( + /** @type {API.MultihashDigest} */ + decode10(multihash) + ); + return _CID.create(version3, code15, digest3); + } else { + return null; + } + } + /** + * + * @template {unknown} Data + * @template {number} Format + * @template {number} Alg + * @template {API.Version} Version + * @param {Version} version - Version of the CID + * @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv + * @param {API.MultihashDigest} digest - (Multi)hash of the of the content. + * @returns {CID} + */ + static create(version3, code15, digest3) { + if (typeof code15 !== "number") { + throw new Error("String codecs are no longer supported"); + } + if (!(digest3.bytes instanceof Uint8Array)) { + throw new Error("Invalid digest"); + } + switch (version3) { + case 0: { + if (code15 !== DAG_PB_CODE2) { + throw new Error( + `Version 0 CID must use dag-pb (code: ${DAG_PB_CODE2}) block encoding` + ); + } else { + return new _CID(version3, code15, digest3, digest3.bytes); + } + } + case 1: { + const bytes2 = encodeCID2(version3, code15, digest3.bytes); + return new _CID(version3, code15, digest3, bytes2); + } + default: { + throw new Error("Invalid version"); + } + } + } + /** + * Simplified version of `create` for CIDv0. + * + * @template {unknown} [T=unknown] + * @param {API.MultihashDigest} digest - Multihash. + * @returns {CID} + */ + static createV0(digest3) { + return _CID.create(0, DAG_PB_CODE2, digest3); + } + /** + * Simplified version of `create` for CIDv1. + * + * @template {unknown} Data + * @template {number} Code + * @template {number} Alg + * @param {Code} code - Content encoding format code. + * @param {API.MultihashDigest} digest - Miltihash of the content. + * @returns {CID} + */ + static createV1(code15, digest3) { + return _CID.create(1, code15, digest3); + } + /** + * Decoded a CID from its binary representation. The byte array must contain + * only the CID with no additional bytes. + * + * An error will be thrown if the bytes provided do not contain a valid + * binary representation of a CID. + * + * @template {unknown} Data + * @template {number} Code + * @template {number} Alg + * @template {API.Version} Ver + * @param {API.ByteView>} bytes + * @returns {CID} + */ + static decode(bytes2) { + const [cid, remainder] = _CID.decodeFirst(bytes2); + if (remainder.length) { + throw new Error("Incorrect length"); + } + return cid; + } + /** + * Decoded a CID from its binary representation at the beginning of a byte + * array. + * + * Returns an array with the first element containing the CID and the second + * element containing the remainder of the original byte array. The remainder + * will be a zero-length byte array if the provided bytes only contained a + * binary CID representation. + * + * @template {unknown} T + * @template {number} C + * @template {number} A + * @template {API.Version} V + * @param {API.ByteView>} bytes + * @returns {[CID, Uint8Array]} + */ + static decodeFirst(bytes2) { + const specs = _CID.inspectBytes(bytes2); + const prefixSize = specs.size - specs.multihashSize; + const multihashBytes = coerce2( + bytes2.subarray(prefixSize, prefixSize + specs.multihashSize) + ); + if (multihashBytes.byteLength !== specs.multihashSize) { + throw new Error("Incorrect length"); + } + const digestBytes = multihashBytes.subarray( + specs.multihashSize - specs.digestSize + ); + const digest3 = new Digest2( + specs.multihashCode, + specs.digestSize, + digestBytes, + multihashBytes + ); + const cid = specs.version === 0 ? _CID.createV0( + /** @type {API.MultihashDigest} */ + digest3 + ) : _CID.createV1(specs.codec, digest3); + return [ + /** @type {CID} */ + cid, + bytes2.subarray(specs.size) + ]; + } + /** + * Inspect the initial bytes of a CID to determine its properties. + * + * Involves decoding up to 4 varints. Typically this will require only 4 to 6 + * bytes but for larger multicodec code values and larger multihash digest + * lengths these varints can be quite large. It is recommended that at least + * 10 bytes be made available in the `initialBytes` argument for a complete + * inspection. + * + * @template {unknown} T + * @template {number} C + * @template {number} A + * @template {API.Version} V + * @param {API.ByteView>} initialBytes + * @returns {{ version:V, codec:C, multihashCode:A, digestSize:number, multihashSize:number, size:number }} + */ + static inspectBytes(initialBytes) { + let offset2 = 0; + const next = () => { + const [i8, length3] = decode9(initialBytes.subarray(offset2)); + offset2 += length3; + return i8; + }; + let version3 = ( + /** @type {V} */ + next() + ); + let codec = ( + /** @type {C} */ + DAG_PB_CODE2 + ); + if ( + /** @type {number} */ + version3 === 18 + ) { + version3 = /** @type {V} */ + 0; + offset2 = 0; + } else { + codec = /** @type {C} */ + next(); + } + if (version3 !== 0 && version3 !== 1) { + throw new RangeError(`Invalid CID version ${version3}`); + } + const prefixSize = offset2; + const multihashCode = ( + /** @type {A} */ + next() + ); + const digestSize = next(); + const size4 = offset2 + digestSize; + const multihashSize = size4 - prefixSize; + return { version: version3, codec, multihashCode, digestSize, multihashSize, size: size4 }; + } + /** + * Takes cid in a string representation and creates an instance. If `base` + * decoder is not provided will use a default from the configuration. It will + * throw an error if encoding of the CID is not compatible with supplied (or + * a default decoder). + * + * @template {string} Prefix + * @template {unknown} Data + * @template {number} Code + * @template {number} Alg + * @template {API.Version} Ver + * @param {API.ToString, Prefix>} source + * @param {API.MultibaseDecoder} [base] + * @returns {CID} + */ + static parse(source, base3) { + const [prefix, bytes2] = parseCIDtoBytes2(source, base3); + const cid = _CID.decode(bytes2); + if (cid.version === 0 && source[0] !== "Q") { + throw Error("Version 0 CID string must not include multibase prefix"); + } + baseCache2(cid).set(prefix, source); + return cid; + } + }; + var parseCIDtoBytes2 = (source, base3) => { + switch (source[0]) { + case "Q": { + const decoder4 = base3 || base58btc2; + return [ + /** @type {Prefix} */ + base58btc2.prefix, + decoder4.decode(`${base58btc2.prefix}${source}`) + ]; + } + case base58btc2.prefix: { + const decoder4 = base3 || base58btc2; + return [ + /** @type {Prefix} */ + base58btc2.prefix, + decoder4.decode(source) + ]; + } + case base322.prefix: { + const decoder4 = base3 || base322; + return [ + /** @type {Prefix} */ + base322.prefix, + decoder4.decode(source) + ]; + } + default: { + if (base3 == null) { + throw Error( + "To parse non base32 or base58btc encoded CID multibase decoder must be provided" + ); + } + return [ + /** @type {Prefix} */ + source[0], + base3.decode(source) + ]; + } + } + }; + var toStringV02 = (bytes2, cache3, base3) => { + const { prefix } = base3; + if (prefix !== base58btc2.prefix) { + throw Error(`Cannot string encode V0 in ${base3.name} encoding`); + } + const cid = cache3.get(prefix); + if (cid == null) { + const cid2 = base3.encode(bytes2).slice(1); + cache3.set(prefix, cid2); + return cid2; + } else { + return cid; + } + }; + var toStringV12 = (bytes2, cache3, base3) => { + const { prefix } = base3; + const cid = cache3.get(prefix); + if (cid == null) { + const cid2 = base3.encode(bytes2); + cache3.set(prefix, cid2); + return cid2; + } else { + return cid; + } + }; + var DAG_PB_CODE2 = 112; + var SHA_256_CODE2 = 18; + var encodeCID2 = (version3, code15, multihash) => { + const codeOffset = encodingLength2(version3); + const hashOffset = codeOffset + encodingLength2(code15); + const bytes2 = new Uint8Array(hashOffset + multihash.byteLength); + encodeTo2(version3, bytes2, 0); + encodeTo2(code15, bytes2, codeOffset); + bytes2.set(multihash, hashOffset); + return bytes2; + }; + var cidSymbol2 = Symbol.for("@ipld/js-cid/CID"); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/link.js + var DAG_PB_CODE3 = 112; + var createLegacy = (digest3) => CID2.create(0, DAG_PB_CODE3, digest3); + var create3 = (code15, digest3) => CID2.create(1, code15, digest3); + var isLink = (value) => { + if (value == null) { + return false; + } + const withSlash = ( + /** @type {{'/'?: Uint8Array, bytes: Uint8Array}} */ + value + ); + if (withSlash["/"] != null && withSlash["/"] === withSlash.bytes) { + return true; + } + const withAsCID = ( + /** @type {{'asCID'?: unknown}} */ + value + ); + if (withAsCID.asCID === value) { + return true; + } + return false; + }; + var parse = (source, base3) => CID2.parse(source, base3); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/hashes/identity.js + var identity_exports = {}; + __export(identity_exports, { + identity: () => identity + }); + init_dirname(); + init_buffer2(); + init_process(); + var code2 = 0; + var name3 = "identity"; + var encode8 = coerce2; + var digest = (input) => create2(code2, encode8(input)); + var identity = { code: code2, name: name3, encode: encode8, digest }; + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/did.js + var did_exports = {}; + __export(did_exports, { + BLS12381G1: () => BLS12381G1, + BLS12381G2: () => BLS12381G2, + DID_CORE: () => DID_CORE, + ED25519: () => ED25519, + P256: () => P256, + P384: () => P384, + P521: () => P521, + RSA: () => RSA, + SECP256K1: () => SECP256K1, + decode: () => decode12, + encode: () => encode9, + format: () => format3, + from: () => from4, + parse: () => parse2 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/hashes/hasher.js + init_dirname(); + init_buffer2(); + init_process(); + var from3 = ({ name: name15, code: code15, encode: encode41 }) => new Hasher(name15, code15, encode41); + var Hasher = class { + /** + * + * @param {Name} name + * @param {Code} code + * @param {(input: Uint8Array) => Await} encode + */ + constructor(name15, code15, encode41) { + this.name = name15; + this.code = code15; + this.encode = encode41; + } + /** + * @param {Uint8Array} input + * @returns {Await>} + */ + digest(input) { + if (input instanceof Uint8Array) { + const result = this.encode(input); + return result instanceof Uint8Array ? create2(this.code, result) : result.then((digest3) => create2(this.code, digest3)); + } else { + throw Error("Unknown type, must be binary type"); + } + } + }; + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/interface.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/did.js + var DID_PREFIX = "did:"; + var DID_PREFIX_SIZE = DID_PREFIX.length; + var DID_KEY_PREFIX = `did:key:`; + var DID_KEY_PREFIX_SIZE = DID_KEY_PREFIX.length; + var ED25519 = 237; + var RSA = 4613; + var P256 = 4608; + var P384 = 4609; + var P521 = 4610; + var SECP256K1 = 231; + var BLS12381G1 = 234; + var BLS12381G2 = 235; + var DID_CORE = 3357; + var METHOD_OFFSET = varint_exports2.encodingLength(DID_CORE); + var parse2 = (did3) => { + if (!did3.startsWith(DID_PREFIX)) { + throw new RangeError(`Invalid DID "${did3}", must start with 'did:'`); + } else if (did3.startsWith(DID_KEY_PREFIX)) { + const key = base58btc2.decode(did3.slice(DID_KEY_PREFIX_SIZE)); + return decode12(key); + } else { + const suffix = encode5(did3.slice(DID_PREFIX_SIZE)); + const bytes2 = new Uint8Array(suffix.byteLength + METHOD_OFFSET); + varint_exports2.encodeTo(DID_CORE, bytes2); + bytes2.set(suffix, METHOD_OFFSET); + return new DID(bytes2); + } + }; + var format3 = (id) => id.did(); + var from4 = (principal) => { + if (principal instanceof DID) { + return principal; + } else if (principal instanceof Uint8Array) { + return decode12(principal); + } else if (typeof principal === "string") { + return parse2(principal); + } else { + return parse2(principal.did()); + } + }; + var decode12 = (bytes2) => { + const [code15] = varint_exports2.decode(bytes2); + const { buffer: buffer4, byteOffset, byteLength } = bytes2; + switch (code15) { + case P256: + if (bytes2.length > 35) { + throw new RangeError(`Only p256-pub compressed is supported.`); + } + case ED25519: + case RSA: + case P384: + case P521: + return ( + /** @type {UCAN.PrincipalView} */ + new DIDKey(buffer4, byteOffset, byteLength) + ); + case DID_CORE: + return new DID(buffer4, byteOffset, byteLength); + default: + throw new RangeError( + `Unsupported DID encoding, unknown multicode 0x${code15.toString(16)}.` + ); + } + }; + var encode9 = (principal) => parse2(principal.did()); + var DID = class extends Uint8Array { + /** + * @returns {ID} + */ + did() { + const bytes2 = new Uint8Array(this.buffer, this.byteOffset + METHOD_OFFSET); + return ( + /** @type {ID} */ + `did:${decode7(bytes2)}` + ); + } + toJSON() { + return this.did(); + } + }; + var DIDKey = class extends DID { + /** + * @return {`did:key:${string}`} + */ + did() { + return `did:key:${base58btc2.encode(this)}`; + } + }; + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/codecs/raw.js + var raw_exports = {}; + __export(raw_exports, { + code: () => code3, + decode: () => decode13, + encode: () => encode10, + name: () => name4 + }); + init_dirname(); + init_buffer2(); + init_process(); + var name4 = "raw"; + var code3 = 85; + var encode10 = (node) => coerce2(node); + var decode13 = (data) => coerce2(data); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/signature.js + var signature_exports = {}; + __export(signature_exports, { + BLS12381G1: () => BLS12381G12, + BLS12381G2: () => BLS12381G22, + EIP191: () => EIP191, + ES256: () => ES256, + ES256K: () => ES256K, + ES384: () => ES384, + ES512: () => ES512, + EdDSA: () => EdDSA, + NON_STANDARD: () => NON_STANDARD, + RS256: () => RS256, + Signature: () => Signature, + create: () => create4, + createNamed: () => createNamed, + createNonStandard: () => createNonStandard, + decode: () => decode14, + encode: () => encode11, + format: () => format4, + fromJSON: () => fromJSON2, + nameCode: () => nameCode, + parse: () => parse3, + toJSON: () => toJSON2, + view: () => view + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base64.js + var base64_exports = {}; + __export(base64_exports, { + base64: () => base64, + base64pad: () => base64pad, + base64url: () => base64url, + base64urlpad: () => base64urlpad + }); + init_dirname(); + init_buffer2(); + init_process(); + var base64 = rfc46482({ + prefix: "m", + name: "base64", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", + bitsPerChar: 6 + }); + var base64pad = rfc46482({ + prefix: "M", + name: "base64pad", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + bitsPerChar: 6 + }); + var base64url = rfc46482({ + prefix: "u", + name: "base64url", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", + bitsPerChar: 6 + }); + var base64urlpad = rfc46482({ + prefix: "U", + name: "base64urlpad", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", + bitsPerChar: 6 + }); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/signature.js + var NON_STANDARD = 53248; + var ES256K = 53479; + var BLS12381G12 = 53482; + var BLS12381G22 = 53483; + var EdDSA = 53485; + var ES256 = 13636096; + var ES384 = 13636097; + var ES512 = 13636098; + var RS256 = 13636101; + var EIP191 = 53649; + var codeName = (code15) => { + switch (code15) { + case ES256K: + return "ES256K"; + case BLS12381G12: + return "BLS12381G1"; + case BLS12381G22: + return "BLS12381G2"; + case EdDSA: + return "EdDSA"; + case ES256: + return "ES256"; + case ES384: + return "ES384"; + case ES512: + return "ES512"; + case RS256: + return "RS256"; + case EIP191: + return "EIP191"; + default: + throw new RangeError( + `Unknown signature algorithm code 0x${code15.toString(16)}` + ); + } + }; + var nameCode = (name15) => { + switch (name15) { + case "ES256K": + return ES256K; + case "BLS12381G1": + return BLS12381G12; + case "BLS12381G2": + return BLS12381G22; + case "EdDSA": + return EdDSA; + case "ES256": + return ES256; + case "ES384": + return ES384; + case "ES512": + return ES512; + case "RS256": + return RS256; + case "EIP191": + return EIP191; + default: + return NON_STANDARD; + } + }; + var Signature = class extends Uint8Array { + get code() { + const [code15] = varint_exports2.decode(this); + Object.defineProperties(this, { code: { value: code15 } }); + return ( + /** @type {A} */ + code15 + ); + } + get size() { + const value = size(this); + Object.defineProperties(this, { size: { value } }); + return value; + } + get algorithm() { + const value = algorithm(this); + Object.defineProperties(this, { algorithm: { value } }); + return value; + } + get raw() { + const { buffer: buffer4, byteOffset, size: size4, code: code15 } = this; + const codeSize = varint_exports2.encodingLength(code15); + const rawSize = varint_exports2.encodingLength(size4); + const value = new Uint8Array(buffer4, byteOffset + codeSize + rawSize, size4); + Object.defineProperties(this, { raw: { value } }); + return value; + } + /** + * Verify that this signature was created by the given key. + * + * @param {UCAN.Crypto.Verifier} signer + * @param {UCAN.ByteView} payload + */ + async verify(signer, payload) { + try { + if (await signer.verify(payload, this) === true) { + return { ok: {} }; + } else { + throw new Error("Invalid signature"); + } + } catch (cause) { + return { error: ( + /** @type {Error} */ + cause + ) }; + } + } + toJSON() { + return toJSON2(this); + } + }; + var algorithm = (signature) => { + const { code: code15, raw, buffer: buffer4, byteOffset } = signature; + if (code15 === NON_STANDARD) { + const offset2 = raw.byteLength + varint_exports2.encodingLength(code15) + varint_exports2.encodingLength(raw.byteLength); + const bytes2 = new Uint8Array(buffer4, byteOffset + offset2); + return decode7(bytes2); + } else { + return codeName(code15); + } + }; + var size = (signature) => { + const offset2 = varint_exports2.encodingLength(signature.code); + const [size4] = varint_exports2.decode( + new Uint8Array(signature.buffer, signature.byteOffset + offset2) + ); + return size4; + }; + var create4 = (code15, raw) => { + const _5 = codeName(code15); + const codeSize = varint_exports2.encodingLength(code15); + const rawSize = varint_exports2.encodingLength(raw.byteLength); + const signature = new Signature(codeSize + rawSize + raw.byteLength); + varint_exports2.encodeTo(code15, signature); + varint_exports2.encodeTo(raw.byteLength, signature, codeSize); + signature.set(raw, codeSize + rawSize); + Object.defineProperties(signature, { + code: { value: code15 }, + size: { value: raw.byteLength } + }); + return signature; + }; + var createNamed = (name15, raw) => { + const code15 = nameCode(name15); + return code15 === NON_STANDARD ? createNonStandard(name15, raw) : create4(code15, raw); + }; + var createNonStandard = (name15, raw) => { + const code15 = NON_STANDARD; + const codeSize = varint_exports2.encodingLength(code15); + const rawSize = varint_exports2.encodingLength(raw.byteLength); + const nameBytes = encode5(name15); + const signature = new Signature( + codeSize + rawSize + raw.byteLength + nameBytes.byteLength + ); + varint_exports2.encodeTo(code15, signature); + varint_exports2.encodeTo(raw.byteLength, signature, codeSize); + signature.set(raw, codeSize + rawSize); + signature.set(nameBytes, codeSize + rawSize + raw.byteLength); + return signature; + }; + var view = (bytes2) => new Signature(bytes2.buffer, bytes2.byteOffset, bytes2.byteLength); + var decode14 = (bytes2) => { + if (!(bytes2 instanceof Uint8Array)) { + throw new TypeError( + `Can only decode Uint8Array into a Signature, instead got ${JSON.stringify( + bytes2 + )}` + ); + } + const signature = view(bytes2); + const { code: code15, algorithm: algorithm2, raw } = signature; + return signature; + }; + var encode11 = (signature) => decode14(signature); + var format4 = (signature, base3) => (base3 || base64url).encode(signature); + var parse3 = (signature, base3) => ( + /** @type {UCAN.SignatureView} */ + decode14((base3 || base64url).decode(signature)) + ); + var toJSON2 = (signature) => ({ + "/": { bytes: base64.baseEncode(signature) } + }); + var fromJSON2 = (json) => decode14(base64.baseDecode(json["/"].bytes)); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/schema.js + var readPayload = (data) => readPayloadWith(data, { + readPrincipal, + readProof + }); + var readJWTPayload = (data) => readPayloadWith(data, { + readPrincipal: readStringPrincipal, + readProof: readStringProof + }); + var readPayloadWith = (data, { readPrincipal: readPrincipal2, readProof: readProof2 }) => ({ + iss: readPrincipal2(data.iss, "iss"), + aud: readPrincipal2(data.aud, "aud"), + att: readCapabilities(data.att, "att"), + prf: readOptionalArray(data.prf, readProof2, "prf") || [], + exp: readNullable(data.exp === Infinity ? null : data.exp, readInt, "exp"), + nbf: readOptional(data.nbf, readInt, "nbf"), + fct: readOptionalArray(data.fct, readFact, "fct") || [], + nnc: readOptional(data.nnc, readString, "nnc") + }); + var readSignature = (source) => { + if (source instanceof Uint8Array) { + return decode14(source); + } else { + throw new TypeError( + `Can only decode Uint8Array into a Signature, instead got ${JSON.stringify( + source + )}` + ); + } + }; + var readInt = (input, name15) => Number.isInteger(input) ? ( + /** @type {number} */ + input + ) : ParseError.throw( + `Expected ${name15} to be integer, instead got ${JSON.stringify(input)}` + ); + var readCapability = (input, context2) => readStruct(input, asCapability, context2); + var readCapabilities = (input, context2) => ( + /** @type {C} */ + readArray(input, readCapability, context2) + ); + var asCapability = (input) => ( + /** @type {C} */ + { + ...input, + can: readAbility(input.can), + with: readResource(input.with) + } + ); + var readAbility = (input) => typeof input !== "string" ? ParseError.throw( + `Capability has invalid 'can: ${JSON.stringify( + input + )}', value must be a string` + ) : input.slice(1, -1).includes("/") ? ( + /** @type {UCAN.Ability} */ + input.toLocaleLowerCase() + ) : input === "*" ? input : ParseError.throw( + `Capability has invalid 'can: "${input}"', value must have at least one path segment` + ); + var readResource = (input) => typeof input !== "string" ? ParseError.throw( + `Capability has invalid 'with: ${JSON.stringify( + input + )}', value must be a string` + ) : parseURL(input) || ParseError.throw( + `Capability has invalid 'with: "${input}"', value must be a valid URI string` + ); + var parseURL = (input) => { + try { + new URL(input); + return input; + } catch (_5) { + return null; + } + }; + var readArray = (input, read13, context2) => Array.isArray(input) ? input.map((element, n9) => read13(element, `${context2}[${n9}]`)) : ParseError.throw(`${context2} must be an array`); + var readOptionalArray = (input, reader2, context2) => input === void 0 ? input : readArray(input, reader2, context2); + var readStruct = (input, reader2, context2) => input != null && typeof input === "object" ? reader2(input) : ParseError.throw( + `${context2} must be of type object, instead got ${input}` + ); + var readFact = (input, context2) => readStruct(input, Object, context2); + var readProof = (source, context2) => isLink(source) ? ( + /** @type {UCAN.Link} */ + source + ) : fail( + `Expected ${context2} to be IPLD link, instead got ${JSON.stringify( + source + )}` + ); + var readStringProof = (source, context2) => parseProof(readString(source, context2)); + var parseProof = (source) => { + try { + return parse(source); + } catch (error7) { + return create3(code3, identity.digest(encode5(source))); + } + }; + var readPrincipal = (input, context2) => decode12(readBytes(input, context2)); + var readStringPrincipal = (source, context2) => parse2(readString(source, context2)); + var readOptional = (source, read13, context2 = "Field") => source !== void 0 ? read13(source, context2) : void 0; + var readNullable = (source, read13, context2) => source === null ? null : read13(source, context2); + var readString = (source, context2 = "Field") => typeof source === "string" ? source : fail(`${context2} has invalid value ${source}`); + var readBytes = (source, context2) => source instanceof Uint8Array ? source : fail( + `Expected ${context2} to be Uint8Array, instead got ${JSON.stringify( + source + )}` + ); + var readVersion = (input, context2) => /\d+\.\d+\.\d+/.test( + /** @type {string} */ + input + ) ? ( + /** @type {UCAN.Version} */ + input + ) : ParseError.throw(`Invalid version '${context2}: ${JSON.stringify(input)}'`); + var readLiteral = (input, literal3, context2) => input === literal3 ? literal3 : ParseError.throw( + `Expected ${context2} to be a ${JSON.stringify( + literal3 + )} instead got ${JSON.stringify(input)}` + ); + var ParseError = class extends TypeError { + get name() { + return "ParseError"; + } + /** + * @param {string} message + * @returns {never} + */ + static throw(message2) { + throw new this(message2); + } + }; + var fail = (reason) => ParseError.throw(reason); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/formatter.js + init_dirname(); + init_buffer2(); + init_process(); + init_src2(); + var format6 = (model) => { + const header = formatHeader(model.v, model.s.algorithm); + const payload = formatPayload(model); + const signature = formatSignature(model.s); + return ( + /** @type {UCAN.JWT} */ + `${header}.${payload}.${signature}` + ); + }; + var formatSignPayload = (payload, version3, alg) => `${formatHeader(version3, alg)}.${formatPayload(payload)}`; + var formatHeader = (version3, alg) => base64url.baseEncode(encodeHeader(version3, alg)); + var formatPayload = (data) => base64url.baseEncode(encodePayload(data)); + var formatSignature = (signature) => base64url.baseEncode(signature.raw); + var encodeHeader = (v7, alg) => encode13({ + alg, + ucv: v7, + typ: "JWT" + }); + var encodePayload = (data) => encode13({ + iss: format3(data.iss), + aud: format3(data.aud), + att: data.att, + exp: data.exp, + prf: data.prf.map(encodeProof), + // leave out optionals and empty fields + ...data.fct.length > 0 && { fct: data.fct }, + ...data.nnc && { nnc: data.nnc }, + ...data.nbf && { nbf: data.nbf } + }); + var encodeProof = (proof) => ( + /** @type {UCAN.ToString} */ + proof.toString() + ); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/view.js + init_dirname(); + init_buffer2(); + init_process(); + init_src2(); + var toJSON3 = (data) => JSON.parse(decode7(encode13(data))); + var View = class { + /** + * @param {UCAN.UCAN} model + */ + constructor(model) { + this.model = model; + } + get version() { + return this.model.v; + } + get issuer() { + return from4(this.model.iss); + } + get audience() { + return from4(this.model.aud); + } + /** + * @returns {C} + */ + get capabilities() { + return this.model.att; + } + /** + * @returns {number} + */ + get expiration() { + const { exp } = this.model; + return exp === null ? Infinity : exp; + } + /** + * @returns {undefined|number} + */ + get notBefore() { + return this.model.nbf; + } + /** + * @returns {undefined|string} + */ + get nonce() { + return this.model.nnc; + } + /** + * @returns {UCAN.Fact[]} + */ + get facts() { + return this.model.fct; + } + /** + * @returns {UCAN.Link[]} + */ + get proofs() { + return this.model.prf; + } + get signature() { + return this.model.s; + } + // compatibility with UCAN.UCAN + get jwt() { + return this.model.jwt; + } + get s() { + return this.model.s; + } + get v() { + return this.model.v; + } + get iss() { + return this.model.iss; + } + get aud() { + return this.model.aud; + } + get att() { + return this.model.att; + } + get exp() { + return this.model.exp; + } + get nbf() { + return this.model.nbf; + } + get nnc() { + return this.model.nnc; + } + get fct() { + return this.model.fct; + } + get prf() { + return this.model.prf; + } + /** + * @returns {UCAN.ToJSON, UCAN.UCANJSON>} + */ + toJSON() { + const { v: v7, iss, aud, s: s7, att, prf, exp, fct, nnc, nbf } = this.model; + return { + iss, + aud, + v: v7, + s: s7, + exp, + ...toJSON3({ + att, + prf, + ...fct.length > 0 && { fct } + }), + ...nnc != null && { nnc }, + ...nbf && { nbf } + }; + } + }; + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/codec/cbor.js + var code4 = code; + var from6 = (model) => new CBORView(model); + var encode14 = (model) => { + const { fct, nnc, nbf, ...payload } = readPayload(model); + return ( + /** @type {Uint8Array} */ + encode4({ + // leave out optionals unless they are set + ...fct.length > 0 && { fct }, + ...nnc != null && { nnc }, + ...nbf && { nbf }, + ...payload, + // add version and signature + v: readVersion(model.v, "v"), + s: encodeSignature(model.s, "s") + }) + ); + }; + var encodeSignature = (signature, context2) => { + try { + return encode11(signature); + } catch (cause) { + throw new Error( + `Expected signature ${context2}, instead got ${JSON.stringify(signature)}`, + // @ts-expect-error - types don't know about second arg + { cause } + ); + } + }; + var decode17 = (bytes2) => { + const model = decode6(bytes2); + return new CBORView({ + ...readPayload(model), + v: readVersion(model.v, "v"), + s: readSignature(model.s) + }); + }; + var CBORView = class extends View { + get code() { + return code4; + } + format() { + return format6(this.model); + } + encode() { + return encode14(this.model); + } + }; + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/codec/jwt.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/parser.js + init_dirname(); + init_buffer2(); + init_process(); + init_src2(); + var parse5 = (jwt) => { + const segments = jwt.split("."); + const [header, payload, signature] = segments.length === 3 ? segments : fail( + `Can't parse UCAN: ${jwt}: Expected JWT format: 3 dot-separated base64url-encoded values.` + ); + const { ucv, alg } = parseHeader(header); + return { + ...parsePayload(payload), + v: ucv, + s: createNamed(alg, base64url.baseDecode(signature)) + }; + }; + var parseHeader = (header) => { + const { ucv, alg, typ } = decode16(base64url.baseDecode(header)); + return { + typ: readLiteral(typ, "JWT", "typ"), + ucv: readVersion(ucv, "ucv"), + alg: readString(alg, "alg") + }; + }; + var parsePayload = (source) => { + const payload = decode16(base64url.baseDecode(source)); + return readJWTPayload(payload); + }; + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/codec/jwt.js + var decode18 = (bytes2) => { + const jwt = ( + /** @type {UCAN.JWT} */ + decode7(bytes2) + ); + return new JWTView({ ...parse5(jwt), jwt }); + }; + var encode15 = ({ jwt }) => encode5(jwt); + var format7 = ({ jwt }) => jwt; + var JWTView = class extends View { + /** + * @param {UCAN.FromJWT} model + */ + constructor(model) { + super(model); + this.model = model; + } + get code() { + return code3; + } + format() { + return format7(this.model); + } + encode() { + return encode15(this.model); + } + }; + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/hashes/sha2-browser.js + var sha2_browser_exports = {}; + __export(sha2_browser_exports, { + sha256: () => sha256, + sha512: () => sha512 + }); + init_dirname(); + init_buffer2(); + init_process(); + var sha = (name15) => ( + /** + * @param {Uint8Array} data + */ + async (data) => new Uint8Array(await crypto.subtle.digest(name15, data)) + ); + var sha256 = from3({ + name: "sha2-256", + code: 18, + encode: sha("SHA-256") + }); + var sha512 = from3({ + name: "sha2-512", + code: 19, + encode: sha("SHA-512") + }); + + // ../../node_modules/.pnpm/@ipld+dag-ucan@3.3.2/node_modules/@ipld/dag-ucan/src/lib.js + var VERSION = "0.9.1"; + var defaultHasher = sha256; + var decode19 = (bytes2) => { + try { + return decode17(bytes2); + } catch (_5) { + return decode18( + /** @type {UCAN.ByteView>} */ + bytes2 + ); + } + }; + var write = async (ucan, { hasher = defaultHasher } = {}) => { + const [code15, bytes2] = ucan.jwt ? [code3, encode15(ucan)] : [code4, encode14(ucan)]; + const digest3 = await hasher.digest(bytes2); + return { + bytes: bytes2, + cid: create3(code15, digest3), + data: ucan + }; + }; + var issue = async ({ + issuer, + audience, + capabilities, + lifetimeInSeconds = 30, + expiration = now() + lifetimeInSeconds, + notBefore, + facts = [], + proofs: proofs3 = [], + nonce + }) => { + const v7 = VERSION; + const data = readPayload({ + iss: parse2(issuer.did()), + aud: parse2(audience.did()), + att: capabilities, + fct: facts, + exp: expiration, + nbf: notBefore, + prf: proofs3, + nnc: nonce + }); + const payload = encodeSignaturePayload(data, v7, issuer.signatureAlgorithm); + return from6({ + ...data, + v: v7, + s: await issuer.sign(payload) + }); + }; + var encodeSignaturePayload = (payload, version3, algorithm2) => encode5(formatSignPayload(payload, version3, algorithm2)); + var now = () => Math.floor(Date.now() / 1e3); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/link.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/dag.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/cbor.js + var cbor_exports2 = {}; + __export(cbor_exports2, { + code: () => code, + contentType: () => contentType, + decode: () => decode6, + encode: () => encode16, + link: () => link, + name: () => name2, + write: () => write2 + }); + init_dirname(); + init_buffer2(); + init_process(); + var contentType = "application/vnd.ipld.dag-cbor"; + var prepare = (data, seen) => { + if (seen.has(data)) { + throw new TypeError("Can not encode circular structure"); + } + if (data === void 0 && seen.size === 0) { + return null; + } + if (data === null) { + return null; + } + if (typeof data === "symbol" && seen.size === 0) { + return null; + } + if (isLink(data)) { + return data; + } + if (ArrayBuffer.isView(data)) { + return data; + } + if (Array.isArray(data)) { + seen.add(data); + const items = []; + for (const item of data) { + items.push( + item === void 0 || typeof item === "symbol" ? null : prepare(item, seen) + ); + } + return items; + } + if (typeof /** @type {{toJSON?:unknown}} */ + data.toJSON === "function") { + seen.add(data); + const json = ( + /** @type {{toJSON():unknown}} */ + data.toJSON() + ); + return prepare(json, seen); + } + if (typeof data === "object") { + seen.add(data); + const object = {}; + for (const [key, value] of Object.entries(data)) { + if (value !== void 0 && typeof value !== "symbol") { + object[key] = prepare(value, seen); + } + } + return object; + } + return data; + }; + var encode16 = (data) => ( + /** @type {CBOR.ByteView} */ + encode4(prepare(data, /* @__PURE__ */ new Set())) + ); + var link = async (bytes2, { hasher = sha256 } = {}) => { + return ( + /** @type {API.Link} */ + create3(code, await hasher.digest(bytes2)) + ); + }; + var write2 = async (data, options) => { + const bytes2 = encode16(data); + const cid = await link(bytes2, options); + return { cid, bytes: bytes2 }; + }; + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/dag.js + var iterate = function* (value) { + if (value && typeof value === "object" && "iterateIPLDBlocks" in value && typeof value.iterateIPLDBlocks === "function") { + yield* value.iterateIPLDBlocks(); + } + }; + var createStore = (blocks = []) => { + const store4 = /* @__PURE__ */ new Map(); + addEveryInto(blocks, store4); + return store4; + }; + var EMBED_CODE = identity.code; + var get = (cid, store4, fallback) => { + if (cid.multihash.code === EMBED_CODE) { + return { cid, bytes: cid.multihash.digest }; + } + const block = ( + /** @type {API.Block|undefined} */ + store4.get(`${cid}`) + ); + return block ? block : fallback === void 0 ? notFound(cid) : fallback; + }; + var notFound = (link10) => { + throw new Error(`Block for the ${link10} is not found`); + }; + var writeInto = async (source, store4, options = {}) => { + const codec = ( + /** @type {MF.BlockEncoder} */ + options.codec || cbor_exports2 + ); + const hasher = ( + /** @type {MF.MultihashHasher} */ + options.hasher || sha256 + ); + const bytes2 = codec.encode(source); + const digest3 = await hasher.digest(bytes2); + const link10 = create3(codec.code, digest3); + store4.set( + /** @type {API.ToString} */ + link10.toString(), + { + bytes: bytes2, + cid: link10 + } + ); + return { bytes: bytes2, cid: link10, data: source }; + }; + var addInto = ({ cid, bytes: bytes2 }, store4) => { + store4.set( + /** @type {API.ToString} */ + cid.toString(), + { + bytes: bytes2, + cid + } + ); + return { bytes: bytes2, cid }; + }; + var addEveryInto = (source, store4) => { + for (const block of source) { + addInto(block, store4); + } + }; + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/car.js + var car_exports = {}; + __export(car_exports, { + code: () => code5, + contentType: () => contentType2, + createWriter: () => createWriter2, + decode: () => decode21, + encode: () => encode18, + link: () => link2, + name: () => name5, + write: () => write3 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/buffer-reader-browser.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/buffer-decoder.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/header-validator.js + init_dirname(); + init_buffer2(); + init_process(); + var Kinds = { + Null: ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => obj === null + ), + Int: ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => Number.isInteger(obj) + ), + Float: ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => typeof obj === "number" && Number.isFinite(obj) + ), + String: ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => typeof obj === "string" + ), + Bool: ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => typeof obj === "boolean" + ), + Bytes: ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => obj instanceof Uint8Array + ), + Link: ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => !Kinds.Null(obj) && typeof obj === "object" && obj.asCID === obj + ), + List: ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => Array.isArray(obj) + ), + Map: ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => !Kinds.Null(obj) && typeof obj === "object" && obj.asCID !== obj && !Kinds.List(obj) && !Kinds.Bytes(obj) + ) + }; + var Types = { + Int: Kinds.Int, + "CarHeader > version": ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => Types.Int(obj) + ), + "CarHeader > roots (anon) > valueType (anon)": Kinds.Link, + "CarHeader > roots (anon)": ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => Kinds.List(obj) && Array.prototype.every.call(obj, Types["CarHeader > roots (anon) > valueType (anon)"]) + ), + "CarHeader > roots": ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => Types["CarHeader > roots (anon)"](obj) + ), + CarHeader: ( + /** + * @param {any} obj + * @returns {boolean} + */ + (obj) => { + const keys2 = obj && Object.keys(obj); + return Kinds.Map(obj) && ["version"].every((k5) => keys2.includes(k5)) && Object.entries(obj).every(([name15, value]) => Types["CarHeader > " + name15] && Types["CarHeader > " + name15](value)); + } + ) + }; + var CarHeader = Types.CarHeader; + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/decoder-common.js + init_dirname(); + init_buffer2(); + init_process(); + var import_varint3 = __toESM(require_varint(), 1); + var CIDV0_BYTES = { + SHA2_256: 18, + LENGTH: 32, + DAG_PB: 112 + }; + var V2_HEADER_LENGTH = ( + /* characteristics */ + 16 + 8 + 8 + 8 + ); + function decodeVarint(bytes2, seeker) { + if (!bytes2.length) { + throw new Error("Unexpected end of data"); + } + const i8 = import_varint3.default.decode(bytes2); + seeker.seek( + /** @type {number} */ + import_varint3.default.decode.bytes + ); + return i8; + } + function decodeV2Header(bytes2) { + const dv = new DataView(bytes2.buffer, bytes2.byteOffset, bytes2.byteLength); + let offset2 = 0; + const header = { + version: 2, + /** @type {[bigint, bigint]} */ + characteristics: [ + dv.getBigUint64(offset2, true), + dv.getBigUint64(offset2 += 8, true) + ], + dataOffset: Number(dv.getBigUint64(offset2 += 8, true)), + dataSize: Number(dv.getBigUint64(offset2 += 8, true)), + indexOffset: Number(dv.getBigUint64(offset2 += 8, true)) + }; + return header; + } + function getMultihashLength(bytes2) { + import_varint3.default.decode(bytes2); + const codeLength = ( + /** @type {number} */ + import_varint3.default.decode.bytes + ); + const length3 = import_varint3.default.decode(bytes2.subarray(import_varint3.default.decode.bytes)); + const lengthLength = ( + /** @type {number} */ + import_varint3.default.decode.bytes + ); + const mhLength = codeLength + lengthLength + length3; + return mhLength; + } + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/buffer-decoder.js + function readHeader(reader2, strictVersion) { + const length3 = decodeVarint(reader2.upTo(8), reader2); + if (length3 === 0) { + throw new Error("Invalid CAR header (zero length)"); + } + const header = reader2.exactly(length3, true); + const block = decode6(header); + if (!CarHeader(block)) { + throw new Error("Invalid CAR header format"); + } + if (block.version !== 1 && block.version !== 2 || strictVersion !== void 0 && block.version !== strictVersion) { + throw new Error(`Invalid CAR version: ${block.version}${strictVersion !== void 0 ? ` (expected ${strictVersion})` : ""}`); + } + const hasRoots = Array.isArray(block.roots); + if (block.version === 1 && !hasRoots || block.version === 2 && hasRoots) { + throw new Error("Invalid CAR header format"); + } + if (block.version === 1) { + return block; + } + const v2Header = decodeV2Header(reader2.exactly(V2_HEADER_LENGTH, true)); + reader2.seek(v2Header.dataOffset - reader2.pos); + const v1Header = readHeader(reader2, 1); + return Object.assign(v1Header, v2Header); + } + function readCid(reader2) { + const first = reader2.exactly(2, false); + if (first[0] === CIDV0_BYTES.SHA2_256 && first[1] === CIDV0_BYTES.LENGTH) { + const bytes3 = reader2.exactly(34, true); + const multihash2 = decode10(bytes3); + return CID2.create(0, CIDV0_BYTES.DAG_PB, multihash2); + } + const version3 = decodeVarint(reader2.upTo(8), reader2); + if (version3 !== 1) { + throw new Error(`Unexpected CID version (${version3})`); + } + const codec = decodeVarint(reader2.upTo(8), reader2); + const bytes2 = reader2.exactly(getMultihashLength(reader2.upTo(8)), true); + const multihash = decode10(bytes2); + return CID2.create(version3, codec, multihash); + } + function readBlockHead(reader2) { + const start = reader2.pos; + let length3 = decodeVarint(reader2.upTo(8), reader2); + if (length3 === 0) { + throw new Error("Invalid CAR section (zero length)"); + } + length3 += reader2.pos - start; + const cid = readCid(reader2); + const blockLength2 = length3 - Number(reader2.pos - start); + return { cid, length: length3, blockLength: blockLength2 }; + } + function fromBytes(bytes2) { + let reader2 = bytesReader(bytes2); + const header = readHeader(reader2); + if (header.version === 2) { + const v1length = reader2.pos - header.dataOffset; + reader2 = limitReader(reader2, header.dataSize - v1length); + } + const blocks = []; + while (reader2.upTo(8).length > 0) { + const { cid, blockLength: blockLength2 } = readBlockHead(reader2); + blocks.push({ cid, bytes: reader2.exactly(blockLength2, true) }); + } + return { + header, + blocks + }; + } + function bytesReader(bytes2) { + let pos = 0; + return { + upTo(length3) { + return bytes2.subarray(pos, pos + Math.min(length3, bytes2.length - pos)); + }, + exactly(length3, seek = false) { + if (length3 > bytes2.length - pos) { + throw new Error("Unexpected end of data"); + } + const out = bytes2.subarray(pos, pos + length3); + if (seek) { + pos += length3; + } + return out; + }, + seek(length3) { + pos += length3; + }, + get pos() { + return pos; + } + }; + } + function limitReader(reader2, byteLimit) { + let bytesRead = 0; + return { + upTo(length3) { + let bytes2 = reader2.upTo(length3); + if (bytes2.length + bytesRead > byteLimit) { + bytes2 = bytes2.subarray(0, byteLimit - bytesRead); + } + return bytes2; + }, + exactly(length3, seek = false) { + const bytes2 = reader2.exactly(length3, seek); + if (bytes2.length + bytesRead > byteLimit) { + throw new Error("Unexpected end of data"); + } + if (seek) { + bytesRead += length3; + } + return bytes2; + }, + seek(length3) { + bytesRead += length3; + reader2.seek(length3); + }, + get pos() { + return reader2.pos; + } + }; + } + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/buffer-reader-browser.js + var CarBufferReader = class _CarBufferReader { + /** + * @constructs CarBufferReader + * @param {CarHeader|CarV2Header} header + * @param {Block[]} blocks + */ + constructor(header, blocks) { + this._header = header; + this._blocks = blocks; + this._cids = void 0; + } + /** + * @property version + * @memberof CarBufferReader + * @instance + */ + get version() { + return this._header.version; + } + /** + * Get the list of roots defined by the CAR referenced by this reader. May be + * zero or more `CID`s. + * + * @function + * @memberof CarBufferReader + * @instance + * @returns {CID[]} + */ + getRoots() { + return this._header.roots; + } + /** + * Check whether a given `CID` exists within the CAR referenced by this + * reader. + * + * @function + * @memberof CarBufferReader + * @instance + * @param {CID} key + * @returns {boolean} + */ + has(key) { + return this._blocks.some((b6) => b6.cid.equals(key)); + } + /** + * Fetch a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) from the CAR + * referenced by this reader matching the provided `CID`. In the case where + * the provided `CID` doesn't exist within the CAR, `undefined` will be + * returned. + * + * @function + * @memberof CarBufferReader + * @instance + * @param {CID} key + * @returns {Block | undefined} + */ + get(key) { + return this._blocks.find((b6) => b6.cid.equals(key)); + } + /** + * Returns a `Block[]` of the `Block`s (`{ cid:CID, bytes:Uint8Array }` pairs) contained within + * the CAR referenced by this reader. + * + * @function + * @memberof CarBufferReader + * @instance + * @returns {Block[]} + */ + blocks() { + return this._blocks; + } + /** + * Returns a `CID[]` of the `CID`s contained within the CAR referenced by this reader. + * + * @function + * @memberof CarBufferReader + * @instance + * @returns {CID[]} + */ + cids() { + if (!this._cids) { + this._cids = this._blocks.map((b6) => b6.cid); + } + return this._cids; + } + /** + * Instantiate a {@link CarBufferReader} from a `Uint8Array` blob. This performs a + * decode fully in memory and maintains the decoded state in memory for full + * access to the data via the `CarReader` API. + * + * @static + * @memberof CarBufferReader + * @param {Uint8Array} bytes + * @returns {CarBufferReader} + */ + static fromBytes(bytes2) { + if (!(bytes2 instanceof Uint8Array)) { + throw new TypeError("fromBytes() requires a Uint8Array"); + } + const { header, blocks } = fromBytes(bytes2); + return new _CarBufferReader(header, blocks); + } + }; + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/buffer-writer.js + init_dirname(); + init_buffer2(); + init_process(); + var import_varint4 = __toESM(require_varint(), 1); + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/cborg.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/encode.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/is.js + init_dirname(); + init_buffer2(); + init_process(); + var typeofs2 = [ + "string", + "number", + "bigint", + "symbol" + ]; + var objectTypeNames2 = [ + "Function", + "Generator", + "AsyncGenerator", + "GeneratorFunction", + "AsyncGeneratorFunction", + "AsyncFunction", + "Observable", + "Array", + "Buffer", + "Object", + "RegExp", + "Date", + "Error", + "Map", + "Set", + "WeakMap", + "WeakSet", + "ArrayBuffer", + "SharedArrayBuffer", + "DataView", + "Promise", + "URL", + "HTMLElement", + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + "BigInt64Array", + "BigUint64Array" + ]; + function is2(value) { + if (value === null) { + return "null"; + } + if (value === void 0) { + return "undefined"; + } + if (value === true || value === false) { + return "boolean"; + } + const typeOf = typeof value; + if (typeofs2.includes(typeOf)) { + return typeOf; + } + if (typeOf === "function") { + return "Function"; + } + if (Array.isArray(value)) { + return "Array"; + } + if (isBuffer3(value)) { + return "Buffer"; + } + const objectType2 = getObjectType2(value); + if (objectType2) { + return objectType2; + } + return "Object"; + } + function isBuffer3(value) { + return value && value.constructor && value.constructor.isBuffer && value.constructor.isBuffer.call(null, value); + } + function getObjectType2(value) { + const objectTypeName = Object.prototype.toString.call(value).slice(8, -1); + if (objectTypeNames2.includes(objectTypeName)) { + return objectTypeName; + } + return void 0; + } + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/token.js + init_dirname(); + init_buffer2(); + init_process(); + var Type2 = class { + constructor(major, name15, terminal) { + this.major = major; + this.majorEncoded = major << 5; + this.name = name15; + this.terminal = terminal; + } + toString() { + return `Type[${this.major}].${this.name}`; + } + compare(typ) { + return this.major < typ.major ? -1 : this.major > typ.major ? 1 : 0; + } + }; + Type2.uint = new Type2(0, "uint", true); + Type2.negint = new Type2(1, "negint", true); + Type2.bytes = new Type2(2, "bytes", true); + Type2.string = new Type2(3, "string", true); + Type2.array = new Type2(4, "array", false); + Type2.map = new Type2(5, "map", false); + Type2.tag = new Type2(6, "tag", false); + Type2.float = new Type2(7, "float", true); + Type2.false = new Type2(7, "false", true); + Type2.true = new Type2(7, "true", true); + Type2.null = new Type2(7, "null", true); + Type2.undefined = new Type2(7, "undefined", true); + Type2.break = new Type2(7, "break", true); + var Token2 = class { + constructor(type3, value, encodedLength) { + this.type = type3; + this.value = value; + this.encodedLength = encodedLength; + this.encodedBytes = void 0; + this.byteValue = void 0; + } + toString() { + return `Token[${this.type}].${this.value}`; + } + }; + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/bl.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/byte-utils.js + init_dirname(); + init_buffer2(); + init_process(); + var useBuffer2 = globalThis.process && !globalThis.process.browser && globalThis.Buffer && typeof globalThis.Buffer.isBuffer === "function"; + var textDecoder2 = new TextDecoder(); + var textEncoder2 = new TextEncoder(); + function isBuffer4(buf3) { + return useBuffer2 && globalThis.Buffer.isBuffer(buf3); + } + function asU8A2(buf3) { + if (!(buf3 instanceof Uint8Array)) { + return Uint8Array.from(buf3); + } + return isBuffer4(buf3) ? new Uint8Array(buf3.buffer, buf3.byteOffset, buf3.byteLength) : buf3; + } + var toString4 = useBuffer2 ? (bytes2, start, end) => { + return end - start > 64 ? globalThis.Buffer.from(bytes2.subarray(start, end)).toString("utf8") : utf8Slice2(bytes2, start, end); + } : (bytes2, start, end) => { + return end - start > 64 ? textDecoder2.decode(bytes2.subarray(start, end)) : utf8Slice2(bytes2, start, end); + }; + var fromString4 = useBuffer2 ? (string4) => { + return string4.length > 64 ? globalThis.Buffer.from(string4) : utf8ToBytes2(string4); + } : (string4) => { + return string4.length > 64 ? textEncoder2.encode(string4) : utf8ToBytes2(string4); + }; + var fromArray2 = (arr) => { + return Uint8Array.from(arr); + }; + var slice2 = useBuffer2 ? (bytes2, start, end) => { + if (isBuffer4(bytes2)) { + return new Uint8Array(bytes2.subarray(start, end)); + } + return bytes2.slice(start, end); + } : (bytes2, start, end) => { + return bytes2.slice(start, end); + }; + var concat2 = useBuffer2 ? (chunks, length3) => { + chunks = chunks.map((c8) => c8 instanceof Uint8Array ? c8 : globalThis.Buffer.from(c8)); + return asU8A2(globalThis.Buffer.concat(chunks, length3)); + } : (chunks, length3) => { + const out = new Uint8Array(length3); + let off = 0; + for (let b6 of chunks) { + if (off + b6.length > out.length) { + b6 = b6.subarray(0, out.length - off); + } + out.set(b6, off); + off += b6.length; + } + return out; + }; + var alloc2 = useBuffer2 ? (size4) => { + return globalThis.Buffer.allocUnsafe(size4); + } : (size4) => { + return new Uint8Array(size4); + }; + function compare2(b1, b22) { + if (isBuffer4(b1) && isBuffer4(b22)) { + return b1.compare(b22); + } + for (let i8 = 0; i8 < b1.length; i8++) { + if (b1[i8] === b22[i8]) { + continue; + } + return b1[i8] < b22[i8] ? -1 : 1; + } + return 0; + } + function utf8ToBytes2(string4, units = Infinity) { + let codePoint; + const length3 = string4.length; + let leadSurrogate = null; + const bytes2 = []; + for (let i8 = 0; i8 < length3; ++i8) { + codePoint = string4.charCodeAt(i8); + if (codePoint > 55295 && codePoint < 57344) { + if (!leadSurrogate) { + if (codePoint > 56319) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + continue; + } else if (i8 + 1 === length3) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + continue; + } + leadSurrogate = codePoint; + continue; + } + if (codePoint < 56320) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + leadSurrogate = codePoint; + continue; + } + codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536; + } else if (leadSurrogate) { + if ((units -= 3) > -1) + bytes2.push(239, 191, 189); + } + leadSurrogate = null; + if (codePoint < 128) { + if ((units -= 1) < 0) + break; + bytes2.push(codePoint); + } else if (codePoint < 2048) { + if ((units -= 2) < 0) + break; + bytes2.push(codePoint >> 6 | 192, codePoint & 63 | 128); + } else if (codePoint < 65536) { + if ((units -= 3) < 0) + break; + bytes2.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128); + } else if (codePoint < 1114112) { + if ((units -= 4) < 0) + break; + bytes2.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128); + } else { + throw new Error("Invalid code point"); + } + } + return bytes2; + } + function utf8Slice2(buf3, offset2, end) { + const res = []; + while (offset2 < end) { + const firstByte = buf3[offset2]; + let codePoint = null; + let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1; + if (offset2 + bytesPerSequence <= end) { + let secondByte, thirdByte, fourthByte, tempCodePoint; + switch (bytesPerSequence) { + case 1: + if (firstByte < 128) { + codePoint = firstByte; + } + break; + case 2: + secondByte = buf3[offset2 + 1]; + if ((secondByte & 192) === 128) { + tempCodePoint = (firstByte & 31) << 6 | secondByte & 63; + if (tempCodePoint > 127) { + codePoint = tempCodePoint; + } + } + break; + case 3: + secondByte = buf3[offset2 + 1]; + thirdByte = buf3[offset2 + 2]; + if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) { + tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63; + if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) { + codePoint = tempCodePoint; + } + } + break; + case 4: + secondByte = buf3[offset2 + 1]; + thirdByte = buf3[offset2 + 2]; + fourthByte = buf3[offset2 + 3]; + if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) { + tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63; + if (tempCodePoint > 65535 && tempCodePoint < 1114112) { + codePoint = tempCodePoint; + } + } + } + } + if (codePoint === null) { + codePoint = 65533; + bytesPerSequence = 1; + } else if (codePoint > 65535) { + codePoint -= 65536; + res.push(codePoint >>> 10 & 1023 | 55296); + codePoint = 56320 | codePoint & 1023; + } + res.push(codePoint); + offset2 += bytesPerSequence; + } + return decodeCodePointsArray2(res); + } + var MAX_ARGUMENTS_LENGTH2 = 4096; + function decodeCodePointsArray2(codePoints) { + const len = codePoints.length; + if (len <= MAX_ARGUMENTS_LENGTH2) { + return String.fromCharCode.apply(String, codePoints); + } + let res = ""; + let i8 = 0; + while (i8 < len) { + res += String.fromCharCode.apply(String, codePoints.slice(i8, i8 += MAX_ARGUMENTS_LENGTH2)); + } + return res; + } + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/bl.js + var defaultChunkSize2 = 256; + var Bl2 = class { + constructor(chunkSize = defaultChunkSize2) { + this.chunkSize = chunkSize; + this.cursor = 0; + this.maxCursor = -1; + this.chunks = []; + this._initReuseChunk = null; + } + reset() { + this.cursor = 0; + this.maxCursor = -1; + if (this.chunks.length) { + this.chunks = []; + } + if (this._initReuseChunk !== null) { + this.chunks.push(this._initReuseChunk); + this.maxCursor = this._initReuseChunk.length - 1; + } + } + push(bytes2) { + let topChunk = this.chunks[this.chunks.length - 1]; + const newMax = this.cursor + bytes2.length; + if (newMax <= this.maxCursor + 1) { + const chunkPos = topChunk.length - (this.maxCursor - this.cursor) - 1; + topChunk.set(bytes2, chunkPos); + } else { + if (topChunk) { + const chunkPos = topChunk.length - (this.maxCursor - this.cursor) - 1; + if (chunkPos < topChunk.length) { + this.chunks[this.chunks.length - 1] = topChunk.subarray(0, chunkPos); + this.maxCursor = this.cursor - 1; + } + } + if (bytes2.length < 64 && bytes2.length < this.chunkSize) { + topChunk = alloc2(this.chunkSize); + this.chunks.push(topChunk); + this.maxCursor += topChunk.length; + if (this._initReuseChunk === null) { + this._initReuseChunk = topChunk; + } + topChunk.set(bytes2, 0); + } else { + this.chunks.push(bytes2); + this.maxCursor += bytes2.length; + } + } + this.cursor += bytes2.length; + } + toBytes(reset = false) { + let byts; + if (this.chunks.length === 1) { + const chunk = this.chunks[0]; + if (reset && this.cursor > chunk.length / 2) { + byts = this.cursor === chunk.length ? chunk : chunk.subarray(0, this.cursor); + this._initReuseChunk = null; + this.chunks = []; + } else { + byts = slice2(chunk, 0, this.cursor); + } + } else { + byts = concat2(this.chunks, this.cursor); + } + if (reset) { + this.reset(); + } + return byts; + } + }; + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/common.js + init_dirname(); + init_buffer2(); + init_process(); + var decodeErrPrefix2 = "CBOR decode error:"; + var encodeErrPrefix2 = "CBOR encode error:"; + var uintMinorPrefixBytes2 = []; + uintMinorPrefixBytes2[23] = 1; + uintMinorPrefixBytes2[24] = 2; + uintMinorPrefixBytes2[25] = 3; + uintMinorPrefixBytes2[26] = 5; + uintMinorPrefixBytes2[27] = 9; + function assertEnoughData2(data, pos, need) { + if (data.length - pos < need) { + throw new Error(`${decodeErrPrefix2} not enough data for type`); + } + } + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/jump.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/0uint.js + init_dirname(); + init_buffer2(); + init_process(); + var uintBoundaries2 = [ + 24, + 256, + 65536, + 4294967296, + BigInt("18446744073709551616") + ]; + function readUint82(data, offset2, options) { + assertEnoughData2(data, offset2, 1); + const value = data[offset2]; + if (options.strict === true && value < uintBoundaries2[0]) { + throw new Error(`${decodeErrPrefix2} integer encoded in more bytes than necessary (strict decode)`); + } + return value; + } + function readUint162(data, offset2, options) { + assertEnoughData2(data, offset2, 2); + const value = data[offset2] << 8 | data[offset2 + 1]; + if (options.strict === true && value < uintBoundaries2[1]) { + throw new Error(`${decodeErrPrefix2} integer encoded in more bytes than necessary (strict decode)`); + } + return value; + } + function readUint322(data, offset2, options) { + assertEnoughData2(data, offset2, 4); + const value = data[offset2] * 16777216 + (data[offset2 + 1] << 16) + (data[offset2 + 2] << 8) + data[offset2 + 3]; + if (options.strict === true && value < uintBoundaries2[2]) { + throw new Error(`${decodeErrPrefix2} integer encoded in more bytes than necessary (strict decode)`); + } + return value; + } + function readUint642(data, offset2, options) { + assertEnoughData2(data, offset2, 8); + const hi = data[offset2] * 16777216 + (data[offset2 + 1] << 16) + (data[offset2 + 2] << 8) + data[offset2 + 3]; + const lo = data[offset2 + 4] * 16777216 + (data[offset2 + 5] << 16) + (data[offset2 + 6] << 8) + data[offset2 + 7]; + const value = (BigInt(hi) << BigInt(32)) + BigInt(lo); + if (options.strict === true && value < uintBoundaries2[3]) { + throw new Error(`${decodeErrPrefix2} integer encoded in more bytes than necessary (strict decode)`); + } + if (value <= Number.MAX_SAFE_INTEGER) { + return Number(value); + } + if (options.allowBigInt === true) { + return value; + } + throw new Error(`${decodeErrPrefix2} integers outside of the safe integer range are not supported`); + } + function decodeUint82(data, pos, _minor, options) { + return new Token2(Type2.uint, readUint82(data, pos + 1, options), 2); + } + function decodeUint162(data, pos, _minor, options) { + return new Token2(Type2.uint, readUint162(data, pos + 1, options), 3); + } + function decodeUint322(data, pos, _minor, options) { + return new Token2(Type2.uint, readUint322(data, pos + 1, options), 5); + } + function decodeUint642(data, pos, _minor, options) { + return new Token2(Type2.uint, readUint642(data, pos + 1, options), 9); + } + function encodeUint2(buf3, token) { + return encodeUintValue2(buf3, 0, token.value); + } + function encodeUintValue2(buf3, major, uint) { + if (uint < uintBoundaries2[0]) { + const nuint = Number(uint); + buf3.push([major | nuint]); + } else if (uint < uintBoundaries2[1]) { + const nuint = Number(uint); + buf3.push([ + major | 24, + nuint + ]); + } else if (uint < uintBoundaries2[2]) { + const nuint = Number(uint); + buf3.push([ + major | 25, + nuint >>> 8, + nuint & 255 + ]); + } else if (uint < uintBoundaries2[3]) { + const nuint = Number(uint); + buf3.push([ + major | 26, + nuint >>> 24 & 255, + nuint >>> 16 & 255, + nuint >>> 8 & 255, + nuint & 255 + ]); + } else { + const buint = BigInt(uint); + if (buint < uintBoundaries2[4]) { + const set5 = [ + major | 27, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ]; + let lo = Number(buint & BigInt(4294967295)); + let hi = Number(buint >> BigInt(32) & BigInt(4294967295)); + set5[8] = lo & 255; + lo = lo >> 8; + set5[7] = lo & 255; + lo = lo >> 8; + set5[6] = lo & 255; + lo = lo >> 8; + set5[5] = lo & 255; + set5[4] = hi & 255; + hi = hi >> 8; + set5[3] = hi & 255; + hi = hi >> 8; + set5[2] = hi & 255; + hi = hi >> 8; + set5[1] = hi & 255; + buf3.push(set5); + } else { + throw new Error(`${decodeErrPrefix2} encountered BigInt larger than allowable range`); + } + } + } + encodeUint2.encodedSize = function encodedSize9(token) { + return encodeUintValue2.encodedSize(token.value); + }; + encodeUintValue2.encodedSize = function encodedSize10(uint) { + if (uint < uintBoundaries2[0]) { + return 1; + } + if (uint < uintBoundaries2[1]) { + return 2; + } + if (uint < uintBoundaries2[2]) { + return 3; + } + if (uint < uintBoundaries2[3]) { + return 5; + } + return 9; + }; + encodeUint2.compareTokens = function compareTokens4(tok1, tok2) { + return tok1.value < tok2.value ? -1 : tok1.value > tok2.value ? 1 : 0; + }; + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/1negint.js + init_dirname(); + init_buffer2(); + init_process(); + function decodeNegint82(data, pos, _minor, options) { + return new Token2(Type2.negint, -1 - readUint82(data, pos + 1, options), 2); + } + function decodeNegint162(data, pos, _minor, options) { + return new Token2(Type2.negint, -1 - readUint162(data, pos + 1, options), 3); + } + function decodeNegint322(data, pos, _minor, options) { + return new Token2(Type2.negint, -1 - readUint322(data, pos + 1, options), 5); + } + var neg1b2 = BigInt(-1); + var pos1b2 = BigInt(1); + function decodeNegint642(data, pos, _minor, options) { + const int = readUint642(data, pos + 1, options); + if (typeof int !== "bigint") { + const value = -1 - int; + if (value >= Number.MIN_SAFE_INTEGER) { + return new Token2(Type2.negint, value, 9); + } + } + if (options.allowBigInt !== true) { + throw new Error(`${decodeErrPrefix2} integers outside of the safe integer range are not supported`); + } + return new Token2(Type2.negint, neg1b2 - BigInt(int), 9); + } + function encodeNegint2(buf3, token) { + const negint = token.value; + const unsigned = typeof negint === "bigint" ? negint * neg1b2 - pos1b2 : negint * -1 - 1; + encodeUintValue2(buf3, token.type.majorEncoded, unsigned); + } + encodeNegint2.encodedSize = function encodedSize11(token) { + const negint = token.value; + const unsigned = typeof negint === "bigint" ? negint * neg1b2 - pos1b2 : negint * -1 - 1; + if (unsigned < uintBoundaries2[0]) { + return 1; + } + if (unsigned < uintBoundaries2[1]) { + return 2; + } + if (unsigned < uintBoundaries2[2]) { + return 3; + } + if (unsigned < uintBoundaries2[3]) { + return 5; + } + return 9; + }; + encodeNegint2.compareTokens = function compareTokens5(tok1, tok2) { + return tok1.value < tok2.value ? 1 : tok1.value > tok2.value ? -1 : 0; + }; + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/2bytes.js + init_dirname(); + init_buffer2(); + init_process(); + function toToken5(data, pos, prefix, length3) { + assertEnoughData2(data, pos, prefix + length3); + const buf3 = slice2(data, pos + prefix, pos + prefix + length3); + return new Token2(Type2.bytes, buf3, prefix + length3); + } + function decodeBytesCompact2(data, pos, minor, _options2) { + return toToken5(data, pos, 1, minor); + } + function decodeBytes82(data, pos, _minor, options) { + return toToken5(data, pos, 2, readUint82(data, pos + 1, options)); + } + function decodeBytes162(data, pos, _minor, options) { + return toToken5(data, pos, 3, readUint162(data, pos + 1, options)); + } + function decodeBytes322(data, pos, _minor, options) { + return toToken5(data, pos, 5, readUint322(data, pos + 1, options)); + } + function decodeBytes642(data, pos, _minor, options) { + const l8 = readUint642(data, pos + 1, options); + if (typeof l8 === "bigint") { + throw new Error(`${decodeErrPrefix2} 64-bit integer bytes lengths not supported`); + } + return toToken5(data, pos, 9, l8); + } + function tokenBytes2(token) { + if (token.encodedBytes === void 0) { + token.encodedBytes = token.type === Type2.string ? fromString4(token.value) : token.value; + } + return token.encodedBytes; + } + function encodeBytes2(buf3, token) { + const bytes2 = tokenBytes2(token); + encodeUintValue2(buf3, token.type.majorEncoded, bytes2.length); + buf3.push(bytes2); + } + encodeBytes2.encodedSize = function encodedSize12(token) { + const bytes2 = tokenBytes2(token); + return encodeUintValue2.encodedSize(bytes2.length) + bytes2.length; + }; + encodeBytes2.compareTokens = function compareTokens6(tok1, tok2) { + return compareBytes2(tokenBytes2(tok1), tokenBytes2(tok2)); + }; + function compareBytes2(b1, b22) { + return b1.length < b22.length ? -1 : b1.length > b22.length ? 1 : compare2(b1, b22); + } + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/3string.js + init_dirname(); + init_buffer2(); + init_process(); + function toToken6(data, pos, prefix, length3, options) { + const totLength = prefix + length3; + assertEnoughData2(data, pos, totLength); + const tok = new Token2(Type2.string, toString4(data, pos + prefix, pos + totLength), totLength); + if (options.retainStringBytes === true) { + tok.byteValue = slice2(data, pos + prefix, pos + totLength); + } + return tok; + } + function decodeStringCompact2(data, pos, minor, options) { + return toToken6(data, pos, 1, minor, options); + } + function decodeString82(data, pos, _minor, options) { + return toToken6(data, pos, 2, readUint82(data, pos + 1, options), options); + } + function decodeString162(data, pos, _minor, options) { + return toToken6(data, pos, 3, readUint162(data, pos + 1, options), options); + } + function decodeString322(data, pos, _minor, options) { + return toToken6(data, pos, 5, readUint322(data, pos + 1, options), options); + } + function decodeString642(data, pos, _minor, options) { + const l8 = readUint642(data, pos + 1, options); + if (typeof l8 === "bigint") { + throw new Error(`${decodeErrPrefix2} 64-bit integer string lengths not supported`); + } + return toToken6(data, pos, 9, l8, options); + } + var encodeString2 = encodeBytes2; + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/4array.js + init_dirname(); + init_buffer2(); + init_process(); + function toToken7(_data2, _pos, prefix, length3) { + return new Token2(Type2.array, length3, prefix); + } + function decodeArrayCompact2(data, pos, minor, _options2) { + return toToken7(data, pos, 1, minor); + } + function decodeArray82(data, pos, _minor, options) { + return toToken7(data, pos, 2, readUint82(data, pos + 1, options)); + } + function decodeArray162(data, pos, _minor, options) { + return toToken7(data, pos, 3, readUint162(data, pos + 1, options)); + } + function decodeArray322(data, pos, _minor, options) { + return toToken7(data, pos, 5, readUint322(data, pos + 1, options)); + } + function decodeArray642(data, pos, _minor, options) { + const l8 = readUint642(data, pos + 1, options); + if (typeof l8 === "bigint") { + throw new Error(`${decodeErrPrefix2} 64-bit integer array lengths not supported`); + } + return toToken7(data, pos, 9, l8); + } + function decodeArrayIndefinite2(data, pos, _minor, options) { + if (options.allowIndefinite === false) { + throw new Error(`${decodeErrPrefix2} indefinite length items not allowed`); + } + return toToken7(data, pos, 1, Infinity); + } + function encodeArray2(buf3, token) { + encodeUintValue2(buf3, Type2.array.majorEncoded, token.value); + } + encodeArray2.compareTokens = encodeUint2.compareTokens; + encodeArray2.encodedSize = function encodedSize13(token) { + return encodeUintValue2.encodedSize(token.value); + }; + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/5map.js + init_dirname(); + init_buffer2(); + init_process(); + function toToken8(_data2, _pos, prefix, length3) { + return new Token2(Type2.map, length3, prefix); + } + function decodeMapCompact2(data, pos, minor, _options2) { + return toToken8(data, pos, 1, minor); + } + function decodeMap82(data, pos, _minor, options) { + return toToken8(data, pos, 2, readUint82(data, pos + 1, options)); + } + function decodeMap162(data, pos, _minor, options) { + return toToken8(data, pos, 3, readUint162(data, pos + 1, options)); + } + function decodeMap322(data, pos, _minor, options) { + return toToken8(data, pos, 5, readUint322(data, pos + 1, options)); + } + function decodeMap642(data, pos, _minor, options) { + const l8 = readUint642(data, pos + 1, options); + if (typeof l8 === "bigint") { + throw new Error(`${decodeErrPrefix2} 64-bit integer map lengths not supported`); + } + return toToken8(data, pos, 9, l8); + } + function decodeMapIndefinite2(data, pos, _minor, options) { + if (options.allowIndefinite === false) { + throw new Error(`${decodeErrPrefix2} indefinite length items not allowed`); + } + return toToken8(data, pos, 1, Infinity); + } + function encodeMap2(buf3, token) { + encodeUintValue2(buf3, Type2.map.majorEncoded, token.value); + } + encodeMap2.compareTokens = encodeUint2.compareTokens; + encodeMap2.encodedSize = function encodedSize14(token) { + return encodeUintValue2.encodedSize(token.value); + }; + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/6tag.js + init_dirname(); + init_buffer2(); + init_process(); + function decodeTagCompact2(_data2, _pos, minor, _options2) { + return new Token2(Type2.tag, minor, 1); + } + function decodeTag82(data, pos, _minor, options) { + return new Token2(Type2.tag, readUint82(data, pos + 1, options), 2); + } + function decodeTag162(data, pos, _minor, options) { + return new Token2(Type2.tag, readUint162(data, pos + 1, options), 3); + } + function decodeTag322(data, pos, _minor, options) { + return new Token2(Type2.tag, readUint322(data, pos + 1, options), 5); + } + function decodeTag642(data, pos, _minor, options) { + return new Token2(Type2.tag, readUint642(data, pos + 1, options), 9); + } + function encodeTag2(buf3, token) { + encodeUintValue2(buf3, Type2.tag.majorEncoded, token.value); + } + encodeTag2.compareTokens = encodeUint2.compareTokens; + encodeTag2.encodedSize = function encodedSize15(token) { + return encodeUintValue2.encodedSize(token.value); + }; + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/7float.js + init_dirname(); + init_buffer2(); + init_process(); + var MINOR_FALSE2 = 20; + var MINOR_TRUE2 = 21; + var MINOR_NULL2 = 22; + var MINOR_UNDEFINED2 = 23; + function decodeUndefined2(_data2, _pos, _minor, options) { + if (options.allowUndefined === false) { + throw new Error(`${decodeErrPrefix2} undefined values are not supported`); + } else if (options.coerceUndefinedToNull === true) { + return new Token2(Type2.null, null, 1); + } + return new Token2(Type2.undefined, void 0, 1); + } + function decodeBreak2(_data2, _pos, _minor, options) { + if (options.allowIndefinite === false) { + throw new Error(`${decodeErrPrefix2} indefinite length items not allowed`); + } + return new Token2(Type2.break, void 0, 1); + } + function createToken2(value, bytes2, options) { + if (options) { + if (options.allowNaN === false && Number.isNaN(value)) { + throw new Error(`${decodeErrPrefix2} NaN values are not supported`); + } + if (options.allowInfinity === false && (value === Infinity || value === -Infinity)) { + throw new Error(`${decodeErrPrefix2} Infinity values are not supported`); + } + } + return new Token2(Type2.float, value, bytes2); + } + function decodeFloat162(data, pos, _minor, options) { + return createToken2(readFloat162(data, pos + 1), 3, options); + } + function decodeFloat322(data, pos, _minor, options) { + return createToken2(readFloat322(data, pos + 1), 5, options); + } + function decodeFloat642(data, pos, _minor, options) { + return createToken2(readFloat642(data, pos + 1), 9, options); + } + function encodeFloat2(buf3, token, options) { + const float3 = token.value; + if (float3 === false) { + buf3.push([Type2.float.majorEncoded | MINOR_FALSE2]); + } else if (float3 === true) { + buf3.push([Type2.float.majorEncoded | MINOR_TRUE2]); + } else if (float3 === null) { + buf3.push([Type2.float.majorEncoded | MINOR_NULL2]); + } else if (float3 === void 0) { + buf3.push([Type2.float.majorEncoded | MINOR_UNDEFINED2]); + } else { + let decoded; + let success = false; + if (!options || options.float64 !== true) { + encodeFloat162(float3); + decoded = readFloat162(ui8a2, 1); + if (float3 === decoded || Number.isNaN(float3)) { + ui8a2[0] = 249; + buf3.push(ui8a2.slice(0, 3)); + success = true; + } else { + encodeFloat322(float3); + decoded = readFloat322(ui8a2, 1); + if (float3 === decoded) { + ui8a2[0] = 250; + buf3.push(ui8a2.slice(0, 5)); + success = true; + } + } + } + if (!success) { + encodeFloat642(float3); + decoded = readFloat642(ui8a2, 1); + ui8a2[0] = 251; + buf3.push(ui8a2.slice(0, 9)); + } + } + } + encodeFloat2.encodedSize = function encodedSize16(token, options) { + const float3 = token.value; + if (float3 === false || float3 === true || float3 === null || float3 === void 0) { + return 1; + } + if (!options || options.float64 !== true) { + encodeFloat162(float3); + let decoded = readFloat162(ui8a2, 1); + if (float3 === decoded || Number.isNaN(float3)) { + return 3; + } + encodeFloat322(float3); + decoded = readFloat322(ui8a2, 1); + if (float3 === decoded) { + return 5; + } + } + return 9; + }; + var buffer2 = new ArrayBuffer(9); + var dataView2 = new DataView(buffer2, 1); + var ui8a2 = new Uint8Array(buffer2, 0); + function encodeFloat162(inp) { + if (inp === Infinity) { + dataView2.setUint16(0, 31744, false); + } else if (inp === -Infinity) { + dataView2.setUint16(0, 64512, false); + } else if (Number.isNaN(inp)) { + dataView2.setUint16(0, 32256, false); + } else { + dataView2.setFloat32(0, inp); + const valu32 = dataView2.getUint32(0); + const exponent = (valu32 & 2139095040) >> 23; + const mantissa = valu32 & 8388607; + if (exponent === 255) { + dataView2.setUint16(0, 31744, false); + } else if (exponent === 0) { + dataView2.setUint16(0, (inp & 2147483648) >> 16 | mantissa >> 13, false); + } else { + const logicalExponent = exponent - 127; + if (logicalExponent < -24) { + dataView2.setUint16(0, 0); + } else if (logicalExponent < -14) { + dataView2.setUint16(0, (valu32 & 2147483648) >> 16 | 1 << 24 + logicalExponent, false); + } else { + dataView2.setUint16(0, (valu32 & 2147483648) >> 16 | logicalExponent + 15 << 10 | mantissa >> 13, false); + } + } + } + } + function readFloat162(ui8a3, pos) { + if (ui8a3.length - pos < 2) { + throw new Error(`${decodeErrPrefix2} not enough data for float16`); + } + const half = (ui8a3[pos] << 8) + ui8a3[pos + 1]; + if (half === 31744) { + return Infinity; + } + if (half === 64512) { + return -Infinity; + } + if (half === 32256) { + return NaN; + } + const exp = half >> 10 & 31; + const mant = half & 1023; + let val; + if (exp === 0) { + val = mant * 2 ** -24; + } else if (exp !== 31) { + val = (mant + 1024) * 2 ** (exp - 25); + } else { + val = mant === 0 ? Infinity : NaN; + } + return half & 32768 ? -val : val; + } + function encodeFloat322(inp) { + dataView2.setFloat32(0, inp, false); + } + function readFloat322(ui8a3, pos) { + if (ui8a3.length - pos < 4) { + throw new Error(`${decodeErrPrefix2} not enough data for float32`); + } + const offset2 = (ui8a3.byteOffset || 0) + pos; + return new DataView(ui8a3.buffer, offset2, 4).getFloat32(0, false); + } + function encodeFloat642(inp) { + dataView2.setFloat64(0, inp, false); + } + function readFloat642(ui8a3, pos) { + if (ui8a3.length - pos < 8) { + throw new Error(`${decodeErrPrefix2} not enough data for float64`); + } + const offset2 = (ui8a3.byteOffset || 0) + pos; + return new DataView(ui8a3.buffer, offset2, 8).getFloat64(0, false); + } + encodeFloat2.compareTokens = encodeUint2.compareTokens; + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/jump.js + function invalidMinor2(data, pos, minor) { + throw new Error(`${decodeErrPrefix2} encountered invalid minor (${minor}) for major ${data[pos] >>> 5}`); + } + function errorer2(msg) { + return () => { + throw new Error(`${decodeErrPrefix2} ${msg}`); + }; + } + var jump2 = []; + for (let i8 = 0; i8 <= 23; i8++) { + jump2[i8] = invalidMinor2; + } + jump2[24] = decodeUint82; + jump2[25] = decodeUint162; + jump2[26] = decodeUint322; + jump2[27] = decodeUint642; + jump2[28] = invalidMinor2; + jump2[29] = invalidMinor2; + jump2[30] = invalidMinor2; + jump2[31] = invalidMinor2; + for (let i8 = 32; i8 <= 55; i8++) { + jump2[i8] = invalidMinor2; + } + jump2[56] = decodeNegint82; + jump2[57] = decodeNegint162; + jump2[58] = decodeNegint322; + jump2[59] = decodeNegint642; + jump2[60] = invalidMinor2; + jump2[61] = invalidMinor2; + jump2[62] = invalidMinor2; + jump2[63] = invalidMinor2; + for (let i8 = 64; i8 <= 87; i8++) { + jump2[i8] = decodeBytesCompact2; + } + jump2[88] = decodeBytes82; + jump2[89] = decodeBytes162; + jump2[90] = decodeBytes322; + jump2[91] = decodeBytes642; + jump2[92] = invalidMinor2; + jump2[93] = invalidMinor2; + jump2[94] = invalidMinor2; + jump2[95] = errorer2("indefinite length bytes/strings are not supported"); + for (let i8 = 96; i8 <= 119; i8++) { + jump2[i8] = decodeStringCompact2; + } + jump2[120] = decodeString82; + jump2[121] = decodeString162; + jump2[122] = decodeString322; + jump2[123] = decodeString642; + jump2[124] = invalidMinor2; + jump2[125] = invalidMinor2; + jump2[126] = invalidMinor2; + jump2[127] = errorer2("indefinite length bytes/strings are not supported"); + for (let i8 = 128; i8 <= 151; i8++) { + jump2[i8] = decodeArrayCompact2; + } + jump2[152] = decodeArray82; + jump2[153] = decodeArray162; + jump2[154] = decodeArray322; + jump2[155] = decodeArray642; + jump2[156] = invalidMinor2; + jump2[157] = invalidMinor2; + jump2[158] = invalidMinor2; + jump2[159] = decodeArrayIndefinite2; + for (let i8 = 160; i8 <= 183; i8++) { + jump2[i8] = decodeMapCompact2; + } + jump2[184] = decodeMap82; + jump2[185] = decodeMap162; + jump2[186] = decodeMap322; + jump2[187] = decodeMap642; + jump2[188] = invalidMinor2; + jump2[189] = invalidMinor2; + jump2[190] = invalidMinor2; + jump2[191] = decodeMapIndefinite2; + for (let i8 = 192; i8 <= 215; i8++) { + jump2[i8] = decodeTagCompact2; + } + jump2[216] = decodeTag82; + jump2[217] = decodeTag162; + jump2[218] = decodeTag322; + jump2[219] = decodeTag642; + jump2[220] = invalidMinor2; + jump2[221] = invalidMinor2; + jump2[222] = invalidMinor2; + jump2[223] = invalidMinor2; + for (let i8 = 224; i8 <= 243; i8++) { + jump2[i8] = errorer2("simple values are not supported"); + } + jump2[244] = invalidMinor2; + jump2[245] = invalidMinor2; + jump2[246] = invalidMinor2; + jump2[247] = decodeUndefined2; + jump2[248] = errorer2("simple values are not supported"); + jump2[249] = decodeFloat162; + jump2[250] = decodeFloat322; + jump2[251] = decodeFloat642; + jump2[252] = invalidMinor2; + jump2[253] = invalidMinor2; + jump2[254] = invalidMinor2; + jump2[255] = decodeBreak2; + var quick2 = []; + for (let i8 = 0; i8 < 24; i8++) { + quick2[i8] = new Token2(Type2.uint, i8, 1); + } + for (let i8 = -1; i8 >= -24; i8--) { + quick2[31 - i8] = new Token2(Type2.negint, i8, 1); + } + quick2[64] = new Token2(Type2.bytes, new Uint8Array(0), 1); + quick2[96] = new Token2(Type2.string, "", 1); + quick2[128] = new Token2(Type2.array, 0, 1); + quick2[160] = new Token2(Type2.map, 0, 1); + quick2[244] = new Token2(Type2.false, false, 1); + quick2[245] = new Token2(Type2.true, true, 1); + quick2[246] = new Token2(Type2.null, null, 1); + function quickEncodeToken2(token) { + switch (token.type) { + case Type2.false: + return fromArray2([244]); + case Type2.true: + return fromArray2([245]); + case Type2.null: + return fromArray2([246]); + case Type2.bytes: + if (!token.value.length) { + return fromArray2([64]); + } + return; + case Type2.string: + if (token.value === "") { + return fromArray2([96]); + } + return; + case Type2.array: + if (token.value === 0) { + return fromArray2([128]); + } + return; + case Type2.map: + if (token.value === 0) { + return fromArray2([160]); + } + return; + case Type2.uint: + if (token.value < 24) { + return fromArray2([Number(token.value)]); + } + return; + case Type2.negint: + if (token.value >= -24) { + return fromArray2([31 - Number(token.value)]); + } + } + } + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/encode.js + function makeCborEncoders2() { + const encoders = []; + encoders[Type2.uint.major] = encodeUint2; + encoders[Type2.negint.major] = encodeNegint2; + encoders[Type2.bytes.major] = encodeBytes2; + encoders[Type2.string.major] = encodeString2; + encoders[Type2.array.major] = encodeArray2; + encoders[Type2.map.major] = encodeMap2; + encoders[Type2.tag.major] = encodeTag2; + encoders[Type2.float.major] = encodeFloat2; + return encoders; + } + var cborEncoders2 = makeCborEncoders2(); + var buf2 = new Bl2(); + var Ref2 = class _Ref { + constructor(obj, parent) { + this.obj = obj; + this.parent = parent; + } + includes(obj) { + let p8 = this; + do { + if (p8.obj === obj) { + return true; + } + } while (p8 = p8.parent); + return false; + } + static createCheck(stack, obj) { + if (stack && stack.includes(obj)) { + throw new Error(`${encodeErrPrefix2} object contains circular references`); + } + return new _Ref(obj, stack); + } + }; + var simpleTokens2 = { + null: new Token2(Type2.null, null), + undefined: new Token2(Type2.undefined, void 0), + true: new Token2(Type2.true, true), + false: new Token2(Type2.false, false), + emptyArray: new Token2(Type2.array, 0), + emptyMap: new Token2(Type2.map, 0) + }; + var typeEncoders2 = { + number(obj, _typ, _options2, _refStack) { + if (!Number.isInteger(obj) || !Number.isSafeInteger(obj)) { + return new Token2(Type2.float, obj); + } else if (obj >= 0) { + return new Token2(Type2.uint, obj); + } else { + return new Token2(Type2.negint, obj); + } + }, + bigint(obj, _typ, _options2, _refStack) { + if (obj >= BigInt(0)) { + return new Token2(Type2.uint, obj); + } else { + return new Token2(Type2.negint, obj); + } + }, + Uint8Array(obj, _typ, _options2, _refStack) { + return new Token2(Type2.bytes, obj); + }, + string(obj, _typ, _options2, _refStack) { + return new Token2(Type2.string, obj); + }, + boolean(obj, _typ, _options2, _refStack) { + return obj ? simpleTokens2.true : simpleTokens2.false; + }, + null(_obj, _typ, _options2, _refStack) { + return simpleTokens2.null; + }, + undefined(_obj, _typ, _options2, _refStack) { + return simpleTokens2.undefined; + }, + ArrayBuffer(obj, _typ, _options2, _refStack) { + return new Token2(Type2.bytes, new Uint8Array(obj)); + }, + DataView(obj, _typ, _options2, _refStack) { + return new Token2(Type2.bytes, new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength)); + }, + Array(obj, _typ, options, refStack) { + if (!obj.length) { + if (options.addBreakTokens === true) { + return [ + simpleTokens2.emptyArray, + new Token2(Type2.break) + ]; + } + return simpleTokens2.emptyArray; + } + refStack = Ref2.createCheck(refStack, obj); + const entries6 = []; + let i8 = 0; + for (const e12 of obj) { + entries6[i8++] = objectToTokens2(e12, options, refStack); + } + if (options.addBreakTokens) { + return [ + new Token2(Type2.array, obj.length), + entries6, + new Token2(Type2.break) + ]; + } + return [ + new Token2(Type2.array, obj.length), + entries6 + ]; + }, + Object(obj, typ, options, refStack) { + const isMap = typ !== "Object"; + const keys2 = isMap ? obj.keys() : Object.keys(obj); + const length3 = isMap ? obj.size : keys2.length; + if (!length3) { + if (options.addBreakTokens === true) { + return [ + simpleTokens2.emptyMap, + new Token2(Type2.break) + ]; + } + return simpleTokens2.emptyMap; + } + refStack = Ref2.createCheck(refStack, obj); + const entries6 = []; + let i8 = 0; + for (const key of keys2) { + entries6[i8++] = [ + objectToTokens2(key, options, refStack), + objectToTokens2(isMap ? obj.get(key) : obj[key], options, refStack) + ]; + } + sortMapEntries2(entries6, options); + if (options.addBreakTokens) { + return [ + new Token2(Type2.map, length3), + entries6, + new Token2(Type2.break) + ]; + } + return [ + new Token2(Type2.map, length3), + entries6 + ]; + } + }; + typeEncoders2.Map = typeEncoders2.Object; + typeEncoders2.Buffer = typeEncoders2.Uint8Array; + for (const typ of "Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" ")) { + typeEncoders2[`${typ}Array`] = typeEncoders2.DataView; + } + function objectToTokens2(obj, options = {}, refStack) { + const typ = is2(obj); + const customTypeEncoder = options && options.typeEncoders && options.typeEncoders[typ] || typeEncoders2[typ]; + if (typeof customTypeEncoder === "function") { + const tokens = customTypeEncoder(obj, typ, options, refStack); + if (tokens != null) { + return tokens; + } + } + const typeEncoder = typeEncoders2[typ]; + if (!typeEncoder) { + throw new Error(`${encodeErrPrefix2} unsupported type: ${typ}`); + } + return typeEncoder(obj, typ, options, refStack); + } + function sortMapEntries2(entries6, options) { + if (options.mapSorter) { + entries6.sort(options.mapSorter); + } + } + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/decode.js + init_dirname(); + init_buffer2(); + init_process(); + var DONE2 = Symbol.for("DONE"); + var BREAK2 = Symbol.for("BREAK"); + + // ../../node_modules/.pnpm/cborg@1.10.0/node_modules/cborg/esm/lib/length.js + init_dirname(); + init_buffer2(); + init_process(); + var cborEncoders3 = makeCborEncoders2(); + var defaultEncodeOptions3 = { + float64: false, + quickEncodeToken: quickEncodeToken2 + }; + function tokensToLength(tokens, encoders = cborEncoders3, options = defaultEncodeOptions3) { + if (Array.isArray(tokens)) { + let len = 0; + for (const token of tokens) { + len += tokensToLength(token, encoders, options); + } + return len; + } else { + const encoder4 = encoders[tokens.type.major]; + if (encoder4.encodedSize === void 0 || typeof encoder4.encodedSize !== "function") { + throw new Error(`Encoder for ${tokens.type.name} does not have an encodedSize()`); + } + return encoder4.encodedSize(tokens, options); + } + } + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/buffer-writer.js + var CarBufferWriter = class { + /** + * @param {Uint8Array} bytes + * @param {number} headerSize + */ + constructor(bytes2, headerSize) { + this.bytes = bytes2; + this.byteOffset = headerSize; + this.roots = []; + this.headerSize = headerSize; + } + /** + * Add a root to this writer, to be used to create a header when the CAR is + * finalized with {@link CarBufferWriter.close `close()`} + * + * @param {CID} root + * @param {{resize?:boolean}} [options] + * @returns {CarBufferWriter} + */ + addRoot(root3, options) { + addRoot(this, root3, options); + return this; + } + /** + * Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive. + * Throws if there is not enough capacity. + * + * @param {Block} block - A `{ cid:CID, bytes:Uint8Array }` pair. + * @returns {CarBufferWriter} + */ + write(block) { + addBlock(this, block); + return this; + } + /** + * Finalize the CAR and return it as a `Uint8Array`. + * + * @param {object} [options] + * @param {boolean} [options.resize] + * @returns {Uint8Array} + */ + close(options) { + return close(this, options); + } + }; + var addRoot = (writer2, root3, options = {}) => { + const { resize = false } = options; + const { bytes: bytes2, headerSize, byteOffset, roots } = writer2; + writer2.roots.push(root3); + const size4 = headerLength(writer2); + if (size4 > headerSize) { + if (size4 - headerSize + byteOffset < bytes2.byteLength) { + if (resize) { + resizeHeader(writer2, size4); + } else { + roots.pop(); + throw new RangeError(`Header of size ${headerSize} has no capacity for new root ${root3}. + However there is a space in the buffer and you could call addRoot(root, { resize: root }) to resize header to make a space for this root.`); + } + } else { + roots.pop(); + throw new RangeError(`Buffer has no capacity for a new root ${root3}`); + } + } + }; + var blockLength = ({ cid, bytes: bytes2 }) => { + const size4 = cid.bytes.byteLength + bytes2.byteLength; + return import_varint4.default.encodingLength(size4) + size4; + }; + var addBlock = (writer2, { cid, bytes: bytes2 }) => { + const byteLength = cid.bytes.byteLength + bytes2.byteLength; + const size4 = import_varint4.default.encode(byteLength); + if (writer2.byteOffset + size4.length + byteLength > writer2.bytes.byteLength) { + throw new RangeError("Buffer has no capacity for this block"); + } else { + writeBytes(writer2, size4); + writeBytes(writer2, cid.bytes); + writeBytes(writer2, bytes2); + } + }; + var close = (writer2, options = {}) => { + const { resize = false } = options; + const { roots, bytes: bytes2, byteOffset, headerSize } = writer2; + const headerBytes = encode4({ version: 1, roots }); + const varintBytes = import_varint4.default.encode(headerBytes.length); + const size4 = varintBytes.length + headerBytes.byteLength; + const offset2 = headerSize - size4; + if (offset2 === 0) { + writeHeader(writer2, varintBytes, headerBytes); + return bytes2.subarray(0, byteOffset); + } else if (resize) { + resizeHeader(writer2, size4); + writeHeader(writer2, varintBytes, headerBytes); + return bytes2.subarray(0, writer2.byteOffset); + } else { + throw new RangeError(`Header size was overestimated. +You can use close({ resize: true }) to resize header`); + } + }; + var resizeHeader = (writer2, byteLength) => { + const { bytes: bytes2, headerSize } = writer2; + bytes2.set(bytes2.subarray(headerSize, writer2.byteOffset), byteLength); + writer2.byteOffset += byteLength - headerSize; + writer2.headerSize = byteLength; + }; + var writeBytes = (writer2, bytes2) => { + writer2.bytes.set(bytes2, writer2.byteOffset); + writer2.byteOffset += bytes2.length; + }; + var writeHeader = ({ bytes: bytes2 }, varint6, header) => { + bytes2.set(varint6); + bytes2.set(header, varint6.length); + }; + var headerPreludeTokens = [ + new Token2(Type2.map, 2), + new Token2(Type2.string, "version"), + new Token2(Type2.uint, 1), + new Token2(Type2.string, "roots") + ]; + var CID_TAG = new Token2(Type2.tag, 42); + var calculateHeaderLength = (rootLengths) => { + const tokens = [...headerPreludeTokens]; + tokens.push(new Token2(Type2.array, rootLengths.length)); + for (const rootLength of rootLengths) { + tokens.push(CID_TAG); + tokens.push(new Token2(Type2.bytes, { length: rootLength + 1 })); + } + const length3 = tokensToLength(tokens); + return import_varint4.default.encodingLength(length3) + length3; + }; + var headerLength = ({ roots }) => calculateHeaderLength(roots.map((cid) => cid.bytes.byteLength)); + var estimateHeaderLength = (rootCount, rootByteLength = 36) => calculateHeaderLength(new Array(rootCount).fill(rootByteLength)); + var createWriter = (buffer4, options = {}) => { + const { + roots = [], + byteOffset = 0, + byteLength = buffer4.byteLength, + headerSize = headerLength({ roots }) + } = options; + const bytes2 = new Uint8Array(buffer4, byteOffset, byteLength); + const writer2 = new CarBufferWriter(bytes2, headerSize); + for (const root3 of roots) { + writer2.addRoot(root3); + } + return writer2; + }; + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/car.js + var contentType2 = "application/vnd.ipld.car"; + var name5 = "CAR"; + var code5 = 514; + var Writer = class { + /** + * @param {API.IPLDBlock[]} blocks + * @param {number} byteLength + */ + constructor(blocks = [], byteLength = 0) { + this.written = /* @__PURE__ */ new Set(); + this.blocks = blocks; + this.byteLength = byteLength; + } + /** + * @param {API.IPLDBlock[]} blocks + */ + write(...blocks) { + for (const block of blocks) { + const id = block.cid.toString(base322); + if (!this.written.has(id)) { + this.blocks.push(block); + this.byteLength += blockLength( + /** @type {any} */ + block + ); + this.written.add(id); + } + } + return this; + } + /** + * @param {API.IPLDBlock[]} rootBlocks + */ + flush(...rootBlocks) { + const roots = []; + for (const block of rootBlocks.reverse()) { + const id = block.cid.toString(base322); + if (!this.written.has(id)) { + this.blocks.unshift(block); + this.byteLength += blockLength({ + cid: ( + /** @type {CarBufferWriter.CID} */ + block.cid + ), + bytes: block.bytes + }); + this.written.add(id); + } + roots.unshift( + /** @type {CarBufferWriter.CID} */ + block.cid + ); + } + this.byteLength += headerLength({ roots }); + const buffer4 = new ArrayBuffer(this.byteLength); + const writer2 = createWriter(buffer4, { roots }); + for ( + const block of + /** @type {CarBufferWriter.Block[]} */ + this.blocks + ) { + writer2.write(block); + } + return writer2.close(); + } + }; + var createWriter2 = () => new Writer(); + var encode18 = ({ roots = [], blocks }) => { + const writer2 = new Writer(); + if (blocks) { + writer2.write(...blocks.values()); + } + return writer2.flush(...roots); + }; + var decode21 = (bytes2) => { + const reader2 = CarBufferReader.fromBytes(bytes2); + const roots = []; + const blocks = /* @__PURE__ */ new Map(); + for (const root3 of reader2.getRoots()) { + const block = ( + /** @type {API.IPLDBlock} */ + reader2.get(root3) + ); + if (block) { + roots.push(block); + } + } + for (const block of reader2.blocks()) { + blocks.set(block.cid.toString(), block); + } + return { roots, blocks }; + }; + var link2 = async (bytes2, { hasher = sha256 } = {}) => { + return ( + /** @type {API.Link} */ + create3(code5, await hasher.digest(bytes2)) + ); + }; + var write3 = async (data, options) => { + const bytes2 = encode18(data); + const cid = await link2(bytes2, options); + return { bytes: bytes2, cid }; + }; + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/schema.js + var schema_exports3 = {}; + __export(schema_exports3, { + API: () => API, + Bytes: () => Bytes, + DID: () => did_exports2, + Link: () => link_exports2, + Text: () => text_exports, + URI: () => uri_exports, + and: () => and, + array: () => array, + boolean: () => boolean, + bytes: () => bytes, + dictionary: () => dictionary, + did: () => match3, + endsWith: () => endsWith, + enum: () => createEnum, + error: () => error2, + float: () => float, + greaterThan: () => greaterThan, + integer: () => integer, + intersection: () => intersection, + lessThan: () => lessThan, + link: () => match2, + literal: () => literal, + memberError: () => memberError, + never: () => never, + nullable: () => nullable, + number: () => number, + ok: () => ok, + optional: () => optional, + or: () => or3, + refine: () => refine, + startsWith: () => startsWith, + string: () => string, + struct: () => struct, + text: () => match4, + tuple: () => tuple, + typeError: () => typeError, + unknown: () => unknown, + uri: () => match, + variant: () => variant + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/schema/uri.js + var uri_exports = {}; + __export(uri_exports, { + from: () => from8, + match: () => match, + read: () => read3, + uri: () => uri + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/schema/schema.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/schema/type.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/result.js + init_dirname(); + init_buffer2(); + init_process(); + var ok = (value) => { + if (value == null) { + throw new TypeError(`ok(${value}) is not allowed, consider ok({}) instead`); + } else { + return { ok: value }; + } + }; + var error = (cause) => { + if (cause == null) { + throw new TypeError( + `error(${cause}) is not allowed, consider passing an error instead` + ); + } else { + return { error: cause }; + } + }; + var panic = (message2) => { + throw new Failure(message2); + }; + var fail2 = (message2) => ({ error: new Failure(message2) }); + var Failure = class extends Error { + describe() { + return this.toString(); + } + get message() { + return this.describe(); + } + toJSON() { + const { name: name15, message: message2, stack } = this; + return { name: name15, message: message2, stack }; + } + }; + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/schema/schema.js + var API = class { + /** + * @param {Settings} settings + */ + constructor(settings3) { + this.settings = settings3; + } + toString() { + return `new ${this.constructor.name}()`; + } + /** + * @abstract + * @param {I} input + * @param {Settings} settings + * @returns {Schema.ReadResult} + */ + /* c8 ignore next 3 */ + readWith(input, settings3) { + throw new Error(`Abstract method readWith must be implemented by subclass`); + } + /** + * @param {I} input + * @returns {Schema.ReadResult} + */ + read(input) { + return this.readWith(input, this.settings); + } + /** + * @param {unknown} value + * @returns {value is T} + */ + is(value) { + return !this.read( + /** @type {I} */ + value + )?.error; + } + /** + * @param {unknown} value + * @return {T} + */ + from(value) { + const result = this.read( + /** @type {I} */ + value + ); + if (result.error) { + throw result.error; + } else { + return result.ok; + } + } + /** + * @returns {Schema.Schema} + */ + optional() { + return optional(this); + } + /** + * @returns {Schema.Schema} + */ + nullable() { + return nullable(this); + } + /** + * @returns {Schema.Schema} + */ + array() { + return array(this); + } + /** + * @template U + * @param {Schema.Reader} schema + * @returns {Schema.Schema} + */ + or(schema9) { + return or3(this, schema9); + } + /** + * @template U + * @param {Schema.Reader} schema + * @returns {Schema.Schema} + */ + and(schema9) { + return and(this, schema9); + } + /** + * @template {T} U + * @param {Schema.Reader} schema + * @returns {Schema.Schema} + */ + refine(schema9) { + return refine(this, schema9); + } + /** + * @template {string} Kind + * @param {Kind} [kind] + * @returns {Schema.Schema, I>} + */ + brand(kind) { + return ( + /** @type {Schema.Schema, I>} */ + this + ); + } + /** + * @param {Schema.NotUndefined} value + * @returns {Schema.DefaultSchema, I>} + */ + default(value) { + const fallback = this.from(value); + if (fallback === void 0) { + throw new Error(`Value of type undefined is not a valid default`); + } + const schema9 = new Default({ + reader: ( + /** @type {Schema.Reader} */ + this + ), + value: ( + /** @type {Schema.NotUndefined} */ + fallback + ) + }); + return ( + /** @type {Schema.DefaultSchema, I>} */ + schema9 + ); + } + }; + var Never = class extends API { + toString() { + return "never()"; + } + /** + * @param {I} input + * @returns {Schema.ReadResult} + */ + read(input) { + return typeError({ expect: "never", actual: input }); + } + }; + var never = () => new Never(); + var Unknown = class extends API { + /** + * @param {I} input + */ + read(input) { + return ( + /** @type {Schema.ReadResult}*/ + { ok: input } + ); + } + toString() { + return "unknown()"; + } + }; + var unknown = () => new Unknown(); + var Nullable = class extends API { + /** + * @param {I} input + * @param {Schema.Reader} reader + */ + readWith(input, reader2) { + const result = reader2.read(input); + if (result.error) { + return input === null ? { ok: null } : { + error: new UnionError({ + causes: [ + result.error, + typeError({ expect: "null", actual: input }).error + ] + }) + }; + } else { + return result; + } + } + toString() { + return `${this.settings}.nullable()`; + } + }; + var nullable = (schema9) => new Nullable(schema9); + var Optional = class extends API { + optional() { + return this; + } + /** + * @param {I} input + * @param {Schema.Reader} reader + * @returns {Schema.ReadResult} + */ + readWith(input, reader2) { + const result = reader2.read(input); + return result.error && input === void 0 ? { ok: void 0 } : result; + } + toString() { + return `${this.settings}.optional()`; + } + }; + var Default = class extends API { + /** + * @returns {Schema.DefaultSchema, I>} + */ + optional() { + return ( + /** @type {Schema.DefaultSchema, I>} */ + this + ); + } + /** + * @param {I} input + * @param {object} options + * @param {Schema.Reader} options.reader + * @param {O} options.value + * @returns {Schema.ReadResult} + */ + readWith(input, { reader: reader2, value }) { + if (input === void 0) { + return ( + /** @type {Schema.ReadResult} */ + { ok: value } + ); + } else { + const result = reader2.read(input); + return result.error ? result : result.ok !== void 0 ? ( + // We just checked that result.ok is not undefined but still needs + // reassurance + /** @type {Schema.ReadResult} */ + result + ) : { ok: value }; + } + } + toString() { + return `${this.settings.reader}.default(${JSON.stringify( + this.settings.value + )})`; + } + get value() { + return this.settings.value; + } + }; + var optional = (schema9) => new Optional(schema9); + var ArrayOf = class extends API { + /** + * @param {I} input + * @param {Schema.Reader} schema + */ + readWith(input, schema9) { + if (!Array.isArray(input)) { + return typeError({ expect: "array", actual: input }); + } + const results = []; + for (const [index2, value] of input.entries()) { + const result = schema9.read(value); + if (result.error) { + return memberError({ at: index2, cause: result.error }); + } else { + results.push(result.ok); + } + } + return { ok: results }; + } + get element() { + return this.settings; + } + toString() { + return `array(${this.element})`; + } + }; + var array = (schema9) => new ArrayOf(schema9); + var Tuple = class extends API { + /** + * @param {I} input + * @param {U} shape + * @returns {Schema.ReadResult>} + */ + readWith(input, shape) { + if (!Array.isArray(input)) { + return typeError({ expect: "array", actual: input }); + } + if (input.length !== this.shape.length) { + return error2(`Array must contain exactly ${this.shape.length} elements`); + } + const results = []; + for (const [index2, reader2] of shape.entries()) { + const result = reader2.read(input[index2]); + if (result.error) { + return memberError({ at: index2, cause: result.error }); + } else { + results[index2] = result.ok; + } + } + return { ok: ( + /** @type {Schema.InferTuple} */ + results + ) }; + } + /** @type {U} */ + get shape() { + return this.settings; + } + toString() { + return `tuple([${this.shape.map((reader2) => reader2.toString()).join(", ")}])`; + } + }; + var tuple = (shape) => new Tuple(shape); + var Dictionary = class _Dictionary extends API { + /** + * @param {I} input + * @param {object} schema + * @param {Schema.Reader} schema.key + * @param {Schema.Reader} schema.value + */ + readWith(input, { key, value }) { + if (typeof input != "object" || input === null || Array.isArray(input)) { + return typeError({ + expect: "dictionary", + actual: input + }); + } + const dict = ( + /** @type {Schema.Dictionary} */ + {} + ); + for (const [k5, v7] of Object.entries(input)) { + const keyResult = key.read(k5); + if (keyResult.error) { + return memberError({ at: k5, cause: keyResult.error }); + } + const valueResult = value.read(v7); + if (valueResult.error) { + return memberError({ at: k5, cause: valueResult.error }); + } + if (valueResult.ok !== void 0) { + dict[keyResult.ok] = valueResult.ok; + } + } + return { ok: dict }; + } + get key() { + return this.settings.key; + } + get value() { + return this.settings.value; + } + partial() { + const { key, value } = this.settings; + return new _Dictionary({ + key, + value: optional(value) + }); + } + toString() { + return `dictionary(${this.settings})`; + } + }; + var dictionary = ({ value, key }) => new Dictionary({ + value, + key: key || /** @type {Schema.Reader} */ + string() + }); + var Enum = class extends API { + /** + * @param {I} input + * @param {{type:string, variants:Set}} settings + * @returns {Schema.ReadResult} + */ + readWith(input, { variants, type: type3 }) { + if (variants.has(input)) { + return ( + /** @type {Schema.ReadResult} */ + { ok: input } + ); + } else { + return typeError({ expect: type3, actual: input }); + } + } + toString() { + return this.settings.type; + } + }; + var createEnum = (variants) => new Enum({ + type: variants.join("|"), + variants: new Set(variants) + }); + var Union = class extends API { + /** + * @param {I} input + * @param {U} variants + */ + readWith(input, variants) { + const causes = []; + for (const reader2 of variants) { + const result = reader2.read(input); + if (result.error) { + causes.push(result.error); + } else { + return ( + /** @type {Schema.ReadResult>} */ + result + ); + } + } + return { error: new UnionError({ causes }) }; + } + get variants() { + return this.settings; + } + toString() { + return `union([${this.variants.map((type3) => type3.toString()).join(", ")}])`; + } + }; + var union = (variants) => new Union(variants); + var or3 = (left, right) => union([left, right]); + var Intersection = class extends API { + /** + * @param {I} input + * @param {U} schemas + * @returns {Schema.ReadResult>} + */ + readWith(input, schemas) { + const causes = []; + for (const schema9 of schemas) { + const result = schema9.read(input); + if (result.error) { + causes.push(result.error); + } + } + return causes.length > 0 ? { error: new IntersectionError({ causes }) } : ( + /** @type {Schema.ReadResult>} */ + { + ok: input + } + ); + } + toString() { + return `intersection([${this.settings.map((type3) => type3.toString()).join(",")}])`; + } + }; + var intersection = (variants) => new Intersection(variants); + var and = (left, right) => intersection([left, right]); + var Boolean2 = class extends API { + /** + * @param {I} input + */ + readWith(input) { + switch (input) { + case true: + case false: + return { ok: ( + /** @type {boolean} */ + input + ) }; + default: + return typeError({ + expect: "boolean", + actual: input + }); + } + } + toString() { + return `boolean()`; + } + }; + var anyBoolean = new Boolean2(); + var boolean = () => anyBoolean; + var UnknownNumber = class extends API { + /** + * @param {number} n + */ + greaterThan(n9) { + return this.refine(greaterThan(n9)); + } + /** + * @param {number} n + */ + lessThan(n9) { + return this.refine(lessThan(n9)); + } + /** + * @template {O} U + * @param {Schema.Reader} schema + * @returns {Schema.NumberSchema} + */ + refine(schema9) { + return new RefinedNumber({ base: this, schema: schema9 }); + } + }; + var AnyNumber = class extends UnknownNumber { + /** + * @param {I} input + * @returns {Schema.ReadResult} + */ + readWith(input) { + return typeof input === "number" ? { ok: input } : typeError({ expect: "number", actual: input }); + } + toString() { + return `number()`; + } + }; + var anyNumber = new AnyNumber(); + var number = () => anyNumber; + var RefinedNumber = class extends UnknownNumber { + /** + * @param {I} input + * @param {{base:Schema.Reader, schema:Schema.Reader}} settings + * @returns {Schema.ReadResult} + */ + readWith(input, { base: base3, schema: schema9 }) { + const result = base3.read(input); + return result.error ? result : schema9.read(result.ok); + } + toString() { + return `${this.settings.base}.refine(${this.settings.schema})`; + } + }; + var LessThan = class extends API { + /** + * @param {T} input + * @param {number} number + * @returns {Schema.ReadResult} + */ + readWith(input, number3) { + if (input < number3) { + return { ok: input }; + } else { + return error2(`Expected ${input} < ${number3}`); + } + } + toString() { + return `lessThan(${this.settings})`; + } + }; + var lessThan = (n9) => new LessThan(n9); + var GreaterThan = class extends API { + /** + * @param {T} input + * @param {number} number + * @returns {Schema.ReadResult} + */ + readWith(input, number3) { + if (input > number3) { + return { ok: input }; + } else { + return error2(`Expected ${input} > ${number3}`); + } + } + toString() { + return `greaterThan(${this.settings})`; + } + }; + var greaterThan = (n9) => new GreaterThan(n9); + var Integer = { + /** + * @param {number} input + * @returns {Schema.ReadResult} + */ + read(input) { + return Number.isInteger(input) ? { ok: ( + /** @type {Schema.Integer} */ + input + ) } : typeError({ + expect: "integer", + actual: input + }); + }, + toString() { + return `Integer`; + } + }; + var anyInteger = anyNumber.refine(Integer); + var integer = () => anyInteger; + var Float = { + /** + * @param {number} number + * @returns {Schema.ReadResult} + */ + read(number3) { + return Number.isFinite(number3) ? { ok: ( + /** @type {Schema.Float} */ + number3 + ) } : typeError({ + expect: "Float", + actual: number3 + }); + }, + toString() { + return "Float"; + } + }; + var anyFloat = anyNumber.refine(Float); + var float = () => anyFloat; + var UnknownString = class extends API { + /** + * @template {O|unknown} U + * @param {Schema.Reader} schema + * @returns {Schema.StringSchema} + */ + refine(schema9) { + const other = ( + /** @type {Schema.Reader} */ + schema9 + ); + const rest = new RefinedString({ + base: this, + schema: other + }); + return ( + /** @type {Schema.StringSchema} */ + rest + ); + } + /** + * @template {string} Prefix + * @param {Prefix} prefix + */ + startsWith(prefix) { + return this.refine(startsWith(prefix)); + } + /** + * @template {string} Suffix + * @param {Suffix} suffix + */ + endsWith(suffix) { + return this.refine(endsWith(suffix)); + } + toString() { + return `string()`; + } + }; + var RefinedString = class extends UnknownString { + /** + * @param {I} input + * @param {{base:Schema.Reader, schema:Schema.Reader}} settings + * @returns {Schema.ReadResult} + */ + readWith(input, { base: base3, schema: schema9 }) { + const result = base3.read(input); + return result.error ? result : ( + /** @type {Schema.ReadResult} */ + schema9.read(result.ok) + ); + } + toString() { + return `${this.settings.base}.refine(${this.settings.schema})`; + } + }; + var AnyString = class extends UnknownString { + /** + * @param {I} input + * @returns {Schema.ReadResult} + */ + readWith(input) { + return typeof input === "string" ? { ok: input } : typeError({ expect: "string", actual: input }); + } + }; + var anyString = new AnyString(); + var string = () => anyString; + var BytesSchema = class extends API { + /** + * @param {I} input + * @returns {Schema.ReadResult} + */ + readWith(input) { + if (input instanceof Uint8Array) { + return { ok: input }; + } else { + return typeError({ expect: "Uint8Array", actual: input }); + } + } + }; + var Bytes = new BytesSchema(); + var bytes = () => Bytes; + var StartsWith = class extends API { + /** + * @param {Body} input + * @param {Prefix} prefix + */ + readWith(input, prefix) { + const result = input.startsWith(prefix) ? ( + /** @type {Schema.ReadResult} */ + { + ok: input + } + ) : error2(`Expect string to start with "${prefix}" instead got "${input}"`); + return result; + } + get prefix() { + return this.settings; + } + toString() { + return `startsWith("${this.prefix}")`; + } + }; + var startsWith = (prefix) => new StartsWith(prefix); + var EndsWith = class extends API { + /** + * @param {Body} input + * @param {Suffix} suffix + */ + readWith(input, suffix) { + return input.endsWith(suffix) ? ( + /** @type {Schema.ReadResult} */ + { + ok: input + } + ) : error2(`Expect string to end with "${suffix}" instead got "${input}"`); + } + get suffix() { + return this.settings; + } + toString() { + return `endsWith("${this.suffix}")`; + } + }; + var endsWith = (suffix) => new EndsWith(suffix); + var Refine = class extends API { + /** + * @param {I} input + * @param {{ base: Schema.Reader, schema: Schema.Reader }} settings + */ + readWith(input, { base: base3, schema: schema9 }) { + const result = base3.read(input); + return result.error ? result : schema9.read(result.ok); + } + toString() { + return `${this.settings.base}.refine(${this.settings.schema})`; + } + }; + var refine = (base3, schema9) => new Refine({ base: base3, schema: schema9 }); + var Literal = class extends API { + /** + * @param {I} input + * @param {T} expect + * @returns {Schema.ReadResult} + */ + readWith(input, expect) { + return input !== /** @type {unknown} */ + expect ? { error: new LiteralError({ expect, actual: input }) } : { ok: expect }; + } + get value() { + return ( + /** @type {Exclude} */ + this.settings + ); + } + /** + * @template {Schema.NotUndefined} U + * @param {U} value + */ + default(value = ( + /** @type {U} */ + this.value + )) { + return super.default(value); + } + toString() { + return `literal(${displayTypeName(this.value)})`; + } + }; + var literal = (value) => new Literal(value); + var Struct = class _Struct extends API { + /** + * @param {I} input + * @param {U} shape + * @returns {Schema.ReadResult>} + */ + readWith(input, shape) { + if (typeof input != "object" || input === null || Array.isArray(input)) { + return typeError({ + expect: "object", + actual: input + }); + } + const source = ( + /** @type {{[K in keyof U]: unknown}} */ + input + ); + const struct3 = ( + /** @type {{[K in keyof U]: Schema.Infer}} */ + {} + ); + const entries6 = ( + /** @type {{[K in keyof U]: [K & string, U[K]]}[keyof U][]} */ + Object.entries(shape) + ); + for (const [at2, reader2] of entries6) { + const result = reader2.read(source[at2]); + if (result.error) { + return memberError({ at: at2, cause: result.error }); + } else if (result.ok !== void 0) { + struct3[at2] = /** @type {Schema.Infer} */ + result.ok; + } + } + return { ok: struct3 }; + } + /** + * @returns {Schema.MapRepresentation>> & Schema.StructSchema} + */ + partial() { + return new _Struct( + Object.fromEntries( + Object.entries(this.shape).map(([key, value]) => [key, optional(value)]) + ) + ); + } + /** @type {U} */ + get shape() { + return this.settings; + } + toString() { + return [ + `struct({ `, + ...Object.entries(this.shape).map( + ([key, schema9]) => `${key}: ${schema9}, ` + ), + `})` + ].join(""); + } + /** + * @param {Schema.InferStructSource} data + */ + create(data) { + return this.from(data || {}); + } + /** + * @template {{[key:string]: Schema.Reader}} E + * @param {E} extension + * @returns {Schema.StructSchema} + */ + extend(extension) { + return new _Struct({ ...this.shape, ...extension }); + } + }; + var struct = (fields) => { + const shape = ( + /** @type {{[K in keyof U]: Schema.Reader}} */ + {} + ); + const entries6 = Object.entries(fields); + for (const [key, field] of entries6) { + switch (typeof field) { + case "number": + case "string": + case "boolean": + shape[key] = literal(field); + break; + case "object": + shape[key] = field === null ? literal(null) : field; + break; + default: + throw new Error( + `Invalid struct field "${key}", expected schema or literal, instead got ${typeof field}` + ); + } + } + return new Struct( + /** @type {V} */ + shape + ); + }; + var Variant = class extends API { + /** + * @param {I} input + * @param {U} variants + * @returns {Schema.ReadResult>} + */ + readWith(input, variants) { + if (typeof input != "object" || input === null || Array.isArray(input)) { + return typeError({ + expect: "object", + actual: input + }); + } + const keys2 = ( + /** @type {Array} */ + Object.keys(input) + ); + const [key] = keys2.length === 1 ? keys2 : []; + const reader2 = key ? variants[key] : void 0; + if (reader2) { + const result = reader2.read(input[key]); + return result.error ? memberError({ at: key, cause: result.error }) : { ok: ( + /** @type {Schema.InferVariant} */ + { [key]: result.ok } + ) }; + } else if (variants._) { + const result = variants._.read(input); + return result.error ? result : { ok: ( + /** @type {Schema.InferVariant} */ + { _: result.ok } + ) }; + } else if (key) { + return error2( + `Expected an object with one of the these keys: ${Object.keys(variants).sort().join(", ")} instead got object with key ${key}` + ); + } else { + return error2( + "Expected an object with a single key instead got object with keys " + keys2.sort().join(", ") + ); + } + } + /** + * @template [E=never] + * @param {I} input + * @param {E} [fallback] + */ + match(input, fallback) { + const result = this.read(input); + if (result.error) { + if (fallback !== void 0) { + return [null, fallback]; + } else { + throw result.error; + } + } else { + const [key] = Object.keys(result.ok); + const value = result.ok[key]; + return ( + /** @type {any} */ + [key, value] + ); + } + } + /** + * @template {Schema.InferVariant} O + * @param {O} source + * @returns {O} + */ + create(source) { + return ( + /** @type {O} */ + this.from(source) + ); + } + }; + var variant = (variants) => new Variant(variants); + var error2 = (message2) => ({ error: new SchemaError(message2) }); + var SchemaError = class extends Failure { + get name() { + return "SchemaError"; + } + /* c8 ignore next 3 */ + describe() { + return this.name; + } + }; + var TypeError2 = class extends SchemaError { + /** + * @param {{expect:string, actual:unknown}} data + */ + constructor({ expect, actual }) { + super(); + this.expect = expect; + this.actual = actual; + } + get name() { + return "TypeError"; + } + describe() { + return `Expected value of type ${this.expect} instead got ${displayTypeName( + this.actual + )}`; + } + }; + var typeError = (data) => ({ error: new TypeError2(data) }); + var displayTypeName = (value) => { + const type3 = typeof value; + switch (type3) { + case "boolean": + case "string": + return JSON.stringify(value); + case "bigint": + return `${value}n`; + case "number": + case "symbol": + case "undefined": + return String(value); + case "object": + return value === null ? "null" : Array.isArray(value) ? "array" : Symbol.toStringTag in /** @type {object} */ + value ? value[Symbol.toStringTag] : "object"; + default: + return type3; + } + }; + var LiteralError = class extends SchemaError { + /** + * @param {{ + * expect:string|number|boolean|null + * actual:unknown + * }} data + */ + constructor({ expect, actual }) { + super(); + this.expect = expect; + this.actual = actual; + } + get name() { + return "LiteralError"; + } + describe() { + return `Expected literal ${displayTypeName( + this.expect + )} instead got ${displayTypeName(this.actual)}`; + } + }; + var ElementError = class extends SchemaError { + /** + * @param {{at:number, cause:Schema.Error}} data + */ + constructor({ at: at2, cause }) { + super(); + this.at = at2; + this.cause = cause; + } + get name() { + return "ElementError"; + } + describe() { + return [ + `Array contains invalid element at ${this.at}:`, + li(this.cause.message) + ].join("\n"); + } + }; + var FieldError = class extends SchemaError { + /** + * @param {{at:string, cause:Schema.Error}} data + */ + constructor({ at: at2, cause }) { + super(); + this.at = at2; + this.cause = cause; + } + get name() { + return "FieldError"; + } + describe() { + return [ + `Object contains invalid field "${this.at}":`, + li(this.cause.message) + ].join("\n"); + } + }; + var memberError = ({ at: at2, cause }) => typeof at2 === "string" ? { error: new FieldError({ at: at2, cause }) } : { error: new ElementError({ at: at2, cause }) }; + var UnionError = class extends SchemaError { + /** + * @param {{causes: Schema.Error[]}} data + */ + constructor({ causes }) { + super(); + this.causes = causes; + } + get name() { + return "UnionError"; + } + describe() { + const { causes } = this; + return [ + `Value does not match any type of the union:`, + ...causes.map((cause) => li(cause.message)) + ].join("\n"); + } + }; + var IntersectionError = class extends SchemaError { + /** + * @param {{causes: Schema.Error[]}} data + */ + constructor({ causes }) { + super(); + this.causes = causes; + } + get name() { + return "IntersectionError"; + } + describe() { + const { causes } = this; + return [ + `Value does not match following types of the intersection:`, + ...causes.map((cause) => li(cause.message)) + ].join("\n"); + } + }; + var indent = (message2, indent5 = " ") => `${indent5}${message2.split("\n").join(` +${indent5}`)}`; + var li = (message2) => indent(`- ${message2}`); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/schema/uri.js + var URISchema = class extends API { + /** + * @param {unknown} input + * @param {Partial} options + * @returns {Schema.ReadResult>} + */ + readWith(input, { protocol } = {}) { + if (typeof input !== "string" && !(input instanceof URL)) { + return error2( + `Expected URI but got ${input === null ? "null" : typeof input}` + ); + } + try { + const url = new URL(String(input)); + if (protocol != null && url.protocol !== protocol) { + return error2(`Expected ${protocol} URI instead got ${url.href}`); + } else { + return { ok: ( + /** @type {API.URI} */ + url.href + ) }; + } + } catch (_5) { + return error2(`Invalid URI`); + } + } + }; + var schema = new URISchema({}); + var uri = () => schema; + var read3 = (input) => schema.read(input); + var match = (options) => new URISchema(options); + var from8 = (input) => ( + /** @type {API.URI<`${Scheme}:`>} */ + schema.from(input) + ); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/schema/link.js + var link_exports2 = {}; + __export(link_exports2, { + create: () => create3, + createLegacy: () => createLegacy, + isLink: () => isLink, + link: () => link3, + match: () => match2, + optional: () => optional2, + parse: () => parse, + read: () => read4, + schema: () => schema2 + }); + init_dirname(); + init_buffer2(); + init_process(); + var LinkSchema = class extends API { + /** + * + * @param {unknown} cid + * @param {Settings} settings + * @returns {Schema.ReadResult>} + */ + readWith(cid, { code: code15, multihash = {}, version: version3 }) { + if (cid == null) { + return error2(`Expected link but got ${cid} instead`); + } else { + if (!isLink(cid)) { + return error2(`Expected link to be a CID instead of ${cid}`); + } else { + if (code15 != null && cid.code !== code15) { + return error2( + `Expected link to be CID with 0x${code15.toString(16)} codec` + ); + } + if (multihash.code != null && cid.multihash.code !== multihash.code) + return error2( + `Expected link to be CID with 0x${multihash.code.toString( + 16 + )} hashing algorithm` + ); + if (version3 != null && cid.version !== version3) { + return error2( + `Expected link to be CID version ${version3} instead of ${cid.version}` + ); + } + const [expectDigest, actualDigest] = multihash.digest != null ? [ + base322.baseEncode(multihash.digest), + base322.baseEncode(cid.multihash.digest) + ] : ["", ""]; + if (expectDigest !== actualDigest) { + return error2( + `Expected link with "${expectDigest}" hash digest instead of "${actualDigest}"` + ); + } + return { + ok: ( + /** @type {API.Link} */ + cid + ) + }; + } + } + } + }; + var schema2 = new LinkSchema({}); + var link3 = () => schema2; + var match2 = (options = {}) => new LinkSchema(options); + var read4 = (input) => schema2.read(input); + var optional2 = () => schema2.optional(); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/schema/did.js + var did_exports2 = {}; + __export(did_exports2, { + did: () => did, + from: () => from9, + match: () => match3, + read: () => read5 + }); + init_dirname(); + init_buffer2(); + init_process(); + var DIDSchema = class extends API { + /** + * @param {string} source + * @param {void|Method} method + */ + readWith(source, method) { + const prefix = method ? `did:${method}:` : `did:`; + if (!source.startsWith(prefix)) { + return error2(`Expected a ${prefix} but got "${source}" instead`); + } else { + return { ok: ( + /** @type {API.DID} */ + source + ) }; + } + } + }; + var schema3 = string().refine(new DIDSchema()); + var did = () => schema3; + var read5 = (input) => schema3.read(input); + var match3 = (options = {}) => ( + /** @type {Schema.Schema & API.URI<"did:">>} */ + string().refine(new DIDSchema(options.method)) + ); + var from9 = (input) => match3({}).from(input); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/schema/text.js + var text_exports = {}; + __export(text_exports, { + match: () => match4, + read: () => read6, + text: () => text + }); + init_dirname(); + init_buffer2(); + init_process(); + var schema4 = string(); + var match4 = (options) => options ? schema4.refine(new Match(options.pattern)) : schema4; + var text = match4; + var read6 = (input) => schema4.read(input); + var Match = class extends API { + /** + * @param {string} source + * @param {RegExp} pattern + */ + readWith(source, pattern) { + if (!pattern.test(source)) { + return error2( + `Expected to match ${pattern} but got "${source}" instead` + ); + } else { + return { ok: source }; + } + } + }; + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/delegation.js + var isLink2 = isLink; + var isDelegation = (proof) => !isLink(proof); + var allows = (...delegations) => { + let allow = {}; + for (const delegation of delegations) { + for (const { with: uri3, can, nb } of iterateCapabilities(delegation)) { + const resource = allow[uri3] || (allow[uri3] = {}); + const abilities = resource[can] || (resource[can] = []); + abilities.push({ ...nb }); + } + } + return ( + /** @type {API.InferAllowedFromDelegations} */ + allow + ); + }; + var iterateCapabilities = function* ({ issuer, capabilities, proofs: proofs3 }) { + for (const own of capabilities) { + if (own.with === "ucan:*") { + yield { + ...own, + with: issuer.did() + }; + for (const proof of proofs3) { + if (isDelegation(proof)) { + for (const capability3 of iterateCapabilities(proof)) { + const can = matchAbility(capability3.can, own.can); + if (can) { + yield { + ...capability3, + can, + // We do not know capability semantics so it is impossible + // for us to eliminate capabilities that do not satisfy imposed + // caveats (`own.nb`). Therefore we optimistically assume that + // `own.nb` further constraints `capability.nb` and do a shallow + // merge of the two. As a result we may include capabilities + // that during validation will be considered invalid due to + // constraint violations. While that is not ideal validator + // will treat them as if they were omitted and therefore it + // is a reasonable compromise. + nb: { ...capability3.nb, ...Object(own.nb) } + }; + } + } + } + } + } else { + yield own; + } + } + }; + var matchAbility = (provided, claimed) => { + if (provided === "*") { + return claimed; + } + if (claimed === "*") { + return provided; + } + if (claimed.endsWith("/*") && provided.startsWith(claimed.slice(0, -1))) { + return provided; + } + if (provided.endsWith("/*") && claimed.startsWith(provided.slice(0, -1))) { + return claimed; + } + if (provided === claimed) { + return provided; + } + return null; + }; + var Delegation = class { + /** + * @param {API.UCANBlock} root + * @param {DAG.BlockStore} [blocks] + */ + constructor(root3, blocks = /* @__PURE__ */ new Map()) { + this.root = root3; + this.blocks = blocks; + Object.defineProperties(this, { + blocks: { + enumerable: false + } + }); + } + /** + * @returns {API.AttachedLinkSet} + */ + get attachedLinks() { + const _attachedLinks = /* @__PURE__ */ new Set(); + const ucanView = this.data; + for (const capability3 of ucanView.capabilities) { + const links4 = getLinksFromObject(capability3); + for (const link10 of links4) { + _attachedLinks.add(`${link10}`); + } + } + for (const fact of ucanView.facts) { + if (isLink(fact)) { + _attachedLinks.add(`${fact}`); + } else { + const links4 = Object.values(fact).filter((e12) => isLink(e12)); + for (const link10 of links4) { + _attachedLinks.add(`${link10}`); + } + } + } + return _attachedLinks; + } + get version() { + return this.data.version; + } + get signature() { + return this.data.signature; + } + get cid() { + return this.root.cid; + } + link() { + return this.root.cid; + } + get asCID() { + return this.cid; + } + get bytes() { + return this.root.bytes; + } + get data() { + const data = decode22(this.root); + Object.defineProperties(this, { data: { value: data, enumerable: false } }); + return data; + } + /** + * Attach a block to the delegation DAG so it would be included in the + * block iterator. + * ⚠️ You can only attach blocks that are referenced from the `capabilities` + * or `facts`. + * + * @param {API.Block} block + */ + attach(block) { + if (!this.attachedLinks.has(`${block.cid.link()}`)) { + throw new Error(`given block with ${block.cid} is not an attached link`); + } + this.blocks.set(`${block.cid}`, block); + } + export() { + return exportDAG(this.root, this.blocks, this.attachedLinks); + } + /** + * @returns {API.Await>} + */ + archive() { + return archive(this); + } + iterateIPLDBlocks() { + return exportDAG(this.root, this.blocks, this.attachedLinks); + } + /** + * @type {API.Proof[]} + */ + get proofs() { + return proofs(this); + } + /** + * @type {API.Principal} + */ + get issuer() { + return this.data.issuer; + } + /** + * @type {API.Principal} + */ + get audience() { + return this.data.audience; + } + /** + * @returns {C} + */ + get capabilities() { + return ( + /** @type {C} */ + this.data.capabilities + ); + } + /** + * @returns {number} + */ + get expiration() { + return this.data.expiration; + } + /** + * @returns {undefined|number} + */ + get notBefore() { + return this.data.notBefore; + } + /** + * @returns {undefined|string} + */ + get nonce() { + return this.data.nonce; + } + /** + * @returns {API.Fact[]} + */ + get facts() { + return this.data.facts; + } + /** + * Iterate over the proofs + * + * @returns {IterableIterator} + */ + iterate() { + return it(this); + } + delegate() { + return this; + } + buildIPLDView() { + return this; + } + /** + * @returns {API.DelegationJSON} + */ + toJSON() { + return ( + /** @type {any} */ + { + ...this.data.toJSON(), + "/": this.cid.toString(), + prf: this.proofs.map( + (proof) => isDelegation(proof) ? proof : { "/": proof.toString() } + ) + } + ); + } + }; + var archive = async (delegation) => { + try { + const store4 = /* @__PURE__ */ new Map(); + for (const block of delegation.iterateIPLDBlocks()) { + store4.set(`${block.cid}`, block); + } + const variant3 = await write2({ + [`ucan@${delegation.version}`]: delegation.root.cid + }); + store4.set(`${variant3.cid}`, variant3); + const bytes2 = encode18({ + roots: [variant3], + blocks: store4 + }); + return ok(bytes2); + } catch (cause) { + return error( + /** @type {Error} */ + cause + ); + } + }; + var ArchiveSchema = variant({ + "ucan@0.9.1": ( + /** @type {Schema.Schema} */ + match2({ version: 1 }) + ) + }); + var extract = async (archive2) => { + try { + const { roots, blocks } = decode21(archive2); + const [root3] = roots; + if (root3 == null) { + return error2("CAR archive does not contain a root block"); + } + const { bytes: bytes2 } = root3; + const variant3 = decode6(bytes2); + const [, link10] = ArchiveSchema.match(variant3); + return ok(view2({ root: link10, blocks })); + } catch (cause) { + return error( + /** @type {Error} */ + cause + ); + } + }; + var it = function* (delegation) { + for (const proof of delegation.proofs) { + if (isDelegation(proof)) { + yield* it(proof); + yield proof; + } + } + }; + var decodeCache = /* @__PURE__ */ new WeakMap(); + var decode22 = ({ bytes: bytes2 }) => { + const data = decodeCache.get(bytes2); + if (!data) { + const data2 = decode19(bytes2); + decodeCache.set(bytes2, data2); + return data2; + } + return data; + }; + var delegate = async ({ issuer, audience, proofs: proofs3 = [], attachedBlocks = /* @__PURE__ */ new Map(), ...input }, options) => { + const links4 = []; + const blocks = /* @__PURE__ */ new Map(); + for (const proof of proofs3) { + if (!isDelegation(proof)) { + links4.push(proof); + } else { + links4.push(proof.cid); + for (const block of proof.export()) { + blocks.set(block.cid.toString(), block); + } + } + } + const data = await issue({ + ...input, + issuer, + audience, + proofs: links4 + }); + const { cid, bytes: bytes2 } = await write(data, options); + decodeCache.set(cid, data); + const delegation = new Delegation({ cid, bytes: bytes2 }, blocks); + Object.defineProperties(delegation, { proofs: { value: proofs3 } }); + for (const block of attachedBlocks.values()) { + delegation.attach(block); + } + return delegation; + }; + var exportDAG = function* (root3, blocks, attachedLinks) { + for (const link10 of decode22(root3).proofs) { + const root4 = ( + /** @type {UCAN.Block} */ + blocks.get(`${link10}`) + ); + if (root4) { + yield* exportSubDAG(root4, blocks); + } + } + for (const link10 of attachedLinks.values()) { + const block = blocks.get(link10); + if (block) { + yield block; + } + } + yield root3; + }; + var exportSubDAG = function* (root3, blocks) { + for (const link10 of decode22(root3).proofs) { + const root4 = ( + /** @type {UCAN.Block} */ + blocks.get(`${link10}`) + ); + if (root4) { + yield* exportSubDAG(root4, blocks); + } + } + yield root3; + }; + var importDAG = (dag) => { + let entries6 = []; + for (const block of dag) { + entries6.push([block.cid.toString(), block]); + } + const last2 = entries6.pop(); + if (!last2) { + throw new RangeError("Empty DAG can not be turned into a delegation"); + } else { + const [, root3] = last2; + return new Delegation( + /** @type {API.UCANBlock} */ + root3, + new Map(entries6) + ); + } + }; + var create5 = ({ root: root3, blocks }) => new Delegation(root3, blocks); + var view2 = ({ root: root3, blocks }, fallback) => { + const block = get(root3, blocks, null); + if (block == null) { + return fallback !== void 0 ? fallback : notFound(root3); + } + return create5({ root: block, blocks }); + }; + var proofs = (delegation) => { + const proofs3 = []; + const { root: root3, blocks } = delegation; + for (const link10 of decode22(root3).proofs) { + const root4 = ( + /** @type {UCAN.Block} */ + blocks.get(link10.toString()) + ); + proofs3.push(root4 ? create5({ root: root4, blocks }) : link10); + } + Object.defineProperty(delegation, "proofs", { value: proofs3 }); + return proofs3; + }; + function getLinksFromObject(obj) { + const links4 = []; + function recurse(obj2) { + for (const key in obj2) { + const value = obj2[key]; + if (isLink(value)) { + links4.push(value); + } else if (value && typeof value === "object") { + recurse(value); + } + } + } + recurse(obj); + return links4; + } + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/invocation.js + var invocation_exports = {}; + __export(invocation_exports, { + Invocation: () => Invocation, + create: () => create6, + invoke: () => invoke, + view: () => view3 + }); + init_dirname(); + init_buffer2(); + init_process(); + var invoke = (options) => new IssuedInvocation(options); + var create6 = ({ root: root3, blocks }) => new Invocation(root3, blocks); + var view3 = ({ root: root3, blocks }, fallback) => { + const block = get(root3, blocks, null); + if (block == null) { + return fallback !== void 0 ? fallback : notFound(root3); + } + return ( + /** @type {API.Invocation} */ + create6({ root: block, blocks }) + ); + }; + var IssuedInvocation = class { + /** + * @param {API.InvocationOptions} data + */ + constructor({ + issuer, + audience, + capability: capability3, + proofs: proofs3 = [], + expiration, + lifetimeInSeconds, + notBefore, + nonce, + facts = [] + }) { + this.issuer = issuer; + this.audience = audience; + this.proofs = proofs3; + this.capabilities = [capability3]; + this.expiration = expiration; + this.lifetimeInSeconds = lifetimeInSeconds; + this.notBefore = notBefore; + this.nonce = nonce; + this.facts = facts; + this.attachedBlocks = /* @__PURE__ */ new Map(); + } + /** + * @param {API.Block} block + */ + attach(block) { + this.attachedBlocks.set(`${block.cid}`, block); + } + delegate() { + return delegate(this); + } + buildIPLDView() { + return delegate(this); + } + /** + * @template {API.InvocationService} Service + * @param {API.ConnectionView} connection + * @returns {Promise>} + */ + async execute(connection3) { + const invocation = this; + const [result] = await connection3.execute(invocation); + return result; + } + }; + var Invocation = class extends Delegation { + }; + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/message.js + var message_exports = {}; + __export(message_exports, { + MessageSchema: () => MessageSchema, + build: () => build, + view: () => view5 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/receipt.js + var receipt_exports = {}; + __export(receipt_exports, { + issue: () => issue2, + view: () => view4 + }); + init_dirname(); + init_buffer2(); + init_process(); + var view4 = ({ root: root3, blocks }, fallback) => { + const block = get(root3, blocks, null); + if (block == null) { + return fallback !== void 0 ? fallback : notFound(root3); + } + const data = decode6(block.bytes); + return new Receipt({ root: { ...block, data }, store: blocks }); + }; + var Receipt = class { + /** + * @param {object} input + * @param {Required>>} input.root + * @param {DAG.BlockStore} input.store + * @param {API.Meta} [input.meta] + * @param {Ran|ReturnType} [input.ran] + * @param {API.EffectsModel} [input.fx] + * @param {API.SignatureView, SigAlg>} [input.signature] + * @param {API.UCAN.Principal} [input.issuer] + * @param {API.Proof[]} [input.proofs] + */ + constructor({ root: root3, store: store4, ran, issuer, signature, proofs: proofs3 }) { + this.store = store4; + this.root = root3; + this._ran = ran; + this._signature = signature; + this._proofs = proofs3; + this._issuer = issuer; + } + /** + * @returns {Ran|ReturnType} + */ + get ran() { + const ran = this._ran; + if (!ran) { + const ran2 = ( + /** @type {Ran} */ + view3( + { + root: this.root.data.ocm.ran, + blocks: this.store + }, + this.root.data.ocm.ran + ) + ); + this._ran = ran2; + return ran2; + } else { + return ran; + } + } + get proofs() { + const proofs3 = this._proofs; + if (proofs3) { + return proofs3; + } else { + const { store: store4, root: root3 } = this; + const { prf } = root3.data.ocm; + const proofs4 = []; + if (prf) { + for (const link10 of prf) { + const proof = view2({ root: link10, blocks: store4 }, link10); + proofs4.push(proof); + } + } + this._proofs = proofs4; + return proofs4; + } + } + get meta() { + return this.root.data.ocm.meta; + } + get issuer() { + const issuer = this._issuer; + if (issuer) { + return issuer; + } else { + const { iss } = this.root.data.ocm; + if (iss) { + const issuer2 = parse2(iss); + this._issuer = issuer2; + return issuer2; + } + } + } + get out() { + return this.root.data.ocm.out; + } + get fx() { + return this.root.data.ocm.fx; + } + get signature() { + const signature = this._signature; + if (signature) { + return signature; + } else { + const signature2 = ( + /** @type {API.SignatureView, SigAlg>} */ + view(this.root.data.sig) + ); + this._signature = signature2; + return signature2; + } + } + /** + * @param {API.Crypto.Verifier} signingPrincipal + */ + verifySignature(signingPrincipal) { + return this.signature.verify( + signingPrincipal, + encode16(this.root.data.ocm) + ); + } + buildIPLDView() { + return this; + } + *iterateIPLDBlocks() { + const { ran, fx, proofs: proofs3, root: root3 } = this; + yield* iterate(ran); + for (const fork5 of fx.fork) { + yield* iterate(fork5); + } + if (fx.join) { + yield* iterate(fx.join); + } + for (const proof of proofs3) { + yield* iterate(proof); + } + yield root3; + } + }; + var ReceptBuilder = class { + /** + * @param {object} options + * @param {API.Signer} options.issuer + * @param {Ran|ReturnType} options.ran + * @param {API.Result} options.result + * @param {API.EffectsModel} [options.fx] + * @param {API.Proof[]} [options.proofs] + * @param {Record} [options.meta] + */ + constructor({ issuer, result, ran, fx = NOFX, proofs: proofs3 = [], meta = {} }) { + this.issuer = issuer; + this.result = result; + this.ran = ran; + this.fx = fx; + this.proofs = proofs3; + this.meta = meta; + } + async buildIPLDView({ hasher = sha256, codec = cbor_exports2 } = {}) { + const store4 = createStore(); + addEveryInto(iterate(this.ran), store4); + for (const proof of this.proofs) { + addEveryInto(iterate(proof), store4); + } + const outcome = { + ran: ( + /** @type {ReturnType} */ + this.ran.link() + ), + out: this.result, + fx: this.fx, + meta: this.meta, + iss: this.issuer.did(), + prf: this.proofs.map((p8) => p8.link()) + }; + const signature = await this.issuer.sign(encode16(outcome)); + const model = { + ocm: outcome, + sig: signature + }; + const root3 = await writeInto(model, store4, { + hasher, + codec + }); + return new Receipt({ + root: root3, + store: store4, + signature, + proofs: this.proofs, + ran: this.ran + }); + } + }; + var NOFX = Object.freeze({ fork: Object.freeze([]) }); + var issue2 = (options) => new ReceptBuilder(options).buildIPLDView(); + + // ../../node_modules/.pnpm/@ucanto+core@8.0.0/node_modules/@ucanto/core/src/message.js + var MessageSchema = variant({ + "ucanto/message@7.0.0": struct({ + execute: match2().array().optional(), + delegate: dictionary({ + key: string(), + value: ( + /** @type {API.Reader>} */ + match2() + ) + }).array().optional() + }) + }); + var build = ({ invocations, receipts }) => new MessageBuilder({ invocations, receipts }).buildIPLDView(); + var view5 = ({ root: root3, store: store4 }, fallback) => { + const block = get(root3, store4, null); + if (block === null) { + return fallback !== void 0 ? fallback : notFound(root3); + } + const data = cbor_exports2.decode(block.bytes); + const [branch, value] = MessageSchema.match(data, fallback); + switch (branch) { + case "ucanto/message@7.0.0": + return new Message({ root: { ...block, data }, store: store4 }); + default: + return value; + } + }; + var MessageBuilder = class { + /** + * @param {object} source + * @param {I} [source.invocations] + * @param {R} [source.receipts] + */ + constructor({ invocations, receipts }) { + this.invocations = invocations; + this.receipts = receipts; + } + /** + * + * @param {API.BuildOptions} [options] + * @returns {Promise, Out: R }>>} + */ + async buildIPLDView(options) { + const store4 = /* @__PURE__ */ new Map(); + const { invocations, ...executeField } = await writeInvocations( + this.invocations || [], + store4 + ); + const { receipts, ...receiptsField } = await writeReceipts( + this.receipts || [], + store4 + ); + const root3 = await writeInto( + /** @type {API.AgentMessageModel<{ In: API.InferInvocations, Out: R }>} */ + { + "ucanto/message@7.0.0": { + ...executeField, + ...receiptsField + } + }, + store4, + options + ); + return new Message({ root: root3, store: store4 }, { receipts, invocations }); + } + }; + var writeInvocations = async (run, store4) => { + const invocations = []; + const execute3 = []; + for (const invocation of run) { + const view10 = await invocation.buildIPLDView(); + execute3.push(view10.link()); + invocations.push(view10); + for (const block of view10.iterateIPLDBlocks()) { + store4.set(`${block.cid}`, block); + } + } + return { invocations, ...execute3.length > 0 ? { execute: execute3 } : {} }; + }; + var writeReceipts = async (source, store4) => { + if (source.length === 0) { + return {}; + } + const receipts = /* @__PURE__ */ new Map(); + const report = {}; + for (const [n9, receipt] of source.entries()) { + const view10 = await receipt.buildIPLDView(); + for (const block of view10.iterateIPLDBlocks()) { + store4.set(`${block.cid}`, block); + } + const key = `${view10.ran.link()}`; + if (!(key in report)) { + report[key] = view10.root.cid; + receipts.set(key, view10); + } else { + receipts.set(`${key}@${n9}`, view10); + } + } + return { receipts, report }; + }; + var Message = class { + /** + * @param {object} source + * @param {Required>>} source.root + * @param {DAG.BlockStore} source.store + * @param {object} build + * @param {API.Invocation[]} [build.invocations] + * @param {Map} [build.receipts] + */ + constructor({ root: root3, store: store4 }, { invocations, receipts } = {}) { + this.root = root3; + this.store = store4; + this._invocations = invocations; + this._receipts = receipts; + } + *iterateIPLDBlocks() { + for (const invocation of this.invocations) { + yield* invocation.iterateIPLDBlocks(); + } + for (const receipt of this.receipts.values()) { + yield* receipt.iterateIPLDBlocks(); + } + yield this.root; + } + /** + * @template [E=never] + * @param {API.Link} link + * @param {E} [fallback] + * @returns {API.Receipt|E} + */ + get(link10, fallback) { + const receipts = this.root.data["ucanto/message@7.0.0"].report || {}; + const receipt = receipts[`${link10}`]; + if (receipt) { + return view4({ root: receipt, blocks: this.store }); + } else { + return fallback !== void 0 ? fallback : panic(`Message does not include receipt for ${link10}`); + } + } + get invocationLinks() { + return this.root.data["ucanto/message@7.0.0"].execute || []; + } + get invocations() { + let invocations = this._invocations; + if (!invocations) { + invocations = this.invocationLinks.map((link10) => { + return invocation_exports.view({ root: link10, blocks: this.store }); + }); + } + return invocations; + } + get receipts() { + let receipts = this._receipts; + if (!receipts) { + receipts = /* @__PURE__ */ new Map(); + const report = this.root.data["ucanto/message@7.0.0"].report || {}; + for (const [key, link10] of Object.entries(report)) { + const receipt = view4({ root: link10, blocks: this.store }); + receipts.set(`${receipt.ran.link()}`, receipt); + } + } + return receipts; + } + }; + + // ../../node_modules/.pnpm/@ucanto+client@8.0.0/node_modules/@ucanto/client/src/connection.js + var connect = (options) => new Connection(options); + var Connection = class { + /** + * @param {API.ConnectionOptions} options + */ + constructor(options) { + this.id = options.id; + this.options = options; + this.codec = options.codec; + this.channel = options.channel; + this.hasher = options.hasher || sha256; + } + /** + * @template {API.Capability} C + * @template {API.Tuple>} I + * @param {I} invocations + * @returns {Promise>} + */ + async execute(...invocations) { + return execute(invocations, this); + } + }; + var execute = async (invocations, connection3) => { + const input = await message_exports.build({ invocations }); + const request = await connection3.codec.encode(input, connection3); + const response = await connection3.channel.request(request); + try { + const output = await connection3.codec.decode(response); + const receipts = input.invocationLinks.map((link10) => output.get(link10)); + return ( + /** @type {API.InferReceipts} */ + receipts + ); + } catch (error7) { + const { message: message2, ...cause } = ( + /** @type {Error} */ + error7 + ); + const receipts = []; + for await (const ran of input.invocationLinks) { + const receipt = await receipt_exports.issue({ + ran, + result: { error: { ...cause, message: message2 } }, + // @ts-expect-error - we can not really sign a receipt without having + // an access to a signer which client does not have. In the future + // we will change client API requiring a signer to be passed in but + // for now we just use a dummy signer. + issuer: { + did() { + return connection3.id.did(); + }, + sign() { + return signature_exports.createNonStandard("", new Uint8Array()); + } + } + }); + receipts.push(receipt); + } + return ( + /** @type {API.InferReceipts} */ + receipts + ); + } + }; + + // ../../node_modules/.pnpm/@ucanto+client@8.0.0/node_modules/@ucanto/client/src/lib.js + var delegate2 = delegation_exports.delegate; + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/car.js + var car_exports2 = {}; + __export(car_exports2, { + codec: () => car_exports, + contentType: () => contentType5, + inbound: () => inbound2, + outbound: () => outbound2, + request: () => request_exports, + response: () => response_exports + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/car/request.js + var request_exports = {}; + __export(request_exports, { + codec: () => car_exports, + contentType: () => contentType3, + decode: () => decode24, + encode: () => encode19 + }); + init_dirname(); + init_buffer2(); + init_process(); + var contentType3 = car_exports.contentType; + var HEADERS = Object.freeze({ + "content-type": contentType3, + // We will signal that we want to receive a CAR file in the response + accept: contentType3 + }); + var encode19 = (message2, options) => { + const blocks = /* @__PURE__ */ new Map(); + for (const block of message2.iterateIPLDBlocks()) { + blocks.set(`${block.cid}`, block); + } + const body = car_exports.encode({ + roots: [message2.root], + blocks + }); + return { + headers: options?.headers || HEADERS, + body + }; + }; + var decode24 = async ({ headers, body }) => { + const { roots, blocks } = car_exports.decode( + /** @type {Uint8Array} */ + body + ); + const message2 = message_exports.view({ root: roots[0].cid, store: blocks }); + return ( + /** @type {Message} */ + message2 + ); + }; + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/car/response.js + var response_exports = {}; + __export(response_exports, { + codec: () => car_exports, + contentType: () => contentType4, + decode: () => decode25, + encode: () => encode20 + }); + init_dirname(); + init_buffer2(); + init_process(); + var contentType4 = car_exports.contentType; + var HEADERS2 = Object.freeze({ + "content-type": contentType4 + }); + var encode20 = (message2, options) => { + const blocks = /* @__PURE__ */ new Map(); + for (const block of message2.iterateIPLDBlocks()) { + blocks.set(`${block.cid}`, block); + } + const body = car_exports.encode({ + roots: [message2.root], + blocks + }); + return { + headers: HEADERS2, + body + }; + }; + var decode25 = async ({ headers, body }) => { + const { roots, blocks } = car_exports.decode( + /** @type {Uint8Array} */ + body + ); + const message2 = message_exports.view({ root: roots[0].cid, store: blocks }); + return ( + /** @type {Message} */ + message2 + ); + }; + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/codec.js + init_dirname(); + init_buffer2(); + init_process(); + var inbound = (source) => new Inbound(source); + var Inbound = class { + /** + * @param {API.HTTPRequest} request + * @returns {API.Result} transport + */ + accept({ headers }) { + const contentType17 = headers["content-type"] || headers["Content-Type"]; + const decoder4 = this.decoders[contentType17]; + if (!decoder4) { + return { + error: { + status: 415, + message: `The server cannot process the request because the payload format is not supported. Please check the content-type header and try again with a supported media type.`, + headers: { + accept: Object.keys(this.decoders).join(", ") + } + } + }; + } + const accept = parseAcceptHeader(headers.accept || headers.Accept || "*/*"); + for (const { category, type: type3 } of accept) { + for (const encoder4 of this.encoders) { + const select3 = (category === "*" || category === encoder4.category) && (type3 === "*" || type3 === encoder4.type); + if (select3) { + return { ok: { ...encoder4, decoder: decoder4 } }; + } + } + } + return { + error: { + status: 406, + message: `The requested resource cannot be served in the requested content type. Please specify a supported content type using the Accept header.`, + headers: { + accept: formatAcceptHeader(Object.values(this.encoders)) + } + } + }; + } + /** + * @param {object} source + * @param {Record} source.decoders + * @param {Record} source.encoders + */ + constructor({ decoders = {}, encoders = {} }) { + this.decoders = decoders; + if (Object.keys(decoders).length === 0) { + throw new Error("At least one decoder MUST be provided"); + } + this.encoders = Object.entries(encoders).map(([mediaType, encoder4]) => { + return { ...parseMediaType(mediaType), encoder: encoder4 }; + }).sort((a8, b6) => b6.preference - a8.preference); + if (this.encoders.length === 0) { + throw new Error("At least one encoder MUST be provided"); + } + } + }; + var outbound = (source) => new Outbound(source); + var Outbound = class { + /** + * @param {object} source + * @param {Record} source.encoders + * @param {Record} source.decoders + */ + constructor({ decoders = {}, encoders = {} }) { + this.decoders = decoders; + if (Object.keys(decoders).length === 0) { + throw new Error("At least one decoder MUST be provided"); + } + this.encoders = Object.entries(encoders).map(([mediaType, encoder4]) => { + return { ...parseMediaType(mediaType), encoder: encoder4 }; + }).sort((a8, b6) => b6.preference - a8.preference); + this.acceptType = formatAcceptHeader(this.encoders); + if (this.encoders.length === 0) { + throw new Error("At least one encoder MUST be provided"); + } + this.encoder = this.encoders[0].encoder; + } + /** + * @template {API.AgentMessage} Message + * @param {Message} message + */ + encode(message2) { + return this.encoder.encode(message2, { + accept: this.acceptType + }); + } + /** + * @template {API.AgentMessage} Message + * @param {API.HTTPResponse} response + * @returns {API.Await} + */ + decode(response) { + const { headers } = response; + const contentType17 = headers["content-type"] || headers["Content-Type"]; + const decoder4 = this.decoders[contentType17] || this.decoders["*/*"]; + switch (response.status) { + case 415: + case 406: + throw Object.assign( + new RangeError(new TextDecoder().decode(response.body)), + { + status: response.status, + headers: response.headers + } + ); + } + if (!decoder4) { + throw Object.assign( + TypeError( + `Can not decode response with content-type '${contentType17}' because no matching transport decoder is configured.` + ), + { + error: true + } + ); + } + return decoder4.decode(response); + } + }; + var parseMediaType = (source) => { + const [mediaType = "*/*", mediaRange = ""] = source.trim().split(";"); + const [category = "*", type3 = "*"] = mediaType.split("/"); + const params = new URLSearchParams(mediaRange); + const preference = parseFloat(params.get("q") || "0"); + return { + category, + type: type3, + /* c8 ignore next */ + preference: isNaN(preference) ? 0 : preference + }; + }; + var formatMediaType = ({ category, type: type3, preference }) => ( + /** @type {MediaType} */ + `${category}/${type3}${preference ? `;q=${preference}` : ""}` + ); + var parseAcceptHeader = (source) => source.split(",").map(parseMediaType).sort((a8, b6) => b6.preference - a8.preference); + var formatAcceptHeader = (source) => source.map(formatMediaType).join(", "); + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/car.js + var contentType5 = car_exports.contentType; + var inbound2 = inbound({ + decoders: { + [contentType3]: request_exports + }, + encoders: { + [contentType4]: response_exports + } + }); + var outbound2 = outbound({ + encoders: { + [contentType3]: request_exports + }, + decoders: { + [contentType4]: response_exports + } + }); + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/http.js + var http_exports = {}; + __export(http_exports, { + open: () => open + }); + init_dirname(); + init_buffer2(); + init_process(); + var open = ({ url, method = "POST", fetch: fetch4 }) => { + if (!fetch4) { + if (typeof globalThis.fetch !== "undefined") { + fetch4 = globalThis.fetch.bind(globalThis); + } else { + throw new TypeError( + `ucanto HTTP transport got undefined \`fetch\`. Try passing in a \`fetch\` implementation explicitly.` + ); + } + } + return new Channel({ url, method, fetch: fetch4 }); + }; + var Channel = class { + /** + * @param {object} options + * @param {URL} options.url + * @param {Fetcher} options.fetch + * @param {string} [options.method] + */ + constructor({ url, fetch: fetch4, method }) { + this.fetch = fetch4; + this.method = method; + this.url = url; + } + /** + * @template {API.Tuple>} I + * @param {API.HTTPRequest, Out: API.Tuple }>>} request + * @returns {Promise, In: API.Tuple }>>>} + */ + async request({ headers, body }) { + const response = await this.fetch(this.url.href, { + headers, + body, + method: this.method + }); + const buffer4 = response.ok ? await response.arrayBuffer() : HTTPError.throw("HTTP Request failed", response); + return { + headers: response.headers.entries ? Object.fromEntries(response.headers.entries()) : ( + /* c8 ignore next */ + {} + ), + body: new Uint8Array(buffer4) + }; + } + }; + var HTTPError = class extends Error { + /** + * @param {string} message + * @param {Options} options + * @returns {never} + */ + static throw(message2, options) { + throw new this(message2, options); + } + /** + * @param {string} message + * @param {Options} options + */ + constructor(message2, { url, status = 500, statusText = "Server error" }) { + super(message2); + this.name = "HTTPError"; + this.url = url; + this.status = status; + this.statusText = statusText; + } + }; + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/awake/peer.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/ed25519.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/ed25519/signer.js + var signer_exports = {}; + __export(signer_exports, { + PUB_KEY_OFFSET: () => PUB_KEY_OFFSET, + code: () => code7, + decode: () => decode27, + derive: () => derive, + encode: () => encode22, + format: () => format10, + from: () => from10, + generate: () => generate, + name: () => name7, + or: () => or7, + parse: () => parse7, + signatureAlgorithm: () => signatureAlgorithm2, + signatureCode: () => signatureCode2 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@noble+ed25519@1.7.3/node_modules/@noble/ed25519/lib/esm/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/crypto.js + var crypto_exports = {}; + __export(crypto_exports, { + Cipher: () => Cipher, + Cipheriv: () => Cipheriv, + Decipher: () => Decipher, + Decipheriv: () => Decipheriv, + DiffieHellman: () => DiffieHellman, + DiffieHellmanGroup: () => DiffieHellmanGroup, + Hash: () => Hash, + Hmac: () => Hmac, + Sign: () => Sign, + Verify: () => Verify, + constants: () => constants, + createCipher: () => createCipher, + createCipheriv: () => createCipheriv, + createCredentials: () => createCredentials, + createDecipher: () => createDecipher, + createDecipheriv: () => createDecipheriv, + createDiffieHellman: () => createDiffieHellman, + createDiffieHellmanGroup: () => createDiffieHellmanGroup, + createECDH: () => createECDH, + createHash: () => createHash, + createHmac: () => createHmac, + createSign: () => createSign, + createVerify: () => createVerify, + default: () => exports6, + getCiphers: () => getCiphers, + getDiffieHellman: () => getDiffieHellman, + getHashes: () => getHashes, + listCiphers: () => listCiphers, + pbkdf2: () => pbkdf2, + pbkdf2Sync: () => pbkdf2Sync, + privateDecrypt: () => privateDecrypt, + privateEncrypt: () => privateEncrypt, + prng: () => prng, + pseudoRandomBytes: () => pseudoRandomBytes, + publicDecrypt: () => publicDecrypt, + publicEncrypt: () => publicEncrypt, + randomBytes: () => randomBytes, + randomFill: () => randomFill, + randomFillSync: () => randomFillSync, + rng: () => rng, + webcrypto: () => webcrypto + }); + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_44e51b61(); + init_chunk_2eac56ff(); + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/chunk-c3d025d9.js + init_dirname(); + init_buffer2(); + init_process(); + init_chunk_44e51b61(); + var exports5 = {}; + var _dewExec4 = false; + function dew4() { + if (_dewExec4) + return exports5; + _dewExec4 = true; + exports5 = exports5 = dew$3(); + exports5.Stream = exports5; + exports5.Readable = exports5; + exports5.Writable = dew$8(); + exports5.Duplex = dew$7(); + exports5.Transform = dew$22(); + exports5.PassThrough = dew$12(); + exports5.finished = dew$6(); + exports5.pipeline = dew3(); + return exports5; + } + + // ../../node_modules/.pnpm/@jspm+core@2.0.1/node_modules/@jspm/core/nodelibs/browser/crypto.js + init_chunk_4bd36a8f(); + init_chunk_4ccc3a29(); + init_chunk_ce0fbc82(); + init_chunk_b4205b57(); + init_chunk_5decc758(); + var exports$2Q = {}; + var _dewExec$2P = false; + function dew$2P() { + if (_dewExec$2P) + return exports$2Q; + _dewExec$2P = true; + var buffer$1 = buffer3; + var Buffer2 = buffer$1.Buffer; + function copyProps(src3, dst) { + for (var key in src3) { + dst[key] = src3[key]; + } + } + if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) { + exports$2Q = buffer$1; + } else { + copyProps(buffer$1, exports$2Q); + exports$2Q.Buffer = SafeBuffer; + } + function SafeBuffer(arg, encodingOrOffset, length3) { + return Buffer2(arg, encodingOrOffset, length3); + } + copyProps(Buffer2, SafeBuffer); + SafeBuffer.from = function(arg, encodingOrOffset, length3) { + if (typeof arg === "number") { + throw new TypeError("Argument must not be a number"); + } + return Buffer2(arg, encodingOrOffset, length3); + }; + SafeBuffer.alloc = function(size4, fill, encoding) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + var buf3 = Buffer2(size4); + if (fill !== void 0) { + if (typeof encoding === "string") { + buf3.fill(fill, encoding); + } else { + buf3.fill(fill); + } + } else { + buf3.fill(0); + } + return buf3; + }; + SafeBuffer.allocUnsafe = function(size4) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + return Buffer2(size4); + }; + SafeBuffer.allocUnsafeSlow = function(size4) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + return buffer$1.SlowBuffer(size4); + }; + return exports$2Q; + } + var exports$2P = {}; + var _dewExec$2O = false; + var _global$U = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2O() { + if (_dewExec$2O) + return exports$2P; + _dewExec$2O = true; + var process$1 = process2; + var MAX_BYTES = 65536; + var MAX_UINT322 = 4294967295; + function oldBrowser() { + throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11"); + } + var Buffer2 = dew$2P().Buffer; + var crypto5 = _global$U.crypto || _global$U.msCrypto; + if (crypto5 && crypto5.getRandomValues) { + exports$2P = randomBytes3; + } else { + exports$2P = oldBrowser; + } + function randomBytes3(size4, cb) { + if (size4 > MAX_UINT322) + throw new RangeError("requested too many random bytes"); + var bytes2 = Buffer2.allocUnsafe(size4); + if (size4 > 0) { + if (size4 > MAX_BYTES) { + for (var generated = 0; generated < size4; generated += MAX_BYTES) { + crypto5.getRandomValues(bytes2.slice(generated, generated + MAX_BYTES)); + } + } else { + crypto5.getRandomValues(bytes2); + } + } + if (typeof cb === "function") { + return process$1.nextTick(function() { + cb(null, bytes2); + }); + } + return bytes2; + } + return exports$2P; + } + var exports$2O = {}; + var _dewExec$2N = false; + function dew$2N() { + if (_dewExec$2N) + return exports$2O; + _dewExec$2N = true; + var buffer$1 = buffer3; + var Buffer2 = buffer$1.Buffer; + function copyProps(src3, dst) { + for (var key in src3) { + dst[key] = src3[key]; + } + } + if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) { + exports$2O = buffer$1; + } else { + copyProps(buffer$1, exports$2O); + exports$2O.Buffer = SafeBuffer; + } + function SafeBuffer(arg, encodingOrOffset, length3) { + return Buffer2(arg, encodingOrOffset, length3); + } + SafeBuffer.prototype = Object.create(Buffer2.prototype); + copyProps(Buffer2, SafeBuffer); + SafeBuffer.from = function(arg, encodingOrOffset, length3) { + if (typeof arg === "number") { + throw new TypeError("Argument must not be a number"); + } + return Buffer2(arg, encodingOrOffset, length3); + }; + SafeBuffer.alloc = function(size4, fill, encoding) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + var buf3 = Buffer2(size4); + if (fill !== void 0) { + if (typeof encoding === "string") { + buf3.fill(fill, encoding); + } else { + buf3.fill(fill); + } + } else { + buf3.fill(0); + } + return buf3; + }; + SafeBuffer.allocUnsafe = function(size4) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + return Buffer2(size4); + }; + SafeBuffer.allocUnsafeSlow = function(size4) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + return buffer$1.SlowBuffer(size4); + }; + return exports$2O; + } + var exports$2N = {}; + var _dewExec$2M = false; + function dew$2M() { + if (_dewExec$2M) + return exports$2N; + _dewExec$2M = true; + var Buffer2 = dew$2N().Buffer; + var Transform2 = dew4().Transform; + var inherits3 = dew$f(); + function throwIfNotStringOrBuffer(val, prefix) { + if (!Buffer2.isBuffer(val) && typeof val !== "string") { + throw new TypeError(prefix + " must be a string or a buffer"); + } + } + function HashBase(blockSize2) { + Transform2.call(this); + this._block = Buffer2.allocUnsafe(blockSize2); + this._blockSize = blockSize2; + this._blockOffset = 0; + this._length = [0, 0, 0, 0]; + this._finalized = false; + } + inherits3(HashBase, Transform2); + HashBase.prototype._transform = function(chunk, encoding, callback) { + var error7 = null; + try { + this.update(chunk, encoding); + } catch (err) { + error7 = err; + } + callback(error7); + }; + HashBase.prototype._flush = function(callback) { + var error7 = null; + try { + this.push(this.digest()); + } catch (err) { + error7 = err; + } + callback(error7); + }; + HashBase.prototype.update = function(data, encoding) { + throwIfNotStringOrBuffer(data, "Data"); + if (this._finalized) + throw new Error("Digest already called"); + if (!Buffer2.isBuffer(data)) + data = Buffer2.from(data, encoding); + var block = this._block; + var offset2 = 0; + while (this._blockOffset + data.length - offset2 >= this._blockSize) { + for (var i8 = this._blockOffset; i8 < this._blockSize; ) + block[i8++] = data[offset2++]; + this._update(); + this._blockOffset = 0; + } + while (offset2 < data.length) + block[this._blockOffset++] = data[offset2++]; + for (var j5 = 0, carry = data.length * 8; carry > 0; ++j5) { + this._length[j5] += carry; + carry = this._length[j5] / 4294967296 | 0; + if (carry > 0) + this._length[j5] -= 4294967296 * carry; + } + return this; + }; + HashBase.prototype._update = function() { + throw new Error("_update is not implemented"); + }; + HashBase.prototype.digest = function(encoding) { + if (this._finalized) + throw new Error("Digest already called"); + this._finalized = true; + var digest3 = this._digest(); + if (encoding !== void 0) + digest3 = digest3.toString(encoding); + this._block.fill(0); + this._blockOffset = 0; + for (var i8 = 0; i8 < 4; ++i8) + this._length[i8] = 0; + return digest3; + }; + HashBase.prototype._digest = function() { + throw new Error("_digest is not implemented"); + }; + exports$2N = HashBase; + return exports$2N; + } + var exports$2M = {}; + var _dewExec$2L = false; + function dew$2L() { + if (_dewExec$2L) + return exports$2M; + _dewExec$2L = true; + var inherits3 = dew$f(); + var HashBase = dew$2M(); + var Buffer2 = dew$2P().Buffer; + var ARRAY16 = new Array(16); + function MD5() { + HashBase.call(this, 64); + this._a = 1732584193; + this._b = 4023233417; + this._c = 2562383102; + this._d = 271733878; + } + inherits3(MD5, HashBase); + MD5.prototype._update = function() { + var M5 = ARRAY16; + for (var i8 = 0; i8 < 16; ++i8) + M5[i8] = this._block.readInt32LE(i8 * 4); + var a8 = this._a; + var b6 = this._b; + var c8 = this._c; + var d7 = this._d; + a8 = fnF(a8, b6, c8, d7, M5[0], 3614090360, 7); + d7 = fnF(d7, a8, b6, c8, M5[1], 3905402710, 12); + c8 = fnF(c8, d7, a8, b6, M5[2], 606105819, 17); + b6 = fnF(b6, c8, d7, a8, M5[3], 3250441966, 22); + a8 = fnF(a8, b6, c8, d7, M5[4], 4118548399, 7); + d7 = fnF(d7, a8, b6, c8, M5[5], 1200080426, 12); + c8 = fnF(c8, d7, a8, b6, M5[6], 2821735955, 17); + b6 = fnF(b6, c8, d7, a8, M5[7], 4249261313, 22); + a8 = fnF(a8, b6, c8, d7, M5[8], 1770035416, 7); + d7 = fnF(d7, a8, b6, c8, M5[9], 2336552879, 12); + c8 = fnF(c8, d7, a8, b6, M5[10], 4294925233, 17); + b6 = fnF(b6, c8, d7, a8, M5[11], 2304563134, 22); + a8 = fnF(a8, b6, c8, d7, M5[12], 1804603682, 7); + d7 = fnF(d7, a8, b6, c8, M5[13], 4254626195, 12); + c8 = fnF(c8, d7, a8, b6, M5[14], 2792965006, 17); + b6 = fnF(b6, c8, d7, a8, M5[15], 1236535329, 22); + a8 = fnG(a8, b6, c8, d7, M5[1], 4129170786, 5); + d7 = fnG(d7, a8, b6, c8, M5[6], 3225465664, 9); + c8 = fnG(c8, d7, a8, b6, M5[11], 643717713, 14); + b6 = fnG(b6, c8, d7, a8, M5[0], 3921069994, 20); + a8 = fnG(a8, b6, c8, d7, M5[5], 3593408605, 5); + d7 = fnG(d7, a8, b6, c8, M5[10], 38016083, 9); + c8 = fnG(c8, d7, a8, b6, M5[15], 3634488961, 14); + b6 = fnG(b6, c8, d7, a8, M5[4], 3889429448, 20); + a8 = fnG(a8, b6, c8, d7, M5[9], 568446438, 5); + d7 = fnG(d7, a8, b6, c8, M5[14], 3275163606, 9); + c8 = fnG(c8, d7, a8, b6, M5[3], 4107603335, 14); + b6 = fnG(b6, c8, d7, a8, M5[8], 1163531501, 20); + a8 = fnG(a8, b6, c8, d7, M5[13], 2850285829, 5); + d7 = fnG(d7, a8, b6, c8, M5[2], 4243563512, 9); + c8 = fnG(c8, d7, a8, b6, M5[7], 1735328473, 14); + b6 = fnG(b6, c8, d7, a8, M5[12], 2368359562, 20); + a8 = fnH(a8, b6, c8, d7, M5[5], 4294588738, 4); + d7 = fnH(d7, a8, b6, c8, M5[8], 2272392833, 11); + c8 = fnH(c8, d7, a8, b6, M5[11], 1839030562, 16); + b6 = fnH(b6, c8, d7, a8, M5[14], 4259657740, 23); + a8 = fnH(a8, b6, c8, d7, M5[1], 2763975236, 4); + d7 = fnH(d7, a8, b6, c8, M5[4], 1272893353, 11); + c8 = fnH(c8, d7, a8, b6, M5[7], 4139469664, 16); + b6 = fnH(b6, c8, d7, a8, M5[10], 3200236656, 23); + a8 = fnH(a8, b6, c8, d7, M5[13], 681279174, 4); + d7 = fnH(d7, a8, b6, c8, M5[0], 3936430074, 11); + c8 = fnH(c8, d7, a8, b6, M5[3], 3572445317, 16); + b6 = fnH(b6, c8, d7, a8, M5[6], 76029189, 23); + a8 = fnH(a8, b6, c8, d7, M5[9], 3654602809, 4); + d7 = fnH(d7, a8, b6, c8, M5[12], 3873151461, 11); + c8 = fnH(c8, d7, a8, b6, M5[15], 530742520, 16); + b6 = fnH(b6, c8, d7, a8, M5[2], 3299628645, 23); + a8 = fnI(a8, b6, c8, d7, M5[0], 4096336452, 6); + d7 = fnI(d7, a8, b6, c8, M5[7], 1126891415, 10); + c8 = fnI(c8, d7, a8, b6, M5[14], 2878612391, 15); + b6 = fnI(b6, c8, d7, a8, M5[5], 4237533241, 21); + a8 = fnI(a8, b6, c8, d7, M5[12], 1700485571, 6); + d7 = fnI(d7, a8, b6, c8, M5[3], 2399980690, 10); + c8 = fnI(c8, d7, a8, b6, M5[10], 4293915773, 15); + b6 = fnI(b6, c8, d7, a8, M5[1], 2240044497, 21); + a8 = fnI(a8, b6, c8, d7, M5[8], 1873313359, 6); + d7 = fnI(d7, a8, b6, c8, M5[15], 4264355552, 10); + c8 = fnI(c8, d7, a8, b6, M5[6], 2734768916, 15); + b6 = fnI(b6, c8, d7, a8, M5[13], 1309151649, 21); + a8 = fnI(a8, b6, c8, d7, M5[4], 4149444226, 6); + d7 = fnI(d7, a8, b6, c8, M5[11], 3174756917, 10); + c8 = fnI(c8, d7, a8, b6, M5[2], 718787259, 15); + b6 = fnI(b6, c8, d7, a8, M5[9], 3951481745, 21); + this._a = this._a + a8 | 0; + this._b = this._b + b6 | 0; + this._c = this._c + c8 | 0; + this._d = this._d + d7 | 0; + }; + MD5.prototype._digest = function() { + this._block[this._blockOffset++] = 128; + if (this._blockOffset > 56) { + this._block.fill(0, this._blockOffset, 64); + this._update(); + this._blockOffset = 0; + } + this._block.fill(0, this._blockOffset, 56); + this._block.writeUInt32LE(this._length[0], 56); + this._block.writeUInt32LE(this._length[1], 60); + this._update(); + var buffer4 = Buffer2.allocUnsafe(16); + buffer4.writeInt32LE(this._a, 0); + buffer4.writeInt32LE(this._b, 4); + buffer4.writeInt32LE(this._c, 8); + buffer4.writeInt32LE(this._d, 12); + return buffer4; + }; + function rotl(x5, n9) { + return x5 << n9 | x5 >>> 32 - n9; + } + function fnF(a8, b6, c8, d7, m7, k5, s7) { + return rotl(a8 + (b6 & c8 | ~b6 & d7) + m7 + k5 | 0, s7) + b6 | 0; + } + function fnG(a8, b6, c8, d7, m7, k5, s7) { + return rotl(a8 + (b6 & d7 | c8 & ~d7) + m7 + k5 | 0, s7) + b6 | 0; + } + function fnH(a8, b6, c8, d7, m7, k5, s7) { + return rotl(a8 + (b6 ^ c8 ^ d7) + m7 + k5 | 0, s7) + b6 | 0; + } + function fnI(a8, b6, c8, d7, m7, k5, s7) { + return rotl(a8 + (c8 ^ (b6 | ~d7)) + m7 + k5 | 0, s7) + b6 | 0; + } + exports$2M = MD5; + return exports$2M; + } + var exports$2L = {}; + var _dewExec$2K = false; + function dew$2K() { + if (_dewExec$2K) + return exports$2L; + _dewExec$2K = true; + var Buffer2 = buffer3.Buffer; + var inherits3 = dew$f(); + var HashBase = dew$2M(); + var ARRAY16 = new Array(16); + var zl = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]; + var zr = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]; + var sl = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]; + var sr = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]; + var hl = [0, 1518500249, 1859775393, 2400959708, 2840853838]; + var hr = [1352829926, 1548603684, 1836072691, 2053994217, 0]; + function RIPEMD160() { + HashBase.call(this, 64); + this._a = 1732584193; + this._b = 4023233417; + this._c = 2562383102; + this._d = 271733878; + this._e = 3285377520; + } + inherits3(RIPEMD160, HashBase); + RIPEMD160.prototype._update = function() { + var words = ARRAY16; + for (var j5 = 0; j5 < 16; ++j5) + words[j5] = this._block.readInt32LE(j5 * 4); + var al = this._a | 0; + var bl = this._b | 0; + var cl = this._c | 0; + var dl = this._d | 0; + var el = this._e | 0; + var ar = this._a | 0; + var br = this._b | 0; + var cr = this._c | 0; + var dr = this._d | 0; + var er = this._e | 0; + for (var i8 = 0; i8 < 80; i8 += 1) { + var tl; + var tr; + if (i8 < 16) { + tl = fn1(al, bl, cl, dl, el, words[zl[i8]], hl[0], sl[i8]); + tr = fn5(ar, br, cr, dr, er, words[zr[i8]], hr[0], sr[i8]); + } else if (i8 < 32) { + tl = fn2(al, bl, cl, dl, el, words[zl[i8]], hl[1], sl[i8]); + tr = fn4(ar, br, cr, dr, er, words[zr[i8]], hr[1], sr[i8]); + } else if (i8 < 48) { + tl = fn3(al, bl, cl, dl, el, words[zl[i8]], hl[2], sl[i8]); + tr = fn3(ar, br, cr, dr, er, words[zr[i8]], hr[2], sr[i8]); + } else if (i8 < 64) { + tl = fn4(al, bl, cl, dl, el, words[zl[i8]], hl[3], sl[i8]); + tr = fn2(ar, br, cr, dr, er, words[zr[i8]], hr[3], sr[i8]); + } else { + tl = fn5(al, bl, cl, dl, el, words[zl[i8]], hl[4], sl[i8]); + tr = fn1(ar, br, cr, dr, er, words[zr[i8]], hr[4], sr[i8]); + } + al = el; + el = dl; + dl = rotl(cl, 10); + cl = bl; + bl = tl; + ar = er; + er = dr; + dr = rotl(cr, 10); + cr = br; + br = tr; + } + var t9 = this._b + cl + dr | 0; + this._b = this._c + dl + er | 0; + this._c = this._d + el + ar | 0; + this._d = this._e + al + br | 0; + this._e = this._a + bl + cr | 0; + this._a = t9; + }; + RIPEMD160.prototype._digest = function() { + this._block[this._blockOffset++] = 128; + if (this._blockOffset > 56) { + this._block.fill(0, this._blockOffset, 64); + this._update(); + this._blockOffset = 0; + } + this._block.fill(0, this._blockOffset, 56); + this._block.writeUInt32LE(this._length[0], 56); + this._block.writeUInt32LE(this._length[1], 60); + this._update(); + var buffer4 = Buffer2.alloc ? Buffer2.alloc(20) : new Buffer2(20); + buffer4.writeInt32LE(this._a, 0); + buffer4.writeInt32LE(this._b, 4); + buffer4.writeInt32LE(this._c, 8); + buffer4.writeInt32LE(this._d, 12); + buffer4.writeInt32LE(this._e, 16); + return buffer4; + }; + function rotl(x5, n9) { + return x5 << n9 | x5 >>> 32 - n9; + } + function fn1(a8, b6, c8, d7, e12, m7, k5, s7) { + return rotl(a8 + (b6 ^ c8 ^ d7) + m7 + k5 | 0, s7) + e12 | 0; + } + function fn2(a8, b6, c8, d7, e12, m7, k5, s7) { + return rotl(a8 + (b6 & c8 | ~b6 & d7) + m7 + k5 | 0, s7) + e12 | 0; + } + function fn3(a8, b6, c8, d7, e12, m7, k5, s7) { + return rotl(a8 + ((b6 | ~c8) ^ d7) + m7 + k5 | 0, s7) + e12 | 0; + } + function fn4(a8, b6, c8, d7, e12, m7, k5, s7) { + return rotl(a8 + (b6 & d7 | c8 & ~d7) + m7 + k5 | 0, s7) + e12 | 0; + } + function fn5(a8, b6, c8, d7, e12, m7, k5, s7) { + return rotl(a8 + (b6 ^ (c8 | ~d7)) + m7 + k5 | 0, s7) + e12 | 0; + } + exports$2L = RIPEMD160; + return exports$2L; + } + var exports$2K = {}; + var _dewExec$2J = false; + var _global$T = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2J() { + if (_dewExec$2J) + return exports$2K; + _dewExec$2J = true; + var Buffer2 = dew$2P().Buffer; + function Hash2(blockSize2, finalSize) { + (this || _global$T)._block = Buffer2.alloc(blockSize2); + (this || _global$T)._finalSize = finalSize; + (this || _global$T)._blockSize = blockSize2; + (this || _global$T)._len = 0; + } + Hash2.prototype.update = function(data, enc) { + if (typeof data === "string") { + enc = enc || "utf8"; + data = Buffer2.from(data, enc); + } + var block = (this || _global$T)._block; + var blockSize2 = (this || _global$T)._blockSize; + var length3 = data.length; + var accum = (this || _global$T)._len; + for (var offset2 = 0; offset2 < length3; ) { + var assigned = accum % blockSize2; + var remainder = Math.min(length3 - offset2, blockSize2 - assigned); + for (var i8 = 0; i8 < remainder; i8++) { + block[assigned + i8] = data[offset2 + i8]; + } + accum += remainder; + offset2 += remainder; + if (accum % blockSize2 === 0) { + this._update(block); + } + } + (this || _global$T)._len += length3; + return this || _global$T; + }; + Hash2.prototype.digest = function(enc) { + var rem = (this || _global$T)._len % (this || _global$T)._blockSize; + (this || _global$T)._block[rem] = 128; + (this || _global$T)._block.fill(0, rem + 1); + if (rem >= (this || _global$T)._finalSize) { + this._update((this || _global$T)._block); + (this || _global$T)._block.fill(0); + } + var bits = (this || _global$T)._len * 8; + if (bits <= 4294967295) { + (this || _global$T)._block.writeUInt32BE(bits, (this || _global$T)._blockSize - 4); + } else { + var lowBits = (bits & 4294967295) >>> 0; + var highBits = (bits - lowBits) / 4294967296; + (this || _global$T)._block.writeUInt32BE(highBits, (this || _global$T)._blockSize - 8); + (this || _global$T)._block.writeUInt32BE(lowBits, (this || _global$T)._blockSize - 4); + } + this._update((this || _global$T)._block); + var hash = this._hash(); + return enc ? hash.toString(enc) : hash; + }; + Hash2.prototype._update = function() { + throw new Error("_update must be implemented by subclass"); + }; + exports$2K = Hash2; + return exports$2K; + } + var exports$2J = {}; + var _dewExec$2I = false; + var _global$S = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2I() { + if (_dewExec$2I) + return exports$2J; + _dewExec$2I = true; + var inherits3 = dew$f(); + var Hash2 = dew$2J(); + var Buffer2 = dew$2P().Buffer; + var K4 = [1518500249, 1859775393, 2400959708 | 0, 3395469782 | 0]; + var W4 = new Array(80); + function Sha() { + this.init(); + (this || _global$S)._w = W4; + Hash2.call(this || _global$S, 64, 56); + } + inherits3(Sha, Hash2); + Sha.prototype.init = function() { + (this || _global$S)._a = 1732584193; + (this || _global$S)._b = 4023233417; + (this || _global$S)._c = 2562383102; + (this || _global$S)._d = 271733878; + (this || _global$S)._e = 3285377520; + return this || _global$S; + }; + function rotl5(num) { + return num << 5 | num >>> 27; + } + function rotl30(num) { + return num << 30 | num >>> 2; + } + function ft(s7, b6, c8, d7) { + if (s7 === 0) + return b6 & c8 | ~b6 & d7; + if (s7 === 2) + return b6 & c8 | b6 & d7 | c8 & d7; + return b6 ^ c8 ^ d7; + } + Sha.prototype._update = function(M5) { + var W5 = (this || _global$S)._w; + var a8 = (this || _global$S)._a | 0; + var b6 = (this || _global$S)._b | 0; + var c8 = (this || _global$S)._c | 0; + var d7 = (this || _global$S)._d | 0; + var e12 = (this || _global$S)._e | 0; + for (var i8 = 0; i8 < 16; ++i8) + W5[i8] = M5.readInt32BE(i8 * 4); + for (; i8 < 80; ++i8) + W5[i8] = W5[i8 - 3] ^ W5[i8 - 8] ^ W5[i8 - 14] ^ W5[i8 - 16]; + for (var j5 = 0; j5 < 80; ++j5) { + var s7 = ~~(j5 / 20); + var t9 = rotl5(a8) + ft(s7, b6, c8, d7) + e12 + W5[j5] + K4[s7] | 0; + e12 = d7; + d7 = c8; + c8 = rotl30(b6); + b6 = a8; + a8 = t9; + } + (this || _global$S)._a = a8 + (this || _global$S)._a | 0; + (this || _global$S)._b = b6 + (this || _global$S)._b | 0; + (this || _global$S)._c = c8 + (this || _global$S)._c | 0; + (this || _global$S)._d = d7 + (this || _global$S)._d | 0; + (this || _global$S)._e = e12 + (this || _global$S)._e | 0; + }; + Sha.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(20); + H4.writeInt32BE((this || _global$S)._a | 0, 0); + H4.writeInt32BE((this || _global$S)._b | 0, 4); + H4.writeInt32BE((this || _global$S)._c | 0, 8); + H4.writeInt32BE((this || _global$S)._d | 0, 12); + H4.writeInt32BE((this || _global$S)._e | 0, 16); + return H4; + }; + exports$2J = Sha; + return exports$2J; + } + var exports$2I = {}; + var _dewExec$2H = false; + var _global$R = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2H() { + if (_dewExec$2H) + return exports$2I; + _dewExec$2H = true; + var inherits3 = dew$f(); + var Hash2 = dew$2J(); + var Buffer2 = dew$2P().Buffer; + var K4 = [1518500249, 1859775393, 2400959708 | 0, 3395469782 | 0]; + var W4 = new Array(80); + function Sha1() { + this.init(); + (this || _global$R)._w = W4; + Hash2.call(this || _global$R, 64, 56); + } + inherits3(Sha1, Hash2); + Sha1.prototype.init = function() { + (this || _global$R)._a = 1732584193; + (this || _global$R)._b = 4023233417; + (this || _global$R)._c = 2562383102; + (this || _global$R)._d = 271733878; + (this || _global$R)._e = 3285377520; + return this || _global$R; + }; + function rotl1(num) { + return num << 1 | num >>> 31; + } + function rotl5(num) { + return num << 5 | num >>> 27; + } + function rotl30(num) { + return num << 30 | num >>> 2; + } + function ft(s7, b6, c8, d7) { + if (s7 === 0) + return b6 & c8 | ~b6 & d7; + if (s7 === 2) + return b6 & c8 | b6 & d7 | c8 & d7; + return b6 ^ c8 ^ d7; + } + Sha1.prototype._update = function(M5) { + var W5 = (this || _global$R)._w; + var a8 = (this || _global$R)._a | 0; + var b6 = (this || _global$R)._b | 0; + var c8 = (this || _global$R)._c | 0; + var d7 = (this || _global$R)._d | 0; + var e12 = (this || _global$R)._e | 0; + for (var i8 = 0; i8 < 16; ++i8) + W5[i8] = M5.readInt32BE(i8 * 4); + for (; i8 < 80; ++i8) + W5[i8] = rotl1(W5[i8 - 3] ^ W5[i8 - 8] ^ W5[i8 - 14] ^ W5[i8 - 16]); + for (var j5 = 0; j5 < 80; ++j5) { + var s7 = ~~(j5 / 20); + var t9 = rotl5(a8) + ft(s7, b6, c8, d7) + e12 + W5[j5] + K4[s7] | 0; + e12 = d7; + d7 = c8; + c8 = rotl30(b6); + b6 = a8; + a8 = t9; + } + (this || _global$R)._a = a8 + (this || _global$R)._a | 0; + (this || _global$R)._b = b6 + (this || _global$R)._b | 0; + (this || _global$R)._c = c8 + (this || _global$R)._c | 0; + (this || _global$R)._d = d7 + (this || _global$R)._d | 0; + (this || _global$R)._e = e12 + (this || _global$R)._e | 0; + }; + Sha1.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(20); + H4.writeInt32BE((this || _global$R)._a | 0, 0); + H4.writeInt32BE((this || _global$R)._b | 0, 4); + H4.writeInt32BE((this || _global$R)._c | 0, 8); + H4.writeInt32BE((this || _global$R)._d | 0, 12); + H4.writeInt32BE((this || _global$R)._e | 0, 16); + return H4; + }; + exports$2I = Sha1; + return exports$2I; + } + var exports$2H = {}; + var _dewExec$2G = false; + var _global$Q = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2G() { + if (_dewExec$2G) + return exports$2H; + _dewExec$2G = true; + var inherits3 = dew$f(); + var Hash2 = dew$2J(); + var Buffer2 = dew$2P().Buffer; + var K4 = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298]; + var W4 = new Array(64); + function Sha256() { + this.init(); + (this || _global$Q)._w = W4; + Hash2.call(this || _global$Q, 64, 56); + } + inherits3(Sha256, Hash2); + Sha256.prototype.init = function() { + (this || _global$Q)._a = 1779033703; + (this || _global$Q)._b = 3144134277; + (this || _global$Q)._c = 1013904242; + (this || _global$Q)._d = 2773480762; + (this || _global$Q)._e = 1359893119; + (this || _global$Q)._f = 2600822924; + (this || _global$Q)._g = 528734635; + (this || _global$Q)._h = 1541459225; + return this || _global$Q; + }; + function ch(x5, y7, z6) { + return z6 ^ x5 & (y7 ^ z6); + } + function maj(x5, y7, z6) { + return x5 & y7 | z6 & (x5 | y7); + } + function sigma0(x5) { + return (x5 >>> 2 | x5 << 30) ^ (x5 >>> 13 | x5 << 19) ^ (x5 >>> 22 | x5 << 10); + } + function sigma1(x5) { + return (x5 >>> 6 | x5 << 26) ^ (x5 >>> 11 | x5 << 21) ^ (x5 >>> 25 | x5 << 7); + } + function gamma0(x5) { + return (x5 >>> 7 | x5 << 25) ^ (x5 >>> 18 | x5 << 14) ^ x5 >>> 3; + } + function gamma1(x5) { + return (x5 >>> 17 | x5 << 15) ^ (x5 >>> 19 | x5 << 13) ^ x5 >>> 10; + } + Sha256.prototype._update = function(M5) { + var W5 = (this || _global$Q)._w; + var a8 = (this || _global$Q)._a | 0; + var b6 = (this || _global$Q)._b | 0; + var c8 = (this || _global$Q)._c | 0; + var d7 = (this || _global$Q)._d | 0; + var e12 = (this || _global$Q)._e | 0; + var f9 = (this || _global$Q)._f | 0; + var g6 = (this || _global$Q)._g | 0; + var h9 = (this || _global$Q)._h | 0; + for (var i8 = 0; i8 < 16; ++i8) + W5[i8] = M5.readInt32BE(i8 * 4); + for (; i8 < 64; ++i8) + W5[i8] = gamma1(W5[i8 - 2]) + W5[i8 - 7] + gamma0(W5[i8 - 15]) + W5[i8 - 16] | 0; + for (var j5 = 0; j5 < 64; ++j5) { + var T1 = h9 + sigma1(e12) + ch(e12, f9, g6) + K4[j5] + W5[j5] | 0; + var T22 = sigma0(a8) + maj(a8, b6, c8) | 0; + h9 = g6; + g6 = f9; + f9 = e12; + e12 = d7 + T1 | 0; + d7 = c8; + c8 = b6; + b6 = a8; + a8 = T1 + T22 | 0; + } + (this || _global$Q)._a = a8 + (this || _global$Q)._a | 0; + (this || _global$Q)._b = b6 + (this || _global$Q)._b | 0; + (this || _global$Q)._c = c8 + (this || _global$Q)._c | 0; + (this || _global$Q)._d = d7 + (this || _global$Q)._d | 0; + (this || _global$Q)._e = e12 + (this || _global$Q)._e | 0; + (this || _global$Q)._f = f9 + (this || _global$Q)._f | 0; + (this || _global$Q)._g = g6 + (this || _global$Q)._g | 0; + (this || _global$Q)._h = h9 + (this || _global$Q)._h | 0; + }; + Sha256.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(32); + H4.writeInt32BE((this || _global$Q)._a, 0); + H4.writeInt32BE((this || _global$Q)._b, 4); + H4.writeInt32BE((this || _global$Q)._c, 8); + H4.writeInt32BE((this || _global$Q)._d, 12); + H4.writeInt32BE((this || _global$Q)._e, 16); + H4.writeInt32BE((this || _global$Q)._f, 20); + H4.writeInt32BE((this || _global$Q)._g, 24); + H4.writeInt32BE((this || _global$Q)._h, 28); + return H4; + }; + exports$2H = Sha256; + return exports$2H; + } + var exports$2G = {}; + var _dewExec$2F = false; + var _global$P = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2F() { + if (_dewExec$2F) + return exports$2G; + _dewExec$2F = true; + var inherits3 = dew$f(); + var Sha256 = dew$2G(); + var Hash2 = dew$2J(); + var Buffer2 = dew$2P().Buffer; + var W4 = new Array(64); + function Sha224() { + this.init(); + (this || _global$P)._w = W4; + Hash2.call(this || _global$P, 64, 56); + } + inherits3(Sha224, Sha256); + Sha224.prototype.init = function() { + (this || _global$P)._a = 3238371032; + (this || _global$P)._b = 914150663; + (this || _global$P)._c = 812702999; + (this || _global$P)._d = 4144912697; + (this || _global$P)._e = 4290775857; + (this || _global$P)._f = 1750603025; + (this || _global$P)._g = 1694076839; + (this || _global$P)._h = 3204075428; + return this || _global$P; + }; + Sha224.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(28); + H4.writeInt32BE((this || _global$P)._a, 0); + H4.writeInt32BE((this || _global$P)._b, 4); + H4.writeInt32BE((this || _global$P)._c, 8); + H4.writeInt32BE((this || _global$P)._d, 12); + H4.writeInt32BE((this || _global$P)._e, 16); + H4.writeInt32BE((this || _global$P)._f, 20); + H4.writeInt32BE((this || _global$P)._g, 24); + return H4; + }; + exports$2G = Sha224; + return exports$2G; + } + var exports$2F = {}; + var _dewExec$2E = false; + var _global$O = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2E() { + if (_dewExec$2E) + return exports$2F; + _dewExec$2E = true; + var inherits3 = dew$f(); + var Hash2 = dew$2J(); + var Buffer2 = dew$2P().Buffer; + var K4 = [1116352408, 3609767458, 1899447441, 602891725, 3049323471, 3964484399, 3921009573, 2173295548, 961987163, 4081628472, 1508970993, 3053834265, 2453635748, 2937671579, 2870763221, 3664609560, 3624381080, 2734883394, 310598401, 1164996542, 607225278, 1323610764, 1426881987, 3590304994, 1925078388, 4068182383, 2162078206, 991336113, 2614888103, 633803317, 3248222580, 3479774868, 3835390401, 2666613458, 4022224774, 944711139, 264347078, 2341262773, 604807628, 2007800933, 770255983, 1495990901, 1249150122, 1856431235, 1555081692, 3175218132, 1996064986, 2198950837, 2554220882, 3999719339, 2821834349, 766784016, 2952996808, 2566594879, 3210313671, 3203337956, 3336571891, 1034457026, 3584528711, 2466948901, 113926993, 3758326383, 338241895, 168717936, 666307205, 1188179964, 773529912, 1546045734, 1294757372, 1522805485, 1396182291, 2643833823, 1695183700, 2343527390, 1986661051, 1014477480, 2177026350, 1206759142, 2456956037, 344077627, 2730485921, 1290863460, 2820302411, 3158454273, 3259730800, 3505952657, 3345764771, 106217008, 3516065817, 3606008344, 3600352804, 1432725776, 4094571909, 1467031594, 275423344, 851169720, 430227734, 3100823752, 506948616, 1363258195, 659060556, 3750685593, 883997877, 3785050280, 958139571, 3318307427, 1322822218, 3812723403, 1537002063, 2003034995, 1747873779, 3602036899, 1955562222, 1575990012, 2024104815, 1125592928, 2227730452, 2716904306, 2361852424, 442776044, 2428436474, 593698344, 2756734187, 3733110249, 3204031479, 2999351573, 3329325298, 3815920427, 3391569614, 3928383900, 3515267271, 566280711, 3940187606, 3454069534, 4118630271, 4000239992, 116418474, 1914138554, 174292421, 2731055270, 289380356, 3203993006, 460393269, 320620315, 685471733, 587496836, 852142971, 1086792851, 1017036298, 365543100, 1126000580, 2618297676, 1288033470, 3409855158, 1501505948, 4234509866, 1607167915, 987167468, 1816402316, 1246189591]; + var W4 = new Array(160); + function Sha512() { + this.init(); + (this || _global$O)._w = W4; + Hash2.call(this || _global$O, 128, 112); + } + inherits3(Sha512, Hash2); + Sha512.prototype.init = function() { + (this || _global$O)._ah = 1779033703; + (this || _global$O)._bh = 3144134277; + (this || _global$O)._ch = 1013904242; + (this || _global$O)._dh = 2773480762; + (this || _global$O)._eh = 1359893119; + (this || _global$O)._fh = 2600822924; + (this || _global$O)._gh = 528734635; + (this || _global$O)._hh = 1541459225; + (this || _global$O)._al = 4089235720; + (this || _global$O)._bl = 2227873595; + (this || _global$O)._cl = 4271175723; + (this || _global$O)._dl = 1595750129; + (this || _global$O)._el = 2917565137; + (this || _global$O)._fl = 725511199; + (this || _global$O)._gl = 4215389547; + (this || _global$O)._hl = 327033209; + return this || _global$O; + }; + function Ch(x5, y7, z6) { + return z6 ^ x5 & (y7 ^ z6); + } + function maj(x5, y7, z6) { + return x5 & y7 | z6 & (x5 | y7); + } + function sigma0(x5, xl) { + return (x5 >>> 28 | xl << 4) ^ (xl >>> 2 | x5 << 30) ^ (xl >>> 7 | x5 << 25); + } + function sigma1(x5, xl) { + return (x5 >>> 14 | xl << 18) ^ (x5 >>> 18 | xl << 14) ^ (xl >>> 9 | x5 << 23); + } + function Gamma0(x5, xl) { + return (x5 >>> 1 | xl << 31) ^ (x5 >>> 8 | xl << 24) ^ x5 >>> 7; + } + function Gamma0l(x5, xl) { + return (x5 >>> 1 | xl << 31) ^ (x5 >>> 8 | xl << 24) ^ (x5 >>> 7 | xl << 25); + } + function Gamma1(x5, xl) { + return (x5 >>> 19 | xl << 13) ^ (xl >>> 29 | x5 << 3) ^ x5 >>> 6; + } + function Gamma1l(x5, xl) { + return (x5 >>> 19 | xl << 13) ^ (xl >>> 29 | x5 << 3) ^ (x5 >>> 6 | xl << 26); + } + function getCarry(a8, b6) { + return a8 >>> 0 < b6 >>> 0 ? 1 : 0; + } + Sha512.prototype._update = function(M5) { + var W5 = (this || _global$O)._w; + var ah = (this || _global$O)._ah | 0; + var bh = (this || _global$O)._bh | 0; + var ch = (this || _global$O)._ch | 0; + var dh = (this || _global$O)._dh | 0; + var eh = (this || _global$O)._eh | 0; + var fh = (this || _global$O)._fh | 0; + var gh = (this || _global$O)._gh | 0; + var hh = (this || _global$O)._hh | 0; + var al = (this || _global$O)._al | 0; + var bl = (this || _global$O)._bl | 0; + var cl = (this || _global$O)._cl | 0; + var dl = (this || _global$O)._dl | 0; + var el = (this || _global$O)._el | 0; + var fl = (this || _global$O)._fl | 0; + var gl = (this || _global$O)._gl | 0; + var hl = (this || _global$O)._hl | 0; + for (var i8 = 0; i8 < 32; i8 += 2) { + W5[i8] = M5.readInt32BE(i8 * 4); + W5[i8 + 1] = M5.readInt32BE(i8 * 4 + 4); + } + for (; i8 < 160; i8 += 2) { + var xh = W5[i8 - 15 * 2]; + var xl = W5[i8 - 15 * 2 + 1]; + var gamma0 = Gamma0(xh, xl); + var gamma0l = Gamma0l(xl, xh); + xh = W5[i8 - 2 * 2]; + xl = W5[i8 - 2 * 2 + 1]; + var gamma1 = Gamma1(xh, xl); + var gamma1l = Gamma1l(xl, xh); + var Wi7h = W5[i8 - 7 * 2]; + var Wi7l = W5[i8 - 7 * 2 + 1]; + var Wi16h = W5[i8 - 16 * 2]; + var Wi16l = W5[i8 - 16 * 2 + 1]; + var Wil = gamma0l + Wi7l | 0; + var Wih = gamma0 + Wi7h + getCarry(Wil, gamma0l) | 0; + Wil = Wil + gamma1l | 0; + Wih = Wih + gamma1 + getCarry(Wil, gamma1l) | 0; + Wil = Wil + Wi16l | 0; + Wih = Wih + Wi16h + getCarry(Wil, Wi16l) | 0; + W5[i8] = Wih; + W5[i8 + 1] = Wil; + } + for (var j5 = 0; j5 < 160; j5 += 2) { + Wih = W5[j5]; + Wil = W5[j5 + 1]; + var majh = maj(ah, bh, ch); + var majl = maj(al, bl, cl); + var sigma0h = sigma0(ah, al); + var sigma0l = sigma0(al, ah); + var sigma1h = sigma1(eh, el); + var sigma1l = sigma1(el, eh); + var Kih = K4[j5]; + var Kil = K4[j5 + 1]; + var chh = Ch(eh, fh, gh); + var chl = Ch(el, fl, gl); + var t1l = hl + sigma1l | 0; + var t1h = hh + sigma1h + getCarry(t1l, hl) | 0; + t1l = t1l + chl | 0; + t1h = t1h + chh + getCarry(t1l, chl) | 0; + t1l = t1l + Kil | 0; + t1h = t1h + Kih + getCarry(t1l, Kil) | 0; + t1l = t1l + Wil | 0; + t1h = t1h + Wih + getCarry(t1l, Wil) | 0; + var t2l = sigma0l + majl | 0; + var t2h = sigma0h + majh + getCarry(t2l, sigma0l) | 0; + hh = gh; + hl = gl; + gh = fh; + gl = fl; + fh = eh; + fl = el; + el = dl + t1l | 0; + eh = dh + t1h + getCarry(el, dl) | 0; + dh = ch; + dl = cl; + ch = bh; + cl = bl; + bh = ah; + bl = al; + al = t1l + t2l | 0; + ah = t1h + t2h + getCarry(al, t1l) | 0; + } + (this || _global$O)._al = (this || _global$O)._al + al | 0; + (this || _global$O)._bl = (this || _global$O)._bl + bl | 0; + (this || _global$O)._cl = (this || _global$O)._cl + cl | 0; + (this || _global$O)._dl = (this || _global$O)._dl + dl | 0; + (this || _global$O)._el = (this || _global$O)._el + el | 0; + (this || _global$O)._fl = (this || _global$O)._fl + fl | 0; + (this || _global$O)._gl = (this || _global$O)._gl + gl | 0; + (this || _global$O)._hl = (this || _global$O)._hl + hl | 0; + (this || _global$O)._ah = (this || _global$O)._ah + ah + getCarry((this || _global$O)._al, al) | 0; + (this || _global$O)._bh = (this || _global$O)._bh + bh + getCarry((this || _global$O)._bl, bl) | 0; + (this || _global$O)._ch = (this || _global$O)._ch + ch + getCarry((this || _global$O)._cl, cl) | 0; + (this || _global$O)._dh = (this || _global$O)._dh + dh + getCarry((this || _global$O)._dl, dl) | 0; + (this || _global$O)._eh = (this || _global$O)._eh + eh + getCarry((this || _global$O)._el, el) | 0; + (this || _global$O)._fh = (this || _global$O)._fh + fh + getCarry((this || _global$O)._fl, fl) | 0; + (this || _global$O)._gh = (this || _global$O)._gh + gh + getCarry((this || _global$O)._gl, gl) | 0; + (this || _global$O)._hh = (this || _global$O)._hh + hh + getCarry((this || _global$O)._hl, hl) | 0; + }; + Sha512.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(64); + function writeInt64BE(h9, l8, offset2) { + H4.writeInt32BE(h9, offset2); + H4.writeInt32BE(l8, offset2 + 4); + } + writeInt64BE((this || _global$O)._ah, (this || _global$O)._al, 0); + writeInt64BE((this || _global$O)._bh, (this || _global$O)._bl, 8); + writeInt64BE((this || _global$O)._ch, (this || _global$O)._cl, 16); + writeInt64BE((this || _global$O)._dh, (this || _global$O)._dl, 24); + writeInt64BE((this || _global$O)._eh, (this || _global$O)._el, 32); + writeInt64BE((this || _global$O)._fh, (this || _global$O)._fl, 40); + writeInt64BE((this || _global$O)._gh, (this || _global$O)._gl, 48); + writeInt64BE((this || _global$O)._hh, (this || _global$O)._hl, 56); + return H4; + }; + exports$2F = Sha512; + return exports$2F; + } + var exports$2E = {}; + var _dewExec$2D = false; + var _global$N = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2D() { + if (_dewExec$2D) + return exports$2E; + _dewExec$2D = true; + var inherits3 = dew$f(); + var SHA512 = dew$2E(); + var Hash2 = dew$2J(); + var Buffer2 = dew$2P().Buffer; + var W4 = new Array(160); + function Sha384() { + this.init(); + (this || _global$N)._w = W4; + Hash2.call(this || _global$N, 128, 112); + } + inherits3(Sha384, SHA512); + Sha384.prototype.init = function() { + (this || _global$N)._ah = 3418070365; + (this || _global$N)._bh = 1654270250; + (this || _global$N)._ch = 2438529370; + (this || _global$N)._dh = 355462360; + (this || _global$N)._eh = 1731405415; + (this || _global$N)._fh = 2394180231; + (this || _global$N)._gh = 3675008525; + (this || _global$N)._hh = 1203062813; + (this || _global$N)._al = 3238371032; + (this || _global$N)._bl = 914150663; + (this || _global$N)._cl = 812702999; + (this || _global$N)._dl = 4144912697; + (this || _global$N)._el = 4290775857; + (this || _global$N)._fl = 1750603025; + (this || _global$N)._gl = 1694076839; + (this || _global$N)._hl = 3204075428; + return this || _global$N; + }; + Sha384.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(48); + function writeInt64BE(h9, l8, offset2) { + H4.writeInt32BE(h9, offset2); + H4.writeInt32BE(l8, offset2 + 4); + } + writeInt64BE((this || _global$N)._ah, (this || _global$N)._al, 0); + writeInt64BE((this || _global$N)._bh, (this || _global$N)._bl, 8); + writeInt64BE((this || _global$N)._ch, (this || _global$N)._cl, 16); + writeInt64BE((this || _global$N)._dh, (this || _global$N)._dl, 24); + writeInt64BE((this || _global$N)._eh, (this || _global$N)._el, 32); + writeInt64BE((this || _global$N)._fh, (this || _global$N)._fl, 40); + return H4; + }; + exports$2E = Sha384; + return exports$2E; + } + var exports$2D = {}; + var _dewExec$2C = false; + var module$b = { + exports: exports$2D + }; + function dew$2C() { + if (_dewExec$2C) + return module$b.exports; + _dewExec$2C = true; + var exports12 = module$b.exports = function SHA(algorithm2) { + algorithm2 = algorithm2.toLowerCase(); + var Algorithm = exports12[algorithm2]; + if (!Algorithm) + throw new Error(algorithm2 + " is not supported (we accept pull requests)"); + return new Algorithm(); + }; + exports12.sha = dew$2I(); + exports12.sha1 = dew$2H(); + exports12.sha224 = dew$2F(); + exports12.sha256 = dew$2G(); + exports12.sha384 = dew$2D(); + exports12.sha512 = dew$2E(); + return module$b.exports; + } + var exports$f$2 = {}; + var _dewExec$f$2 = false; + function dew$f$2() { + if (_dewExec$f$2) + return exports$f$2; + _dewExec$f$2 = true; + if (typeof Object.create === "function") { + exports$f$2 = function inherits3(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + } + }; + } else { + exports$f$2 = function inherits3(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + }; + } + return exports$f$2; + } + var exports$e$2 = {}; + var _dewExec$e$2 = false; + function dew$e$2() { + if (_dewExec$e$2) + return exports$e$2; + _dewExec$e$2 = true; + exports$e$2 = y.EventEmitter; + return exports$e$2; + } + var exports$d$2 = {}; + var _dewExec$d$2 = false; + function dew$d$2() { + if (_dewExec$d$2) + return exports$d$2; + _dewExec$d$2 = true; + function ownKeys(object, enumerableOnly) { + var keys2 = Object.keys(object); + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) + symbols = symbols.filter(function(sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys2.push.apply(keys2, symbols); + } + return keys2; + } + function _objectSpread(target) { + for (var i8 = 1; i8 < arguments.length; i8++) { + var source = arguments[i8] != null ? arguments[i8] : {}; + if (i8 % 2) { + ownKeys(Object(source), true).forEach(function(key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function(key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + return target; + } + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; + } + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + function _defineProperties(target, props) { + for (var i8 = 0; i8 < props.length; i8++) { + var descriptor = props[i8]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) + descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) + _defineProperties(Constructor.prototype, protoProps); + if (staticProps) + _defineProperties(Constructor, staticProps); + return Constructor; + } + var _require = e$1$1, Buffer2 = _require.Buffer; + var _require2 = X, inspect3 = _require2.inspect; + var custom2 = inspect3 && inspect3.custom || "inspect"; + function copyBuffer(src3, target, offset2) { + Buffer2.prototype.copy.call(src3, target, offset2); + } + exports$d$2 = /* @__PURE__ */ function() { + function BufferList() { + _classCallCheck(this, BufferList); + this.head = null; + this.tail = null; + this.length = 0; + } + _createClass(BufferList, [{ + key: "push", + value: function push2(v7) { + var entry = { + data: v7, + next: null + }; + if (this.length > 0) + this.tail.next = entry; + else + this.head = entry; + this.tail = entry; + ++this.length; + } + }, { + key: "unshift", + value: function unshift(v7) { + var entry = { + data: v7, + next: this.head + }; + if (this.length === 0) + this.tail = entry; + this.head = entry; + ++this.length; + } + }, { + key: "shift", + value: function shift() { + if (this.length === 0) + return; + var ret = this.head.data; + if (this.length === 1) + this.head = this.tail = null; + else + this.head = this.head.next; + --this.length; + return ret; + } + }, { + key: "clear", + value: function clear() { + this.head = this.tail = null; + this.length = 0; + } + }, { + key: "join", + value: function join3(s7) { + if (this.length === 0) + return ""; + var p8 = this.head; + var ret = "" + p8.data; + while (p8 = p8.next) { + ret += s7 + p8.data; + } + return ret; + } + }, { + key: "concat", + value: function concat6(n9) { + if (this.length === 0) + return Buffer2.alloc(0); + var ret = Buffer2.allocUnsafe(n9 >>> 0); + var p8 = this.head; + var i8 = 0; + while (p8) { + copyBuffer(p8.data, ret, i8); + i8 += p8.data.length; + p8 = p8.next; + } + return ret; + } + // Consumes a specified amount of bytes or characters from the buffered data. + }, { + key: "consume", + value: function consume(n9, hasStrings) { + var ret; + if (n9 < this.head.data.length) { + ret = this.head.data.slice(0, n9); + this.head.data = this.head.data.slice(n9); + } else if (n9 === this.head.data.length) { + ret = this.shift(); + } else { + ret = hasStrings ? this._getString(n9) : this._getBuffer(n9); + } + return ret; + } + }, { + key: "first", + value: function first() { + return this.head.data; + } + // Consumes a specified amount of characters from the buffered data. + }, { + key: "_getString", + value: function _getString(n9) { + var p8 = this.head; + var c8 = 1; + var ret = p8.data; + n9 -= ret.length; + while (p8 = p8.next) { + var str = p8.data; + var nb = n9 > str.length ? str.length : n9; + if (nb === str.length) + ret += str; + else + ret += str.slice(0, n9); + n9 -= nb; + if (n9 === 0) { + if (nb === str.length) { + ++c8; + if (p8.next) + this.head = p8.next; + else + this.head = this.tail = null; + } else { + this.head = p8; + p8.data = str.slice(nb); + } + break; + } + ++c8; + } + this.length -= c8; + return ret; + } + // Consumes a specified amount of bytes from the buffered data. + }, { + key: "_getBuffer", + value: function _getBuffer(n9) { + var ret = Buffer2.allocUnsafe(n9); + var p8 = this.head; + var c8 = 1; + p8.data.copy(ret); + n9 -= p8.data.length; + while (p8 = p8.next) { + var buf3 = p8.data; + var nb = n9 > buf3.length ? buf3.length : n9; + buf3.copy(ret, ret.length - n9, 0, nb); + n9 -= nb; + if (n9 === 0) { + if (nb === buf3.length) { + ++c8; + if (p8.next) + this.head = p8.next; + else + this.head = this.tail = null; + } else { + this.head = p8; + p8.data = buf3.slice(nb); + } + break; + } + ++c8; + } + this.length -= c8; + return ret; + } + // Make sure the linked list only shows the minimal necessary information. + }, { + key: custom2, + value: function value(_5, options) { + return inspect3(this, _objectSpread({}, options, { + // Only inspect one level. + depth: 0, + // It should not recurse. + customInspect: false + })); + } + }]); + return BufferList; + }(); + return exports$d$2; + } + var exports$c$2 = {}; + var _dewExec$c$2 = false; + function dew$c$2() { + if (_dewExec$c$2) + return exports$c$2; + _dewExec$c$2 = true; + var process3 = T; + function destroy(err, cb) { + var _this = this; + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err) { + if (!this._writableState) { + process3.nextTick(emitErrorNT, this, err); + } else if (!this._writableState.errorEmitted) { + this._writableState.errorEmitted = true; + process3.nextTick(emitErrorNT, this, err); + } + } + return this; + } + if (this._readableState) { + this._readableState.destroyed = true; + } + if (this._writableState) { + this._writableState.destroyed = true; + } + this._destroy(err || null, function(err2) { + if (!cb && err2) { + if (!_this._writableState) { + process3.nextTick(emitErrorAndCloseNT, _this, err2); + } else if (!_this._writableState.errorEmitted) { + _this._writableState.errorEmitted = true; + process3.nextTick(emitErrorAndCloseNT, _this, err2); + } else { + process3.nextTick(emitCloseNT, _this); + } + } else if (cb) { + process3.nextTick(emitCloseNT, _this); + cb(err2); + } else { + process3.nextTick(emitCloseNT, _this); + } + }); + return this; + } + function emitErrorAndCloseNT(self2, err) { + emitErrorNT(self2, err); + emitCloseNT(self2); + } + function emitCloseNT(self2) { + if (self2._writableState && !self2._writableState.emitClose) + return; + if (self2._readableState && !self2._readableState.emitClose) + return; + self2.emit("close"); + } + function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } + } + function emitErrorNT(self2, err) { + self2.emit("error", err); + } + function errorOrDestroy(stream2, err) { + var rState = stream2._readableState; + var wState = stream2._writableState; + if (rState && rState.autoDestroy || wState && wState.autoDestroy) + stream2.destroy(err); + else + stream2.emit("error", err); + } + exports$c$2 = { + destroy, + undestroy, + errorOrDestroy + }; + return exports$c$2; + } + var exports$b$2 = {}; + var _dewExec$b$2 = false; + function dew$b$2() { + if (_dewExec$b$2) + return exports$b$2; + _dewExec$b$2 = true; + const codes = {}; + function createErrorType(code15, message2, Base2) { + if (!Base2) { + Base2 = Error; + } + function getMessage(arg1, arg2, arg3) { + if (typeof message2 === "string") { + return message2; + } else { + return message2(arg1, arg2, arg3); + } + } + class NodeError extends Base2 { + constructor(arg1, arg2, arg3) { + super(getMessage(arg1, arg2, arg3)); + } + } + NodeError.prototype.name = Base2.name; + NodeError.prototype.code = code15; + codes[code15] = NodeError; + } + function oneOf(expected, thing) { + if (Array.isArray(expected)) { + const len = expected.length; + expected = expected.map((i8) => String(i8)); + if (len > 2) { + return `one of ${thing} ${expected.slice(0, len - 1).join(", ")}, or ` + expected[len - 1]; + } else if (len === 2) { + return `one of ${thing} ${expected[0]} or ${expected[1]}`; + } else { + return `of ${thing} ${expected[0]}`; + } + } else { + return `of ${thing} ${String(expected)}`; + } + } + function startsWith3(str, search, pos) { + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; + } + function endsWith3(str, search, this_len) { + if (this_len === void 0 || this_len > str.length) { + this_len = str.length; + } + return str.substring(this_len - search.length, this_len) === search; + } + function includes(str, search, start) { + if (typeof start !== "number") { + start = 0; + } + if (start + search.length > str.length) { + return false; + } else { + return str.indexOf(search, start) !== -1; + } + } + createErrorType("ERR_INVALID_OPT_VALUE", function(name15, value) { + return 'The value "' + value + '" is invalid for option "' + name15 + '"'; + }, TypeError); + createErrorType("ERR_INVALID_ARG_TYPE", function(name15, expected, actual) { + let determiner; + if (typeof expected === "string" && startsWith3(expected, "not ")) { + determiner = "must not be"; + expected = expected.replace(/^not /, ""); + } else { + determiner = "must be"; + } + let msg; + if (endsWith3(name15, " argument")) { + msg = `The ${name15} ${determiner} ${oneOf(expected, "type")}`; + } else { + const type3 = includes(name15, ".") ? "property" : "argument"; + msg = `The "${name15}" ${type3} ${determiner} ${oneOf(expected, "type")}`; + } + msg += `. Received type ${typeof actual}`; + return msg; + }, TypeError); + createErrorType("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF"); + createErrorType("ERR_METHOD_NOT_IMPLEMENTED", function(name15) { + return "The " + name15 + " method is not implemented"; + }); + createErrorType("ERR_STREAM_PREMATURE_CLOSE", "Premature close"); + createErrorType("ERR_STREAM_DESTROYED", function(name15) { + return "Cannot call " + name15 + " after a stream was destroyed"; + }); + createErrorType("ERR_MULTIPLE_CALLBACK", "Callback called multiple times"); + createErrorType("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable"); + createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end"); + createErrorType("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError); + createErrorType("ERR_UNKNOWN_ENCODING", function(arg) { + return "Unknown encoding: " + arg; + }, TypeError); + createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event"); + exports$b$2.codes = codes; + return exports$b$2; + } + var exports$a$2 = {}; + var _dewExec$a$2 = false; + function dew$a$2() { + if (_dewExec$a$2) + return exports$a$2; + _dewExec$a$2 = true; + var ERR_INVALID_OPT_VALUE = dew$b$2().codes.ERR_INVALID_OPT_VALUE; + function highWaterMarkFrom(options, isDuplex2, duplexKey) { + return options.highWaterMark != null ? options.highWaterMark : isDuplex2 ? options[duplexKey] : null; + } + function getHighWaterMark(state, options, duplexKey, isDuplex2) { + var hwm = highWaterMarkFrom(options, isDuplex2, duplexKey); + if (hwm != null) { + if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { + var name15 = isDuplex2 ? duplexKey : "highWaterMark"; + throw new ERR_INVALID_OPT_VALUE(name15, hwm); + } + return Math.floor(hwm); + } + return state.objectMode ? 16 : 16 * 1024; + } + exports$a$2 = { + getHighWaterMark + }; + return exports$a$2; + } + var exports$9$2 = {}; + var _dewExec$9$2 = false; + var _global$2$2 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$9$2() { + if (_dewExec$9$2) + return exports$9$2; + _dewExec$9$2 = true; + exports$9$2 = deprecate3; + function deprecate3(fn, msg) { + if (config2("noDeprecation")) { + return fn; + } + var warned = false; + function deprecated() { + if (!warned) { + if (config2("throwDeprecation")) { + throw new Error(msg); + } else if (config2("traceDeprecation")) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; + } + return fn.apply(this || _global$2$2, arguments); + } + return deprecated; + } + function config2(name15) { + try { + if (!_global$2$2.localStorage) + return false; + } catch (_5) { + return false; + } + var val = _global$2$2.localStorage[name15]; + if (null == val) + return false; + return String(val).toLowerCase() === "true"; + } + return exports$9$2; + } + var exports$8$2 = {}; + var _dewExec$8$2 = false; + var _global$1$2 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$8$2() { + if (_dewExec$8$2) + return exports$8$2; + _dewExec$8$2 = true; + var process3 = T; + exports$8$2 = Writable2; + function CorkedRequest(state) { + var _this = this; + this.next = null; + this.entry = null; + this.finish = function() { + onCorkedFinish(_this, state); + }; + } + var Duplex2; + Writable2.WritableState = WritableState; + var internalUtil = { + deprecate: dew$9$2() + }; + var Stream2 = dew$e$2(); + var Buffer2 = e$1$1.Buffer; + var OurUint8Array = _global$1$2.Uint8Array || function() { + }; + function _uint8ArrayToBuffer(chunk) { + return Buffer2.from(chunk); + } + function _isUint8Array(obj) { + return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array; + } + var destroyImpl = dew$c$2(); + var _require = dew$a$2(), getHighWaterMark = _require.getHighWaterMark; + var _require$codes = dew$b$2().codes, ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; + var errorOrDestroy = destroyImpl.errorOrDestroy; + dew$f$2()(Writable2, Stream2); + function nop() { + } + function WritableState(options, stream2, isDuplex2) { + Duplex2 = Duplex2 || dew$7$2(); + options = options || {}; + if (typeof isDuplex2 !== "boolean") + isDuplex2 = stream2 instanceof Duplex2; + this.objectMode = !!options.objectMode; + if (isDuplex2) + this.objectMode = this.objectMode || !!options.writableObjectMode; + this.highWaterMark = getHighWaterMark(this, options, "writableHighWaterMark", isDuplex2); + this.finalCalled = false; + this.needDrain = false; + this.ending = false; + this.ended = false; + this.finished = false; + this.destroyed = false; + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + this.defaultEncoding = options.defaultEncoding || "utf8"; + this.length = 0; + this.writing = false; + this.corked = 0; + this.sync = true; + this.bufferProcessing = false; + this.onwrite = function(er) { + onwrite(stream2, er); + }; + this.writecb = null; + this.writelen = 0; + this.bufferedRequest = null; + this.lastBufferedRequest = null; + this.pendingcb = 0; + this.prefinished = false; + this.errorEmitted = false; + this.emitClose = options.emitClose !== false; + this.autoDestroy = !!options.autoDestroy; + this.bufferedRequestCount = 0; + this.corkedRequestsFree = new CorkedRequest(this); + } + WritableState.prototype.getBuffer = function getBuffer() { + var current2 = this.bufferedRequest; + var out = []; + while (current2) { + out.push(current2); + current2 = current2.next; + } + return out; + }; + (function() { + try { + Object.defineProperty(WritableState.prototype, "buffer", { + get: internalUtil.deprecate(function writableStateBufferGetter() { + return this.getBuffer(); + }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003") + }); + } catch (_5) { + } + })(); + var realHasInstance; + if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable2, Symbol.hasInstance, { + value: function value(object) { + if (realHasInstance.call(this, object)) + return true; + if (this !== Writable2) + return false; + return object && object._writableState instanceof WritableState; + } + }); + } else { + realHasInstance = function realHasInstance2(object) { + return object instanceof this; + }; + } + function Writable2(options) { + Duplex2 = Duplex2 || dew$7$2(); + var isDuplex2 = this instanceof Duplex2; + if (!isDuplex2 && !realHasInstance.call(Writable2, this)) + return new Writable2(options); + this._writableState = new WritableState(options, this, isDuplex2); + this.writable = true; + if (options) { + if (typeof options.write === "function") + this._write = options.write; + if (typeof options.writev === "function") + this._writev = options.writev; + if (typeof options.destroy === "function") + this._destroy = options.destroy; + if (typeof options.final === "function") + this._final = options.final; + } + Stream2.call(this); + } + Writable2.prototype.pipe = function() { + errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); + }; + function writeAfterEnd(stream2, cb) { + var er = new ERR_STREAM_WRITE_AFTER_END(); + errorOrDestroy(stream2, er); + process3.nextTick(cb, er); + } + function validChunk(stream2, state, chunk, cb) { + var er; + if (chunk === null) { + er = new ERR_STREAM_NULL_VALUES(); + } else if (typeof chunk !== "string" && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer"], chunk); + } + if (er) { + errorOrDestroy(stream2, er); + process3.nextTick(cb, er); + return false; + } + return true; + } + Writable2.prototype.write = function(chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); + if (isBuf && !Buffer2.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + if (typeof encoding === "function") { + cb = encoding; + encoding = null; + } + if (isBuf) + encoding = "buffer"; + else if (!encoding) + encoding = state.defaultEncoding; + if (typeof cb !== "function") + cb = nop; + if (state.ending) + writeAfterEnd(this, cb); + else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } + return ret; + }; + Writable2.prototype.cork = function() { + this._writableState.corked++; + }; + Writable2.prototype.uncork = function() { + var state = this._writableState; + if (state.corked) { + state.corked--; + if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) + clearBuffer(this, state); + } + }; + Writable2.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + if (typeof encoding === "string") + encoding = encoding.toLowerCase(); + if (!(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((encoding + "").toLowerCase()) > -1)) + throw new ERR_UNKNOWN_ENCODING(encoding); + this._writableState.defaultEncoding = encoding; + return this; + }; + Object.defineProperty(Writable2.prototype, "writableBuffer", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState && this._writableState.getBuffer(); + } + }); + function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") { + chunk = Buffer2.from(chunk, encoding); + } + return chunk; + } + Object.defineProperty(Writable2.prototype, "writableHighWaterMark", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState.highWaterMark; + } + }); + function writeOrBuffer(stream2, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = "buffer"; + chunk = newChunk; + } + } + var len = state.objectMode ? 1 : chunk.length; + state.length += len; + var ret = state.length < state.highWaterMark; + if (!ret) + state.needDrain = true; + if (state.writing || state.corked) { + var last2 = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk, + encoding, + isBuf, + callback: cb, + next: null + }; + if (last2) { + last2.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream2, state, false, len, chunk, encoding, cb); + } + return ret; + } + function doWrite(stream2, state, writev2, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (state.destroyed) + state.onwrite(new ERR_STREAM_DESTROYED("write")); + else if (writev2) + stream2._writev(chunk, state.onwrite); + else + stream2._write(chunk, encoding, state.onwrite); + state.sync = false; + } + function onwriteError(stream2, state, sync, er, cb) { + --state.pendingcb; + if (sync) { + process3.nextTick(cb, er); + process3.nextTick(finishMaybe, stream2, state); + stream2._writableState.errorEmitted = true; + errorOrDestroy(stream2, er); + } else { + cb(er); + stream2._writableState.errorEmitted = true; + errorOrDestroy(stream2, er); + finishMaybe(stream2, state); + } + } + function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; + } + function onwrite(stream2, er) { + var state = stream2._writableState; + var sync = state.sync; + var cb = state.writecb; + if (typeof cb !== "function") + throw new ERR_MULTIPLE_CALLBACK(); + onwriteStateUpdate(state); + if (er) + onwriteError(stream2, state, sync, er, cb); + else { + var finished2 = needFinish(state) || stream2.destroyed; + if (!finished2 && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream2, state); + } + if (sync) { + process3.nextTick(afterWrite, stream2, state, finished2, cb); + } else { + afterWrite(stream2, state, finished2, cb); + } + } + } + function afterWrite(stream2, state, finished2, cb) { + if (!finished2) + onwriteDrain(stream2, state); + state.pendingcb--; + cb(); + finishMaybe(stream2, state); + } + function onwriteDrain(stream2, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream2.emit("drain"); + } + } + function clearBuffer(stream2, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + if (stream2._writev && entry && entry.next) { + var l8 = state.bufferedRequestCount; + var buffer4 = new Array(l8); + var holder = state.corkedRequestsFree; + holder.entry = entry; + var count = 0; + var allBuffers = true; + while (entry) { + buffer4[count] = entry; + if (!entry.isBuf) + allBuffers = false; + entry = entry.next; + count += 1; + } + buffer4.allBuffers = allBuffers; + doWrite(stream2, state, true, state.length, buffer4, "", holder.finish); + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + state.bufferedRequestCount = 0; + } else { + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + doWrite(stream2, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; + if (state.writing) { + break; + } + } + if (entry === null) + state.lastBufferedRequest = null; + } + state.bufferedRequest = entry; + state.bufferProcessing = false; + } + Writable2.prototype._write = function(chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED("_write()")); + }; + Writable2.prototype._writev = null; + Writable2.prototype.end = function(chunk, encoding, cb) { + var state = this._writableState; + if (typeof chunk === "function") { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === "function") { + cb = encoding; + encoding = null; + } + if (chunk !== null && chunk !== void 0) + this.write(chunk, encoding); + if (state.corked) { + state.corked = 1; + this.uncork(); + } + if (!state.ending) + endWritable(this, state, cb); + return this; + }; + Object.defineProperty(Writable2.prototype, "writableLength", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState.length; + } + }); + function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; + } + function callFinal(stream2, state) { + stream2._final(function(err) { + state.pendingcb--; + if (err) { + errorOrDestroy(stream2, err); + } + state.prefinished = true; + stream2.emit("prefinish"); + finishMaybe(stream2, state); + }); + } + function prefinish(stream2, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream2._final === "function" && !state.destroyed) { + state.pendingcb++; + state.finalCalled = true; + process3.nextTick(callFinal, stream2, state); + } else { + state.prefinished = true; + stream2.emit("prefinish"); + } + } + } + function finishMaybe(stream2, state) { + var need = needFinish(state); + if (need) { + prefinish(stream2, state); + if (state.pendingcb === 0) { + state.finished = true; + stream2.emit("finish"); + if (state.autoDestroy) { + var rState = stream2._readableState; + if (!rState || rState.autoDestroy && rState.endEmitted) { + stream2.destroy(); + } + } + } + } + return need; + } + function endWritable(stream2, state, cb) { + state.ending = true; + finishMaybe(stream2, state); + if (cb) { + if (state.finished) + process3.nextTick(cb); + else + stream2.once("finish", cb); + } + state.ended = true; + stream2.writable = false; + } + function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + state.corkedRequestsFree.next = corkReq; + } + Object.defineProperty(Writable2.prototype, "destroyed", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + if (this._writableState === void 0) { + return false; + } + return this._writableState.destroyed; + }, + set: function set5(value) { + if (!this._writableState) { + return; + } + this._writableState.destroyed = value; + } + }); + Writable2.prototype.destroy = destroyImpl.destroy; + Writable2.prototype._undestroy = destroyImpl.undestroy; + Writable2.prototype._destroy = function(err, cb) { + cb(err); + }; + return exports$8$2; + } + var exports$7$2 = {}; + var _dewExec$7$2 = false; + function dew$7$2() { + if (_dewExec$7$2) + return exports$7$2; + _dewExec$7$2 = true; + var process3 = T; + var objectKeys = Object.keys || function(obj) { + var keys3 = []; + for (var key in obj) { + keys3.push(key); + } + return keys3; + }; + exports$7$2 = Duplex2; + var Readable2 = dew$3$2(); + var Writable2 = dew$8$2(); + dew$f$2()(Duplex2, Readable2); + { + var keys2 = objectKeys(Writable2.prototype); + for (var v7 = 0; v7 < keys2.length; v7++) { + var method = keys2[v7]; + if (!Duplex2.prototype[method]) + Duplex2.prototype[method] = Writable2.prototype[method]; + } + } + function Duplex2(options) { + if (!(this instanceof Duplex2)) + return new Duplex2(options); + Readable2.call(this, options); + Writable2.call(this, options); + this.allowHalfOpen = true; + if (options) { + if (options.readable === false) + this.readable = false; + if (options.writable === false) + this.writable = false; + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once("end", onend); + } + } + } + Object.defineProperty(Duplex2.prototype, "writableHighWaterMark", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState.highWaterMark; + } + }); + Object.defineProperty(Duplex2.prototype, "writableBuffer", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState && this._writableState.getBuffer(); + } + }); + Object.defineProperty(Duplex2.prototype, "writableLength", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._writableState.length; + } + }); + function onend() { + if (this._writableState.ended) + return; + process3.nextTick(onEndNT, this); + } + function onEndNT(self2) { + self2.end(); + } + Object.defineProperty(Duplex2.prototype, "destroyed", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + if (this._readableState === void 0 || this._writableState === void 0) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function set5(value) { + if (this._readableState === void 0 || this._writableState === void 0) { + return; + } + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } + }); + return exports$7$2; + } + var exports$6$2 = {}; + var _dewExec$6$2 = false; + function dew$6$2() { + if (_dewExec$6$2) + return exports$6$2; + _dewExec$6$2 = true; + var ERR_STREAM_PREMATURE_CLOSE = dew$b$2().codes.ERR_STREAM_PREMATURE_CLOSE; + function once2(callback) { + var called = false; + return function() { + if (called) + return; + called = true; + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + callback.apply(this, args); + }; + } + function noop2() { + } + function isRequest(stream2) { + return stream2.setHeader && typeof stream2.abort === "function"; + } + function eos(stream2, opts, callback) { + if (typeof opts === "function") + return eos(stream2, null, opts); + if (!opts) + opts = {}; + callback = once2(callback || noop2); + var readable = opts.readable || opts.readable !== false && stream2.readable; + var writable = opts.writable || opts.writable !== false && stream2.writable; + var onlegacyfinish = function onlegacyfinish2() { + if (!stream2.writable) + onfinish(); + }; + var writableEnded = stream2._writableState && stream2._writableState.finished; + var onfinish = function onfinish2() { + writable = false; + writableEnded = true; + if (!readable) + callback.call(stream2); + }; + var readableEnded = stream2._readableState && stream2._readableState.endEmitted; + var onend = function onend2() { + readable = false; + readableEnded = true; + if (!writable) + callback.call(stream2); + }; + var onerror = function onerror2(err) { + callback.call(stream2, err); + }; + var onclose = function onclose2() { + var err; + if (readable && !readableEnded) { + if (!stream2._readableState || !stream2._readableState.ended) + err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream2, err); + } + if (writable && !writableEnded) { + if (!stream2._writableState || !stream2._writableState.ended) + err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream2, err); + } + }; + var onrequest = function onrequest2() { + stream2.req.on("finish", onfinish); + }; + if (isRequest(stream2)) { + stream2.on("complete", onfinish); + stream2.on("abort", onclose); + if (stream2.req) + onrequest(); + else + stream2.on("request", onrequest); + } else if (writable && !stream2._writableState) { + stream2.on("end", onlegacyfinish); + stream2.on("close", onlegacyfinish); + } + stream2.on("end", onend); + stream2.on("finish", onfinish); + if (opts.error !== false) + stream2.on("error", onerror); + stream2.on("close", onclose); + return function() { + stream2.removeListener("complete", onfinish); + stream2.removeListener("abort", onclose); + stream2.removeListener("request", onrequest); + if (stream2.req) + stream2.req.removeListener("finish", onfinish); + stream2.removeListener("end", onlegacyfinish); + stream2.removeListener("close", onlegacyfinish); + stream2.removeListener("finish", onfinish); + stream2.removeListener("end", onend); + stream2.removeListener("error", onerror); + stream2.removeListener("close", onclose); + }; + } + exports$6$2 = eos; + return exports$6$2; + } + var exports$5$2 = {}; + var _dewExec$5$2 = false; + function dew$5$2() { + if (_dewExec$5$2) + return exports$5$2; + _dewExec$5$2 = true; + var process3 = T; + var _Object$setPrototypeO; + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; + } + var finished2 = dew$6$2(); + var kLastResolve = Symbol("lastResolve"); + var kLastReject = Symbol("lastReject"); + var kError = Symbol("error"); + var kEnded = Symbol("ended"); + var kLastPromise = Symbol("lastPromise"); + var kHandlePromise = Symbol("handlePromise"); + var kStream = Symbol("stream"); + function createIterResult2(value, done) { + return { + value, + done + }; + } + function readAndResolve(iter) { + var resolve7 = iter[kLastResolve]; + if (resolve7 !== null) { + var data = iter[kStream].read(); + if (data !== null) { + iter[kLastPromise] = null; + iter[kLastResolve] = null; + iter[kLastReject] = null; + resolve7(createIterResult2(data, false)); + } + } + } + function onReadable(iter) { + process3.nextTick(readAndResolve, iter); + } + function wrapForNext(lastPromise, iter) { + return function(resolve7, reject) { + lastPromise.then(function() { + if (iter[kEnded]) { + resolve7(createIterResult2(void 0, true)); + return; + } + iter[kHandlePromise](resolve7, reject); + }, reject); + }; + } + var AsyncIteratorPrototype = Object.getPrototypeOf(function() { + }); + var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { + get stream() { + return this[kStream]; + }, + next: function next() { + var _this = this; + var error7 = this[kError]; + if (error7 !== null) { + return Promise.reject(error7); + } + if (this[kEnded]) { + return Promise.resolve(createIterResult2(void 0, true)); + } + if (this[kStream].destroyed) { + return new Promise(function(resolve7, reject) { + process3.nextTick(function() { + if (_this[kError]) { + reject(_this[kError]); + } else { + resolve7(createIterResult2(void 0, true)); + } + }); + }); + } + var lastPromise = this[kLastPromise]; + var promise; + if (lastPromise) { + promise = new Promise(wrapForNext(lastPromise, this)); + } else { + var data = this[kStream].read(); + if (data !== null) { + return Promise.resolve(createIterResult2(data, false)); + } + promise = new Promise(this[kHandlePromise]); + } + this[kLastPromise] = promise; + return promise; + } + }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function() { + return this; + }), _defineProperty(_Object$setPrototypeO, "return", function _return() { + var _this2 = this; + return new Promise(function(resolve7, reject) { + _this2[kStream].destroy(null, function(err) { + if (err) { + reject(err); + return; + } + resolve7(createIterResult2(void 0, true)); + }); + }); + }), _Object$setPrototypeO), AsyncIteratorPrototype); + var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator2(stream2) { + var _Object$create; + var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { + value: stream2, + writable: true + }), _defineProperty(_Object$create, kLastResolve, { + value: null, + writable: true + }), _defineProperty(_Object$create, kLastReject, { + value: null, + writable: true + }), _defineProperty(_Object$create, kError, { + value: null, + writable: true + }), _defineProperty(_Object$create, kEnded, { + value: stream2._readableState.endEmitted, + writable: true + }), _defineProperty(_Object$create, kHandlePromise, { + value: function value(resolve7, reject) { + var data = iterator[kStream].read(); + if (data) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve7(createIterResult2(data, false)); + } else { + iterator[kLastResolve] = resolve7; + iterator[kLastReject] = reject; + } + }, + writable: true + }), _Object$create)); + iterator[kLastPromise] = null; + finished2(stream2, function(err) { + if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") { + var reject = iterator[kLastReject]; + if (reject !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + reject(err); + } + iterator[kError] = err; + return; + } + var resolve7 = iterator[kLastResolve]; + if (resolve7 !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve7(createIterResult2(void 0, true)); + } + iterator[kEnded] = true; + }); + stream2.on("readable", onReadable.bind(null, iterator)); + return iterator; + }; + exports$5$2 = createReadableStreamAsyncIterator; + return exports$5$2; + } + var exports$4$2 = {}; + var _dewExec$4$2 = false; + function dew$4$2() { + if (_dewExec$4$2) + return exports$4$2; + _dewExec$4$2 = true; + exports$4$2 = function() { + throw new Error("Readable.from is not available in the browser"); + }; + return exports$4$2; + } + var exports$3$2 = {}; + var _dewExec$3$2 = false; + var _global$M = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$3$2() { + if (_dewExec$3$2) + return exports$3$2; + _dewExec$3$2 = true; + var process3 = T; + exports$3$2 = Readable2; + var Duplex2; + Readable2.ReadableState = ReadableState; + y.EventEmitter; + var EElistenerCount = function EElistenerCount2(emitter, type3) { + return emitter.listeners(type3).length; + }; + var Stream2 = dew$e$2(); + var Buffer2 = e$1$1.Buffer; + var OurUint8Array = _global$M.Uint8Array || function() { + }; + function _uint8ArrayToBuffer(chunk) { + return Buffer2.from(chunk); + } + function _isUint8Array(obj) { + return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array; + } + var debugUtil = X; + var debug; + if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog("stream"); + } else { + debug = function debug2() { + }; + } + var BufferList = dew$d$2(); + var destroyImpl = dew$c$2(); + var _require = dew$a$2(), getHighWaterMark = _require.getHighWaterMark; + var _require$codes = dew$b$2().codes, ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; + var StringDecoder; + var createReadableStreamAsyncIterator; + var from18; + dew$f$2()(Readable2, Stream2); + var errorOrDestroy = destroyImpl.errorOrDestroy; + var kProxyEvents = ["error", "close", "destroy", "pause", "resume"]; + function prependListener(emitter, event, fn) { + if (typeof emitter.prependListener === "function") + return emitter.prependListener(event, fn); + if (!emitter._events || !emitter._events[event]) + emitter.on(event, fn); + else if (Array.isArray(emitter._events[event])) + emitter._events[event].unshift(fn); + else + emitter._events[event] = [fn, emitter._events[event]]; + } + function ReadableState(options, stream2, isDuplex2) { + Duplex2 = Duplex2 || dew$7$2(); + options = options || {}; + if (typeof isDuplex2 !== "boolean") + isDuplex2 = stream2 instanceof Duplex2; + this.objectMode = !!options.objectMode; + if (isDuplex2) + this.objectMode = this.objectMode || !!options.readableObjectMode; + this.highWaterMark = getHighWaterMark(this, options, "readableHighWaterMark", isDuplex2); + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + this.sync = true; + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + this.paused = true; + this.emitClose = options.emitClose !== false; + this.autoDestroy = !!options.autoDestroy; + this.destroyed = false; + this.defaultEncoding = options.defaultEncoding || "utf8"; + this.awaitDrain = 0; + this.readingMore = false; + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) + StringDecoder = e$12.StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } + } + function Readable2(options) { + Duplex2 = Duplex2 || dew$7$2(); + if (!(this instanceof Readable2)) + return new Readable2(options); + var isDuplex2 = this instanceof Duplex2; + this._readableState = new ReadableState(options, this, isDuplex2); + this.readable = true; + if (options) { + if (typeof options.read === "function") + this._read = options.read; + if (typeof options.destroy === "function") + this._destroy = options.destroy; + } + Stream2.call(this); + } + Object.defineProperty(Readable2.prototype, "destroyed", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + if (this._readableState === void 0) { + return false; + } + return this._readableState.destroyed; + }, + set: function set5(value) { + if (!this._readableState) { + return; + } + this._readableState.destroyed = value; + } + }); + Readable2.prototype.destroy = destroyImpl.destroy; + Readable2.prototype._undestroy = destroyImpl.undestroy; + Readable2.prototype._destroy = function(err, cb) { + cb(err); + }; + Readable2.prototype.push = function(chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + if (!state.objectMode) { + if (typeof chunk === "string") { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer2.from(chunk, encoding); + encoding = ""; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); + }; + Readable2.prototype.unshift = function(chunk) { + return readableAddChunk(this, chunk, null, true, false); + }; + function readableAddChunk(stream2, chunk, encoding, addToFront, skipChunkCheck) { + debug("readableAddChunk", chunk); + var state = stream2._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream2, state); + } else { + var er; + if (!skipChunkCheck) + er = chunkInvalid(state, chunk); + if (er) { + errorOrDestroy(stream2, er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer2.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + if (addToFront) { + if (state.endEmitted) + errorOrDestroy(stream2, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT()); + else + addChunk(stream2, state, chunk, true); + } else if (state.ended) { + errorOrDestroy(stream2, new ERR_STREAM_PUSH_AFTER_EOF()); + } else if (state.destroyed) { + return false; + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) + addChunk(stream2, state, chunk, false); + else + maybeReadMore(stream2, state); + } else { + addChunk(stream2, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + maybeReadMore(stream2, state); + } + } + return !state.ended && (state.length < state.highWaterMark || state.length === 0); + } + function addChunk(stream2, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + state.awaitDrain = 0; + stream2.emit("data", chunk); + } else { + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) + state.buffer.unshift(chunk); + else + state.buffer.push(chunk); + if (state.needReadable) + emitReadable(stream2); + } + maybeReadMore(stream2, state); + } + function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer", "Uint8Array"], chunk); + } + return er; + } + Readable2.prototype.isPaused = function() { + return this._readableState.flowing === false; + }; + Readable2.prototype.setEncoding = function(enc) { + if (!StringDecoder) + StringDecoder = e$12.StringDecoder; + var decoder4 = new StringDecoder(enc); + this._readableState.decoder = decoder4; + this._readableState.encoding = this._readableState.decoder.encoding; + var p8 = this._readableState.buffer.head; + var content = ""; + while (p8 !== null) { + content += decoder4.write(p8.data); + p8 = p8.next; + } + this._readableState.buffer.clear(); + if (content !== "") + this._readableState.buffer.push(content); + this._readableState.length = content.length; + return this; + }; + var MAX_HWM = 1073741824; + function computeNewHighWaterMark(n9) { + if (n9 >= MAX_HWM) { + n9 = MAX_HWM; + } else { + n9--; + n9 |= n9 >>> 1; + n9 |= n9 >>> 2; + n9 |= n9 >>> 4; + n9 |= n9 >>> 8; + n9 |= n9 >>> 16; + n9++; + } + return n9; + } + function howMuchToRead(n9, state) { + if (n9 <= 0 || state.length === 0 && state.ended) + return 0; + if (state.objectMode) + return 1; + if (n9 !== n9) { + if (state.flowing && state.length) + return state.buffer.head.data.length; + else + return state.length; + } + if (n9 > state.highWaterMark) + state.highWaterMark = computeNewHighWaterMark(n9); + if (n9 <= state.length) + return n9; + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; + } + Readable2.prototype.read = function(n9) { + debug("read", n9); + n9 = parseInt(n9, 10); + var state = this._readableState; + var nOrig = n9; + if (n9 !== 0) + state.emittedReadable = false; + if (n9 === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { + debug("read: emitReadable", state.length, state.ended); + if (state.length === 0 && state.ended) + endReadable(this); + else + emitReadable(this); + return null; + } + n9 = howMuchToRead(n9, state); + if (n9 === 0 && state.ended) { + if (state.length === 0) + endReadable(this); + return null; + } + var doRead = state.needReadable; + debug("need readable", doRead); + if (state.length === 0 || state.length - n9 < state.highWaterMark) { + doRead = true; + debug("length less than watermark", doRead); + } + if (state.ended || state.reading) { + doRead = false; + debug("reading or ended", doRead); + } else if (doRead) { + debug("do read"); + state.reading = true; + state.sync = true; + if (state.length === 0) + state.needReadable = true; + this._read(state.highWaterMark); + state.sync = false; + if (!state.reading) + n9 = howMuchToRead(nOrig, state); + } + var ret; + if (n9 > 0) + ret = fromList(n9, state); + else + ret = null; + if (ret === null) { + state.needReadable = state.length <= state.highWaterMark; + n9 = 0; + } else { + state.length -= n9; + state.awaitDrain = 0; + } + if (state.length === 0) { + if (!state.ended) + state.needReadable = true; + if (nOrig !== n9 && state.ended) + endReadable(this); + } + if (ret !== null) + this.emit("data", ret); + return ret; + }; + function onEofChunk(stream2, state) { + debug("onEofChunk"); + if (state.ended) + return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + if (state.sync) { + emitReadable(stream2); + } else { + state.needReadable = false; + if (!state.emittedReadable) { + state.emittedReadable = true; + emitReadable_(stream2); + } + } + } + function emitReadable(stream2) { + var state = stream2._readableState; + debug("emitReadable", state.needReadable, state.emittedReadable); + state.needReadable = false; + if (!state.emittedReadable) { + debug("emitReadable", state.flowing); + state.emittedReadable = true; + process3.nextTick(emitReadable_, stream2); + } + } + function emitReadable_(stream2) { + var state = stream2._readableState; + debug("emitReadable_", state.destroyed, state.length, state.ended); + if (!state.destroyed && (state.length || state.ended)) { + stream2.emit("readable"); + state.emittedReadable = false; + } + state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; + flow(stream2); + } + function maybeReadMore(stream2, state) { + if (!state.readingMore) { + state.readingMore = true; + process3.nextTick(maybeReadMore_, stream2, state); + } + } + function maybeReadMore_(stream2, state) { + while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { + var len = state.length; + debug("maybeReadMore read 0"); + stream2.read(0); + if (len === state.length) + break; + } + state.readingMore = false; + } + Readable2.prototype._read = function(n9) { + errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED("_read()")); + }; + Readable2.prototype.pipe = function(dest, pipeOpts) { + var src3 = this; + var state = this._readableState; + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts); + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process3.stdout && dest !== process3.stderr; + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) + process3.nextTick(endFn); + else + src3.once("end", endFn); + dest.on("unpipe", onunpipe); + function onunpipe(readable, unpipeInfo) { + debug("onunpipe"); + if (readable === src3) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + function onend() { + debug("onend"); + dest.end(); + } + var ondrain = pipeOnDrain(src3); + dest.on("drain", ondrain); + var cleanedUp = false; + function cleanup() { + debug("cleanup"); + dest.removeListener("close", onclose); + dest.removeListener("finish", onfinish); + dest.removeListener("drain", ondrain); + dest.removeListener("error", onerror); + dest.removeListener("unpipe", onunpipe); + src3.removeListener("end", onend); + src3.removeListener("end", unpipe); + src3.removeListener("data", ondata); + cleanedUp = true; + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) + ondrain(); + } + src3.on("data", ondata); + function ondata(chunk) { + debug("ondata"); + var ret = dest.write(chunk); + debug("dest.write", ret); + if (ret === false) { + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf2(state.pipes, dest) !== -1) && !cleanedUp) { + debug("false write response, pause", state.awaitDrain); + state.awaitDrain++; + } + src3.pause(); + } + } + function onerror(er) { + debug("onerror", er); + unpipe(); + dest.removeListener("error", onerror); + if (EElistenerCount(dest, "error") === 0) + errorOrDestroy(dest, er); + } + prependListener(dest, "error", onerror); + function onclose() { + dest.removeListener("finish", onfinish); + unpipe(); + } + dest.once("close", onclose); + function onfinish() { + debug("onfinish"); + dest.removeListener("close", onclose); + unpipe(); + } + dest.once("finish", onfinish); + function unpipe() { + debug("unpipe"); + src3.unpipe(dest); + } + dest.emit("pipe", src3); + if (!state.flowing) { + debug("pipe resume"); + src3.resume(); + } + return dest; + }; + function pipeOnDrain(src3) { + return function pipeOnDrainFunctionResult() { + var state = src3._readableState; + debug("pipeOnDrain", state.awaitDrain); + if (state.awaitDrain) + state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src3, "data")) { + state.flowing = true; + flow(src3); + } + }; + } + Readable2.prototype.unpipe = function(dest) { + var state = this._readableState; + var unpipeInfo = { + hasUnpiped: false + }; + if (state.pipesCount === 0) + return this; + if (state.pipesCount === 1) { + if (dest && dest !== state.pipes) + return this; + if (!dest) + dest = state.pipes; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) + dest.emit("unpipe", this, unpipeInfo); + return this; + } + if (!dest) { + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + for (var i8 = 0; i8 < len; i8++) { + dests[i8].emit("unpipe", this, { + hasUnpiped: false + }); + } + return this; + } + var index2 = indexOf2(state.pipes, dest); + if (index2 === -1) + return this; + state.pipes.splice(index2, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) + state.pipes = state.pipes[0]; + dest.emit("unpipe", this, unpipeInfo); + return this; + }; + Readable2.prototype.on = function(ev, fn) { + var res = Stream2.prototype.on.call(this, ev, fn); + var state = this._readableState; + if (ev === "data") { + state.readableListening = this.listenerCount("readable") > 0; + if (state.flowing !== false) + this.resume(); + } else if (ev === "readable") { + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.flowing = false; + state.emittedReadable = false; + debug("on readable", state.length, state.reading); + if (state.length) { + emitReadable(this); + } else if (!state.reading) { + process3.nextTick(nReadingNextTick, this); + } + } + } + return res; + }; + Readable2.prototype.addListener = Readable2.prototype.on; + Readable2.prototype.removeListener = function(ev, fn) { + var res = Stream2.prototype.removeListener.call(this, ev, fn); + if (ev === "readable") { + process3.nextTick(updateReadableListening, this); + } + return res; + }; + Readable2.prototype.removeAllListeners = function(ev) { + var res = Stream2.prototype.removeAllListeners.apply(this, arguments); + if (ev === "readable" || ev === void 0) { + process3.nextTick(updateReadableListening, this); + } + return res; + }; + function updateReadableListening(self2) { + var state = self2._readableState; + state.readableListening = self2.listenerCount("readable") > 0; + if (state.resumeScheduled && !state.paused) { + state.flowing = true; + } else if (self2.listenerCount("data") > 0) { + self2.resume(); + } + } + function nReadingNextTick(self2) { + debug("readable nexttick read 0"); + self2.read(0); + } + Readable2.prototype.resume = function() { + var state = this._readableState; + if (!state.flowing) { + debug("resume"); + state.flowing = !state.readableListening; + resume2(this, state); + } + state.paused = false; + return this; + }; + function resume2(stream2, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + process3.nextTick(resume_, stream2, state); + } + } + function resume_(stream2, state) { + debug("resume", state.reading); + if (!state.reading) { + stream2.read(0); + } + state.resumeScheduled = false; + stream2.emit("resume"); + flow(stream2); + if (state.flowing && !state.reading) + stream2.read(0); + } + Readable2.prototype.pause = function() { + debug("call pause flowing=%j", this._readableState.flowing); + if (this._readableState.flowing !== false) { + debug("pause"); + this._readableState.flowing = false; + this.emit("pause"); + } + this._readableState.paused = true; + return this; + }; + function flow(stream2) { + var state = stream2._readableState; + debug("flow", state.flowing); + while (state.flowing && stream2.read() !== null) { + } + } + Readable2.prototype.wrap = function(stream2) { + var _this = this; + var state = this._readableState; + var paused = false; + stream2.on("end", function() { + debug("wrapped end"); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) + _this.push(chunk); + } + _this.push(null); + }); + stream2.on("data", function(chunk) { + debug("wrapped data"); + if (state.decoder) + chunk = state.decoder.write(chunk); + if (state.objectMode && (chunk === null || chunk === void 0)) + return; + else if (!state.objectMode && (!chunk || !chunk.length)) + return; + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream2.pause(); + } + }); + for (var i8 in stream2) { + if (this[i8] === void 0 && typeof stream2[i8] === "function") { + this[i8] = function methodWrap(method) { + return function methodWrapReturnFunction() { + return stream2[method].apply(stream2, arguments); + }; + }(i8); + } + } + for (var n9 = 0; n9 < kProxyEvents.length; n9++) { + stream2.on(kProxyEvents[n9], this.emit.bind(this, kProxyEvents[n9])); + } + this._read = function(n10) { + debug("wrapped _read", n10); + if (paused) { + paused = false; + stream2.resume(); + } + }; + return this; + }; + if (typeof Symbol === "function") { + Readable2.prototype[Symbol.asyncIterator] = function() { + if (createReadableStreamAsyncIterator === void 0) { + createReadableStreamAsyncIterator = dew$5$2(); + } + return createReadableStreamAsyncIterator(this); + }; + } + Object.defineProperty(Readable2.prototype, "readableHighWaterMark", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._readableState.highWaterMark; + } + }); + Object.defineProperty(Readable2.prototype, "readableBuffer", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._readableState && this._readableState.buffer; + } + }); + Object.defineProperty(Readable2.prototype, "readableFlowing", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._readableState.flowing; + }, + set: function set5(state) { + if (this._readableState) { + this._readableState.flowing = state; + } + } + }); + Readable2._fromList = fromList; + Object.defineProperty(Readable2.prototype, "readableLength", { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get17() { + return this._readableState.length; + } + }); + function fromList(n9, state) { + if (state.length === 0) + return null; + var ret; + if (state.objectMode) + ret = state.buffer.shift(); + else if (!n9 || n9 >= state.length) { + if (state.decoder) + ret = state.buffer.join(""); + else if (state.buffer.length === 1) + ret = state.buffer.first(); + else + ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + ret = state.buffer.consume(n9, state.decoder); + } + return ret; + } + function endReadable(stream2) { + var state = stream2._readableState; + debug("endReadable", state.endEmitted); + if (!state.endEmitted) { + state.ended = true; + process3.nextTick(endReadableNT, state, stream2); + } + } + function endReadableNT(state, stream2) { + debug("endReadableNT", state.endEmitted, state.length); + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream2.readable = false; + stream2.emit("end"); + if (state.autoDestroy) { + var wState = stream2._writableState; + if (!wState || wState.autoDestroy && wState.finished) { + stream2.destroy(); + } + } + } + } + if (typeof Symbol === "function") { + Readable2.from = function(iterable, opts) { + if (from18 === void 0) { + from18 = dew$4$2(); + } + return from18(Readable2, iterable, opts); + }; + } + function indexOf2(xs, x5) { + for (var i8 = 0, l8 = xs.length; i8 < l8; i8++) { + if (xs[i8] === x5) + return i8; + } + return -1; + } + return exports$3$2; + } + var exports$2$2 = {}; + var _dewExec$2$2 = false; + function dew$2$2() { + if (_dewExec$2$2) + return exports$2$2; + _dewExec$2$2 = true; + exports$2$2 = Transform2; + var _require$codes = dew$b$2().codes, ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; + var Duplex2 = dew$7$2(); + dew$f$2()(Transform2, Duplex2); + function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + var cb = ts.writecb; + if (cb === null) { + return this.emit("error", new ERR_MULTIPLE_CALLBACK()); + } + ts.writechunk = null; + ts.writecb = null; + if (data != null) + this.push(data); + cb(er); + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } + } + function Transform2(options) { + if (!(this instanceof Transform2)) + return new Transform2(options); + Duplex2.call(this, options); + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; + this._readableState.needReadable = true; + this._readableState.sync = false; + if (options) { + if (typeof options.transform === "function") + this._transform = options.transform; + if (typeof options.flush === "function") + this._flush = options.flush; + } + this.on("prefinish", prefinish); + } + function prefinish() { + var _this = this; + if (typeof this._flush === "function" && !this._readableState.destroyed) { + this._flush(function(er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } + } + Transform2.prototype.push = function(chunk, encoding) { + this._transformState.needTransform = false; + return Duplex2.prototype.push.call(this, chunk, encoding); + }; + Transform2.prototype._transform = function(chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED("_transform()")); + }; + Transform2.prototype._write = function(chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) + this._read(rs.highWaterMark); + } + }; + Transform2.prototype._read = function(n9) { + var ts = this._transformState; + if (ts.writechunk !== null && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + ts.needTransform = true; + } + }; + Transform2.prototype._destroy = function(err, cb) { + Duplex2.prototype._destroy.call(this, err, function(err2) { + cb(err2); + }); + }; + function done(stream2, er, data) { + if (er) + return stream2.emit("error", er); + if (data != null) + stream2.push(data); + if (stream2._writableState.length) + throw new ERR_TRANSFORM_WITH_LENGTH_0(); + if (stream2._transformState.transforming) + throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); + return stream2.push(null); + } + return exports$2$2; + } + var exports$1$2 = {}; + var _dewExec$1$2 = false; + function dew$1$2() { + if (_dewExec$1$2) + return exports$1$2; + _dewExec$1$2 = true; + exports$1$2 = PassThrough2; + var Transform2 = dew$2$2(); + dew$f$2()(PassThrough2, Transform2); + function PassThrough2(options) { + if (!(this instanceof PassThrough2)) + return new PassThrough2(options); + Transform2.call(this, options); + } + PassThrough2.prototype._transform = function(chunk, encoding, cb) { + cb(null, chunk); + }; + return exports$1$2; + } + var exports$2C = {}; + var _dewExec$2B = false; + function dew$2B() { + if (_dewExec$2B) + return exports$2C; + _dewExec$2B = true; + var eos; + function once2(callback) { + var called = false; + return function() { + if (called) + return; + called = true; + callback.apply(void 0, arguments); + }; + } + var _require$codes = dew$b$2().codes, ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; + function noop2(err) { + if (err) + throw err; + } + function isRequest(stream2) { + return stream2.setHeader && typeof stream2.abort === "function"; + } + function destroyer(stream2, reading, writing, callback) { + callback = once2(callback); + var closed = false; + stream2.on("close", function() { + closed = true; + }); + if (eos === void 0) + eos = dew$6$2(); + eos(stream2, { + readable: reading, + writable: writing + }, function(err) { + if (err) + return callback(err); + closed = true; + callback(); + }); + var destroyed = false; + return function(err) { + if (closed) + return; + if (destroyed) + return; + destroyed = true; + if (isRequest(stream2)) + return stream2.abort(); + if (typeof stream2.destroy === "function") + return stream2.destroy(); + callback(err || new ERR_STREAM_DESTROYED("pipe")); + }; + } + function call(fn) { + fn(); + } + function pipe2(from18, to) { + return from18.pipe(to); + } + function popCallback(streams) { + if (!streams.length) + return noop2; + if (typeof streams[streams.length - 1] !== "function") + return noop2; + return streams.pop(); + } + function pipeline2() { + for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { + streams[_key] = arguments[_key]; + } + var callback = popCallback(streams); + if (Array.isArray(streams[0])) + streams = streams[0]; + if (streams.length < 2) { + throw new ERR_MISSING_ARGS("streams"); + } + var error7; + var destroys = streams.map(function(stream2, i8) { + var reading = i8 < streams.length - 1; + var writing = i8 > 0; + return destroyer(stream2, reading, writing, function(err) { + if (!error7) + error7 = err; + if (err) + destroys.forEach(call); + if (reading) + return; + destroys.forEach(call); + callback(error7); + }); + }); + return streams.reduce(pipe2); + } + exports$2C = pipeline2; + return exports$2C; + } + var exports$2B = {}; + var _dewExec$2A = false; + var _global$L = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2A() { + if (_dewExec$2A) + return exports$2B; + _dewExec$2A = true; + exports$2B = Stream2; + var EE = y.EventEmitter; + var inherits3 = dew$f$2(); + inherits3(Stream2, EE); + Stream2.Readable = dew$3$2(); + Stream2.Writable = dew$8$2(); + Stream2.Duplex = dew$7$2(); + Stream2.Transform = dew$2$2(); + Stream2.PassThrough = dew$1$2(); + Stream2.finished = dew$6$2(); + Stream2.pipeline = dew$2B(); + Stream2.Stream = Stream2; + function Stream2() { + EE.call(this || _global$L); + } + Stream2.prototype.pipe = function(dest, options) { + var source = this || _global$L; + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } + source.on("data", ondata); + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } + dest.on("drain", ondrain); + if (!dest._isStdio && (!options || options.end !== false)) { + source.on("end", onend); + source.on("close", onclose); + } + var didOnEnd = false; + function onend() { + if (didOnEnd) + return; + didOnEnd = true; + dest.end(); + } + function onclose() { + if (didOnEnd) + return; + didOnEnd = true; + if (typeof dest.destroy === "function") + dest.destroy(); + } + function onerror(er) { + cleanup(); + if (EE.listenerCount(this || _global$L, "error") === 0) { + throw er; + } + } + source.on("error", onerror); + dest.on("error", onerror); + function cleanup() { + source.removeListener("data", ondata); + dest.removeListener("drain", ondrain); + source.removeListener("end", onend); + source.removeListener("close", onclose); + source.removeListener("error", onerror); + dest.removeListener("error", onerror); + source.removeListener("end", cleanup); + source.removeListener("close", cleanup); + dest.removeListener("close", cleanup); + } + source.on("end", cleanup); + source.on("close", cleanup); + dest.on("close", cleanup); + dest.emit("pipe", source); + return dest; + }; + return exports$2B; + } + var stream = dew$2A(); + stream.Readable; + stream.Writable; + stream.Duplex; + stream.Transform; + stream.PassThrough; + stream.finished; + stream.pipeline; + stream.Stream; + ({ + finished: promisify(stream.finished), + pipeline: promisify(stream.pipeline) + }); + var exports$2A = {}; + var _dewExec$2z = false; + var _global$K = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2z() { + if (_dewExec$2z) + return exports$2A; + _dewExec$2z = true; + var Buffer2 = dew$2P().Buffer; + var Transform2 = stream.Transform; + var StringDecoder = e$12.StringDecoder; + var inherits3 = dew$f(); + function CipherBase(hashMode) { + Transform2.call(this || _global$K); + (this || _global$K).hashMode = typeof hashMode === "string"; + if ((this || _global$K).hashMode) { + (this || _global$K)[hashMode] = (this || _global$K)._finalOrDigest; + } else { + (this || _global$K).final = (this || _global$K)._finalOrDigest; + } + if ((this || _global$K)._final) { + (this || _global$K).__final = (this || _global$K)._final; + (this || _global$K)._final = null; + } + (this || _global$K)._decoder = null; + (this || _global$K)._encoding = null; + } + inherits3(CipherBase, Transform2); + CipherBase.prototype.update = function(data, inputEnc, outputEnc) { + if (typeof data === "string") { + data = Buffer2.from(data, inputEnc); + } + var outData = this._update(data); + if ((this || _global$K).hashMode) + return this || _global$K; + if (outputEnc) { + outData = this._toString(outData, outputEnc); + } + return outData; + }; + CipherBase.prototype.setAutoPadding = function() { + }; + CipherBase.prototype.getAuthTag = function() { + throw new Error("trying to get auth tag in unsupported state"); + }; + CipherBase.prototype.setAuthTag = function() { + throw new Error("trying to set auth tag in unsupported state"); + }; + CipherBase.prototype.setAAD = function() { + throw new Error("trying to set aad in unsupported state"); + }; + CipherBase.prototype._transform = function(data, _5, next) { + var err; + try { + if ((this || _global$K).hashMode) { + this._update(data); + } else { + this.push(this._update(data)); + } + } catch (e12) { + err = e12; + } finally { + next(err); + } + }; + CipherBase.prototype._flush = function(done) { + var err; + try { + this.push(this.__final()); + } catch (e12) { + err = e12; + } + done(err); + }; + CipherBase.prototype._finalOrDigest = function(outputEnc) { + var outData = this.__final() || Buffer2.alloc(0); + if (outputEnc) { + outData = this._toString(outData, outputEnc, true); + } + return outData; + }; + CipherBase.prototype._toString = function(value, enc, fin) { + if (!(this || _global$K)._decoder) { + (this || _global$K)._decoder = new StringDecoder(enc); + (this || _global$K)._encoding = enc; + } + if ((this || _global$K)._encoding !== enc) + throw new Error("can't switch encodings"); + var out = (this || _global$K)._decoder.write(value); + if (fin) { + out += (this || _global$K)._decoder.end(); + } + return out; + }; + exports$2A = CipherBase; + return exports$2A; + } + var exports$2z = {}; + var _dewExec$2y = false; + function dew$2y() { + if (_dewExec$2y) + return exports$2z; + _dewExec$2y = true; + var inherits3 = dew$f(); + var MD5 = dew$2L(); + var RIPEMD160 = dew$2K(); + var sha3 = dew$2C(); + var Base2 = dew$2z(); + function Hash2(hash) { + Base2.call(this, "digest"); + this._hash = hash; + } + inherits3(Hash2, Base2); + Hash2.prototype._update = function(data) { + this._hash.update(data); + }; + Hash2.prototype._final = function() { + return this._hash.digest(); + }; + exports$2z = function createHash2(alg) { + alg = alg.toLowerCase(); + if (alg === "md5") + return new MD5(); + if (alg === "rmd160" || alg === "ripemd160") + return new RIPEMD160(); + return new Hash2(sha3(alg)); + }; + return exports$2z; + } + var exports$2y = {}; + var _dewExec$2x = false; + function dew$2x() { + if (_dewExec$2x) + return exports$2y; + _dewExec$2x = true; + var inherits3 = dew$f(); + var Buffer2 = dew$2P().Buffer; + var Base2 = dew$2z(); + var ZEROS = Buffer2.alloc(128); + var blocksize = 64; + function Hmac2(alg, key) { + Base2.call(this, "digest"); + if (typeof key === "string") { + key = Buffer2.from(key); + } + this._alg = alg; + this._key = key; + if (key.length > blocksize) { + key = alg(key); + } else if (key.length < blocksize) { + key = Buffer2.concat([key, ZEROS], blocksize); + } + var ipad = this._ipad = Buffer2.allocUnsafe(blocksize); + var opad = this._opad = Buffer2.allocUnsafe(blocksize); + for (var i8 = 0; i8 < blocksize; i8++) { + ipad[i8] = key[i8] ^ 54; + opad[i8] = key[i8] ^ 92; + } + this._hash = [ipad]; + } + inherits3(Hmac2, Base2); + Hmac2.prototype._update = function(data) { + this._hash.push(data); + }; + Hmac2.prototype._final = function() { + var h9 = this._alg(Buffer2.concat(this._hash)); + return this._alg(Buffer2.concat([this._opad, h9])); + }; + exports$2y = Hmac2; + return exports$2y; + } + var exports$2x = {}; + var _dewExec$2w = false; + function dew$2w() { + if (_dewExec$2w) + return exports$2x; + _dewExec$2w = true; + var MD5 = dew$2L(); + exports$2x = function(buffer4) { + return new MD5().update(buffer4).digest(); + }; + return exports$2x; + } + var exports$2w = {}; + var _dewExec$2v = false; + function dew$2v() { + if (_dewExec$2v) + return exports$2w; + _dewExec$2v = true; + var inherits3 = dew$f(); + var Legacy = dew$2x(); + var Base2 = dew$2z(); + var Buffer2 = dew$2P().Buffer; + var md5 = dew$2w(); + var RIPEMD160 = dew$2K(); + var sha3 = dew$2C(); + var ZEROS = Buffer2.alloc(128); + function Hmac2(alg, key) { + Base2.call(this, "digest"); + if (typeof key === "string") { + key = Buffer2.from(key); + } + var blocksize = alg === "sha512" || alg === "sha384" ? 128 : 64; + this._alg = alg; + this._key = key; + if (key.length > blocksize) { + var hash = alg === "rmd160" ? new RIPEMD160() : sha3(alg); + key = hash.update(key).digest(); + } else if (key.length < blocksize) { + key = Buffer2.concat([key, ZEROS], blocksize); + } + var ipad = this._ipad = Buffer2.allocUnsafe(blocksize); + var opad = this._opad = Buffer2.allocUnsafe(blocksize); + for (var i8 = 0; i8 < blocksize; i8++) { + ipad[i8] = key[i8] ^ 54; + opad[i8] = key[i8] ^ 92; + } + this._hash = alg === "rmd160" ? new RIPEMD160() : sha3(alg); + this._hash.update(ipad); + } + inherits3(Hmac2, Base2); + Hmac2.prototype._update = function(data) { + this._hash.update(data); + }; + Hmac2.prototype._final = function() { + var h9 = this._hash.digest(); + var hash = this._alg === "rmd160" ? new RIPEMD160() : sha3(this._alg); + return hash.update(this._opad).update(h9).digest(); + }; + exports$2w = function createHmac2(alg, key) { + alg = alg.toLowerCase(); + if (alg === "rmd160" || alg === "ripemd160") { + return new Hmac2("rmd160", key); + } + if (alg === "md5") { + return new Legacy(md5, key); + } + return new Hmac2(alg, key); + }; + return exports$2w; + } + var _algorithms$1 = { + "sha224WithRSAEncryption": { + "sign": "rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "RSA-SHA224": { + "sign": "ecdsa/rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "sha256WithRSAEncryption": { + "sign": "rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "RSA-SHA256": { + "sign": "ecdsa/rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "sha384WithRSAEncryption": { + "sign": "rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "RSA-SHA384": { + "sign": "ecdsa/rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "sha512WithRSAEncryption": { + "sign": "rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA512": { + "sign": "ecdsa/rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA1": { + "sign": "rsa", + "hash": "sha1", + "id": "3021300906052b0e03021a05000414" + }, + "ecdsa-with-SHA1": { + "sign": "ecdsa", + "hash": "sha1", + "id": "" + }, + "sha256": { + "sign": "ecdsa", + "hash": "sha256", + "id": "" + }, + "sha224": { + "sign": "ecdsa", + "hash": "sha224", + "id": "" + }, + "sha384": { + "sign": "ecdsa", + "hash": "sha384", + "id": "" + }, + "sha512": { + "sign": "ecdsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-SHA1": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-WITH-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-WITH-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-WITH-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-WITH-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-RIPEMD160": { + "sign": "dsa", + "hash": "rmd160", + "id": "" + }, + "ripemd160WithRSA": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "RSA-RIPEMD160": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "md5WithRSAEncryption": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + }, + "RSA-MD5": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + } + }; + var exports$2v = {}; + var _dewExec$2u = false; + function dew$2u() { + if (_dewExec$2u) + return exports$2v; + _dewExec$2u = true; + exports$2v = _algorithms$1; + return exports$2v; + } + var exports$2u = {}; + var _dewExec$2t = false; + function dew$2t() { + if (_dewExec$2t) + return exports$2u; + _dewExec$2t = true; + var MAX_ALLOC = Math.pow(2, 30) - 1; + exports$2u = function(iterations, keylen) { + if (typeof iterations !== "number") { + throw new TypeError("Iterations not a number"); + } + if (iterations < 0) { + throw new TypeError("Bad iterations"); + } + if (typeof keylen !== "number") { + throw new TypeError("Key length not a number"); + } + if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { + throw new TypeError("Bad key length"); + } + }; + return exports$2u; + } + var exports$2t = {}; + var _dewExec$2s = false; + var _global$J = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2s() { + if (_dewExec$2s) + return exports$2t; + _dewExec$2s = true; + var process$1 = process2; + var defaultEncoding; + if (_global$J.process && _global$J.process.browser) { + defaultEncoding = "utf-8"; + } else if (_global$J.process && _global$J.process.version) { + var pVersionMajor = parseInt(process$1.version.split(".")[0].slice(1), 10); + defaultEncoding = pVersionMajor >= 6 ? "utf-8" : "binary"; + } else { + defaultEncoding = "utf-8"; + } + exports$2t = defaultEncoding; + return exports$2t; + } + var exports$2s = {}; + var _dewExec$2r = false; + function dew$2r() { + if (_dewExec$2r) + return exports$2s; + _dewExec$2r = true; + var Buffer2 = dew$2P().Buffer; + exports$2s = function(thing, encoding, name15) { + if (Buffer2.isBuffer(thing)) { + return thing; + } else if (typeof thing === "string") { + return Buffer2.from(thing, encoding); + } else if (ArrayBuffer.isView(thing)) { + return Buffer2.from(thing.buffer); + } else { + throw new TypeError(name15 + " must be a string, a Buffer, a typed array or a DataView"); + } + }; + return exports$2s; + } + var exports$2r = {}; + var _dewExec$2q = false; + var _global$I = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2q() { + if (_dewExec$2q) + return exports$2r; + _dewExec$2q = true; + var md5 = dew$2w(); + var RIPEMD160 = dew$2K(); + var sha3 = dew$2C(); + var Buffer2 = dew$2P().Buffer; + var checkParameters = dew$2t(); + var defaultEncoding = dew$2s(); + var toBuffer = dew$2r(); + var ZEROS = Buffer2.alloc(128); + var sizes = { + md5: 16, + sha1: 20, + sha224: 28, + sha256: 32, + sha384: 48, + sha512: 64, + rmd160: 20, + ripemd160: 20 + }; + function Hmac2(alg, key, saltLen) { + var hash = getDigest(alg); + var blocksize = alg === "sha512" || alg === "sha384" ? 128 : 64; + if (key.length > blocksize) { + key = hash(key); + } else if (key.length < blocksize) { + key = Buffer2.concat([key, ZEROS], blocksize); + } + var ipad = Buffer2.allocUnsafe(blocksize + sizes[alg]); + var opad = Buffer2.allocUnsafe(blocksize + sizes[alg]); + for (var i8 = 0; i8 < blocksize; i8++) { + ipad[i8] = key[i8] ^ 54; + opad[i8] = key[i8] ^ 92; + } + var ipad1 = Buffer2.allocUnsafe(blocksize + saltLen + 4); + ipad.copy(ipad1, 0, 0, blocksize); + (this || _global$I).ipad1 = ipad1; + (this || _global$I).ipad2 = ipad; + (this || _global$I).opad = opad; + (this || _global$I).alg = alg; + (this || _global$I).blocksize = blocksize; + (this || _global$I).hash = hash; + (this || _global$I).size = sizes[alg]; + } + Hmac2.prototype.run = function(data, ipad) { + data.copy(ipad, (this || _global$I).blocksize); + var h9 = this.hash(ipad); + h9.copy((this || _global$I).opad, (this || _global$I).blocksize); + return this.hash((this || _global$I).opad); + }; + function getDigest(alg) { + function shaFunc(data) { + return sha3(alg).update(data).digest(); + } + function rmd160Func(data) { + return new RIPEMD160().update(data).digest(); + } + if (alg === "rmd160" || alg === "ripemd160") + return rmd160Func; + if (alg === "md5") + return md5; + return shaFunc; + } + function pbkdf22(password, salt, iterations, keylen, digest3) { + checkParameters(iterations, keylen); + password = toBuffer(password, defaultEncoding, "Password"); + salt = toBuffer(salt, defaultEncoding, "Salt"); + digest3 = digest3 || "sha1"; + var hmac = new Hmac2(digest3, password, salt.length); + var DK = Buffer2.allocUnsafe(keylen); + var block1 = Buffer2.allocUnsafe(salt.length + 4); + salt.copy(block1, 0, 0, salt.length); + var destPos = 0; + var hLen = sizes[digest3]; + var l8 = Math.ceil(keylen / hLen); + for (var i8 = 1; i8 <= l8; i8++) { + block1.writeUInt32BE(i8, salt.length); + var T6 = hmac.run(block1, hmac.ipad1); + var U5 = T6; + for (var j5 = 1; j5 < iterations; j5++) { + U5 = hmac.run(U5, hmac.ipad2); + for (var k5 = 0; k5 < hLen; k5++) + T6[k5] ^= U5[k5]; + } + T6.copy(DK, destPos); + destPos += hLen; + } + return DK; + } + exports$2r = pbkdf22; + return exports$2r; + } + var exports$2q = {}; + var _dewExec$2p = false; + var _global$H = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2p() { + if (_dewExec$2p) + return exports$2q; + _dewExec$2p = true; + var Buffer2 = dew$2P().Buffer; + var checkParameters = dew$2t(); + var defaultEncoding = dew$2s(); + var sync = dew$2q(); + var toBuffer = dew$2r(); + var ZERO_BUF; + var subtle = _global$H.crypto && _global$H.crypto.subtle; + var toBrowser = { + sha: "SHA-1", + "sha-1": "SHA-1", + sha1: "SHA-1", + sha256: "SHA-256", + "sha-256": "SHA-256", + sha384: "SHA-384", + "sha-384": "SHA-384", + "sha-512": "SHA-512", + sha512: "SHA-512" + }; + var checks = []; + function checkNative(algo) { + if (_global$H.process && !_global$H.process.browser) { + return Promise.resolve(false); + } + if (!subtle || !subtle.importKey || !subtle.deriveBits) { + return Promise.resolve(false); + } + if (checks[algo] !== void 0) { + return checks[algo]; + } + ZERO_BUF = ZERO_BUF || Buffer2.alloc(8); + var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo).then(function() { + return true; + }).catch(function() { + return false; + }); + checks[algo] = prom; + return prom; + } + var nextTick; + function getNextTick() { + if (nextTick) { + return nextTick; + } + if (_global$H.process && _global$H.process.nextTick) { + nextTick = _global$H.process.nextTick; + } else if (_global$H.queueMicrotask) { + nextTick = _global$H.queueMicrotask; + } else if (_global$H.setImmediate) { + nextTick = _global$H.setImmediate; + } else { + nextTick = _global$H.setTimeout; + } + return nextTick; + } + function browserPbkdf2(password, salt, iterations, length3, algo) { + return subtle.importKey("raw", password, { + name: "PBKDF2" + }, false, ["deriveBits"]).then(function(key) { + return subtle.deriveBits({ + name: "PBKDF2", + salt, + iterations, + hash: { + name: algo + } + }, key, length3 << 3); + }).then(function(res) { + return Buffer2.from(res); + }); + } + function resolvePromise(promise, callback) { + promise.then(function(out) { + getNextTick()(function() { + callback(null, out); + }); + }, function(e12) { + getNextTick()(function() { + callback(e12); + }); + }); + } + exports$2q = function(password, salt, iterations, keylen, digest3, callback) { + if (typeof digest3 === "function") { + callback = digest3; + digest3 = void 0; + } + digest3 = digest3 || "sha1"; + var algo = toBrowser[digest3.toLowerCase()]; + if (!algo || typeof _global$H.Promise !== "function") { + getNextTick()(function() { + var out; + try { + out = sync(password, salt, iterations, keylen, digest3); + } catch (e12) { + return callback(e12); + } + callback(null, out); + }); + return; + } + checkParameters(iterations, keylen); + password = toBuffer(password, defaultEncoding, "Password"); + salt = toBuffer(salt, defaultEncoding, "Salt"); + if (typeof callback !== "function") + throw new Error("No callback provided to pbkdf2"); + resolvePromise(checkNative(algo).then(function(resp) { + if (resp) + return browserPbkdf2(password, salt, iterations, keylen, algo); + return sync(password, salt, iterations, keylen, digest3); + }), callback); + }; + return exports$2q; + } + var exports$2p = {}; + var _dewExec$2o = false; + function dew$2o() { + if (_dewExec$2o) + return exports$2p; + _dewExec$2o = true; + exports$2p.pbkdf2 = dew$2p(); + exports$2p.pbkdf2Sync = dew$2q(); + return exports$2p; + } + var exports$2o = {}; + var _dewExec$2n = false; + function dew$2n() { + if (_dewExec$2n) + return exports$2o; + _dewExec$2n = true; + exports$2o.readUInt32BE = function readUInt32BE(bytes2, off) { + var res = bytes2[0 + off] << 24 | bytes2[1 + off] << 16 | bytes2[2 + off] << 8 | bytes2[3 + off]; + return res >>> 0; + }; + exports$2o.writeUInt32BE = function writeUInt32BE(bytes2, value, off) { + bytes2[0 + off] = value >>> 24; + bytes2[1 + off] = value >>> 16 & 255; + bytes2[2 + off] = value >>> 8 & 255; + bytes2[3 + off] = value & 255; + }; + exports$2o.ip = function ip(inL, inR, out, off) { + var outL = 0; + var outR = 0; + for (var i8 = 6; i8 >= 0; i8 -= 2) { + for (var j5 = 0; j5 <= 24; j5 += 8) { + outL <<= 1; + outL |= inR >>> j5 + i8 & 1; + } + for (var j5 = 0; j5 <= 24; j5 += 8) { + outL <<= 1; + outL |= inL >>> j5 + i8 & 1; + } + } + for (var i8 = 6; i8 >= 0; i8 -= 2) { + for (var j5 = 1; j5 <= 25; j5 += 8) { + outR <<= 1; + outR |= inR >>> j5 + i8 & 1; + } + for (var j5 = 1; j5 <= 25; j5 += 8) { + outR <<= 1; + outR |= inL >>> j5 + i8 & 1; + } + } + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + exports$2o.rip = function rip(inL, inR, out, off) { + var outL = 0; + var outR = 0; + for (var i8 = 0; i8 < 4; i8++) { + for (var j5 = 24; j5 >= 0; j5 -= 8) { + outL <<= 1; + outL |= inR >>> j5 + i8 & 1; + outL <<= 1; + outL |= inL >>> j5 + i8 & 1; + } + } + for (var i8 = 4; i8 < 8; i8++) { + for (var j5 = 24; j5 >= 0; j5 -= 8) { + outR <<= 1; + outR |= inR >>> j5 + i8 & 1; + outR <<= 1; + outR |= inL >>> j5 + i8 & 1; + } + } + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + exports$2o.pc1 = function pc1(inL, inR, out, off) { + var outL = 0; + var outR = 0; + for (var i8 = 7; i8 >= 5; i8--) { + for (var j5 = 0; j5 <= 24; j5 += 8) { + outL <<= 1; + outL |= inR >> j5 + i8 & 1; + } + for (var j5 = 0; j5 <= 24; j5 += 8) { + outL <<= 1; + outL |= inL >> j5 + i8 & 1; + } + } + for (var j5 = 0; j5 <= 24; j5 += 8) { + outL <<= 1; + outL |= inR >> j5 + i8 & 1; + } + for (var i8 = 1; i8 <= 3; i8++) { + for (var j5 = 0; j5 <= 24; j5 += 8) { + outR <<= 1; + outR |= inR >> j5 + i8 & 1; + } + for (var j5 = 0; j5 <= 24; j5 += 8) { + outR <<= 1; + outR |= inL >> j5 + i8 & 1; + } + } + for (var j5 = 0; j5 <= 24; j5 += 8) { + outR <<= 1; + outR |= inL >> j5 + i8 & 1; + } + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + exports$2o.r28shl = function r28shl(num, shift) { + return num << shift & 268435455 | num >>> 28 - shift; + }; + var pc2table = [ + // inL => outL + 14, + 11, + 17, + 4, + 27, + 23, + 25, + 0, + 13, + 22, + 7, + 18, + 5, + 9, + 16, + 24, + 2, + 20, + 12, + 21, + 1, + 8, + 15, + 26, + // inR => outR + 15, + 4, + 25, + 19, + 9, + 1, + 26, + 16, + 5, + 11, + 23, + 8, + 12, + 7, + 17, + 0, + 22, + 3, + 10, + 14, + 6, + 20, + 27, + 24 + ]; + exports$2o.pc2 = function pc2(inL, inR, out, off) { + var outL = 0; + var outR = 0; + var len = pc2table.length >>> 1; + for (var i8 = 0; i8 < len; i8++) { + outL <<= 1; + outL |= inL >>> pc2table[i8] & 1; + } + for (var i8 = len; i8 < pc2table.length; i8++) { + outR <<= 1; + outR |= inR >>> pc2table[i8] & 1; + } + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + exports$2o.expand = function expand(r10, out, off) { + var outL = 0; + var outR = 0; + outL = (r10 & 1) << 5 | r10 >>> 27; + for (var i8 = 23; i8 >= 15; i8 -= 4) { + outL <<= 6; + outL |= r10 >>> i8 & 63; + } + for (var i8 = 11; i8 >= 3; i8 -= 4) { + outR |= r10 >>> i8 & 63; + outR <<= 6; + } + outR |= (r10 & 31) << 1 | r10 >>> 31; + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + var sTable = [14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11]; + exports$2o.substitute = function substitute(inL, inR) { + var out = 0; + for (var i8 = 0; i8 < 4; i8++) { + var b6 = inL >>> 18 - i8 * 6 & 63; + var sb = sTable[i8 * 64 + b6]; + out <<= 4; + out |= sb; + } + for (var i8 = 0; i8 < 4; i8++) { + var b6 = inR >>> 18 - i8 * 6 & 63; + var sb = sTable[4 * 64 + i8 * 64 + b6]; + out <<= 4; + out |= sb; + } + return out >>> 0; + }; + var permuteTable = [16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7]; + exports$2o.permute = function permute(num) { + var out = 0; + for (var i8 = 0; i8 < permuteTable.length; i8++) { + out <<= 1; + out |= num >>> permuteTable[i8] & 1; + } + return out >>> 0; + }; + exports$2o.padSplit = function padSplit(num, size4, group2) { + var str = num.toString(2); + while (str.length < size4) + str = "0" + str; + var out = []; + for (var i8 = 0; i8 < size4; i8 += group2) + out.push(str.slice(i8, i8 + group2)); + return out.join(" "); + }; + return exports$2o; + } + var exports$2n = {}; + var _dewExec$2m = false; + function dew$2m() { + if (_dewExec$2m) + return exports$2n; + _dewExec$2m = true; + exports$2n = assert; + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + assert.equal = function assertEqual(l8, r10, msg) { + if (l8 != r10) + throw new Error(msg || "Assertion failed: " + l8 + " != " + r10); + }; + return exports$2n; + } + var exports$2m = {}; + var _dewExec$2l = false; + function dew$2l() { + if (_dewExec$2l) + return exports$2m; + _dewExec$2l = true; + var assert = dew$2m(); + function Cipher2(options) { + this.options = options; + this.type = this.options.type; + this.blockSize = 8; + this._init(); + this.buffer = new Array(this.blockSize); + this.bufferOff = 0; + } + exports$2m = Cipher2; + Cipher2.prototype._init = function _init() { + }; + Cipher2.prototype.update = function update2(data) { + if (data.length === 0) + return []; + if (this.type === "decrypt") + return this._updateDecrypt(data); + else + return this._updateEncrypt(data); + }; + Cipher2.prototype._buffer = function _buffer(data, off) { + var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); + for (var i8 = 0; i8 < min; i8++) + this.buffer[this.bufferOff + i8] = data[off + i8]; + this.bufferOff += min; + return min; + }; + Cipher2.prototype._flushBuffer = function _flushBuffer(out, off) { + this._update(this.buffer, 0, out, off); + this.bufferOff = 0; + return this.blockSize; + }; + Cipher2.prototype._updateEncrypt = function _updateEncrypt(data) { + var inputOff = 0; + var outputOff = 0; + var count = (this.bufferOff + data.length) / this.blockSize | 0; + var out = new Array(count * this.blockSize); + if (this.bufferOff !== 0) { + inputOff += this._buffer(data, inputOff); + if (this.bufferOff === this.buffer.length) + outputOff += this._flushBuffer(out, outputOff); + } + var max = data.length - (data.length - inputOff) % this.blockSize; + for (; inputOff < max; inputOff += this.blockSize) { + this._update(data, inputOff, out, outputOff); + outputOff += this.blockSize; + } + for (; inputOff < data.length; inputOff++, this.bufferOff++) + this.buffer[this.bufferOff] = data[inputOff]; + return out; + }; + Cipher2.prototype._updateDecrypt = function _updateDecrypt(data) { + var inputOff = 0; + var outputOff = 0; + var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; + var out = new Array(count * this.blockSize); + for (; count > 0; count--) { + inputOff += this._buffer(data, inputOff); + outputOff += this._flushBuffer(out, outputOff); + } + inputOff += this._buffer(data, inputOff); + return out; + }; + Cipher2.prototype.final = function final(buffer4) { + var first; + if (buffer4) + first = this.update(buffer4); + var last2; + if (this.type === "encrypt") + last2 = this._finalEncrypt(); + else + last2 = this._finalDecrypt(); + if (first) + return first.concat(last2); + else + return last2; + }; + Cipher2.prototype._pad = function _pad(buffer4, off) { + if (off === 0) + return false; + while (off < buffer4.length) + buffer4[off++] = 0; + return true; + }; + Cipher2.prototype._finalEncrypt = function _finalEncrypt() { + if (!this._pad(this.buffer, this.bufferOff)) + return []; + var out = new Array(this.blockSize); + this._update(this.buffer, 0, out, 0); + return out; + }; + Cipher2.prototype._unpad = function _unpad(buffer4) { + return buffer4; + }; + Cipher2.prototype._finalDecrypt = function _finalDecrypt() { + assert.equal(this.bufferOff, this.blockSize, "Not enough data to decrypt"); + var out = new Array(this.blockSize); + this._flushBuffer(out, 0); + return this._unpad(out); + }; + return exports$2m; + } + var exports$2l = {}; + var _dewExec$2k = false; + function dew$2k() { + if (_dewExec$2k) + return exports$2l; + _dewExec$2k = true; + var assert = dew$2m(); + var inherits3 = dew$f(); + var utils2 = dew$2n(); + var Cipher2 = dew$2l(); + function DESState() { + this.tmp = new Array(2); + this.keys = null; + } + function DES(options) { + Cipher2.call(this, options); + var state = new DESState(); + this._desState = state; + this.deriveKeys(state, options.key); + } + inherits3(DES, Cipher2); + exports$2l = DES; + DES.create = function create21(options) { + return new DES(options); + }; + var shiftTable = [1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1]; + DES.prototype.deriveKeys = function deriveKeys(state, key) { + state.keys = new Array(16 * 2); + assert.equal(key.length, this.blockSize, "Invalid key length"); + var kL = utils2.readUInt32BE(key, 0); + var kR = utils2.readUInt32BE(key, 4); + utils2.pc1(kL, kR, state.tmp, 0); + kL = state.tmp[0]; + kR = state.tmp[1]; + for (var i8 = 0; i8 < state.keys.length; i8 += 2) { + var shift = shiftTable[i8 >>> 1]; + kL = utils2.r28shl(kL, shift); + kR = utils2.r28shl(kR, shift); + utils2.pc2(kL, kR, state.keys, i8); + } + }; + DES.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._desState; + var l8 = utils2.readUInt32BE(inp, inOff); + var r10 = utils2.readUInt32BE(inp, inOff + 4); + utils2.ip(l8, r10, state.tmp, 0); + l8 = state.tmp[0]; + r10 = state.tmp[1]; + if (this.type === "encrypt") + this._encrypt(state, l8, r10, state.tmp, 0); + else + this._decrypt(state, l8, r10, state.tmp, 0); + l8 = state.tmp[0]; + r10 = state.tmp[1]; + utils2.writeUInt32BE(out, l8, outOff); + utils2.writeUInt32BE(out, r10, outOff + 4); + }; + DES.prototype._pad = function _pad(buffer4, off) { + var value = buffer4.length - off; + for (var i8 = off; i8 < buffer4.length; i8++) + buffer4[i8] = value; + return true; + }; + DES.prototype._unpad = function _unpad(buffer4) { + var pad = buffer4[buffer4.length - 1]; + for (var i8 = buffer4.length - pad; i8 < buffer4.length; i8++) + assert.equal(buffer4[i8], pad); + return buffer4.slice(0, buffer4.length - pad); + }; + DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { + var l8 = lStart; + var r10 = rStart; + for (var i8 = 0; i8 < state.keys.length; i8 += 2) { + var keyL = state.keys[i8]; + var keyR = state.keys[i8 + 1]; + utils2.expand(r10, state.tmp, 0); + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s7 = utils2.substitute(keyL, keyR); + var f9 = utils2.permute(s7); + var t9 = r10; + r10 = (l8 ^ f9) >>> 0; + l8 = t9; + } + utils2.rip(r10, l8, out, off); + }; + DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { + var l8 = rStart; + var r10 = lStart; + for (var i8 = state.keys.length - 2; i8 >= 0; i8 -= 2) { + var keyL = state.keys[i8]; + var keyR = state.keys[i8 + 1]; + utils2.expand(l8, state.tmp, 0); + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s7 = utils2.substitute(keyL, keyR); + var f9 = utils2.permute(s7); + var t9 = l8; + l8 = (r10 ^ f9) >>> 0; + r10 = t9; + } + utils2.rip(l8, r10, out, off); + }; + return exports$2l; + } + var exports$2k = {}; + var _dewExec$2j = false; + function dew$2j() { + if (_dewExec$2j) + return exports$2k; + _dewExec$2j = true; + var assert = dew$2m(); + var inherits3 = dew$f(); + var proto = {}; + function CBCState(iv) { + assert.equal(iv.length, 8, "Invalid IV length"); + this.iv = new Array(8); + for (var i8 = 0; i8 < this.iv.length; i8++) + this.iv[i8] = iv[i8]; + } + function instantiate(Base2) { + function CBC(options) { + Base2.call(this, options); + this._cbcInit(); + } + inherits3(CBC, Base2); + var keys2 = Object.keys(proto); + for (var i8 = 0; i8 < keys2.length; i8++) { + var key = keys2[i8]; + CBC.prototype[key] = proto[key]; + } + CBC.create = function create21(options) { + return new CBC(options); + }; + return CBC; + } + exports$2k.instantiate = instantiate; + proto._cbcInit = function _cbcInit() { + var state = new CBCState(this.options.iv); + this._cbcState = state; + }; + proto._update = function _update(inp, inOff, out, outOff) { + var state = this._cbcState; + var superProto = this.constructor.super_.prototype; + var iv = state.iv; + if (this.type === "encrypt") { + for (var i8 = 0; i8 < this.blockSize; i8++) + iv[i8] ^= inp[inOff + i8]; + superProto._update.call(this, iv, 0, out, outOff); + for (var i8 = 0; i8 < this.blockSize; i8++) + iv[i8] = out[outOff + i8]; + } else { + superProto._update.call(this, inp, inOff, out, outOff); + for (var i8 = 0; i8 < this.blockSize; i8++) + out[outOff + i8] ^= iv[i8]; + for (var i8 = 0; i8 < this.blockSize; i8++) + iv[i8] = inp[inOff + i8]; + } + }; + return exports$2k; + } + var exports$2j = {}; + var _dewExec$2i = false; + function dew$2i() { + if (_dewExec$2i) + return exports$2j; + _dewExec$2i = true; + var assert = dew$2m(); + var inherits3 = dew$f(); + var Cipher2 = dew$2l(); + var DES = dew$2k(); + function EDEState(type3, key) { + assert.equal(key.length, 24, "Invalid key length"); + var k1 = key.slice(0, 8); + var k22 = key.slice(8, 16); + var k32 = key.slice(16, 24); + if (type3 === "encrypt") { + this.ciphers = [DES.create({ + type: "encrypt", + key: k1 + }), DES.create({ + type: "decrypt", + key: k22 + }), DES.create({ + type: "encrypt", + key: k32 + })]; + } else { + this.ciphers = [DES.create({ + type: "decrypt", + key: k32 + }), DES.create({ + type: "encrypt", + key: k22 + }), DES.create({ + type: "decrypt", + key: k1 + })]; + } + } + function EDE(options) { + Cipher2.call(this, options); + var state = new EDEState(this.type, this.options.key); + this._edeState = state; + } + inherits3(EDE, Cipher2); + exports$2j = EDE; + EDE.create = function create21(options) { + return new EDE(options); + }; + EDE.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._edeState; + state.ciphers[0]._update(inp, inOff, out, outOff); + state.ciphers[1]._update(out, outOff, out, outOff); + state.ciphers[2]._update(out, outOff, out, outOff); + }; + EDE.prototype._pad = DES.prototype._pad; + EDE.prototype._unpad = DES.prototype._unpad; + return exports$2j; + } + var exports$2i = {}; + var _dewExec$2h = false; + function dew$2h() { + if (_dewExec$2h) + return exports$2i; + _dewExec$2h = true; + exports$2i.utils = dew$2n(); + exports$2i.Cipher = dew$2l(); + exports$2i.DES = dew$2k(); + exports$2i.CBC = dew$2j(); + exports$2i.EDE = dew$2i(); + return exports$2i; + } + var exports$2h = {}; + var _dewExec$2g = false; + var _global$G = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$2g() { + if (_dewExec$2g) + return exports$2h; + _dewExec$2g = true; + var CipherBase = dew$2z(); + var des = dew$2h(); + var inherits3 = dew$f(); + var Buffer2 = dew$2P().Buffer; + var modes = { + "des-ede3-cbc": des.CBC.instantiate(des.EDE), + "des-ede3": des.EDE, + "des-ede-cbc": des.CBC.instantiate(des.EDE), + "des-ede": des.EDE, + "des-cbc": des.CBC.instantiate(des.DES), + "des-ecb": des.DES + }; + modes.des = modes["des-cbc"]; + modes.des3 = modes["des-ede3-cbc"]; + exports$2h = DES; + inherits3(DES, CipherBase); + function DES(opts) { + CipherBase.call(this || _global$G); + var modeName = opts.mode.toLowerCase(); + var mode = modes[modeName]; + var type3; + if (opts.decrypt) { + type3 = "decrypt"; + } else { + type3 = "encrypt"; + } + var key = opts.key; + if (!Buffer2.isBuffer(key)) { + key = Buffer2.from(key); + } + if (modeName === "des-ede" || modeName === "des-ede-cbc") { + key = Buffer2.concat([key, key.slice(0, 8)]); + } + var iv = opts.iv; + if (!Buffer2.isBuffer(iv)) { + iv = Buffer2.from(iv); + } + (this || _global$G)._des = mode.create({ + key, + iv, + type: type3 + }); + } + DES.prototype._update = function(data) { + return Buffer2.from((this || _global$G)._des.update(data)); + }; + DES.prototype._final = function() { + return Buffer2.from((this || _global$G)._des.final()); + }; + return exports$2h; + } + var exports$2g = {}; + var _dewExec$2f = false; + function dew$2f() { + if (_dewExec$2f) + return exports$2g; + _dewExec$2f = true; + exports$2g.encrypt = function(self2, block) { + return self2._cipher.encryptBlock(block); + }; + exports$2g.decrypt = function(self2, block) { + return self2._cipher.decryptBlock(block); + }; + return exports$2g; + } + var exports$2f = {}; + var _dewExec$2e = false; + function dew$2e() { + if (_dewExec$2e) + return exports$2f; + _dewExec$2e = true; + var Buffer2 = buffer3.Buffer; + exports$2f = function xor3(a8, b6) { + var length3 = Math.min(a8.length, b6.length); + var buffer4 = new Buffer2(length3); + for (var i8 = 0; i8 < length3; ++i8) { + buffer4[i8] = a8[i8] ^ b6[i8]; + } + return buffer4; + }; + return exports$2f; + } + var exports$2e = {}; + var _dewExec$2d = false; + function dew$2d() { + if (_dewExec$2d) + return exports$2e; + _dewExec$2d = true; + var xor3 = dew$2e(); + exports$2e.encrypt = function(self2, block) { + var data = xor3(block, self2._prev); + self2._prev = self2._cipher.encryptBlock(data); + return self2._prev; + }; + exports$2e.decrypt = function(self2, block) { + var pad = self2._prev; + self2._prev = block; + var out = self2._cipher.decryptBlock(block); + return xor3(out, pad); + }; + return exports$2e; + } + var exports$2d = {}; + var _dewExec$2c = false; + function dew$2c() { + if (_dewExec$2c) + return exports$2d; + _dewExec$2c = true; + var Buffer2 = dew$2P().Buffer; + var xor3 = dew$2e(); + function encryptStart(self2, data, decrypt3) { + var len = data.length; + var out = xor3(data, self2._cache); + self2._cache = self2._cache.slice(len); + self2._prev = Buffer2.concat([self2._prev, decrypt3 ? data : out]); + return out; + } + exports$2d.encrypt = function(self2, data, decrypt3) { + var out = Buffer2.allocUnsafe(0); + var len; + while (data.length) { + if (self2._cache.length === 0) { + self2._cache = self2._cipher.encryptBlock(self2._prev); + self2._prev = Buffer2.allocUnsafe(0); + } + if (self2._cache.length <= data.length) { + len = self2._cache.length; + out = Buffer2.concat([out, encryptStart(self2, data.slice(0, len), decrypt3)]); + data = data.slice(len); + } else { + out = Buffer2.concat([out, encryptStart(self2, data, decrypt3)]); + break; + } + } + return out; + }; + return exports$2d; + } + var exports$2c = {}; + var _dewExec$2b = false; + function dew$2b() { + if (_dewExec$2b) + return exports$2c; + _dewExec$2b = true; + var Buffer2 = dew$2P().Buffer; + function encryptByte(self2, byteParam, decrypt3) { + var pad = self2._cipher.encryptBlock(self2._prev); + var out = pad[0] ^ byteParam; + self2._prev = Buffer2.concat([self2._prev.slice(1), Buffer2.from([decrypt3 ? byteParam : out])]); + return out; + } + exports$2c.encrypt = function(self2, chunk, decrypt3) { + var len = chunk.length; + var out = Buffer2.allocUnsafe(len); + var i8 = -1; + while (++i8 < len) { + out[i8] = encryptByte(self2, chunk[i8], decrypt3); + } + return out; + }; + return exports$2c; + } + var exports$2b = {}; + var _dewExec$2a = false; + function dew$2a() { + if (_dewExec$2a) + return exports$2b; + _dewExec$2a = true; + var Buffer2 = dew$2P().Buffer; + function encryptByte(self2, byteParam, decrypt3) { + var pad; + var i8 = -1; + var len = 8; + var out = 0; + var bit, value; + while (++i8 < len) { + pad = self2._cipher.encryptBlock(self2._prev); + bit = byteParam & 1 << 7 - i8 ? 128 : 0; + value = pad[0] ^ bit; + out += (value & 128) >> i8 % 8; + self2._prev = shiftIn(self2._prev, decrypt3 ? bit : value); + } + return out; + } + function shiftIn(buffer4, value) { + var len = buffer4.length; + var i8 = -1; + var out = Buffer2.allocUnsafe(buffer4.length); + buffer4 = Buffer2.concat([buffer4, Buffer2.from([value])]); + while (++i8 < len) { + out[i8] = buffer4[i8] << 1 | buffer4[i8 + 1] >> 7; + } + return out; + } + exports$2b.encrypt = function(self2, chunk, decrypt3) { + var len = chunk.length; + var out = Buffer2.allocUnsafe(len); + var i8 = -1; + while (++i8 < len) { + out[i8] = encryptByte(self2, chunk[i8], decrypt3); + } + return out; + }; + return exports$2b; + } + var exports$2a = {}; + var _dewExec$29 = false; + function dew$29() { + if (_dewExec$29) + return exports$2a; + _dewExec$29 = true; + var Buffer2 = buffer3.Buffer; + var xor3 = dew$2e(); + function getBlock(self2) { + self2._prev = self2._cipher.encryptBlock(self2._prev); + return self2._prev; + } + exports$2a.encrypt = function(self2, chunk) { + while (self2._cache.length < chunk.length) { + self2._cache = Buffer2.concat([self2._cache, getBlock(self2)]); + } + var pad = self2._cache.slice(0, chunk.length); + self2._cache = self2._cache.slice(chunk.length); + return xor3(chunk, pad); + }; + return exports$2a; + } + var exports$29 = {}; + var _dewExec$28 = false; + function dew$28() { + if (_dewExec$28) + return exports$29; + _dewExec$28 = true; + function incr32(iv) { + var len = iv.length; + var item; + while (len--) { + item = iv.readUInt8(len); + if (item === 255) { + iv.writeUInt8(0, len); + } else { + item++; + iv.writeUInt8(item, len); + break; + } + } + } + exports$29 = incr32; + return exports$29; + } + var exports$28 = {}; + var _dewExec$27 = false; + function dew$27() { + if (_dewExec$27) + return exports$28; + _dewExec$27 = true; + var xor3 = dew$2e(); + var Buffer2 = dew$2P().Buffer; + var incr32 = dew$28(); + function getBlock(self2) { + var out = self2._cipher.encryptBlockRaw(self2._prev); + incr32(self2._prev); + return out; + } + var blockSize2 = 16; + exports$28.encrypt = function(self2, chunk) { + var chunkNum = Math.ceil(chunk.length / blockSize2); + var start = self2._cache.length; + self2._cache = Buffer2.concat([self2._cache, Buffer2.allocUnsafe(chunkNum * blockSize2)]); + for (var i8 = 0; i8 < chunkNum; i8++) { + var out = getBlock(self2); + var offset2 = start + i8 * blockSize2; + self2._cache.writeUInt32BE(out[0], offset2 + 0); + self2._cache.writeUInt32BE(out[1], offset2 + 4); + self2._cache.writeUInt32BE(out[2], offset2 + 8); + self2._cache.writeUInt32BE(out[3], offset2 + 12); + } + var pad = self2._cache.slice(0, chunk.length); + self2._cache = self2._cache.slice(chunk.length); + return xor3(chunk, pad); + }; + return exports$28; + } + var _list$1 = { + "aes-128-ecb": { + "cipher": "AES", + "key": 128, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-192-ecb": { + "cipher": "AES", + "key": 192, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-256-ecb": { + "cipher": "AES", + "key": 256, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-128-cbc": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-192-cbc": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-256-cbc": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes128": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes192": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes256": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-128-cfb": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-192-cfb": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-256-cfb": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-128-cfb8": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-192-cfb8": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-256-cfb8": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-128-cfb1": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-192-cfb1": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-256-cfb1": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-128-ofb": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-192-ofb": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-256-ofb": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-128-ctr": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-192-ctr": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-256-ctr": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-128-gcm": { + "cipher": "AES", + "key": 128, + "iv": 12, + "mode": "GCM", + "type": "auth" + }, + "aes-192-gcm": { + "cipher": "AES", + "key": 192, + "iv": 12, + "mode": "GCM", + "type": "auth" + }, + "aes-256-gcm": { + "cipher": "AES", + "key": 256, + "iv": 12, + "mode": "GCM", + "type": "auth" + } + }; + var exports$27 = {}; + var _dewExec$26 = false; + function dew$26() { + if (_dewExec$26) + return exports$27; + _dewExec$26 = true; + var modeModules = { + ECB: dew$2f(), + CBC: dew$2d(), + CFB: dew$2c(), + CFB8: dew$2b(), + CFB1: dew$2a(), + OFB: dew$29(), + CTR: dew$27(), + GCM: dew$27() + }; + var modes = _list$1; + for (var key in modes) { + modes[key].module = modeModules[modes[key].mode]; + } + exports$27 = modes; + return exports$27; + } + var exports$26 = {}; + var _dewExec$25 = false; + var _global$F = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$25() { + if (_dewExec$25) + return exports$26; + _dewExec$25 = true; + var Buffer2 = dew$2P().Buffer; + function asUInt32Array(buf3) { + if (!Buffer2.isBuffer(buf3)) + buf3 = Buffer2.from(buf3); + var len = buf3.length / 4 | 0; + var out = new Array(len); + for (var i8 = 0; i8 < len; i8++) { + out[i8] = buf3.readUInt32BE(i8 * 4); + } + return out; + } + function scrubVec(v7) { + for (var i8 = 0; i8 < v7.length; v7++) { + v7[i8] = 0; + } + } + function cryptBlock(M5, keySchedule, SUB_MIX, SBOX, nRounds) { + var SUB_MIX0 = SUB_MIX[0]; + var SUB_MIX1 = SUB_MIX[1]; + var SUB_MIX2 = SUB_MIX[2]; + var SUB_MIX3 = SUB_MIX[3]; + var s0 = M5[0] ^ keySchedule[0]; + var s1 = M5[1] ^ keySchedule[1]; + var s22 = M5[2] ^ keySchedule[2]; + var s32 = M5[3] ^ keySchedule[3]; + var t0, t1, t22, t32; + var ksRow = 4; + for (var round = 1; round < nRounds; round++) { + t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[s1 >>> 16 & 255] ^ SUB_MIX2[s22 >>> 8 & 255] ^ SUB_MIX3[s32 & 255] ^ keySchedule[ksRow++]; + t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[s22 >>> 16 & 255] ^ SUB_MIX2[s32 >>> 8 & 255] ^ SUB_MIX3[s0 & 255] ^ keySchedule[ksRow++]; + t22 = SUB_MIX0[s22 >>> 24] ^ SUB_MIX1[s32 >>> 16 & 255] ^ SUB_MIX2[s0 >>> 8 & 255] ^ SUB_MIX3[s1 & 255] ^ keySchedule[ksRow++]; + t32 = SUB_MIX0[s32 >>> 24] ^ SUB_MIX1[s0 >>> 16 & 255] ^ SUB_MIX2[s1 >>> 8 & 255] ^ SUB_MIX3[s22 & 255] ^ keySchedule[ksRow++]; + s0 = t0; + s1 = t1; + s22 = t22; + s32 = t32; + } + t0 = (SBOX[s0 >>> 24] << 24 | SBOX[s1 >>> 16 & 255] << 16 | SBOX[s22 >>> 8 & 255] << 8 | SBOX[s32 & 255]) ^ keySchedule[ksRow++]; + t1 = (SBOX[s1 >>> 24] << 24 | SBOX[s22 >>> 16 & 255] << 16 | SBOX[s32 >>> 8 & 255] << 8 | SBOX[s0 & 255]) ^ keySchedule[ksRow++]; + t22 = (SBOX[s22 >>> 24] << 24 | SBOX[s32 >>> 16 & 255] << 16 | SBOX[s0 >>> 8 & 255] << 8 | SBOX[s1 & 255]) ^ keySchedule[ksRow++]; + t32 = (SBOX[s32 >>> 24] << 24 | SBOX[s0 >>> 16 & 255] << 16 | SBOX[s1 >>> 8 & 255] << 8 | SBOX[s22 & 255]) ^ keySchedule[ksRow++]; + t0 = t0 >>> 0; + t1 = t1 >>> 0; + t22 = t22 >>> 0; + t32 = t32 >>> 0; + return [t0, t1, t22, t32]; + } + var RCON = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54]; + var G4 = function() { + var d7 = new Array(256); + for (var j5 = 0; j5 < 256; j5++) { + if (j5 < 128) { + d7[j5] = j5 << 1; + } else { + d7[j5] = j5 << 1 ^ 283; + } + } + var SBOX = []; + var INV_SBOX = []; + var SUB_MIX = [[], [], [], []]; + var INV_SUB_MIX = [[], [], [], []]; + var x5 = 0; + var xi = 0; + for (var i8 = 0; i8 < 256; ++i8) { + var sx = xi ^ xi << 1 ^ xi << 2 ^ xi << 3 ^ xi << 4; + sx = sx >>> 8 ^ sx & 255 ^ 99; + SBOX[x5] = sx; + INV_SBOX[sx] = x5; + var x22 = d7[x5]; + var x42 = d7[x22]; + var x8 = d7[x42]; + var t9 = d7[sx] * 257 ^ sx * 16843008; + SUB_MIX[0][x5] = t9 << 24 | t9 >>> 8; + SUB_MIX[1][x5] = t9 << 16 | t9 >>> 16; + SUB_MIX[2][x5] = t9 << 8 | t9 >>> 24; + SUB_MIX[3][x5] = t9; + t9 = x8 * 16843009 ^ x42 * 65537 ^ x22 * 257 ^ x5 * 16843008; + INV_SUB_MIX[0][sx] = t9 << 24 | t9 >>> 8; + INV_SUB_MIX[1][sx] = t9 << 16 | t9 >>> 16; + INV_SUB_MIX[2][sx] = t9 << 8 | t9 >>> 24; + INV_SUB_MIX[3][sx] = t9; + if (x5 === 0) { + x5 = xi = 1; + } else { + x5 = x22 ^ d7[d7[d7[x8 ^ x22]]]; + xi ^= d7[d7[xi]]; + } + } + return { + SBOX, + INV_SBOX, + SUB_MIX, + INV_SUB_MIX + }; + }(); + function AES(key) { + (this || _global$F)._key = asUInt32Array(key); + this._reset(); + } + AES.blockSize = 4 * 4; + AES.keySize = 256 / 8; + AES.prototype.blockSize = AES.blockSize; + AES.prototype.keySize = AES.keySize; + AES.prototype._reset = function() { + var keyWords = (this || _global$F)._key; + var keySize = keyWords.length; + var nRounds = keySize + 6; + var ksRows = (nRounds + 1) * 4; + var keySchedule = []; + for (var k5 = 0; k5 < keySize; k5++) { + keySchedule[k5] = keyWords[k5]; + } + for (k5 = keySize; k5 < ksRows; k5++) { + var t9 = keySchedule[k5 - 1]; + if (k5 % keySize === 0) { + t9 = t9 << 8 | t9 >>> 24; + t9 = G4.SBOX[t9 >>> 24] << 24 | G4.SBOX[t9 >>> 16 & 255] << 16 | G4.SBOX[t9 >>> 8 & 255] << 8 | G4.SBOX[t9 & 255]; + t9 ^= RCON[k5 / keySize | 0] << 24; + } else if (keySize > 6 && k5 % keySize === 4) { + t9 = G4.SBOX[t9 >>> 24] << 24 | G4.SBOX[t9 >>> 16 & 255] << 16 | G4.SBOX[t9 >>> 8 & 255] << 8 | G4.SBOX[t9 & 255]; + } + keySchedule[k5] = keySchedule[k5 - keySize] ^ t9; + } + var invKeySchedule = []; + for (var ik = 0; ik < ksRows; ik++) { + var ksR = ksRows - ik; + var tt3 = keySchedule[ksR - (ik % 4 ? 0 : 4)]; + if (ik < 4 || ksR <= 4) { + invKeySchedule[ik] = tt3; + } else { + invKeySchedule[ik] = G4.INV_SUB_MIX[0][G4.SBOX[tt3 >>> 24]] ^ G4.INV_SUB_MIX[1][G4.SBOX[tt3 >>> 16 & 255]] ^ G4.INV_SUB_MIX[2][G4.SBOX[tt3 >>> 8 & 255]] ^ G4.INV_SUB_MIX[3][G4.SBOX[tt3 & 255]]; + } + } + (this || _global$F)._nRounds = nRounds; + (this || _global$F)._keySchedule = keySchedule; + (this || _global$F)._invKeySchedule = invKeySchedule; + }; + AES.prototype.encryptBlockRaw = function(M5) { + M5 = asUInt32Array(M5); + return cryptBlock(M5, (this || _global$F)._keySchedule, G4.SUB_MIX, G4.SBOX, (this || _global$F)._nRounds); + }; + AES.prototype.encryptBlock = function(M5) { + var out = this.encryptBlockRaw(M5); + var buf3 = Buffer2.allocUnsafe(16); + buf3.writeUInt32BE(out[0], 0); + buf3.writeUInt32BE(out[1], 4); + buf3.writeUInt32BE(out[2], 8); + buf3.writeUInt32BE(out[3], 12); + return buf3; + }; + AES.prototype.decryptBlock = function(M5) { + M5 = asUInt32Array(M5); + var m1 = M5[1]; + M5[1] = M5[3]; + M5[3] = m1; + var out = cryptBlock(M5, (this || _global$F)._invKeySchedule, G4.INV_SUB_MIX, G4.INV_SBOX, (this || _global$F)._nRounds); + var buf3 = Buffer2.allocUnsafe(16); + buf3.writeUInt32BE(out[0], 0); + buf3.writeUInt32BE(out[3], 4); + buf3.writeUInt32BE(out[2], 8); + buf3.writeUInt32BE(out[1], 12); + return buf3; + }; + AES.prototype.scrub = function() { + scrubVec((this || _global$F)._keySchedule); + scrubVec((this || _global$F)._invKeySchedule); + scrubVec((this || _global$F)._key); + }; + exports$26.AES = AES; + return exports$26; + } + var exports$25 = {}; + var _dewExec$24 = false; + var _global$E = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$24() { + if (_dewExec$24) + return exports$25; + _dewExec$24 = true; + var Buffer2 = dew$2P().Buffer; + var ZEROES = Buffer2.alloc(16, 0); + function toArray(buf3) { + return [buf3.readUInt32BE(0), buf3.readUInt32BE(4), buf3.readUInt32BE(8), buf3.readUInt32BE(12)]; + } + function fromArray3(out) { + var buf3 = Buffer2.allocUnsafe(16); + buf3.writeUInt32BE(out[0] >>> 0, 0); + buf3.writeUInt32BE(out[1] >>> 0, 4); + buf3.writeUInt32BE(out[2] >>> 0, 8); + buf3.writeUInt32BE(out[3] >>> 0, 12); + return buf3; + } + function GHASH(key) { + (this || _global$E).h = key; + (this || _global$E).state = Buffer2.alloc(16, 0); + (this || _global$E).cache = Buffer2.allocUnsafe(0); + } + GHASH.prototype.ghash = function(block) { + var i8 = -1; + while (++i8 < block.length) { + (this || _global$E).state[i8] ^= block[i8]; + } + this._multiply(); + }; + GHASH.prototype._multiply = function() { + var Vi = toArray((this || _global$E).h); + var Zi = [0, 0, 0, 0]; + var j5, xi, lsbVi; + var i8 = -1; + while (++i8 < 128) { + xi = ((this || _global$E).state[~~(i8 / 8)] & 1 << 7 - i8 % 8) !== 0; + if (xi) { + Zi[0] ^= Vi[0]; + Zi[1] ^= Vi[1]; + Zi[2] ^= Vi[2]; + Zi[3] ^= Vi[3]; + } + lsbVi = (Vi[3] & 1) !== 0; + for (j5 = 3; j5 > 0; j5--) { + Vi[j5] = Vi[j5] >>> 1 | (Vi[j5 - 1] & 1) << 31; + } + Vi[0] = Vi[0] >>> 1; + if (lsbVi) { + Vi[0] = Vi[0] ^ 225 << 24; + } + } + (this || _global$E).state = fromArray3(Zi); + }; + GHASH.prototype.update = function(buf3) { + (this || _global$E).cache = Buffer2.concat([(this || _global$E).cache, buf3]); + var chunk; + while ((this || _global$E).cache.length >= 16) { + chunk = (this || _global$E).cache.slice(0, 16); + (this || _global$E).cache = (this || _global$E).cache.slice(16); + this.ghash(chunk); + } + }; + GHASH.prototype.final = function(abl, bl) { + if ((this || _global$E).cache.length) { + this.ghash(Buffer2.concat([(this || _global$E).cache, ZEROES], 16)); + } + this.ghash(fromArray3([0, abl, 0, bl])); + return (this || _global$E).state; + }; + exports$25 = GHASH; + return exports$25; + } + var exports$24 = {}; + var _dewExec$23 = false; + var _global$D = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$23() { + if (_dewExec$23) + return exports$24; + _dewExec$23 = true; + var aes2 = dew$25(); + var Buffer2 = dew$2P().Buffer; + var Transform2 = dew$2z(); + var inherits3 = dew$f(); + var GHASH = dew$24(); + var xor3 = dew$2e(); + var incr32 = dew$28(); + function xorTest(a8, b6) { + var out = 0; + if (a8.length !== b6.length) + out++; + var len = Math.min(a8.length, b6.length); + for (var i8 = 0; i8 < len; ++i8) { + out += a8[i8] ^ b6[i8]; + } + return out; + } + function calcIv(self2, iv, ck) { + if (iv.length === 12) { + self2._finID = Buffer2.concat([iv, Buffer2.from([0, 0, 0, 1])]); + return Buffer2.concat([iv, Buffer2.from([0, 0, 0, 2])]); + } + var ghash = new GHASH(ck); + var len = iv.length; + var toPad = len % 16; + ghash.update(iv); + if (toPad) { + toPad = 16 - toPad; + ghash.update(Buffer2.alloc(toPad, 0)); + } + ghash.update(Buffer2.alloc(8, 0)); + var ivBits = len * 8; + var tail = Buffer2.alloc(8); + tail.writeUIntBE(ivBits, 0, 8); + ghash.update(tail); + self2._finID = ghash.state; + var out = Buffer2.from(self2._finID); + incr32(out); + return out; + } + function StreamCipher(mode, key, iv, decrypt3) { + Transform2.call(this || _global$D); + var h9 = Buffer2.alloc(4, 0); + (this || _global$D)._cipher = new aes2.AES(key); + var ck = (this || _global$D)._cipher.encryptBlock(h9); + (this || _global$D)._ghash = new GHASH(ck); + iv = calcIv(this || _global$D, iv, ck); + (this || _global$D)._prev = Buffer2.from(iv); + (this || _global$D)._cache = Buffer2.allocUnsafe(0); + (this || _global$D)._secCache = Buffer2.allocUnsafe(0); + (this || _global$D)._decrypt = decrypt3; + (this || _global$D)._alen = 0; + (this || _global$D)._len = 0; + (this || _global$D)._mode = mode; + (this || _global$D)._authTag = null; + (this || _global$D)._called = false; + } + inherits3(StreamCipher, Transform2); + StreamCipher.prototype._update = function(chunk) { + if (!(this || _global$D)._called && (this || _global$D)._alen) { + var rump = 16 - (this || _global$D)._alen % 16; + if (rump < 16) { + rump = Buffer2.alloc(rump, 0); + (this || _global$D)._ghash.update(rump); + } + } + (this || _global$D)._called = true; + var out = (this || _global$D)._mode.encrypt(this || _global$D, chunk); + if ((this || _global$D)._decrypt) { + (this || _global$D)._ghash.update(chunk); + } else { + (this || _global$D)._ghash.update(out); + } + (this || _global$D)._len += chunk.length; + return out; + }; + StreamCipher.prototype._final = function() { + if ((this || _global$D)._decrypt && !(this || _global$D)._authTag) + throw new Error("Unsupported state or unable to authenticate data"); + var tag2 = xor3((this || _global$D)._ghash.final((this || _global$D)._alen * 8, (this || _global$D)._len * 8), (this || _global$D)._cipher.encryptBlock((this || _global$D)._finID)); + if ((this || _global$D)._decrypt && xorTest(tag2, (this || _global$D)._authTag)) + throw new Error("Unsupported state or unable to authenticate data"); + (this || _global$D)._authTag = tag2; + (this || _global$D)._cipher.scrub(); + }; + StreamCipher.prototype.getAuthTag = function getAuthTag() { + if ((this || _global$D)._decrypt || !Buffer2.isBuffer((this || _global$D)._authTag)) + throw new Error("Attempting to get auth tag in unsupported state"); + return (this || _global$D)._authTag; + }; + StreamCipher.prototype.setAuthTag = function setAuthTag(tag2) { + if (!(this || _global$D)._decrypt) + throw new Error("Attempting to set auth tag in unsupported state"); + (this || _global$D)._authTag = tag2; + }; + StreamCipher.prototype.setAAD = function setAAD(buf3) { + if ((this || _global$D)._called) + throw new Error("Attempting to set AAD in unsupported state"); + (this || _global$D)._ghash.update(buf3); + (this || _global$D)._alen += buf3.length; + }; + exports$24 = StreamCipher; + return exports$24; + } + var exports$23 = {}; + var _dewExec$222 = false; + var _global$C = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$222() { + if (_dewExec$222) + return exports$23; + _dewExec$222 = true; + var aes2 = dew$25(); + var Buffer2 = dew$2P().Buffer; + var Transform2 = dew$2z(); + var inherits3 = dew$f(); + function StreamCipher(mode, key, iv, decrypt3) { + Transform2.call(this || _global$C); + (this || _global$C)._cipher = new aes2.AES(key); + (this || _global$C)._prev = Buffer2.from(iv); + (this || _global$C)._cache = Buffer2.allocUnsafe(0); + (this || _global$C)._secCache = Buffer2.allocUnsafe(0); + (this || _global$C)._decrypt = decrypt3; + (this || _global$C)._mode = mode; + } + inherits3(StreamCipher, Transform2); + StreamCipher.prototype._update = function(chunk) { + return (this || _global$C)._mode.encrypt(this || _global$C, chunk, (this || _global$C)._decrypt); + }; + StreamCipher.prototype._final = function() { + (this || _global$C)._cipher.scrub(); + }; + exports$23 = StreamCipher; + return exports$23; + } + var exports$222 = {}; + var _dewExec$21 = false; + function dew$21() { + if (_dewExec$21) + return exports$222; + _dewExec$21 = true; + var Buffer2 = dew$2P().Buffer; + var MD5 = dew$2L(); + function EVP_BytesToKey(password, salt, keyBits, ivLen) { + if (!Buffer2.isBuffer(password)) + password = Buffer2.from(password, "binary"); + if (salt) { + if (!Buffer2.isBuffer(salt)) + salt = Buffer2.from(salt, "binary"); + if (salt.length !== 8) + throw new RangeError("salt should be Buffer with 8 byte length"); + } + var keyLen = keyBits / 8; + var key = Buffer2.alloc(keyLen); + var iv = Buffer2.alloc(ivLen || 0); + var tmp = Buffer2.alloc(0); + while (keyLen > 0 || ivLen > 0) { + var hash = new MD5(); + hash.update(tmp); + hash.update(password); + if (salt) + hash.update(salt); + tmp = hash.digest(); + var used = 0; + if (keyLen > 0) { + var keyStart = key.length - keyLen; + used = Math.min(keyLen, tmp.length); + tmp.copy(key, keyStart, 0, used); + keyLen -= used; + } + if (used < tmp.length && ivLen > 0) { + var ivStart = iv.length - ivLen; + var length3 = Math.min(ivLen, tmp.length - used); + tmp.copy(iv, ivStart, used, used + length3); + ivLen -= length3; + } + } + tmp.fill(0); + return { + key, + iv + }; + } + exports$222 = EVP_BytesToKey; + return exports$222; + } + var exports$21 = {}; + var _dewExec$20 = false; + var _global$B = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$20() { + if (_dewExec$20) + return exports$21; + _dewExec$20 = true; + var MODES = dew$26(); + var AuthCipher = dew$23(); + var Buffer2 = dew$2P().Buffer; + var StreamCipher = dew$222(); + var Transform2 = dew$2z(); + var aes2 = dew$25(); + var ebtk = dew$21(); + var inherits3 = dew$f(); + function Cipher2(mode, key, iv) { + Transform2.call(this || _global$B); + (this || _global$B)._cache = new Splitter(); + (this || _global$B)._cipher = new aes2.AES(key); + (this || _global$B)._prev = Buffer2.from(iv); + (this || _global$B)._mode = mode; + (this || _global$B)._autopadding = true; + } + inherits3(Cipher2, Transform2); + Cipher2.prototype._update = function(data) { + (this || _global$B)._cache.add(data); + var chunk; + var thing; + var out = []; + while (chunk = (this || _global$B)._cache.get()) { + thing = (this || _global$B)._mode.encrypt(this || _global$B, chunk); + out.push(thing); + } + return Buffer2.concat(out); + }; + var PADDING = Buffer2.alloc(16, 16); + Cipher2.prototype._final = function() { + var chunk = (this || _global$B)._cache.flush(); + if ((this || _global$B)._autopadding) { + chunk = (this || _global$B)._mode.encrypt(this || _global$B, chunk); + (this || _global$B)._cipher.scrub(); + return chunk; + } + if (!chunk.equals(PADDING)) { + (this || _global$B)._cipher.scrub(); + throw new Error("data not multiple of block length"); + } + }; + Cipher2.prototype.setAutoPadding = function(setTo) { + (this || _global$B)._autopadding = !!setTo; + return this || _global$B; + }; + function Splitter() { + (this || _global$B).cache = Buffer2.allocUnsafe(0); + } + Splitter.prototype.add = function(data) { + (this || _global$B).cache = Buffer2.concat([(this || _global$B).cache, data]); + }; + Splitter.prototype.get = function() { + if ((this || _global$B).cache.length > 15) { + var out = (this || _global$B).cache.slice(0, 16); + (this || _global$B).cache = (this || _global$B).cache.slice(16); + return out; + } + return null; + }; + Splitter.prototype.flush = function() { + var len = 16 - (this || _global$B).cache.length; + var padBuff = Buffer2.allocUnsafe(len); + var i8 = -1; + while (++i8 < len) { + padBuff.writeUInt8(len, i8); + } + return Buffer2.concat([(this || _global$B).cache, padBuff]); + }; + function createCipheriv2(suite, password, iv) { + var config2 = MODES[suite.toLowerCase()]; + if (!config2) + throw new TypeError("invalid suite type"); + if (typeof password === "string") + password = Buffer2.from(password); + if (password.length !== config2.key / 8) + throw new TypeError("invalid key length " + password.length); + if (typeof iv === "string") + iv = Buffer2.from(iv); + if (config2.mode !== "GCM" && iv.length !== config2.iv) + throw new TypeError("invalid iv length " + iv.length); + if (config2.type === "stream") { + return new StreamCipher(config2.module, password, iv); + } else if (config2.type === "auth") { + return new AuthCipher(config2.module, password, iv); + } + return new Cipher2(config2.module, password, iv); + } + function createCipher2(suite, password) { + var config2 = MODES[suite.toLowerCase()]; + if (!config2) + throw new TypeError("invalid suite type"); + var keys2 = ebtk(password, false, config2.key, config2.iv); + return createCipheriv2(suite, keys2.key, keys2.iv); + } + exports$21.createCipheriv = createCipheriv2; + exports$21.createCipher = createCipher2; + return exports$21; + } + var exports$20 = {}; + var _dewExec$1$ = false; + var _global$A = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1$() { + if (_dewExec$1$) + return exports$20; + _dewExec$1$ = true; + var AuthCipher = dew$23(); + var Buffer2 = dew$2P().Buffer; + var MODES = dew$26(); + var StreamCipher = dew$222(); + var Transform2 = dew$2z(); + var aes2 = dew$25(); + var ebtk = dew$21(); + var inherits3 = dew$f(); + function Decipher2(mode, key, iv) { + Transform2.call(this || _global$A); + (this || _global$A)._cache = new Splitter(); + (this || _global$A)._last = void 0; + (this || _global$A)._cipher = new aes2.AES(key); + (this || _global$A)._prev = Buffer2.from(iv); + (this || _global$A)._mode = mode; + (this || _global$A)._autopadding = true; + } + inherits3(Decipher2, Transform2); + Decipher2.prototype._update = function(data) { + (this || _global$A)._cache.add(data); + var chunk; + var thing; + var out = []; + while (chunk = (this || _global$A)._cache.get((this || _global$A)._autopadding)) { + thing = (this || _global$A)._mode.decrypt(this || _global$A, chunk); + out.push(thing); + } + return Buffer2.concat(out); + }; + Decipher2.prototype._final = function() { + var chunk = (this || _global$A)._cache.flush(); + if ((this || _global$A)._autopadding) { + return unpad((this || _global$A)._mode.decrypt(this || _global$A, chunk)); + } else if (chunk) { + throw new Error("data not multiple of block length"); + } + }; + Decipher2.prototype.setAutoPadding = function(setTo) { + (this || _global$A)._autopadding = !!setTo; + return this || _global$A; + }; + function Splitter() { + (this || _global$A).cache = Buffer2.allocUnsafe(0); + } + Splitter.prototype.add = function(data) { + (this || _global$A).cache = Buffer2.concat([(this || _global$A).cache, data]); + }; + Splitter.prototype.get = function(autoPadding) { + var out; + if (autoPadding) { + if ((this || _global$A).cache.length > 16) { + out = (this || _global$A).cache.slice(0, 16); + (this || _global$A).cache = (this || _global$A).cache.slice(16); + return out; + } + } else { + if ((this || _global$A).cache.length >= 16) { + out = (this || _global$A).cache.slice(0, 16); + (this || _global$A).cache = (this || _global$A).cache.slice(16); + return out; + } + } + return null; + }; + Splitter.prototype.flush = function() { + if ((this || _global$A).cache.length) + return (this || _global$A).cache; + }; + function unpad(last2) { + var padded = last2[15]; + if (padded < 1 || padded > 16) { + throw new Error("unable to decrypt data"); + } + var i8 = -1; + while (++i8 < padded) { + if (last2[i8 + (16 - padded)] !== padded) { + throw new Error("unable to decrypt data"); + } + } + if (padded === 16) + return; + return last2.slice(0, 16 - padded); + } + function createDecipheriv2(suite, password, iv) { + var config2 = MODES[suite.toLowerCase()]; + if (!config2) + throw new TypeError("invalid suite type"); + if (typeof iv === "string") + iv = Buffer2.from(iv); + if (config2.mode !== "GCM" && iv.length !== config2.iv) + throw new TypeError("invalid iv length " + iv.length); + if (typeof password === "string") + password = Buffer2.from(password); + if (password.length !== config2.key / 8) + throw new TypeError("invalid key length " + password.length); + if (config2.type === "stream") { + return new StreamCipher(config2.module, password, iv, true); + } else if (config2.type === "auth") { + return new AuthCipher(config2.module, password, iv, true); + } + return new Decipher2(config2.module, password, iv); + } + function createDecipher2(suite, password) { + var config2 = MODES[suite.toLowerCase()]; + if (!config2) + throw new TypeError("invalid suite type"); + var keys2 = ebtk(password, false, config2.key, config2.iv); + return createDecipheriv2(suite, keys2.key, keys2.iv); + } + exports$20.createDecipher = createDecipher2; + exports$20.createDecipheriv = createDecipheriv2; + return exports$20; + } + var exports$1$ = {}; + var _dewExec$1_ = false; + function dew$1_() { + if (_dewExec$1_) + return exports$1$; + _dewExec$1_ = true; + var ciphers = dew$20(); + var deciphers = dew$1$(); + var modes = _list$1; + function getCiphers2() { + return Object.keys(modes); + } + exports$1$.createCipher = exports$1$.Cipher = ciphers.createCipher; + exports$1$.createCipheriv = exports$1$.Cipheriv = ciphers.createCipheriv; + exports$1$.createDecipher = exports$1$.Decipher = deciphers.createDecipher; + exports$1$.createDecipheriv = exports$1$.Decipheriv = deciphers.createDecipheriv; + exports$1$.listCiphers = exports$1$.getCiphers = getCiphers2; + return exports$1$; + } + var exports$1_ = {}; + var _dewExec$1Z = false; + function dew$1Z() { + if (_dewExec$1Z) + return exports$1_; + _dewExec$1Z = true; + exports$1_["des-ecb"] = { + key: 8, + iv: 0 + }; + exports$1_["des-cbc"] = exports$1_.des = { + key: 8, + iv: 8 + }; + exports$1_["des-ede3-cbc"] = exports$1_.des3 = { + key: 24, + iv: 8 + }; + exports$1_["des-ede3"] = { + key: 24, + iv: 0 + }; + exports$1_["des-ede-cbc"] = { + key: 16, + iv: 8 + }; + exports$1_["des-ede"] = { + key: 16, + iv: 0 + }; + return exports$1_; + } + var exports$1Z = {}; + var _dewExec$1Y = false; + function dew$1Y() { + if (_dewExec$1Y) + return exports$1Z; + _dewExec$1Y = true; + var DES = dew$2g(); + var aes2 = dew$1_(); + var aesModes = dew$26(); + var desModes = dew$1Z(); + var ebtk = dew$21(); + function createCipher2(suite, password) { + suite = suite.toLowerCase(); + var keyLen, ivLen; + if (aesModes[suite]) { + keyLen = aesModes[suite].key; + ivLen = aesModes[suite].iv; + } else if (desModes[suite]) { + keyLen = desModes[suite].key * 8; + ivLen = desModes[suite].iv; + } else { + throw new TypeError("invalid suite type"); + } + var keys2 = ebtk(password, false, keyLen, ivLen); + return createCipheriv2(suite, keys2.key, keys2.iv); + } + function createDecipher2(suite, password) { + suite = suite.toLowerCase(); + var keyLen, ivLen; + if (aesModes[suite]) { + keyLen = aesModes[suite].key; + ivLen = aesModes[suite].iv; + } else if (desModes[suite]) { + keyLen = desModes[suite].key * 8; + ivLen = desModes[suite].iv; + } else { + throw new TypeError("invalid suite type"); + } + var keys2 = ebtk(password, false, keyLen, ivLen); + return createDecipheriv2(suite, keys2.key, keys2.iv); + } + function createCipheriv2(suite, key, iv) { + suite = suite.toLowerCase(); + if (aesModes[suite]) + return aes2.createCipheriv(suite, key, iv); + if (desModes[suite]) + return new DES({ + key, + iv, + mode: suite + }); + throw new TypeError("invalid suite type"); + } + function createDecipheriv2(suite, key, iv) { + suite = suite.toLowerCase(); + if (aesModes[suite]) + return aes2.createDecipheriv(suite, key, iv); + if (desModes[suite]) + return new DES({ + key, + iv, + mode: suite, + decrypt: true + }); + throw new TypeError("invalid suite type"); + } + function getCiphers2() { + return Object.keys(desModes).concat(aes2.getCiphers()); + } + exports$1Z.createCipher = exports$1Z.Cipher = createCipher2; + exports$1Z.createCipheriv = exports$1Z.Cipheriv = createCipheriv2; + exports$1Z.createDecipher = exports$1Z.Decipher = createDecipher2; + exports$1Z.createDecipheriv = exports$1Z.Decipheriv = createDecipheriv2; + exports$1Z.listCiphers = exports$1Z.getCiphers = getCiphers2; + return exports$1Z; + } + var exports$1Y = {}; + var _dewExec$1X = false; + var module$a = { + exports: exports$1Y + }; + var _global$z = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1X() { + if (_dewExec$1X) + return module$a.exports; + _dewExec$1X = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$z).negative = 0; + (this || _global$z).words = null; + (this || _global$z).length = 0; + (this || _global$z).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = buffer3.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$z).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$z).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$z).words = [number3 & 67108863]; + (this || _global$z).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$z).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$z).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$z).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$z).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$z).words = [0]; + (this || _global$z).length = 1; + return this || _global$z; + } + (this || _global$z).length = Math.ceil(number3.length / 3); + (this || _global$z).words = new Array((this || _global$z).length); + for (var i8 = 0; i8 < (this || _global$z).length; i8++) { + (this || _global$z).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$z).words[j5] |= w5 << off & 67108863; + (this || _global$z).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$z).words[j5] |= w5 << off & 67108863; + (this || _global$z).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$z).length = Math.ceil((number3.length - start) / 6); + (this || _global$z).words = new Array((this || _global$z).length); + for (var i8 = 0; i8 < (this || _global$z).length; i8++) { + (this || _global$z).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$z).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$z).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$z).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$z).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$z).words = [0]; + (this || _global$z).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$z).words[0] + word < 67108864) { + (this || _global$z).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$z).words[0] + word < 67108864) { + (this || _global$z).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$z).length); + for (var i8 = 0; i8 < (this || _global$z).length; i8++) { + dest.words[i8] = (this || _global$z).words[i8]; + } + dest.length = (this || _global$z).length; + dest.negative = (this || _global$z).negative; + dest.red = (this || _global$z).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$z).length < size4) { + (this || _global$z).words[(this || _global$z).length++] = 0; + } + return this || _global$z; + }; + BN.prototype.strip = function strip() { + while ((this || _global$z).length > 1 && (this || _global$z).words[(this || _global$z).length - 1] === 0) { + (this || _global$z).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$z).length === 1 && (this || _global$z).words[0] === 0) { + (this || _global$z).negative = 0; + } + return this || _global$z; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$z).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$z).length; i8++) { + var w5 = (this || _global$z).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$z).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$z).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$z).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$z).words[0]; + if ((this || _global$z).length === 2) { + ret += (this || _global$z).words[1] * 67108864; + } else if ((this || _global$z).length === 3 && (this || _global$z).words[2] === 1) { + ret += 4503599627370496 + (this || _global$z).words[1] * 67108864; + } else if ((this || _global$z).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$z).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$z).words[(this || _global$z).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$z).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$z).length; i8++) { + var b6 = this._zeroBits((this || _global$z).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$z).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$z).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$z).negative ^= 1; + } + return this || _global$z; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$z).length < num.length) { + (this || _global$z).words[(this || _global$z).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$z).words[i8] = (this || _global$z).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$z).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$z).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$z); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$z).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$z); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$z).length > num.length) { + b6 = num; + } else { + b6 = this || _global$z; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$z).words[i8] = (this || _global$z).words[i8] & num.words[i8]; + } + (this || _global$z).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$z).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$z).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$z); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$z).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$z); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$z).length > num.length) { + a8 = this || _global$z; + b6 = num; + } else { + a8 = num; + b6 = this || _global$z; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$z).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$z) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$z).words[i8] = a8.words[i8]; + } + } + (this || _global$z).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$z).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$z).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$z); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$z).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$z); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$z).words[i8] = ~(this || _global$z).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$z).words[i8] = ~(this || _global$z).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$z).words[off] = (this || _global$z).words[off] | 1 << wbit; + } else { + (this || _global$z).words[off] = (this || _global$z).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$z).negative !== 0 && num.negative === 0) { + (this || _global$z).negative = 0; + r10 = this.isub(num); + (this || _global$z).negative ^= 1; + return this._normSign(); + } else if ((this || _global$z).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$z).length > num.length) { + a8 = this || _global$z; + b6 = num; + } else { + a8 = num; + b6 = this || _global$z; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$z).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$z).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$z).length = a8.length; + if (carry !== 0) { + (this || _global$z).words[(this || _global$z).length] = carry; + (this || _global$z).length++; + } else if (a8 !== (this || _global$z)) { + for (; i8 < a8.length; i8++) { + (this || _global$z).words[i8] = a8.words[i8]; + } + } + return this || _global$z; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$z).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$z).negative !== 0) { + (this || _global$z).negative = 0; + res = num.sub(this || _global$z); + (this || _global$z).negative = 1; + return res; + } + if ((this || _global$z).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$z); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$z).negative !== 0) { + (this || _global$z).negative = 0; + this.iadd(num); + (this || _global$z).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$z).negative = 0; + (this || _global$z).length = 1; + (this || _global$z).words[0] = 0; + return this || _global$z; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$z; + b6 = num; + } else { + a8 = num; + b6 = this || _global$z; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$z).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$z).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$z)) { + for (; i8 < a8.length; i8++) { + (this || _global$z).words[i8] = a8.words[i8]; + } + } + (this || _global$z).length = Math.max((this || _global$z).length, i8); + if (a8 !== (this || _global$z)) { + (this || _global$z).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$z).length + num.length; + if ((this || _global$z).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$z, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$z, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$z, num, out); + } else { + res = jumboMulTo(this || _global$z, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$z).x = x5; + (this || _global$z).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$z).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$z).length + num.length); + return jumboMulTo(this || _global$z, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$z); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$z).length; i8++) { + var w5 = ((this || _global$z).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$z).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$z).words[i8] = carry; + (this || _global$z).length++; + } + return this || _global$z; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$z); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$z; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$z).length; i8++) { + var newCarry = (this || _global$z).words[i8] & carryMask; + var c8 = ((this || _global$z).words[i8] | 0) - newCarry << r10; + (this || _global$z).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$z).words[i8] = carry; + (this || _global$z).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$z).length - 1; i8 >= 0; i8--) { + (this || _global$z).words[i8 + s7] = (this || _global$z).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$z).words[i8] = 0; + } + (this || _global$z).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$z).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$z).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$z).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$z).length > s7) { + (this || _global$z).length -= s7; + for (i8 = 0; i8 < (this || _global$z).length; i8++) { + (this || _global$z).words[i8] = (this || _global$z).words[i8 + s7]; + } + } else { + (this || _global$z).words[0] = 0; + (this || _global$z).length = 1; + } + var carry = 0; + for (i8 = (this || _global$z).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$z).words[i8] | 0; + (this || _global$z).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$z).length === 0) { + (this || _global$z).words[0] = 0; + (this || _global$z).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$z).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$z).length <= s7) + return false; + var w5 = (this || _global$z).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$z).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$z).length <= s7) { + return this || _global$z; + } + if (r10 !== 0) { + s7++; + } + (this || _global$z).length = Math.min(s7, (this || _global$z).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$z).words[(this || _global$z).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$z).negative !== 0) { + if ((this || _global$z).length === 1 && ((this || _global$z).words[0] | 0) < num) { + (this || _global$z).words[0] = num - ((this || _global$z).words[0] | 0); + (this || _global$z).negative = 0; + return this || _global$z; + } + (this || _global$z).negative = 0; + this.isubn(num); + (this || _global$z).negative = 1; + return this || _global$z; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$z).words[0] += num; + for (var i8 = 0; i8 < (this || _global$z).length && (this || _global$z).words[i8] >= 67108864; i8++) { + (this || _global$z).words[i8] -= 67108864; + if (i8 === (this || _global$z).length - 1) { + (this || _global$z).words[i8 + 1] = 1; + } else { + (this || _global$z).words[i8 + 1]++; + } + } + (this || _global$z).length = Math.max((this || _global$z).length, i8 + 1); + return this || _global$z; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$z).negative !== 0) { + (this || _global$z).negative = 0; + this.iaddn(num); + (this || _global$z).negative = 1; + return this || _global$z; + } + (this || _global$z).words[0] -= num; + if ((this || _global$z).length === 1 && (this || _global$z).words[0] < 0) { + (this || _global$z).words[0] = -(this || _global$z).words[0]; + (this || _global$z).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$z).length && (this || _global$z).words[i8] < 0; i8++) { + (this || _global$z).words[i8] += 67108864; + (this || _global$z).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$z).negative = 0; + return this || _global$z; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$z).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$z).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$z).length - shift; i8++) { + w5 = ((this || _global$z).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$z).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$z).length; i8++) { + w5 = -((this || _global$z).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$z).words[i8] = w5 & 67108863; + } + (this || _global$z).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$z).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$z).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$z).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$z).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$z).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$z + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$z).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$z).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$z).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$z).words[i8] | 0) + carry * 67108864; + (this || _global$z).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$z; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$z; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$z).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$z).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$z).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$z).length <= s7) { + this._expand(s7 + 1); + (this || _global$z).words[s7] |= q4; + return this || _global$z; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$z).length; i8++) { + var w5 = (this || _global$z).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$z).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$z).words[i8] = carry; + (this || _global$z).length++; + } + return this || _global$z; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$z).length === 1 && (this || _global$z).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$z).negative !== 0 && !negative) + return -1; + if ((this || _global$z).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$z).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$z).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$z).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$z).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$z).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$z).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$z).length > num.length) + return 1; + if ((this || _global$z).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$z).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$z).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$z).red, "Already a number in reduction context"); + assert((this || _global$z).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$z)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$z).red, "fromRed works only with numbers in reduction context"); + return (this || _global$z).red.convertFrom(this || _global$z); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$z).red = ctx; + return this || _global$z; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$z).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$z).red, "redAdd works only with red numbers"); + return (this || _global$z).red.add(this || _global$z, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$z).red, "redIAdd works only with red numbers"); + return (this || _global$z).red.iadd(this || _global$z, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$z).red, "redSub works only with red numbers"); + return (this || _global$z).red.sub(this || _global$z, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$z).red, "redISub works only with red numbers"); + return (this || _global$z).red.isub(this || _global$z, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$z).red, "redShl works only with red numbers"); + return (this || _global$z).red.shl(this || _global$z, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$z).red, "redMul works only with red numbers"); + (this || _global$z).red._verify2(this || _global$z, num); + return (this || _global$z).red.mul(this || _global$z, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$z).red, "redMul works only with red numbers"); + (this || _global$z).red._verify2(this || _global$z, num); + return (this || _global$z).red.imul(this || _global$z, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$z).red, "redSqr works only with red numbers"); + (this || _global$z).red._verify1(this || _global$z); + return (this || _global$z).red.sqr(this || _global$z); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$z).red, "redISqr works only with red numbers"); + (this || _global$z).red._verify1(this || _global$z); + return (this || _global$z).red.isqr(this || _global$z); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$z).red, "redSqrt works only with red numbers"); + (this || _global$z).red._verify1(this || _global$z); + return (this || _global$z).red.sqrt(this || _global$z); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$z).red, "redInvm works only with red numbers"); + (this || _global$z).red._verify1(this || _global$z); + return (this || _global$z).red.invm(this || _global$z); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$z).red, "redNeg works only with red numbers"); + (this || _global$z).red._verify1(this || _global$z); + return (this || _global$z).red.neg(this || _global$z); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$z).red && !num.red, "redPow(normalNum)"); + (this || _global$z).red._verify1(this || _global$z); + return (this || _global$z).red.pow(this || _global$z, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$z).name = name15; + (this || _global$z).p = new BN(p8, 16); + (this || _global$z).n = (this || _global$z).p.bitLength(); + (this || _global$z).k = new BN(1).iushln((this || _global$z).n).isub((this || _global$z).p); + (this || _global$z).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$z).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$z).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$z).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$z).n); + var cmp = rlen < (this || _global$z).n ? -1 : r10.ucmp((this || _global$z).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$z).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$z).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$z).k); + }; + function K256() { + MPrime.call(this || _global$z, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$z, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$z, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$z, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$z).m = prime.p; + (this || _global$z).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$z).m = m7; + (this || _global$z).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$z).prime) + return (this || _global$z).prime.ireduce(a8)._forceRed(this || _global$z); + return a8.umod((this || _global$z).m)._forceRed(this || _global$z); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$z).m.sub(a8)._forceRed(this || _global$z); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$z).m) >= 0) { + res.isub((this || _global$z).m); + } + return res._forceRed(this || _global$z); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$z).m) >= 0) { + res.isub((this || _global$z).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$z).m); + } + return res._forceRed(this || _global$z); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$z).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$z).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$z).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$z).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$z); + var nOne = one.redNeg(); + var lpow = (this || _global$z).m.subn(1).iushrn(1); + var z6 = (this || _global$z).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$z); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$z).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$z); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$z); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$z).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$z, m7); + (this || _global$z).shift = (this || _global$z).m.bitLength(); + if ((this || _global$z).shift % 26 !== 0) { + (this || _global$z).shift += 26 - (this || _global$z).shift % 26; + } + (this || _global$z).r = new BN(1).iushln((this || _global$z).shift); + (this || _global$z).r2 = this.imod((this || _global$z).r.sqr()); + (this || _global$z).rinv = (this || _global$z).r._invmp((this || _global$z).m); + (this || _global$z).minv = (this || _global$z).rinv.mul((this || _global$z).r).isubn(1).div((this || _global$z).m); + (this || _global$z).minv = (this || _global$z).minv.umod((this || _global$z).r); + (this || _global$z).minv = (this || _global$z).r.sub((this || _global$z).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$z).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$z).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$z).shift).mul((this || _global$z).minv).imaskn((this || _global$z).shift).mul((this || _global$z).m); + var u8 = t9.isub(c8).iushrn((this || _global$z).shift); + var res = u8; + if (u8.cmp((this || _global$z).m) >= 0) { + res = u8.isub((this || _global$z).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$z).m); + } + return res._forceRed(this || _global$z); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$z); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$z).shift).mul((this || _global$z).minv).imaskn((this || _global$z).shift).mul((this || _global$z).m); + var u8 = t9.isub(c8).iushrn((this || _global$z).shift); + var res = u8; + if (u8.cmp((this || _global$z).m) >= 0) { + res = u8.isub((this || _global$z).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$z).m); + } + return res._forceRed(this || _global$z); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$z).m).mul((this || _global$z).r2)); + return res._forceRed(this || _global$z); + }; + })(module$a, exports$1Y); + return module$a.exports; + } + var exports$1X = {}; + var _dewExec$1W = false; + var module$9 = { + exports: exports$1X + }; + var _global$y = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1W() { + if (_dewExec$1W) + return module$9.exports; + _dewExec$1W = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$y).negative = 0; + (this || _global$y).words = null; + (this || _global$y).length = 0; + (this || _global$y).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = buffer3.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$y).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$y).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$y).words = [number3 & 67108863]; + (this || _global$y).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$y).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$y).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$y).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$y).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$y).words = [0]; + (this || _global$y).length = 1; + return this || _global$y; + } + (this || _global$y).length = Math.ceil(number3.length / 3); + (this || _global$y).words = new Array((this || _global$y).length); + for (var i8 = 0; i8 < (this || _global$y).length; i8++) { + (this || _global$y).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$y).words[j5] |= w5 << off & 67108863; + (this || _global$y).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$y).words[j5] |= w5 << off & 67108863; + (this || _global$y).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$y).length = Math.ceil((number3.length - start) / 6); + (this || _global$y).words = new Array((this || _global$y).length); + for (var i8 = 0; i8 < (this || _global$y).length; i8++) { + (this || _global$y).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$y).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$y).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$y).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$y).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$y).words = [0]; + (this || _global$y).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$y).words[0] + word < 67108864) { + (this || _global$y).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$y).words[0] + word < 67108864) { + (this || _global$y).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$y).length); + for (var i8 = 0; i8 < (this || _global$y).length; i8++) { + dest.words[i8] = (this || _global$y).words[i8]; + } + dest.length = (this || _global$y).length; + dest.negative = (this || _global$y).negative; + dest.red = (this || _global$y).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$y).length < size4) { + (this || _global$y).words[(this || _global$y).length++] = 0; + } + return this || _global$y; + }; + BN.prototype.strip = function strip() { + while ((this || _global$y).length > 1 && (this || _global$y).words[(this || _global$y).length - 1] === 0) { + (this || _global$y).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$y).length === 1 && (this || _global$y).words[0] === 0) { + (this || _global$y).negative = 0; + } + return this || _global$y; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$y).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$y).length; i8++) { + var w5 = (this || _global$y).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$y).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$y).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$y).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$y).words[0]; + if ((this || _global$y).length === 2) { + ret += (this || _global$y).words[1] * 67108864; + } else if ((this || _global$y).length === 3 && (this || _global$y).words[2] === 1) { + ret += 4503599627370496 + (this || _global$y).words[1] * 67108864; + } else if ((this || _global$y).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$y).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$y).words[(this || _global$y).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$y).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$y).length; i8++) { + var b6 = this._zeroBits((this || _global$y).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$y).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$y).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$y).negative ^= 1; + } + return this || _global$y; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$y).length < num.length) { + (this || _global$y).words[(this || _global$y).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$y).words[i8] = (this || _global$y).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$y).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$y).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$y); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$y).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$y); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$y).length > num.length) { + b6 = num; + } else { + b6 = this || _global$y; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$y).words[i8] = (this || _global$y).words[i8] & num.words[i8]; + } + (this || _global$y).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$y).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$y).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$y); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$y).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$y); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$y).length > num.length) { + a8 = this || _global$y; + b6 = num; + } else { + a8 = num; + b6 = this || _global$y; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$y).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$y) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$y).words[i8] = a8.words[i8]; + } + } + (this || _global$y).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$y).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$y).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$y); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$y).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$y); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$y).words[i8] = ~(this || _global$y).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$y).words[i8] = ~(this || _global$y).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$y).words[off] = (this || _global$y).words[off] | 1 << wbit; + } else { + (this || _global$y).words[off] = (this || _global$y).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$y).negative !== 0 && num.negative === 0) { + (this || _global$y).negative = 0; + r10 = this.isub(num); + (this || _global$y).negative ^= 1; + return this._normSign(); + } else if ((this || _global$y).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$y).length > num.length) { + a8 = this || _global$y; + b6 = num; + } else { + a8 = num; + b6 = this || _global$y; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$y).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$y).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$y).length = a8.length; + if (carry !== 0) { + (this || _global$y).words[(this || _global$y).length] = carry; + (this || _global$y).length++; + } else if (a8 !== (this || _global$y)) { + for (; i8 < a8.length; i8++) { + (this || _global$y).words[i8] = a8.words[i8]; + } + } + return this || _global$y; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$y).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$y).negative !== 0) { + (this || _global$y).negative = 0; + res = num.sub(this || _global$y); + (this || _global$y).negative = 1; + return res; + } + if ((this || _global$y).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$y); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$y).negative !== 0) { + (this || _global$y).negative = 0; + this.iadd(num); + (this || _global$y).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$y).negative = 0; + (this || _global$y).length = 1; + (this || _global$y).words[0] = 0; + return this || _global$y; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$y; + b6 = num; + } else { + a8 = num; + b6 = this || _global$y; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$y).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$y).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$y)) { + for (; i8 < a8.length; i8++) { + (this || _global$y).words[i8] = a8.words[i8]; + } + } + (this || _global$y).length = Math.max((this || _global$y).length, i8); + if (a8 !== (this || _global$y)) { + (this || _global$y).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$y).length + num.length; + if ((this || _global$y).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$y, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$y, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$y, num, out); + } else { + res = jumboMulTo(this || _global$y, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$y).x = x5; + (this || _global$y).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$y).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$y).length + num.length); + return jumboMulTo(this || _global$y, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$y); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$y).length; i8++) { + var w5 = ((this || _global$y).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$y).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$y).words[i8] = carry; + (this || _global$y).length++; + } + return this || _global$y; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$y); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$y; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$y).length; i8++) { + var newCarry = (this || _global$y).words[i8] & carryMask; + var c8 = ((this || _global$y).words[i8] | 0) - newCarry << r10; + (this || _global$y).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$y).words[i8] = carry; + (this || _global$y).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$y).length - 1; i8 >= 0; i8--) { + (this || _global$y).words[i8 + s7] = (this || _global$y).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$y).words[i8] = 0; + } + (this || _global$y).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$y).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$y).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$y).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$y).length > s7) { + (this || _global$y).length -= s7; + for (i8 = 0; i8 < (this || _global$y).length; i8++) { + (this || _global$y).words[i8] = (this || _global$y).words[i8 + s7]; + } + } else { + (this || _global$y).words[0] = 0; + (this || _global$y).length = 1; + } + var carry = 0; + for (i8 = (this || _global$y).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$y).words[i8] | 0; + (this || _global$y).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$y).length === 0) { + (this || _global$y).words[0] = 0; + (this || _global$y).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$y).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$y).length <= s7) + return false; + var w5 = (this || _global$y).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$y).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$y).length <= s7) { + return this || _global$y; + } + if (r10 !== 0) { + s7++; + } + (this || _global$y).length = Math.min(s7, (this || _global$y).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$y).words[(this || _global$y).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$y).negative !== 0) { + if ((this || _global$y).length === 1 && ((this || _global$y).words[0] | 0) < num) { + (this || _global$y).words[0] = num - ((this || _global$y).words[0] | 0); + (this || _global$y).negative = 0; + return this || _global$y; + } + (this || _global$y).negative = 0; + this.isubn(num); + (this || _global$y).negative = 1; + return this || _global$y; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$y).words[0] += num; + for (var i8 = 0; i8 < (this || _global$y).length && (this || _global$y).words[i8] >= 67108864; i8++) { + (this || _global$y).words[i8] -= 67108864; + if (i8 === (this || _global$y).length - 1) { + (this || _global$y).words[i8 + 1] = 1; + } else { + (this || _global$y).words[i8 + 1]++; + } + } + (this || _global$y).length = Math.max((this || _global$y).length, i8 + 1); + return this || _global$y; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$y).negative !== 0) { + (this || _global$y).negative = 0; + this.iaddn(num); + (this || _global$y).negative = 1; + return this || _global$y; + } + (this || _global$y).words[0] -= num; + if ((this || _global$y).length === 1 && (this || _global$y).words[0] < 0) { + (this || _global$y).words[0] = -(this || _global$y).words[0]; + (this || _global$y).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$y).length && (this || _global$y).words[i8] < 0; i8++) { + (this || _global$y).words[i8] += 67108864; + (this || _global$y).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$y).negative = 0; + return this || _global$y; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$y).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$y).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$y).length - shift; i8++) { + w5 = ((this || _global$y).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$y).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$y).length; i8++) { + w5 = -((this || _global$y).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$y).words[i8] = w5 & 67108863; + } + (this || _global$y).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$y).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$y).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$y).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$y).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$y).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$y + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$y).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$y).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$y).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$y).words[i8] | 0) + carry * 67108864; + (this || _global$y).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$y; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$y; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$y).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$y).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$y).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$y).length <= s7) { + this._expand(s7 + 1); + (this || _global$y).words[s7] |= q4; + return this || _global$y; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$y).length; i8++) { + var w5 = (this || _global$y).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$y).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$y).words[i8] = carry; + (this || _global$y).length++; + } + return this || _global$y; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$y).length === 1 && (this || _global$y).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$y).negative !== 0 && !negative) + return -1; + if ((this || _global$y).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$y).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$y).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$y).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$y).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$y).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$y).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$y).length > num.length) + return 1; + if ((this || _global$y).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$y).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$y).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$y).red, "Already a number in reduction context"); + assert((this || _global$y).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$y)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$y).red, "fromRed works only with numbers in reduction context"); + return (this || _global$y).red.convertFrom(this || _global$y); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$y).red = ctx; + return this || _global$y; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$y).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$y).red, "redAdd works only with red numbers"); + return (this || _global$y).red.add(this || _global$y, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$y).red, "redIAdd works only with red numbers"); + return (this || _global$y).red.iadd(this || _global$y, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$y).red, "redSub works only with red numbers"); + return (this || _global$y).red.sub(this || _global$y, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$y).red, "redISub works only with red numbers"); + return (this || _global$y).red.isub(this || _global$y, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$y).red, "redShl works only with red numbers"); + return (this || _global$y).red.shl(this || _global$y, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$y).red, "redMul works only with red numbers"); + (this || _global$y).red._verify2(this || _global$y, num); + return (this || _global$y).red.mul(this || _global$y, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$y).red, "redMul works only with red numbers"); + (this || _global$y).red._verify2(this || _global$y, num); + return (this || _global$y).red.imul(this || _global$y, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$y).red, "redSqr works only with red numbers"); + (this || _global$y).red._verify1(this || _global$y); + return (this || _global$y).red.sqr(this || _global$y); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$y).red, "redISqr works only with red numbers"); + (this || _global$y).red._verify1(this || _global$y); + return (this || _global$y).red.isqr(this || _global$y); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$y).red, "redSqrt works only with red numbers"); + (this || _global$y).red._verify1(this || _global$y); + return (this || _global$y).red.sqrt(this || _global$y); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$y).red, "redInvm works only with red numbers"); + (this || _global$y).red._verify1(this || _global$y); + return (this || _global$y).red.invm(this || _global$y); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$y).red, "redNeg works only with red numbers"); + (this || _global$y).red._verify1(this || _global$y); + return (this || _global$y).red.neg(this || _global$y); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$y).red && !num.red, "redPow(normalNum)"); + (this || _global$y).red._verify1(this || _global$y); + return (this || _global$y).red.pow(this || _global$y, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$y).name = name15; + (this || _global$y).p = new BN(p8, 16); + (this || _global$y).n = (this || _global$y).p.bitLength(); + (this || _global$y).k = new BN(1).iushln((this || _global$y).n).isub((this || _global$y).p); + (this || _global$y).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$y).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$y).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$y).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$y).n); + var cmp = rlen < (this || _global$y).n ? -1 : r10.ucmp((this || _global$y).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$y).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$y).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$y).k); + }; + function K256() { + MPrime.call(this || _global$y, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$y, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$y, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$y, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$y).m = prime.p; + (this || _global$y).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$y).m = m7; + (this || _global$y).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$y).prime) + return (this || _global$y).prime.ireduce(a8)._forceRed(this || _global$y); + return a8.umod((this || _global$y).m)._forceRed(this || _global$y); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$y).m.sub(a8)._forceRed(this || _global$y); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$y).m) >= 0) { + res.isub((this || _global$y).m); + } + return res._forceRed(this || _global$y); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$y).m) >= 0) { + res.isub((this || _global$y).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$y).m); + } + return res._forceRed(this || _global$y); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$y).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$y).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$y).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$y).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$y); + var nOne = one.redNeg(); + var lpow = (this || _global$y).m.subn(1).iushrn(1); + var z6 = (this || _global$y).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$y); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$y).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$y); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$y); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$y).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$y, m7); + (this || _global$y).shift = (this || _global$y).m.bitLength(); + if ((this || _global$y).shift % 26 !== 0) { + (this || _global$y).shift += 26 - (this || _global$y).shift % 26; + } + (this || _global$y).r = new BN(1).iushln((this || _global$y).shift); + (this || _global$y).r2 = this.imod((this || _global$y).r.sqr()); + (this || _global$y).rinv = (this || _global$y).r._invmp((this || _global$y).m); + (this || _global$y).minv = (this || _global$y).rinv.mul((this || _global$y).r).isubn(1).div((this || _global$y).m); + (this || _global$y).minv = (this || _global$y).minv.umod((this || _global$y).r); + (this || _global$y).minv = (this || _global$y).r.sub((this || _global$y).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$y).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$y).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$y).shift).mul((this || _global$y).minv).imaskn((this || _global$y).shift).mul((this || _global$y).m); + var u8 = t9.isub(c8).iushrn((this || _global$y).shift); + var res = u8; + if (u8.cmp((this || _global$y).m) >= 0) { + res = u8.isub((this || _global$y).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$y).m); + } + return res._forceRed(this || _global$y); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$y); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$y).shift).mul((this || _global$y).minv).imaskn((this || _global$y).shift).mul((this || _global$y).m); + var u8 = t9.isub(c8).iushrn((this || _global$y).shift); + var res = u8; + if (u8.cmp((this || _global$y).m) >= 0) { + res = u8.isub((this || _global$y).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$y).m); + } + return res._forceRed(this || _global$y); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$y).m).mul((this || _global$y).r2)); + return res._forceRed(this || _global$y); + }; + })(module$9, exports$1X); + return module$9.exports; + } + var exports$1W = {}; + var _dewExec$1V = false; + function dew$1V() { + if (_dewExec$1V) + return exports$1W; + _dewExec$1V = true; + exports$1W = exports$1W = dew$3$2(); + exports$1W.Stream = exports$1W; + exports$1W.Readable = exports$1W; + exports$1W.Writable = dew$8$2(); + exports$1W.Duplex = dew$7$2(); + exports$1W.Transform = dew$2$2(); + exports$1W.PassThrough = dew$1$2(); + exports$1W.finished = dew$6$2(); + exports$1W.pipeline = dew$2B(); + return exports$1W; + } + var exports$1U = {}; + var _dewExec$1T = false; + function dew$1T() { + if (_dewExec$1T) + return exports$1U; + _dewExec$1T = true; + var buffer4 = e$1$1; + var Buffer2 = buffer4.Buffer; + function copyProps(src3, dst) { + for (var key in src3) { + dst[key] = src3[key]; + } + } + if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) { + exports$1U = buffer4; + } else { + copyProps(buffer4, exports$1U); + exports$1U.Buffer = SafeBuffer; + } + function SafeBuffer(arg, encodingOrOffset, length3) { + return Buffer2(arg, encodingOrOffset, length3); + } + SafeBuffer.prototype = Object.create(Buffer2.prototype); + copyProps(Buffer2, SafeBuffer); + SafeBuffer.from = function(arg, encodingOrOffset, length3) { + if (typeof arg === "number") { + throw new TypeError("Argument must not be a number"); + } + return Buffer2(arg, encodingOrOffset, length3); + }; + SafeBuffer.alloc = function(size4, fill, encoding) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + var buf3 = Buffer2(size4); + if (fill !== void 0) { + if (typeof encoding === "string") { + buf3.fill(fill, encoding); + } else { + buf3.fill(fill); + } + } else { + buf3.fill(0); + } + return buf3; + }; + SafeBuffer.allocUnsafe = function(size4) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + return Buffer2(size4); + }; + SafeBuffer.allocUnsafeSlow = function(size4) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + return buffer4.SlowBuffer(size4); + }; + return exports$1U; + } + var exports$1T = {}; + var _dewExec$1S = false; + var _global$w = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1S() { + if (_dewExec$1S) + return exports$1T; + _dewExec$1S = true; + var process3 = T; + var MAX_BYTES = 65536; + var MAX_UINT322 = 4294967295; + function oldBrowser() { + throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11"); + } + var Buffer2 = dew$1T().Buffer; + var crypto5 = _global$w.crypto || _global$w.msCrypto; + if (crypto5 && crypto5.getRandomValues) { + exports$1T = randomBytes3; + } else { + exports$1T = oldBrowser; + } + function randomBytes3(size4, cb) { + if (size4 > MAX_UINT322) + throw new RangeError("requested too many random bytes"); + var bytes2 = Buffer2.allocUnsafe(size4); + if (size4 > 0) { + if (size4 > MAX_BYTES) { + for (var generated = 0; generated < size4; generated += MAX_BYTES) { + crypto5.getRandomValues(bytes2.slice(generated, generated + MAX_BYTES)); + } + } else { + crypto5.getRandomValues(bytes2); + } + } + if (typeof cb === "function") { + return process3.nextTick(function() { + cb(null, bytes2); + }); + } + return bytes2; + } + return exports$1T; + } + var exports$1S = {}; + var _dewExec$1R = false; + function dew$1R() { + if (_dewExec$1R) + return exports$1S; + _dewExec$1R = true; + var Buffer2 = dew$1T().Buffer; + var Transform2 = dew$1V().Transform; + var inherits3 = dew$f$2(); + function throwIfNotStringOrBuffer(val, prefix) { + if (!Buffer2.isBuffer(val) && typeof val !== "string") { + throw new TypeError(prefix + " must be a string or a buffer"); + } + } + function HashBase(blockSize2) { + Transform2.call(this); + this._block = Buffer2.allocUnsafe(blockSize2); + this._blockSize = blockSize2; + this._blockOffset = 0; + this._length = [0, 0, 0, 0]; + this._finalized = false; + } + inherits3(HashBase, Transform2); + HashBase.prototype._transform = function(chunk, encoding, callback) { + var error7 = null; + try { + this.update(chunk, encoding); + } catch (err) { + error7 = err; + } + callback(error7); + }; + HashBase.prototype._flush = function(callback) { + var error7 = null; + try { + this.push(this.digest()); + } catch (err) { + error7 = err; + } + callback(error7); + }; + HashBase.prototype.update = function(data, encoding) { + throwIfNotStringOrBuffer(data, "Data"); + if (this._finalized) + throw new Error("Digest already called"); + if (!Buffer2.isBuffer(data)) + data = Buffer2.from(data, encoding); + var block = this._block; + var offset2 = 0; + while (this._blockOffset + data.length - offset2 >= this._blockSize) { + for (var i8 = this._blockOffset; i8 < this._blockSize; ) + block[i8++] = data[offset2++]; + this._update(); + this._blockOffset = 0; + } + while (offset2 < data.length) + block[this._blockOffset++] = data[offset2++]; + for (var j5 = 0, carry = data.length * 8; carry > 0; ++j5) { + this._length[j5] += carry; + carry = this._length[j5] / 4294967296 | 0; + if (carry > 0) + this._length[j5] -= 4294967296 * carry; + } + return this; + }; + HashBase.prototype._update = function() { + throw new Error("_update is not implemented"); + }; + HashBase.prototype.digest = function(encoding) { + if (this._finalized) + throw new Error("Digest already called"); + this._finalized = true; + var digest3 = this._digest(); + if (encoding !== void 0) + digest3 = digest3.toString(encoding); + this._block.fill(0); + this._blockOffset = 0; + for (var i8 = 0; i8 < 4; ++i8) + this._length[i8] = 0; + return digest3; + }; + HashBase.prototype._digest = function() { + throw new Error("_digest is not implemented"); + }; + exports$1S = HashBase; + return exports$1S; + } + var exports$1R = {}; + var _dewExec$1Q = false; + function dew$1Q() { + if (_dewExec$1Q) + return exports$1R; + _dewExec$1Q = true; + var inherits3 = dew$f$2(); + var HashBase = dew$1R(); + var Buffer2 = dew$1T().Buffer; + var ARRAY16 = new Array(16); + function MD5() { + HashBase.call(this, 64); + this._a = 1732584193; + this._b = 4023233417; + this._c = 2562383102; + this._d = 271733878; + } + inherits3(MD5, HashBase); + MD5.prototype._update = function() { + var M5 = ARRAY16; + for (var i8 = 0; i8 < 16; ++i8) + M5[i8] = this._block.readInt32LE(i8 * 4); + var a8 = this._a; + var b6 = this._b; + var c8 = this._c; + var d7 = this._d; + a8 = fnF(a8, b6, c8, d7, M5[0], 3614090360, 7); + d7 = fnF(d7, a8, b6, c8, M5[1], 3905402710, 12); + c8 = fnF(c8, d7, a8, b6, M5[2], 606105819, 17); + b6 = fnF(b6, c8, d7, a8, M5[3], 3250441966, 22); + a8 = fnF(a8, b6, c8, d7, M5[4], 4118548399, 7); + d7 = fnF(d7, a8, b6, c8, M5[5], 1200080426, 12); + c8 = fnF(c8, d7, a8, b6, M5[6], 2821735955, 17); + b6 = fnF(b6, c8, d7, a8, M5[7], 4249261313, 22); + a8 = fnF(a8, b6, c8, d7, M5[8], 1770035416, 7); + d7 = fnF(d7, a8, b6, c8, M5[9], 2336552879, 12); + c8 = fnF(c8, d7, a8, b6, M5[10], 4294925233, 17); + b6 = fnF(b6, c8, d7, a8, M5[11], 2304563134, 22); + a8 = fnF(a8, b6, c8, d7, M5[12], 1804603682, 7); + d7 = fnF(d7, a8, b6, c8, M5[13], 4254626195, 12); + c8 = fnF(c8, d7, a8, b6, M5[14], 2792965006, 17); + b6 = fnF(b6, c8, d7, a8, M5[15], 1236535329, 22); + a8 = fnG(a8, b6, c8, d7, M5[1], 4129170786, 5); + d7 = fnG(d7, a8, b6, c8, M5[6], 3225465664, 9); + c8 = fnG(c8, d7, a8, b6, M5[11], 643717713, 14); + b6 = fnG(b6, c8, d7, a8, M5[0], 3921069994, 20); + a8 = fnG(a8, b6, c8, d7, M5[5], 3593408605, 5); + d7 = fnG(d7, a8, b6, c8, M5[10], 38016083, 9); + c8 = fnG(c8, d7, a8, b6, M5[15], 3634488961, 14); + b6 = fnG(b6, c8, d7, a8, M5[4], 3889429448, 20); + a8 = fnG(a8, b6, c8, d7, M5[9], 568446438, 5); + d7 = fnG(d7, a8, b6, c8, M5[14], 3275163606, 9); + c8 = fnG(c8, d7, a8, b6, M5[3], 4107603335, 14); + b6 = fnG(b6, c8, d7, a8, M5[8], 1163531501, 20); + a8 = fnG(a8, b6, c8, d7, M5[13], 2850285829, 5); + d7 = fnG(d7, a8, b6, c8, M5[2], 4243563512, 9); + c8 = fnG(c8, d7, a8, b6, M5[7], 1735328473, 14); + b6 = fnG(b6, c8, d7, a8, M5[12], 2368359562, 20); + a8 = fnH(a8, b6, c8, d7, M5[5], 4294588738, 4); + d7 = fnH(d7, a8, b6, c8, M5[8], 2272392833, 11); + c8 = fnH(c8, d7, a8, b6, M5[11], 1839030562, 16); + b6 = fnH(b6, c8, d7, a8, M5[14], 4259657740, 23); + a8 = fnH(a8, b6, c8, d7, M5[1], 2763975236, 4); + d7 = fnH(d7, a8, b6, c8, M5[4], 1272893353, 11); + c8 = fnH(c8, d7, a8, b6, M5[7], 4139469664, 16); + b6 = fnH(b6, c8, d7, a8, M5[10], 3200236656, 23); + a8 = fnH(a8, b6, c8, d7, M5[13], 681279174, 4); + d7 = fnH(d7, a8, b6, c8, M5[0], 3936430074, 11); + c8 = fnH(c8, d7, a8, b6, M5[3], 3572445317, 16); + b6 = fnH(b6, c8, d7, a8, M5[6], 76029189, 23); + a8 = fnH(a8, b6, c8, d7, M5[9], 3654602809, 4); + d7 = fnH(d7, a8, b6, c8, M5[12], 3873151461, 11); + c8 = fnH(c8, d7, a8, b6, M5[15], 530742520, 16); + b6 = fnH(b6, c8, d7, a8, M5[2], 3299628645, 23); + a8 = fnI(a8, b6, c8, d7, M5[0], 4096336452, 6); + d7 = fnI(d7, a8, b6, c8, M5[7], 1126891415, 10); + c8 = fnI(c8, d7, a8, b6, M5[14], 2878612391, 15); + b6 = fnI(b6, c8, d7, a8, M5[5], 4237533241, 21); + a8 = fnI(a8, b6, c8, d7, M5[12], 1700485571, 6); + d7 = fnI(d7, a8, b6, c8, M5[3], 2399980690, 10); + c8 = fnI(c8, d7, a8, b6, M5[10], 4293915773, 15); + b6 = fnI(b6, c8, d7, a8, M5[1], 2240044497, 21); + a8 = fnI(a8, b6, c8, d7, M5[8], 1873313359, 6); + d7 = fnI(d7, a8, b6, c8, M5[15], 4264355552, 10); + c8 = fnI(c8, d7, a8, b6, M5[6], 2734768916, 15); + b6 = fnI(b6, c8, d7, a8, M5[13], 1309151649, 21); + a8 = fnI(a8, b6, c8, d7, M5[4], 4149444226, 6); + d7 = fnI(d7, a8, b6, c8, M5[11], 3174756917, 10); + c8 = fnI(c8, d7, a8, b6, M5[2], 718787259, 15); + b6 = fnI(b6, c8, d7, a8, M5[9], 3951481745, 21); + this._a = this._a + a8 | 0; + this._b = this._b + b6 | 0; + this._c = this._c + c8 | 0; + this._d = this._d + d7 | 0; + }; + MD5.prototype._digest = function() { + this._block[this._blockOffset++] = 128; + if (this._blockOffset > 56) { + this._block.fill(0, this._blockOffset, 64); + this._update(); + this._blockOffset = 0; + } + this._block.fill(0, this._blockOffset, 56); + this._block.writeUInt32LE(this._length[0], 56); + this._block.writeUInt32LE(this._length[1], 60); + this._update(); + var buffer4 = Buffer2.allocUnsafe(16); + buffer4.writeInt32LE(this._a, 0); + buffer4.writeInt32LE(this._b, 4); + buffer4.writeInt32LE(this._c, 8); + buffer4.writeInt32LE(this._d, 12); + return buffer4; + }; + function rotl(x5, n9) { + return x5 << n9 | x5 >>> 32 - n9; + } + function fnF(a8, b6, c8, d7, m7, k5, s7) { + return rotl(a8 + (b6 & c8 | ~b6 & d7) + m7 + k5 | 0, s7) + b6 | 0; + } + function fnG(a8, b6, c8, d7, m7, k5, s7) { + return rotl(a8 + (b6 & d7 | c8 & ~d7) + m7 + k5 | 0, s7) + b6 | 0; + } + function fnH(a8, b6, c8, d7, m7, k5, s7) { + return rotl(a8 + (b6 ^ c8 ^ d7) + m7 + k5 | 0, s7) + b6 | 0; + } + function fnI(a8, b6, c8, d7, m7, k5, s7) { + return rotl(a8 + (c8 ^ (b6 | ~d7)) + m7 + k5 | 0, s7) + b6 | 0; + } + exports$1R = MD5; + return exports$1R; + } + var exports$1Q = {}; + var _dewExec$1P = false; + function dew$1P() { + if (_dewExec$1P) + return exports$1Q; + _dewExec$1P = true; + var Buffer2 = e$1$1.Buffer; + var inherits3 = dew$f$2(); + var HashBase = dew$1R(); + var ARRAY16 = new Array(16); + var zl = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]; + var zr = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]; + var sl = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]; + var sr = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]; + var hl = [0, 1518500249, 1859775393, 2400959708, 2840853838]; + var hr = [1352829926, 1548603684, 1836072691, 2053994217, 0]; + function RIPEMD160() { + HashBase.call(this, 64); + this._a = 1732584193; + this._b = 4023233417; + this._c = 2562383102; + this._d = 271733878; + this._e = 3285377520; + } + inherits3(RIPEMD160, HashBase); + RIPEMD160.prototype._update = function() { + var words = ARRAY16; + for (var j5 = 0; j5 < 16; ++j5) + words[j5] = this._block.readInt32LE(j5 * 4); + var al = this._a | 0; + var bl = this._b | 0; + var cl = this._c | 0; + var dl = this._d | 0; + var el = this._e | 0; + var ar = this._a | 0; + var br = this._b | 0; + var cr = this._c | 0; + var dr = this._d | 0; + var er = this._e | 0; + for (var i8 = 0; i8 < 80; i8 += 1) { + var tl; + var tr; + if (i8 < 16) { + tl = fn1(al, bl, cl, dl, el, words[zl[i8]], hl[0], sl[i8]); + tr = fn5(ar, br, cr, dr, er, words[zr[i8]], hr[0], sr[i8]); + } else if (i8 < 32) { + tl = fn2(al, bl, cl, dl, el, words[zl[i8]], hl[1], sl[i8]); + tr = fn4(ar, br, cr, dr, er, words[zr[i8]], hr[1], sr[i8]); + } else if (i8 < 48) { + tl = fn3(al, bl, cl, dl, el, words[zl[i8]], hl[2], sl[i8]); + tr = fn3(ar, br, cr, dr, er, words[zr[i8]], hr[2], sr[i8]); + } else if (i8 < 64) { + tl = fn4(al, bl, cl, dl, el, words[zl[i8]], hl[3], sl[i8]); + tr = fn2(ar, br, cr, dr, er, words[zr[i8]], hr[3], sr[i8]); + } else { + tl = fn5(al, bl, cl, dl, el, words[zl[i8]], hl[4], sl[i8]); + tr = fn1(ar, br, cr, dr, er, words[zr[i8]], hr[4], sr[i8]); + } + al = el; + el = dl; + dl = rotl(cl, 10); + cl = bl; + bl = tl; + ar = er; + er = dr; + dr = rotl(cr, 10); + cr = br; + br = tr; + } + var t9 = this._b + cl + dr | 0; + this._b = this._c + dl + er | 0; + this._c = this._d + el + ar | 0; + this._d = this._e + al + br | 0; + this._e = this._a + bl + cr | 0; + this._a = t9; + }; + RIPEMD160.prototype._digest = function() { + this._block[this._blockOffset++] = 128; + if (this._blockOffset > 56) { + this._block.fill(0, this._blockOffset, 64); + this._update(); + this._blockOffset = 0; + } + this._block.fill(0, this._blockOffset, 56); + this._block.writeUInt32LE(this._length[0], 56); + this._block.writeUInt32LE(this._length[1], 60); + this._update(); + var buffer4 = Buffer2.alloc ? Buffer2.alloc(20) : new Buffer2(20); + buffer4.writeInt32LE(this._a, 0); + buffer4.writeInt32LE(this._b, 4); + buffer4.writeInt32LE(this._c, 8); + buffer4.writeInt32LE(this._d, 12); + buffer4.writeInt32LE(this._e, 16); + return buffer4; + }; + function rotl(x5, n9) { + return x5 << n9 | x5 >>> 32 - n9; + } + function fn1(a8, b6, c8, d7, e12, m7, k5, s7) { + return rotl(a8 + (b6 ^ c8 ^ d7) + m7 + k5 | 0, s7) + e12 | 0; + } + function fn2(a8, b6, c8, d7, e12, m7, k5, s7) { + return rotl(a8 + (b6 & c8 | ~b6 & d7) + m7 + k5 | 0, s7) + e12 | 0; + } + function fn3(a8, b6, c8, d7, e12, m7, k5, s7) { + return rotl(a8 + ((b6 | ~c8) ^ d7) + m7 + k5 | 0, s7) + e12 | 0; + } + function fn4(a8, b6, c8, d7, e12, m7, k5, s7) { + return rotl(a8 + (b6 & d7 | c8 & ~d7) + m7 + k5 | 0, s7) + e12 | 0; + } + function fn5(a8, b6, c8, d7, e12, m7, k5, s7) { + return rotl(a8 + (b6 ^ (c8 | ~d7)) + m7 + k5 | 0, s7) + e12 | 0; + } + exports$1Q = RIPEMD160; + return exports$1Q; + } + var exports$1P = {}; + var _dewExec$1O = false; + var _global$v = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1O() { + if (_dewExec$1O) + return exports$1P; + _dewExec$1O = true; + var Buffer2 = dew$1T().Buffer; + function Hash2(blockSize2, finalSize) { + (this || _global$v)._block = Buffer2.alloc(blockSize2); + (this || _global$v)._finalSize = finalSize; + (this || _global$v)._blockSize = blockSize2; + (this || _global$v)._len = 0; + } + Hash2.prototype.update = function(data, enc) { + if (typeof data === "string") { + enc = enc || "utf8"; + data = Buffer2.from(data, enc); + } + var block = (this || _global$v)._block; + var blockSize2 = (this || _global$v)._blockSize; + var length3 = data.length; + var accum = (this || _global$v)._len; + for (var offset2 = 0; offset2 < length3; ) { + var assigned = accum % blockSize2; + var remainder = Math.min(length3 - offset2, blockSize2 - assigned); + for (var i8 = 0; i8 < remainder; i8++) { + block[assigned + i8] = data[offset2 + i8]; + } + accum += remainder; + offset2 += remainder; + if (accum % blockSize2 === 0) { + this._update(block); + } + } + (this || _global$v)._len += length3; + return this || _global$v; + }; + Hash2.prototype.digest = function(enc) { + var rem = (this || _global$v)._len % (this || _global$v)._blockSize; + (this || _global$v)._block[rem] = 128; + (this || _global$v)._block.fill(0, rem + 1); + if (rem >= (this || _global$v)._finalSize) { + this._update((this || _global$v)._block); + (this || _global$v)._block.fill(0); + } + var bits = (this || _global$v)._len * 8; + if (bits <= 4294967295) { + (this || _global$v)._block.writeUInt32BE(bits, (this || _global$v)._blockSize - 4); + } else { + var lowBits = (bits & 4294967295) >>> 0; + var highBits = (bits - lowBits) / 4294967296; + (this || _global$v)._block.writeUInt32BE(highBits, (this || _global$v)._blockSize - 8); + (this || _global$v)._block.writeUInt32BE(lowBits, (this || _global$v)._blockSize - 4); + } + this._update((this || _global$v)._block); + var hash = this._hash(); + return enc ? hash.toString(enc) : hash; + }; + Hash2.prototype._update = function() { + throw new Error("_update must be implemented by subclass"); + }; + exports$1P = Hash2; + return exports$1P; + } + var exports$1O = {}; + var _dewExec$1N = false; + var _global$u = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1N() { + if (_dewExec$1N) + return exports$1O; + _dewExec$1N = true; + var inherits3 = dew$f$2(); + var Hash2 = dew$1O(); + var Buffer2 = dew$1T().Buffer; + var K4 = [1518500249, 1859775393, 2400959708 | 0, 3395469782 | 0]; + var W4 = new Array(80); + function Sha() { + this.init(); + (this || _global$u)._w = W4; + Hash2.call(this || _global$u, 64, 56); + } + inherits3(Sha, Hash2); + Sha.prototype.init = function() { + (this || _global$u)._a = 1732584193; + (this || _global$u)._b = 4023233417; + (this || _global$u)._c = 2562383102; + (this || _global$u)._d = 271733878; + (this || _global$u)._e = 3285377520; + return this || _global$u; + }; + function rotl5(num) { + return num << 5 | num >>> 27; + } + function rotl30(num) { + return num << 30 | num >>> 2; + } + function ft(s7, b6, c8, d7) { + if (s7 === 0) + return b6 & c8 | ~b6 & d7; + if (s7 === 2) + return b6 & c8 | b6 & d7 | c8 & d7; + return b6 ^ c8 ^ d7; + } + Sha.prototype._update = function(M5) { + var W5 = (this || _global$u)._w; + var a8 = (this || _global$u)._a | 0; + var b6 = (this || _global$u)._b | 0; + var c8 = (this || _global$u)._c | 0; + var d7 = (this || _global$u)._d | 0; + var e12 = (this || _global$u)._e | 0; + for (var i8 = 0; i8 < 16; ++i8) + W5[i8] = M5.readInt32BE(i8 * 4); + for (; i8 < 80; ++i8) + W5[i8] = W5[i8 - 3] ^ W5[i8 - 8] ^ W5[i8 - 14] ^ W5[i8 - 16]; + for (var j5 = 0; j5 < 80; ++j5) { + var s7 = ~~(j5 / 20); + var t9 = rotl5(a8) + ft(s7, b6, c8, d7) + e12 + W5[j5] + K4[s7] | 0; + e12 = d7; + d7 = c8; + c8 = rotl30(b6); + b6 = a8; + a8 = t9; + } + (this || _global$u)._a = a8 + (this || _global$u)._a | 0; + (this || _global$u)._b = b6 + (this || _global$u)._b | 0; + (this || _global$u)._c = c8 + (this || _global$u)._c | 0; + (this || _global$u)._d = d7 + (this || _global$u)._d | 0; + (this || _global$u)._e = e12 + (this || _global$u)._e | 0; + }; + Sha.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(20); + H4.writeInt32BE((this || _global$u)._a | 0, 0); + H4.writeInt32BE((this || _global$u)._b | 0, 4); + H4.writeInt32BE((this || _global$u)._c | 0, 8); + H4.writeInt32BE((this || _global$u)._d | 0, 12); + H4.writeInt32BE((this || _global$u)._e | 0, 16); + return H4; + }; + exports$1O = Sha; + return exports$1O; + } + var exports$1N = {}; + var _dewExec$1M = false; + var _global$t = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1M() { + if (_dewExec$1M) + return exports$1N; + _dewExec$1M = true; + var inherits3 = dew$f$2(); + var Hash2 = dew$1O(); + var Buffer2 = dew$1T().Buffer; + var K4 = [1518500249, 1859775393, 2400959708 | 0, 3395469782 | 0]; + var W4 = new Array(80); + function Sha1() { + this.init(); + (this || _global$t)._w = W4; + Hash2.call(this || _global$t, 64, 56); + } + inherits3(Sha1, Hash2); + Sha1.prototype.init = function() { + (this || _global$t)._a = 1732584193; + (this || _global$t)._b = 4023233417; + (this || _global$t)._c = 2562383102; + (this || _global$t)._d = 271733878; + (this || _global$t)._e = 3285377520; + return this || _global$t; + }; + function rotl1(num) { + return num << 1 | num >>> 31; + } + function rotl5(num) { + return num << 5 | num >>> 27; + } + function rotl30(num) { + return num << 30 | num >>> 2; + } + function ft(s7, b6, c8, d7) { + if (s7 === 0) + return b6 & c8 | ~b6 & d7; + if (s7 === 2) + return b6 & c8 | b6 & d7 | c8 & d7; + return b6 ^ c8 ^ d7; + } + Sha1.prototype._update = function(M5) { + var W5 = (this || _global$t)._w; + var a8 = (this || _global$t)._a | 0; + var b6 = (this || _global$t)._b | 0; + var c8 = (this || _global$t)._c | 0; + var d7 = (this || _global$t)._d | 0; + var e12 = (this || _global$t)._e | 0; + for (var i8 = 0; i8 < 16; ++i8) + W5[i8] = M5.readInt32BE(i8 * 4); + for (; i8 < 80; ++i8) + W5[i8] = rotl1(W5[i8 - 3] ^ W5[i8 - 8] ^ W5[i8 - 14] ^ W5[i8 - 16]); + for (var j5 = 0; j5 < 80; ++j5) { + var s7 = ~~(j5 / 20); + var t9 = rotl5(a8) + ft(s7, b6, c8, d7) + e12 + W5[j5] + K4[s7] | 0; + e12 = d7; + d7 = c8; + c8 = rotl30(b6); + b6 = a8; + a8 = t9; + } + (this || _global$t)._a = a8 + (this || _global$t)._a | 0; + (this || _global$t)._b = b6 + (this || _global$t)._b | 0; + (this || _global$t)._c = c8 + (this || _global$t)._c | 0; + (this || _global$t)._d = d7 + (this || _global$t)._d | 0; + (this || _global$t)._e = e12 + (this || _global$t)._e | 0; + }; + Sha1.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(20); + H4.writeInt32BE((this || _global$t)._a | 0, 0); + H4.writeInt32BE((this || _global$t)._b | 0, 4); + H4.writeInt32BE((this || _global$t)._c | 0, 8); + H4.writeInt32BE((this || _global$t)._d | 0, 12); + H4.writeInt32BE((this || _global$t)._e | 0, 16); + return H4; + }; + exports$1N = Sha1; + return exports$1N; + } + var exports$1M = {}; + var _dewExec$1L = false; + var _global$s = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1L() { + if (_dewExec$1L) + return exports$1M; + _dewExec$1L = true; + var inherits3 = dew$f$2(); + var Hash2 = dew$1O(); + var Buffer2 = dew$1T().Buffer; + var K4 = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298]; + var W4 = new Array(64); + function Sha256() { + this.init(); + (this || _global$s)._w = W4; + Hash2.call(this || _global$s, 64, 56); + } + inherits3(Sha256, Hash2); + Sha256.prototype.init = function() { + (this || _global$s)._a = 1779033703; + (this || _global$s)._b = 3144134277; + (this || _global$s)._c = 1013904242; + (this || _global$s)._d = 2773480762; + (this || _global$s)._e = 1359893119; + (this || _global$s)._f = 2600822924; + (this || _global$s)._g = 528734635; + (this || _global$s)._h = 1541459225; + return this || _global$s; + }; + function ch(x5, y7, z6) { + return z6 ^ x5 & (y7 ^ z6); + } + function maj(x5, y7, z6) { + return x5 & y7 | z6 & (x5 | y7); + } + function sigma0(x5) { + return (x5 >>> 2 | x5 << 30) ^ (x5 >>> 13 | x5 << 19) ^ (x5 >>> 22 | x5 << 10); + } + function sigma1(x5) { + return (x5 >>> 6 | x5 << 26) ^ (x5 >>> 11 | x5 << 21) ^ (x5 >>> 25 | x5 << 7); + } + function gamma0(x5) { + return (x5 >>> 7 | x5 << 25) ^ (x5 >>> 18 | x5 << 14) ^ x5 >>> 3; + } + function gamma1(x5) { + return (x5 >>> 17 | x5 << 15) ^ (x5 >>> 19 | x5 << 13) ^ x5 >>> 10; + } + Sha256.prototype._update = function(M5) { + var W5 = (this || _global$s)._w; + var a8 = (this || _global$s)._a | 0; + var b6 = (this || _global$s)._b | 0; + var c8 = (this || _global$s)._c | 0; + var d7 = (this || _global$s)._d | 0; + var e12 = (this || _global$s)._e | 0; + var f9 = (this || _global$s)._f | 0; + var g6 = (this || _global$s)._g | 0; + var h9 = (this || _global$s)._h | 0; + for (var i8 = 0; i8 < 16; ++i8) + W5[i8] = M5.readInt32BE(i8 * 4); + for (; i8 < 64; ++i8) + W5[i8] = gamma1(W5[i8 - 2]) + W5[i8 - 7] + gamma0(W5[i8 - 15]) + W5[i8 - 16] | 0; + for (var j5 = 0; j5 < 64; ++j5) { + var T1 = h9 + sigma1(e12) + ch(e12, f9, g6) + K4[j5] + W5[j5] | 0; + var T22 = sigma0(a8) + maj(a8, b6, c8) | 0; + h9 = g6; + g6 = f9; + f9 = e12; + e12 = d7 + T1 | 0; + d7 = c8; + c8 = b6; + b6 = a8; + a8 = T1 + T22 | 0; + } + (this || _global$s)._a = a8 + (this || _global$s)._a | 0; + (this || _global$s)._b = b6 + (this || _global$s)._b | 0; + (this || _global$s)._c = c8 + (this || _global$s)._c | 0; + (this || _global$s)._d = d7 + (this || _global$s)._d | 0; + (this || _global$s)._e = e12 + (this || _global$s)._e | 0; + (this || _global$s)._f = f9 + (this || _global$s)._f | 0; + (this || _global$s)._g = g6 + (this || _global$s)._g | 0; + (this || _global$s)._h = h9 + (this || _global$s)._h | 0; + }; + Sha256.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(32); + H4.writeInt32BE((this || _global$s)._a, 0); + H4.writeInt32BE((this || _global$s)._b, 4); + H4.writeInt32BE((this || _global$s)._c, 8); + H4.writeInt32BE((this || _global$s)._d, 12); + H4.writeInt32BE((this || _global$s)._e, 16); + H4.writeInt32BE((this || _global$s)._f, 20); + H4.writeInt32BE((this || _global$s)._g, 24); + H4.writeInt32BE((this || _global$s)._h, 28); + return H4; + }; + exports$1M = Sha256; + return exports$1M; + } + var exports$1L = {}; + var _dewExec$1K = false; + var _global$r = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1K() { + if (_dewExec$1K) + return exports$1L; + _dewExec$1K = true; + var inherits3 = dew$f$2(); + var Sha256 = dew$1L(); + var Hash2 = dew$1O(); + var Buffer2 = dew$1T().Buffer; + var W4 = new Array(64); + function Sha224() { + this.init(); + (this || _global$r)._w = W4; + Hash2.call(this || _global$r, 64, 56); + } + inherits3(Sha224, Sha256); + Sha224.prototype.init = function() { + (this || _global$r)._a = 3238371032; + (this || _global$r)._b = 914150663; + (this || _global$r)._c = 812702999; + (this || _global$r)._d = 4144912697; + (this || _global$r)._e = 4290775857; + (this || _global$r)._f = 1750603025; + (this || _global$r)._g = 1694076839; + (this || _global$r)._h = 3204075428; + return this || _global$r; + }; + Sha224.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(28); + H4.writeInt32BE((this || _global$r)._a, 0); + H4.writeInt32BE((this || _global$r)._b, 4); + H4.writeInt32BE((this || _global$r)._c, 8); + H4.writeInt32BE((this || _global$r)._d, 12); + H4.writeInt32BE((this || _global$r)._e, 16); + H4.writeInt32BE((this || _global$r)._f, 20); + H4.writeInt32BE((this || _global$r)._g, 24); + return H4; + }; + exports$1L = Sha224; + return exports$1L; + } + var exports$1K = {}; + var _dewExec$1J = false; + var _global$q = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1J() { + if (_dewExec$1J) + return exports$1K; + _dewExec$1J = true; + var inherits3 = dew$f$2(); + var Hash2 = dew$1O(); + var Buffer2 = dew$1T().Buffer; + var K4 = [1116352408, 3609767458, 1899447441, 602891725, 3049323471, 3964484399, 3921009573, 2173295548, 961987163, 4081628472, 1508970993, 3053834265, 2453635748, 2937671579, 2870763221, 3664609560, 3624381080, 2734883394, 310598401, 1164996542, 607225278, 1323610764, 1426881987, 3590304994, 1925078388, 4068182383, 2162078206, 991336113, 2614888103, 633803317, 3248222580, 3479774868, 3835390401, 2666613458, 4022224774, 944711139, 264347078, 2341262773, 604807628, 2007800933, 770255983, 1495990901, 1249150122, 1856431235, 1555081692, 3175218132, 1996064986, 2198950837, 2554220882, 3999719339, 2821834349, 766784016, 2952996808, 2566594879, 3210313671, 3203337956, 3336571891, 1034457026, 3584528711, 2466948901, 113926993, 3758326383, 338241895, 168717936, 666307205, 1188179964, 773529912, 1546045734, 1294757372, 1522805485, 1396182291, 2643833823, 1695183700, 2343527390, 1986661051, 1014477480, 2177026350, 1206759142, 2456956037, 344077627, 2730485921, 1290863460, 2820302411, 3158454273, 3259730800, 3505952657, 3345764771, 106217008, 3516065817, 3606008344, 3600352804, 1432725776, 4094571909, 1467031594, 275423344, 851169720, 430227734, 3100823752, 506948616, 1363258195, 659060556, 3750685593, 883997877, 3785050280, 958139571, 3318307427, 1322822218, 3812723403, 1537002063, 2003034995, 1747873779, 3602036899, 1955562222, 1575990012, 2024104815, 1125592928, 2227730452, 2716904306, 2361852424, 442776044, 2428436474, 593698344, 2756734187, 3733110249, 3204031479, 2999351573, 3329325298, 3815920427, 3391569614, 3928383900, 3515267271, 566280711, 3940187606, 3454069534, 4118630271, 4000239992, 116418474, 1914138554, 174292421, 2731055270, 289380356, 3203993006, 460393269, 320620315, 685471733, 587496836, 852142971, 1086792851, 1017036298, 365543100, 1126000580, 2618297676, 1288033470, 3409855158, 1501505948, 4234509866, 1607167915, 987167468, 1816402316, 1246189591]; + var W4 = new Array(160); + function Sha512() { + this.init(); + (this || _global$q)._w = W4; + Hash2.call(this || _global$q, 128, 112); + } + inherits3(Sha512, Hash2); + Sha512.prototype.init = function() { + (this || _global$q)._ah = 1779033703; + (this || _global$q)._bh = 3144134277; + (this || _global$q)._ch = 1013904242; + (this || _global$q)._dh = 2773480762; + (this || _global$q)._eh = 1359893119; + (this || _global$q)._fh = 2600822924; + (this || _global$q)._gh = 528734635; + (this || _global$q)._hh = 1541459225; + (this || _global$q)._al = 4089235720; + (this || _global$q)._bl = 2227873595; + (this || _global$q)._cl = 4271175723; + (this || _global$q)._dl = 1595750129; + (this || _global$q)._el = 2917565137; + (this || _global$q)._fl = 725511199; + (this || _global$q)._gl = 4215389547; + (this || _global$q)._hl = 327033209; + return this || _global$q; + }; + function Ch(x5, y7, z6) { + return z6 ^ x5 & (y7 ^ z6); + } + function maj(x5, y7, z6) { + return x5 & y7 | z6 & (x5 | y7); + } + function sigma0(x5, xl) { + return (x5 >>> 28 | xl << 4) ^ (xl >>> 2 | x5 << 30) ^ (xl >>> 7 | x5 << 25); + } + function sigma1(x5, xl) { + return (x5 >>> 14 | xl << 18) ^ (x5 >>> 18 | xl << 14) ^ (xl >>> 9 | x5 << 23); + } + function Gamma0(x5, xl) { + return (x5 >>> 1 | xl << 31) ^ (x5 >>> 8 | xl << 24) ^ x5 >>> 7; + } + function Gamma0l(x5, xl) { + return (x5 >>> 1 | xl << 31) ^ (x5 >>> 8 | xl << 24) ^ (x5 >>> 7 | xl << 25); + } + function Gamma1(x5, xl) { + return (x5 >>> 19 | xl << 13) ^ (xl >>> 29 | x5 << 3) ^ x5 >>> 6; + } + function Gamma1l(x5, xl) { + return (x5 >>> 19 | xl << 13) ^ (xl >>> 29 | x5 << 3) ^ (x5 >>> 6 | xl << 26); + } + function getCarry(a8, b6) { + return a8 >>> 0 < b6 >>> 0 ? 1 : 0; + } + Sha512.prototype._update = function(M5) { + var W5 = (this || _global$q)._w; + var ah = (this || _global$q)._ah | 0; + var bh = (this || _global$q)._bh | 0; + var ch = (this || _global$q)._ch | 0; + var dh = (this || _global$q)._dh | 0; + var eh = (this || _global$q)._eh | 0; + var fh = (this || _global$q)._fh | 0; + var gh = (this || _global$q)._gh | 0; + var hh = (this || _global$q)._hh | 0; + var al = (this || _global$q)._al | 0; + var bl = (this || _global$q)._bl | 0; + var cl = (this || _global$q)._cl | 0; + var dl = (this || _global$q)._dl | 0; + var el = (this || _global$q)._el | 0; + var fl = (this || _global$q)._fl | 0; + var gl = (this || _global$q)._gl | 0; + var hl = (this || _global$q)._hl | 0; + for (var i8 = 0; i8 < 32; i8 += 2) { + W5[i8] = M5.readInt32BE(i8 * 4); + W5[i8 + 1] = M5.readInt32BE(i8 * 4 + 4); + } + for (; i8 < 160; i8 += 2) { + var xh = W5[i8 - 15 * 2]; + var xl = W5[i8 - 15 * 2 + 1]; + var gamma0 = Gamma0(xh, xl); + var gamma0l = Gamma0l(xl, xh); + xh = W5[i8 - 2 * 2]; + xl = W5[i8 - 2 * 2 + 1]; + var gamma1 = Gamma1(xh, xl); + var gamma1l = Gamma1l(xl, xh); + var Wi7h = W5[i8 - 7 * 2]; + var Wi7l = W5[i8 - 7 * 2 + 1]; + var Wi16h = W5[i8 - 16 * 2]; + var Wi16l = W5[i8 - 16 * 2 + 1]; + var Wil = gamma0l + Wi7l | 0; + var Wih = gamma0 + Wi7h + getCarry(Wil, gamma0l) | 0; + Wil = Wil + gamma1l | 0; + Wih = Wih + gamma1 + getCarry(Wil, gamma1l) | 0; + Wil = Wil + Wi16l | 0; + Wih = Wih + Wi16h + getCarry(Wil, Wi16l) | 0; + W5[i8] = Wih; + W5[i8 + 1] = Wil; + } + for (var j5 = 0; j5 < 160; j5 += 2) { + Wih = W5[j5]; + Wil = W5[j5 + 1]; + var majh = maj(ah, bh, ch); + var majl = maj(al, bl, cl); + var sigma0h = sigma0(ah, al); + var sigma0l = sigma0(al, ah); + var sigma1h = sigma1(eh, el); + var sigma1l = sigma1(el, eh); + var Kih = K4[j5]; + var Kil = K4[j5 + 1]; + var chh = Ch(eh, fh, gh); + var chl = Ch(el, fl, gl); + var t1l = hl + sigma1l | 0; + var t1h = hh + sigma1h + getCarry(t1l, hl) | 0; + t1l = t1l + chl | 0; + t1h = t1h + chh + getCarry(t1l, chl) | 0; + t1l = t1l + Kil | 0; + t1h = t1h + Kih + getCarry(t1l, Kil) | 0; + t1l = t1l + Wil | 0; + t1h = t1h + Wih + getCarry(t1l, Wil) | 0; + var t2l = sigma0l + majl | 0; + var t2h = sigma0h + majh + getCarry(t2l, sigma0l) | 0; + hh = gh; + hl = gl; + gh = fh; + gl = fl; + fh = eh; + fl = el; + el = dl + t1l | 0; + eh = dh + t1h + getCarry(el, dl) | 0; + dh = ch; + dl = cl; + ch = bh; + cl = bl; + bh = ah; + bl = al; + al = t1l + t2l | 0; + ah = t1h + t2h + getCarry(al, t1l) | 0; + } + (this || _global$q)._al = (this || _global$q)._al + al | 0; + (this || _global$q)._bl = (this || _global$q)._bl + bl | 0; + (this || _global$q)._cl = (this || _global$q)._cl + cl | 0; + (this || _global$q)._dl = (this || _global$q)._dl + dl | 0; + (this || _global$q)._el = (this || _global$q)._el + el | 0; + (this || _global$q)._fl = (this || _global$q)._fl + fl | 0; + (this || _global$q)._gl = (this || _global$q)._gl + gl | 0; + (this || _global$q)._hl = (this || _global$q)._hl + hl | 0; + (this || _global$q)._ah = (this || _global$q)._ah + ah + getCarry((this || _global$q)._al, al) | 0; + (this || _global$q)._bh = (this || _global$q)._bh + bh + getCarry((this || _global$q)._bl, bl) | 0; + (this || _global$q)._ch = (this || _global$q)._ch + ch + getCarry((this || _global$q)._cl, cl) | 0; + (this || _global$q)._dh = (this || _global$q)._dh + dh + getCarry((this || _global$q)._dl, dl) | 0; + (this || _global$q)._eh = (this || _global$q)._eh + eh + getCarry((this || _global$q)._el, el) | 0; + (this || _global$q)._fh = (this || _global$q)._fh + fh + getCarry((this || _global$q)._fl, fl) | 0; + (this || _global$q)._gh = (this || _global$q)._gh + gh + getCarry((this || _global$q)._gl, gl) | 0; + (this || _global$q)._hh = (this || _global$q)._hh + hh + getCarry((this || _global$q)._hl, hl) | 0; + }; + Sha512.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(64); + function writeInt64BE(h9, l8, offset2) { + H4.writeInt32BE(h9, offset2); + H4.writeInt32BE(l8, offset2 + 4); + } + writeInt64BE((this || _global$q)._ah, (this || _global$q)._al, 0); + writeInt64BE((this || _global$q)._bh, (this || _global$q)._bl, 8); + writeInt64BE((this || _global$q)._ch, (this || _global$q)._cl, 16); + writeInt64BE((this || _global$q)._dh, (this || _global$q)._dl, 24); + writeInt64BE((this || _global$q)._eh, (this || _global$q)._el, 32); + writeInt64BE((this || _global$q)._fh, (this || _global$q)._fl, 40); + writeInt64BE((this || _global$q)._gh, (this || _global$q)._gl, 48); + writeInt64BE((this || _global$q)._hh, (this || _global$q)._hl, 56); + return H4; + }; + exports$1K = Sha512; + return exports$1K; + } + var exports$1J = {}; + var _dewExec$1I = false; + var _global$p = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1I() { + if (_dewExec$1I) + return exports$1J; + _dewExec$1I = true; + var inherits3 = dew$f$2(); + var SHA512 = dew$1J(); + var Hash2 = dew$1O(); + var Buffer2 = dew$1T().Buffer; + var W4 = new Array(160); + function Sha384() { + this.init(); + (this || _global$p)._w = W4; + Hash2.call(this || _global$p, 128, 112); + } + inherits3(Sha384, SHA512); + Sha384.prototype.init = function() { + (this || _global$p)._ah = 3418070365; + (this || _global$p)._bh = 1654270250; + (this || _global$p)._ch = 2438529370; + (this || _global$p)._dh = 355462360; + (this || _global$p)._eh = 1731405415; + (this || _global$p)._fh = 2394180231; + (this || _global$p)._gh = 3675008525; + (this || _global$p)._hh = 1203062813; + (this || _global$p)._al = 3238371032; + (this || _global$p)._bl = 914150663; + (this || _global$p)._cl = 812702999; + (this || _global$p)._dl = 4144912697; + (this || _global$p)._el = 4290775857; + (this || _global$p)._fl = 1750603025; + (this || _global$p)._gl = 1694076839; + (this || _global$p)._hl = 3204075428; + return this || _global$p; + }; + Sha384.prototype._hash = function() { + var H4 = Buffer2.allocUnsafe(48); + function writeInt64BE(h9, l8, offset2) { + H4.writeInt32BE(h9, offset2); + H4.writeInt32BE(l8, offset2 + 4); + } + writeInt64BE((this || _global$p)._ah, (this || _global$p)._al, 0); + writeInt64BE((this || _global$p)._bh, (this || _global$p)._bl, 8); + writeInt64BE((this || _global$p)._ch, (this || _global$p)._cl, 16); + writeInt64BE((this || _global$p)._dh, (this || _global$p)._dl, 24); + writeInt64BE((this || _global$p)._eh, (this || _global$p)._el, 32); + writeInt64BE((this || _global$p)._fh, (this || _global$p)._fl, 40); + return H4; + }; + exports$1J = Sha384; + return exports$1J; + } + var exports$1I = {}; + var _dewExec$1H = false; + var module$7 = { + exports: exports$1I + }; + function dew$1H() { + if (_dewExec$1H) + return module$7.exports; + _dewExec$1H = true; + var exports12 = module$7.exports = function SHA(algorithm2) { + algorithm2 = algorithm2.toLowerCase(); + var Algorithm = exports12[algorithm2]; + if (!Algorithm) + throw new Error(algorithm2 + " is not supported (we accept pull requests)"); + return new Algorithm(); + }; + exports12.sha = dew$1N(); + exports12.sha1 = dew$1M(); + exports12.sha224 = dew$1K(); + exports12.sha256 = dew$1L(); + exports12.sha384 = dew$1I(); + exports12.sha512 = dew$1J(); + return module$7.exports; + } + var e$g = y.EventEmitter; + var e$1$12 = {}; + var t$c = {}; + function n$q(e12, n9, r10) { + r10 || (r10 = Error); + class o9 extends r10 { + constructor(e13, t9, r11) { + super(function(e14, t10, r12) { + return "string" == typeof n9 ? n9 : n9(e14, t10, r12); + }(e13, t9, r11)); + } + } + o9.prototype.name = r10.name, o9.prototype.code = e12, t$c[e12] = o9; + } + function r$h(e12, t9) { + if (Array.isArray(e12)) { + const n9 = e12.length; + return e12 = e12.map((e13) => String(e13)), n9 > 2 ? `one of ${t9} ${e12.slice(0, n9 - 1).join(", ")}, or ` + e12[n9 - 1] : 2 === n9 ? `one of ${t9} ${e12[0]} or ${e12[1]}` : `of ${t9} ${e12[0]}`; + } + return `of ${t9} ${String(e12)}`; + } + n$q("ERR_INVALID_OPT_VALUE", function(e12, t9) { + return 'The value "' + t9 + '" is invalid for option "' + e12 + '"'; + }, TypeError), n$q("ERR_INVALID_ARG_TYPE", function(e12, t9, n9) { + let o9; + var E5; + let u8; + if ("string" == typeof t9 && (E5 = "not ", t9.substr(0, E5.length) === E5) ? (o9 = "must not be", t9 = t9.replace(/^not /, "")) : o9 = "must be", function(e13, t10, n10) { + return (void 0 === n10 || n10 > e13.length) && (n10 = e13.length), e13.substring(n10 - t10.length, n10) === t10; + }(e12, " argument")) + u8 = `The ${e12} ${o9} ${r$h(t9, "type")}`; + else { + u8 = `The "${e12}" ${function(e13, t10, n10) { + return "number" != typeof n10 && (n10 = 0), !(n10 + t10.length > e13.length) && -1 !== e13.indexOf(t10, n10); + }(e12, ".") ? "property" : "argument"} ${o9} ${r$h(t9, "type")}`; + } + return u8 += `. Received type ${typeof n9}`, u8; + }, TypeError), n$q("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF"), n$q("ERR_METHOD_NOT_IMPLEMENTED", function(e12) { + return "The " + e12 + " method is not implemented"; + }), n$q("ERR_STREAM_PREMATURE_CLOSE", "Premature close"), n$q("ERR_STREAM_DESTROYED", function(e12) { + return "Cannot call " + e12 + " after a stream was destroyed"; + }), n$q("ERR_MULTIPLE_CALLBACK", "Callback called multiple times"), n$q("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable"), n$q("ERR_STREAM_WRITE_AFTER_END", "write after end"), n$q("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError), n$q("ERR_UNKNOWN_ENCODING", function(e12) { + return "Unknown encoding: " + e12; + }, TypeError), n$q("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event"), e$1$12.codes = t$c; + var r$1$1 = function() { + throw new Error("Readable.from is not available in the browser"); + }; + var r$2$1 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + function e$2$1(e12) { + try { + if (!r$2$1.localStorage) + return false; + } catch (r10) { + return false; + } + var t9 = r$2$1.localStorage[e12]; + return null != t9 && "true" === String(t9).toLowerCase(); + } + var t$1$1 = function(t9, n9) { + if (e$2$1("noDeprecation")) + return t9; + var o9 = false; + return function() { + if (!o9) { + if (e$2$1("throwDeprecation")) + throw new Error(n9); + e$2$1("traceDeprecation") ? console.trace(n9) : console.warn(n9), o9 = true; + } + return t9.apply(this || r$2$1, arguments); + }; + }; + function u$p(e12, t9) { + var n9 = Object.keys(e12); + if (Object.getOwnPropertySymbols) { + var r10 = Object.getOwnPropertySymbols(e12); + t9 && (r10 = r10.filter(function(t10) { + return Object.getOwnPropertyDescriptor(e12, t10).enumerable; + })), n9.push.apply(n9, r10); + } + return n9; + } + function f$v(e12, t9, n9) { + return t9 in e12 ? Object.defineProperty(e12, t9, { value: n9, enumerable: true, configurable: true, writable: true }) : e12[t9] = n9, e12; + } + function h$l(e12, t9) { + for (var n9 = 0; n9 < t9.length; n9++) { + var r10 = t9[n9]; + r10.enumerable = r10.enumerable || false, r10.configurable = true, "value" in r10 && (r10.writable = true), Object.defineProperty(e12, r10.key, r10); + } + } + var c$n = e$1$1.Buffer; + var b$j = X.inspect; + var p$s = b$j && b$j.custom || "inspect"; + var g$h = function() { + function e12() { + !function(e13, t10) { + if (!(e13 instanceof t10)) + throw new TypeError("Cannot call a class as a function"); + }(this, e12), this.head = null, this.tail = null, this.length = 0; + } + var t9, n9; + return t9 = e12, (n9 = [{ key: "push", value: function(e13) { + var t10 = { data: e13, next: null }; + this.length > 0 ? this.tail.next = t10 : this.head = t10, this.tail = t10, ++this.length; + } }, { key: "unshift", value: function(e13) { + var t10 = { data: e13, next: this.head }; + 0 === this.length && (this.tail = t10), this.head = t10, ++this.length; + } }, { key: "shift", value: function() { + if (0 !== this.length) { + var e13 = this.head.data; + return 1 === this.length ? this.head = this.tail = null : this.head = this.head.next, --this.length, e13; + } + } }, { key: "clear", value: function() { + this.head = this.tail = null, this.length = 0; + } }, { key: "join", value: function(e13) { + if (0 === this.length) + return ""; + for (var t10 = this.head, n10 = "" + t10.data; t10 = t10.next; ) + n10 += e13 + t10.data; + return n10; + } }, { key: "concat", value: function(e13) { + if (0 === this.length) + return c$n.alloc(0); + for (var t10, n10, r10, i8 = c$n.allocUnsafe(e13 >>> 0), a8 = this.head, o9 = 0; a8; ) + t10 = a8.data, n10 = i8, r10 = o9, void c$n.prototype.copy.call(t10, n10, r10), o9 += a8.data.length, a8 = a8.next; + return i8; + } }, { key: "consume", value: function(e13, t10) { + var n10; + return e13 < this.head.data.length ? (n10 = this.head.data.slice(0, e13), this.head.data = this.head.data.slice(e13)) : n10 = e13 === this.head.data.length ? this.shift() : t10 ? this._getString(e13) : this._getBuffer(e13), n10; + } }, { key: "first", value: function() { + return this.head.data; + } }, { key: "_getString", value: function(e13) { + var t10 = this.head, n10 = 1, r10 = t10.data; + for (e13 -= r10.length; t10 = t10.next; ) { + var i8 = t10.data, a8 = e13 > i8.length ? i8.length : e13; + if (a8 === i8.length ? r10 += i8 : r10 += i8.slice(0, e13), 0 == (e13 -= a8)) { + a8 === i8.length ? (++n10, t10.next ? this.head = t10.next : this.head = this.tail = null) : (this.head = t10, t10.data = i8.slice(a8)); + break; + } + ++n10; + } + return this.length -= n10, r10; + } }, { key: "_getBuffer", value: function(e13) { + var t10 = c$n.allocUnsafe(e13), n10 = this.head, r10 = 1; + for (n10.data.copy(t10), e13 -= n10.data.length; n10 = n10.next; ) { + var i8 = n10.data, a8 = e13 > i8.length ? i8.length : e13; + if (i8.copy(t10, t10.length - e13, 0, a8), 0 == (e13 -= a8)) { + a8 === i8.length ? (++r10, n10.next ? this.head = n10.next : this.head = this.tail = null) : (this.head = n10, n10.data = i8.slice(a8)); + break; + } + ++r10; + } + return this.length -= r10, t10; + } }, { key: p$s, value: function(e13, t10) { + return b$j(this, function(e14) { + for (var t11 = 1; t11 < arguments.length; t11++) { + var n10 = null != arguments[t11] ? arguments[t11] : {}; + t11 % 2 ? u$p(Object(n10), true).forEach(function(t12) { + f$v(e14, t12, n10[t12]); + }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e14, Object.getOwnPropertyDescriptors(n10)) : u$p(Object(n10)).forEach(function(t12) { + Object.defineProperty(e14, t12, Object.getOwnPropertyDescriptor(n10, t12)); + }); + } + return e14; + }({}, t10, { depth: 0, customInspect: false })); + } }]) && h$l(t9.prototype, n9), e12; + }(); + var y$n = T; + function w$j(e12, t9) { + _$h(e12, t9), v$k(e12); + } + function v$k(e12) { + e12._writableState && !e12._writableState.emitClose || e12._readableState && !e12._readableState.emitClose || e12.emit("close"); + } + function _$h(e12, t9) { + e12.emit("error", t9); + } + var m$m = { destroy: function(e12, t9) { + var n9 = this, r10 = this._readableState && this._readableState.destroyed, i8 = this._writableState && this._writableState.destroyed; + return r10 || i8 ? (t9 ? t9(e12) : e12 && (this._writableState ? this._writableState.errorEmitted || (this._writableState.errorEmitted = true, y$n.nextTick(_$h, this, e12)) : y$n.nextTick(_$h, this, e12)), this) : (this._readableState && (this._readableState.destroyed = true), this._writableState && (this._writableState.destroyed = true), this._destroy(e12 || null, function(e13) { + !t9 && e13 ? n9._writableState ? n9._writableState.errorEmitted ? y$n.nextTick(v$k, n9) : (n9._writableState.errorEmitted = true, y$n.nextTick(w$j, n9, e13)) : y$n.nextTick(w$j, n9, e13) : t9 ? (y$n.nextTick(v$k, n9), t9(e13)) : y$n.nextTick(v$k, n9); + }), this); + }, undestroy: function() { + this._readableState && (this._readableState.destroyed = false, this._readableState.reading = false, this._readableState.ended = false, this._readableState.endEmitted = false), this._writableState && (this._writableState.destroyed = false, this._writableState.ended = false, this._writableState.ending = false, this._writableState.finalCalled = false, this._writableState.prefinished = false, this._writableState.finished = false, this._writableState.errorEmitted = false); + }, errorOrDestroy: function(e12, t9) { + var n9 = e12._readableState, r10 = e12._writableState; + n9 && n9.autoDestroy || r10 && r10.autoDestroy ? e12.destroy(t9) : e12.emit("error", t9); + } }; + var S$e = e$1$12.codes.ERR_INVALID_OPT_VALUE; + var R$7 = { getHighWaterMark: function(e12, t9, n9, r10) { + var i8 = function(e13, t10, n10) { + return null != e13.highWaterMark ? e13.highWaterMark : t10 ? e13[n10] : null; + }(t9, r10, n9); + if (null != i8) { + if (!isFinite(i8) || Math.floor(i8) !== i8 || i8 < 0) + throw new S$e(r10 ? n9 : "highWaterMark", i8); + return Math.floor(i8); + } + return e12.objectMode ? 16 : 16384; + } }; + var k$g = e$1$12.codes.ERR_STREAM_PREMATURE_CLOSE; + function E$e() { + } + var M$a; + var j$a = function e5(t9, n9, r10) { + if ("function" == typeof n9) + return e5(t9, null, n9); + n9 || (n9 = {}), r10 = function(e12) { + var t10 = false; + return function() { + if (!t10) { + t10 = true; + for (var n10 = arguments.length, r11 = new Array(n10), i9 = 0; i9 < n10; i9++) + r11[i9] = arguments[i9]; + e12.apply(this, r11); + } + }; + }(r10 || E$e); + var i8 = n9.readable || false !== n9.readable && t9.readable, a8 = n9.writable || false !== n9.writable && t9.writable, o9 = function() { + t9.writable || l8(); + }, s7 = t9._writableState && t9._writableState.finished, l8 = function() { + a8 = false, s7 = true, i8 || r10.call(t9); + }, d7 = t9._readableState && t9._readableState.endEmitted, u8 = function() { + i8 = false, d7 = true, a8 || r10.call(t9); + }, f9 = function(e12) { + r10.call(t9, e12); + }, h9 = function() { + var e12; + return i8 && !d7 ? (t9._readableState && t9._readableState.ended || (e12 = new k$g()), r10.call(t9, e12)) : a8 && !s7 ? (t9._writableState && t9._writableState.ended || (e12 = new k$g()), r10.call(t9, e12)) : void 0; + }, c8 = function() { + t9.req.on("finish", l8); + }; + return !function(e12) { + return e12.setHeader && "function" == typeof e12.abort; + }(t9) ? a8 && !t9._writableState && (t9.on("end", o9), t9.on("close", o9)) : (t9.on("complete", l8), t9.on("abort", h9), t9.req ? c8() : t9.on("request", c8)), t9.on("end", u8), t9.on("finish", l8), false !== n9.error && t9.on("error", f9), t9.on("close", h9), function() { + t9.removeListener("complete", l8), t9.removeListener("abort", h9), t9.removeListener("request", c8), t9.req && t9.req.removeListener("finish", l8), t9.removeListener("end", o9), t9.removeListener("close", o9), t9.removeListener("finish", l8), t9.removeListener("end", u8), t9.removeListener("error", f9), t9.removeListener("close", h9); + }; + }; + var O$8 = T; + function T$8(e12, t9, n9) { + return t9 in e12 ? Object.defineProperty(e12, t9, { value: n9, enumerable: true, configurable: true, writable: true }) : e12[t9] = n9, e12; + } + var P$8 = j$a; + var x$a = Symbol("lastResolve"); + var L$8 = Symbol("lastReject"); + var D$9 = Symbol("error"); + var C$9 = Symbol("ended"); + var A$c = Symbol("lastPromise"); + var q$8 = Symbol("handlePromise"); + var W$5 = Symbol("stream"); + function B$c(e12, t9) { + return { value: e12, done: t9 }; + } + function I$b(e12) { + var t9 = e12[x$a]; + if (null !== t9) { + var n9 = e12[W$5].read(); + null !== n9 && (e12[A$c] = null, e12[x$a] = null, e12[L$8] = null, t9(B$c(n9, false))); + } + } + function N$7(e12) { + O$8.nextTick(I$b, e12); + } + var U$a = Object.getPrototypeOf(function() { + }); + var H$7 = Object.setPrototypeOf((T$8(M$a = { get stream() { + return this[W$5]; + }, next: function() { + var e12 = this, t9 = this[D$9]; + if (null !== t9) + return Promise.reject(t9); + if (this[C$9]) + return Promise.resolve(B$c(void 0, true)); + if (this[W$5].destroyed) + return new Promise(function(t10, n10) { + O$8.nextTick(function() { + e12[D$9] ? n10(e12[D$9]) : t10(B$c(void 0, true)); + }); + }); + var n9, r10 = this[A$c]; + if (r10) + n9 = new Promise(function(e13, t10) { + return function(n10, r11) { + e13.then(function() { + if (t10[C$9]) + return n10(B$c(void 0, true)), void 0; + t10[q$8](n10, r11); + }, r11); + }; + }(r10, this)); + else { + var i8 = this[W$5].read(); + if (null !== i8) + return Promise.resolve(B$c(i8, false)); + n9 = new Promise(this[q$8]); + } + return this[A$c] = n9, n9; + } }, Symbol.asyncIterator, function() { + return this; + }), T$8(M$a, "return", function() { + var e12 = this; + return new Promise(function(t9, n9) { + e12[W$5].destroy(null, function(e13) { + if (e13) + return n9(e13), void 0; + t9(B$c(void 0, true)); + }); + }); + }), M$a), U$a); + var F$8 = function(e12) { + var t9, n9 = Object.create(H$7, (T$8(t9 = {}, W$5, { value: e12, writable: true }), T$8(t9, x$a, { value: null, writable: true }), T$8(t9, L$8, { value: null, writable: true }), T$8(t9, D$9, { value: null, writable: true }), T$8(t9, C$9, { value: e12._readableState.endEmitted, writable: true }), T$8(t9, q$8, { value: function(e13, t10) { + var r10 = n9[W$5].read(); + r10 ? (n9[A$c] = null, n9[x$a] = null, n9[L$8] = null, e13(B$c(r10, false))) : (n9[x$a] = e13, n9[L$8] = t10); + }, writable: true }), t9)); + return n9[A$c] = null, P$8(e12, function(e13) { + if (e13 && "ERR_STREAM_PREMATURE_CLOSE" !== e13.code) { + var t10 = n9[L$8]; + return null !== t10 && (n9[A$c] = null, n9[x$a] = null, n9[L$8] = null, t10(e13)), n9[D$9] = e13, void 0; + } + var r10 = n9[x$a]; + null !== r10 && (n9[A$c] = null, n9[x$a] = null, n9[L$8] = null, r10(B$c(void 0, true))), n9[C$9] = true; + }), e12.on("readable", N$7.bind(null, n9)), n9; + }; + var V$6 = {}; + var G$5 = false; + var Y$4 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + function K$8() { + if (G$5) + return V$6; + G$5 = true; + var d7, u8 = T; + V$6 = C5, C5.ReadableState = D5; + y.EventEmitter; + var f9 = function(e12, t9) { + return e12.listeners(t9).length; + }, h9 = e$g, c8 = e$1$1.Buffer, b6 = Y$4.Uint8Array || function() { + }; + var p8, y7 = X; + p8 = y7 && y7.debuglog ? y7.debuglog("stream") : function() { + }; + var w5, v7, _5, S5 = g$h, k5 = m$m, E5 = R$7.getHighWaterMark, M5 = e$1$12.codes, j5 = M5.ERR_INVALID_ARG_TYPE, O6 = M5.ERR_STREAM_PUSH_AFTER_EOF, T6 = M5.ERR_METHOD_NOT_IMPLEMENTED, P5 = M5.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; + t$2(C5, h9); + var x5 = k5.errorOrDestroy, L5 = ["error", "close", "destroy", "pause", "resume"]; + function D5(e12, t9, n9) { + d7 = d7 || ee$1(), e12 = e12 || {}, "boolean" != typeof n9 && (n9 = t9 instanceof d7), this.objectMode = !!e12.objectMode, n9 && (this.objectMode = this.objectMode || !!e12.readableObjectMode), this.highWaterMark = E5(this, e12, "readableHighWaterMark", n9), this.buffer = new S5(), this.length = 0, this.pipes = null, this.pipesCount = 0, this.flowing = null, this.ended = false, this.endEmitted = false, this.reading = false, this.sync = true, this.needReadable = false, this.emittedReadable = false, this.readableListening = false, this.resumeScheduled = false, this.paused = true, this.emitClose = false !== e12.emitClose, this.autoDestroy = !!e12.autoDestroy, this.destroyed = false, this.defaultEncoding = e12.defaultEncoding || "utf8", this.awaitDrain = 0, this.readingMore = false, this.decoder = null, this.encoding = null, e12.encoding && (w5 || (w5 = e$12.StringDecoder), this.decoder = new w5(e12.encoding), this.encoding = e12.encoding); + } + function C5(e12) { + if (d7 = d7 || ee$1(), !(this instanceof C5)) + return new C5(e12); + var t9 = this instanceof d7; + this._readableState = new D5(e12, this, t9), this.readable = true, e12 && ("function" == typeof e12.read && (this._read = e12.read), "function" == typeof e12.destroy && (this._destroy = e12.destroy)), h9.call(this); + } + function A5(e12, t9, n9, r10, i8) { + p8("readableAddChunk", t9); + var a8, o9 = e12._readableState; + if (null === t9) + o9.reading = false, function(e13, t10) { + if (p8("onEofChunk"), t10.ended) + return; + if (t10.decoder) { + var n10 = t10.decoder.end(); + n10 && n10.length && (t10.buffer.push(n10), t10.length += t10.objectMode ? 1 : n10.length); + } + t10.ended = true, t10.sync ? B5(e13) : (t10.needReadable = false, t10.emittedReadable || (t10.emittedReadable = true, I5(e13))); + }(e12, o9); + else if (i8 || (a8 = function(e13, t10) { + var n10; + r11 = t10, c8.isBuffer(r11) || r11 instanceof b6 || "string" == typeof t10 || void 0 === t10 || e13.objectMode || (n10 = new j5("chunk", ["string", "Buffer", "Uint8Array"], t10)); + var r11; + return n10; + }(o9, t9)), a8) + x5(e12, a8); + else if (o9.objectMode || t9 && t9.length > 0) + if ("string" == typeof t9 || o9.objectMode || Object.getPrototypeOf(t9) === c8.prototype || (t9 = function(e13) { + return c8.from(e13); + }(t9)), r10) + o9.endEmitted ? x5(e12, new P5()) : q4(e12, o9, t9, true); + else if (o9.ended) + x5(e12, new O6()); + else { + if (o9.destroyed) + return false; + o9.reading = false, o9.decoder && !n9 ? (t9 = o9.decoder.write(t9), o9.objectMode || 0 !== t9.length ? q4(e12, o9, t9, false) : N14(e12, o9)) : q4(e12, o9, t9, false); + } + else + r10 || (o9.reading = false, N14(e12, o9)); + return !o9.ended && (o9.length < o9.highWaterMark || 0 === o9.length); + } + function q4(e12, t9, n9, r10) { + t9.flowing && 0 === t9.length && !t9.sync ? (t9.awaitDrain = 0, e12.emit("data", n9)) : (t9.length += t9.objectMode ? 1 : n9.length, r10 ? t9.buffer.unshift(n9) : t9.buffer.push(n9), t9.needReadable && B5(e12)), N14(e12, t9); + } + Object.defineProperty(C5.prototype, "destroyed", { enumerable: false, get: function() { + return void 0 !== this._readableState && this._readableState.destroyed; + }, set: function(e12) { + this._readableState && (this._readableState.destroyed = e12); + } }), C5.prototype.destroy = k5.destroy, C5.prototype._undestroy = k5.undestroy, C5.prototype._destroy = function(e12, t9) { + t9(e12); + }, C5.prototype.push = function(e12, t9) { + var n9, r10 = this._readableState; + return r10.objectMode ? n9 = true : "string" == typeof e12 && ((t9 = t9 || r10.defaultEncoding) !== r10.encoding && (e12 = c8.from(e12, t9), t9 = ""), n9 = true), A5(this, e12, t9, false, n9); + }, C5.prototype.unshift = function(e12) { + return A5(this, e12, null, true, false); + }, C5.prototype.isPaused = function() { + return false === this._readableState.flowing; + }, C5.prototype.setEncoding = function(e12) { + w5 || (w5 = e$12.StringDecoder); + var t9 = new w5(e12); + this._readableState.decoder = t9, this._readableState.encoding = this._readableState.decoder.encoding; + for (var n9 = this._readableState.buffer.head, r10 = ""; null !== n9; ) + r10 += t9.write(n9.data), n9 = n9.next; + return this._readableState.buffer.clear(), "" !== r10 && this._readableState.buffer.push(r10), this._readableState.length = r10.length, this; + }; + function W4(e12, t9) { + return e12 <= 0 || 0 === t9.length && t9.ended ? 0 : t9.objectMode ? 1 : e12 != e12 ? t9.flowing && t9.length ? t9.buffer.head.data.length : t9.length : (e12 > t9.highWaterMark && (t9.highWaterMark = function(e13) { + return e13 >= 1073741824 ? e13 = 1073741824 : (e13--, e13 |= e13 >>> 1, e13 |= e13 >>> 2, e13 |= e13 >>> 4, e13 |= e13 >>> 8, e13 |= e13 >>> 16, e13++), e13; + }(e12)), e12 <= t9.length ? e12 : t9.ended ? t9.length : (t9.needReadable = true, 0)); + } + function B5(e12) { + var t9 = e12._readableState; + p8("emitReadable", t9.needReadable, t9.emittedReadable), t9.needReadable = false, t9.emittedReadable || (p8("emitReadable", t9.flowing), t9.emittedReadable = true, u8.nextTick(I5, e12)); + } + function I5(e12) { + var t9 = e12._readableState; + p8("emitReadable_", t9.destroyed, t9.length, t9.ended), t9.destroyed || !t9.length && !t9.ended || (e12.emit("readable"), t9.emittedReadable = false), t9.needReadable = !t9.flowing && !t9.ended && t9.length <= t9.highWaterMark, J4(e12); + } + function N14(e12, t9) { + t9.readingMore || (t9.readingMore = true, u8.nextTick(U5, e12, t9)); + } + function U5(e12, t9) { + for (; !t9.reading && !t9.ended && (t9.length < t9.highWaterMark || t9.flowing && 0 === t9.length); ) { + var n9 = t9.length; + if (p8("maybeReadMore read 0"), e12.read(0), n9 === t9.length) + break; + } + t9.readingMore = false; + } + function H4(e12) { + var t9 = e12._readableState; + t9.readableListening = e12.listenerCount("readable") > 0, t9.resumeScheduled && !t9.paused ? t9.flowing = true : e12.listenerCount("data") > 0 && e12.resume(); + } + function K4(e12) { + p8("readable nexttick read 0"), e12.read(0); + } + function z6(e12, t9) { + p8("resume", t9.reading), t9.reading || e12.read(0), t9.resumeScheduled = false, e12.emit("resume"), J4(e12), t9.flowing && !t9.reading && e12.read(0); + } + function J4(e12) { + var t9 = e12._readableState; + for (p8("flow", t9.flowing); t9.flowing && null !== e12.read(); ) + ; + } + function Q4(e12, t9) { + return 0 === t9.length ? null : (t9.objectMode ? n9 = t9.buffer.shift() : !e12 || e12 >= t9.length ? (n9 = t9.decoder ? t9.buffer.join("") : 1 === t9.buffer.length ? t9.buffer.first() : t9.buffer.concat(t9.length), t9.buffer.clear()) : n9 = t9.buffer.consume(e12, t9.decoder), n9); + var n9; + } + function X4(e12) { + var t9 = e12._readableState; + p8("endReadable", t9.endEmitted), t9.endEmitted || (t9.ended = true, u8.nextTick(Z4, t9, e12)); + } + function Z4(e12, t9) { + if (p8("endReadableNT", e12.endEmitted, e12.length), !e12.endEmitted && 0 === e12.length && (e12.endEmitted = true, t9.readable = false, t9.emit("end"), e12.autoDestroy)) { + var n9 = t9._writableState; + (!n9 || n9.autoDestroy && n9.finished) && t9.destroy(); + } + } + function $4(e12, t9) { + for (var n9 = 0, r10 = e12.length; n9 < r10; n9++) + if (e12[n9] === t9) + return n9; + return -1; + } + return C5.prototype.read = function(e12) { + p8("read", e12), e12 = parseInt(e12, 10); + var t9 = this._readableState, n9 = e12; + if (0 !== e12 && (t9.emittedReadable = false), 0 === e12 && t9.needReadable && ((0 !== t9.highWaterMark ? t9.length >= t9.highWaterMark : t9.length > 0) || t9.ended)) + return p8("read: emitReadable", t9.length, t9.ended), 0 === t9.length && t9.ended ? X4(this) : B5(this), null; + if (0 === (e12 = W4(e12, t9)) && t9.ended) + return 0 === t9.length && X4(this), null; + var r10, i8 = t9.needReadable; + return p8("need readable", i8), (0 === t9.length || t9.length - e12 < t9.highWaterMark) && p8("length less than watermark", i8 = true), t9.ended || t9.reading ? p8("reading or ended", i8 = false) : i8 && (p8("do read"), t9.reading = true, t9.sync = true, 0 === t9.length && (t9.needReadable = true), this._read(t9.highWaterMark), t9.sync = false, t9.reading || (e12 = W4(n9, t9))), null === (r10 = e12 > 0 ? Q4(e12, t9) : null) ? (t9.needReadable = t9.length <= t9.highWaterMark, e12 = 0) : (t9.length -= e12, t9.awaitDrain = 0), 0 === t9.length && (t9.ended || (t9.needReadable = true), n9 !== e12 && t9.ended && X4(this)), null !== r10 && this.emit("data", r10), r10; + }, C5.prototype._read = function(e12) { + x5(this, new T6("_read()")); + }, C5.prototype.pipe = function(e12, t9) { + var n9 = this, r10 = this._readableState; + switch (r10.pipesCount) { + case 0: + r10.pipes = e12; + break; + case 1: + r10.pipes = [r10.pipes, e12]; + break; + default: + r10.pipes.push(e12); + } + r10.pipesCount += 1, p8("pipe count=%d opts=%j", r10.pipesCount, t9); + var i8 = (!t9 || false !== t9.end) && e12 !== u8.stdout && e12 !== u8.stderr ? o9 : g6; + function a8(t10, i9) { + p8("onunpipe"), t10 === n9 && i9 && false === i9.hasUnpiped && (i9.hasUnpiped = true, p8("cleanup"), e12.removeListener("close", c9), e12.removeListener("finish", b7), e12.removeListener("drain", s7), e12.removeListener("error", h10), e12.removeListener("unpipe", a8), n9.removeListener("end", o9), n9.removeListener("end", g6), n9.removeListener("data", d8), l8 = true, !r10.awaitDrain || e12._writableState && !e12._writableState.needDrain || s7()); + } + function o9() { + p8("onend"), e12.end(); + } + r10.endEmitted ? u8.nextTick(i8) : n9.once("end", i8), e12.on("unpipe", a8); + var s7 = function(e13) { + return function() { + var t10 = e13._readableState; + p8("pipeOnDrain", t10.awaitDrain), t10.awaitDrain && t10.awaitDrain--, 0 === t10.awaitDrain && f9(e13, "data") && (t10.flowing = true, J4(e13)); + }; + }(n9); + e12.on("drain", s7); + var l8 = false; + function d8(t10) { + p8("ondata"); + var i9 = e12.write(t10); + p8("dest.write", i9), false === i9 && ((1 === r10.pipesCount && r10.pipes === e12 || r10.pipesCount > 1 && -1 !== $4(r10.pipes, e12)) && !l8 && (p8("false write response, pause", r10.awaitDrain), r10.awaitDrain++), n9.pause()); + } + function h10(t10) { + p8("onerror", t10), g6(), e12.removeListener("error", h10), 0 === f9(e12, "error") && x5(e12, t10); + } + function c9() { + e12.removeListener("finish", b7), g6(); + } + function b7() { + p8("onfinish"), e12.removeListener("close", c9), g6(); + } + function g6() { + p8("unpipe"), n9.unpipe(e12); + } + return n9.on("data", d8), function(e13, t10, n10) { + if ("function" == typeof e13.prependListener) + return e13.prependListener(t10, n10); + e13._events && e13._events[t10] ? Array.isArray(e13._events[t10]) ? e13._events[t10].unshift(n10) : e13._events[t10] = [n10, e13._events[t10]] : e13.on(t10, n10); + }(e12, "error", h10), e12.once("close", c9), e12.once("finish", b7), e12.emit("pipe", n9), r10.flowing || (p8("pipe resume"), n9.resume()), e12; + }, C5.prototype.unpipe = function(e12) { + var t9 = this._readableState, n9 = { hasUnpiped: false }; + if (0 === t9.pipesCount) + return this; + if (1 === t9.pipesCount) + return e12 && e12 !== t9.pipes || (e12 || (e12 = t9.pipes), t9.pipes = null, t9.pipesCount = 0, t9.flowing = false, e12 && e12.emit("unpipe", this, n9)), this; + if (!e12) { + var r10 = t9.pipes, i8 = t9.pipesCount; + t9.pipes = null, t9.pipesCount = 0, t9.flowing = false; + for (var a8 = 0; a8 < i8; a8++) + r10[a8].emit("unpipe", this, { hasUnpiped: false }); + return this; + } + var o9 = $4(t9.pipes, e12); + return -1 === o9 || (t9.pipes.splice(o9, 1), t9.pipesCount -= 1, 1 === t9.pipesCount && (t9.pipes = t9.pipes[0]), e12.emit("unpipe", this, n9)), this; + }, C5.prototype.on = function(e12, t9) { + var n9 = h9.prototype.on.call(this, e12, t9), r10 = this._readableState; + return "data" === e12 ? (r10.readableListening = this.listenerCount("readable") > 0, false !== r10.flowing && this.resume()) : "readable" === e12 && (r10.endEmitted || r10.readableListening || (r10.readableListening = r10.needReadable = true, r10.flowing = false, r10.emittedReadable = false, p8("on readable", r10.length, r10.reading), r10.length ? B5(this) : r10.reading || u8.nextTick(K4, this))), n9; + }, C5.prototype.addListener = C5.prototype.on, C5.prototype.removeListener = function(e12, t9) { + var n9 = h9.prototype.removeListener.call(this, e12, t9); + return "readable" === e12 && u8.nextTick(H4, this), n9; + }, C5.prototype.removeAllListeners = function(e12) { + var t9 = h9.prototype.removeAllListeners.apply(this, arguments); + return "readable" !== e12 && void 0 !== e12 || u8.nextTick(H4, this), t9; + }, C5.prototype.resume = function() { + var e12 = this._readableState; + return e12.flowing || (p8("resume"), e12.flowing = !e12.readableListening, function(e13, t9) { + t9.resumeScheduled || (t9.resumeScheduled = true, u8.nextTick(z6, e13, t9)); + }(this, e12)), e12.paused = false, this; + }, C5.prototype.pause = function() { + return p8("call pause flowing=%j", this._readableState.flowing), false !== this._readableState.flowing && (p8("pause"), this._readableState.flowing = false, this.emit("pause")), this._readableState.paused = true, this; + }, C5.prototype.wrap = function(e12) { + var t9 = this, n9 = this._readableState, r10 = false; + for (var i8 in e12.on("end", function() { + if (p8("wrapped end"), n9.decoder && !n9.ended) { + var e13 = n9.decoder.end(); + e13 && e13.length && t9.push(e13); + } + t9.push(null); + }), e12.on("data", function(i9) { + (p8("wrapped data"), n9.decoder && (i9 = n9.decoder.write(i9)), n9.objectMode && null == i9) || (n9.objectMode || i9 && i9.length) && (t9.push(i9) || (r10 = true, e12.pause())); + }), e12) + void 0 === this[i8] && "function" == typeof e12[i8] && (this[i8] = function(t10) { + return function() { + return e12[t10].apply(e12, arguments); + }; + }(i8)); + for (var a8 = 0; a8 < L5.length; a8++) + e12.on(L5[a8], this.emit.bind(this, L5[a8])); + return this._read = function(t10) { + p8("wrapped _read", t10), r10 && (r10 = false, e12.resume()); + }, this; + }, "function" == typeof Symbol && (C5.prototype[Symbol.asyncIterator] = function() { + return void 0 === v7 && (v7 = F$8), v7(this); + }), Object.defineProperty(C5.prototype, "readableHighWaterMark", { enumerable: false, get: function() { + return this._readableState.highWaterMark; + } }), Object.defineProperty(C5.prototype, "readableBuffer", { enumerable: false, get: function() { + return this._readableState && this._readableState.buffer; + } }), Object.defineProperty(C5.prototype, "readableFlowing", { enumerable: false, get: function() { + return this._readableState.flowing; + }, set: function(e12) { + this._readableState && (this._readableState.flowing = e12); + } }), C5._fromList = Q4, Object.defineProperty(C5.prototype, "readableLength", { enumerable: false, get: function() { + return this._readableState.length; + } }), "function" == typeof Symbol && (C5.from = function(e12, t9) { + return void 0 === _5 && (_5 = r$1$1), _5(C5, e12, t9); + }), V$6; + } + var z$9 = {}; + var J$5 = false; + var Q$4 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + function X$4() { + if (J$5) + return z$9; + J$5 = true; + var e$23, r10 = T; + function s7(e12) { + var t9 = this; + this.next = null, this.entry = null, this.finish = function() { + !function(e13, t10, n9) { + var r11 = e13.entry; + e13.entry = null; + for (; r11; ) { + var i8 = r11.callback; + t10.pendingcb--, i8(n9), r11 = r11.next; + } + t10.corkedRequestsFree.next = e13; + }(t9, e12); + }; + } + z$9 = P5, P5.WritableState = T6; + var l8 = { deprecate: t$1$1 }, u8 = e$g, f9 = e$1$1.Buffer, h9 = Q$4.Uint8Array || function() { + }; + var c8, b6 = m$m, p8 = R$7.getHighWaterMark, g6 = e$1$12.codes, y7 = g6.ERR_INVALID_ARG_TYPE, w5 = g6.ERR_METHOD_NOT_IMPLEMENTED, v7 = g6.ERR_MULTIPLE_CALLBACK, _5 = g6.ERR_STREAM_CANNOT_PIPE, S5 = g6.ERR_STREAM_DESTROYED, k5 = g6.ERR_STREAM_NULL_VALUES, E5 = g6.ERR_STREAM_WRITE_AFTER_END, M5 = g6.ERR_UNKNOWN_ENCODING, j5 = b6.errorOrDestroy; + function O6() { + } + function T6(t9, n9, i8) { + e$23 = e$23 || ee$1(), t9 = t9 || {}, "boolean" != typeof i8 && (i8 = n9 instanceof e$23), this.objectMode = !!t9.objectMode, i8 && (this.objectMode = this.objectMode || !!t9.writableObjectMode), this.highWaterMark = p8(this, t9, "writableHighWaterMark", i8), this.finalCalled = false, this.needDrain = false, this.ending = false, this.ended = false, this.finished = false, this.destroyed = false; + var a8 = false === t9.decodeStrings; + this.decodeStrings = !a8, this.defaultEncoding = t9.defaultEncoding || "utf8", this.length = 0, this.writing = false, this.corked = 0, this.sync = true, this.bufferProcessing = false, this.onwrite = function(e12) { + !function(e13, t10) { + var n10 = e13._writableState, i9 = n10.sync, a9 = n10.writecb; + if ("function" != typeof a9) + throw new v7(); + if (function(e14) { + e14.writing = false, e14.writecb = null, e14.length -= e14.writelen, e14.writelen = 0; + }(n10), t10) + !function(e14, t11, n11, i10, a10) { + --t11.pendingcb, n11 ? (r10.nextTick(a10, i10), r10.nextTick(q4, e14, t11), e14._writableState.errorEmitted = true, j5(e14, i10)) : (a10(i10), e14._writableState.errorEmitted = true, j5(e14, i10), q4(e14, t11)); + }(e13, n10, i9, t10, a9); + else { + var o9 = C5(n10) || e13.destroyed; + o9 || n10.corked || n10.bufferProcessing || !n10.bufferedRequest || D5(e13, n10), i9 ? r10.nextTick(L5, e13, n10, o9, a9) : L5(e13, n10, o9, a9); + } + }(n9, e12); + }, this.writecb = null, this.writelen = 0, this.bufferedRequest = null, this.lastBufferedRequest = null, this.pendingcb = 0, this.prefinished = false, this.errorEmitted = false, this.emitClose = false !== t9.emitClose, this.autoDestroy = !!t9.autoDestroy, this.bufferedRequestCount = 0, this.corkedRequestsFree = new s7(this); + } + function P5(t9) { + var n9 = this instanceof (e$23 = e$23 || ee$1()); + if (!n9 && !c8.call(P5, this)) + return new P5(t9); + this._writableState = new T6(t9, this, n9), this.writable = true, t9 && ("function" == typeof t9.write && (this._write = t9.write), "function" == typeof t9.writev && (this._writev = t9.writev), "function" == typeof t9.destroy && (this._destroy = t9.destroy), "function" == typeof t9.final && (this._final = t9.final)), u8.call(this); + } + function x5(e12, t9, n9, r11, i8, a8, o9) { + t9.writelen = r11, t9.writecb = o9, t9.writing = true, t9.sync = true, t9.destroyed ? t9.onwrite(new S5("write")) : n9 ? e12._writev(i8, t9.onwrite) : e12._write(i8, a8, t9.onwrite), t9.sync = false; + } + function L5(e12, t9, n9, r11) { + n9 || !function(e13, t10) { + 0 === t10.length && t10.needDrain && (t10.needDrain = false, e13.emit("drain")); + }(e12, t9), t9.pendingcb--, r11(), q4(e12, t9); + } + function D5(e12, t9) { + t9.bufferProcessing = true; + var n9 = t9.bufferedRequest; + if (e12._writev && n9 && n9.next) { + var r11 = t9.bufferedRequestCount, i8 = new Array(r11), a8 = t9.corkedRequestsFree; + a8.entry = n9; + for (var o9 = 0, l9 = true; n9; ) + i8[o9] = n9, n9.isBuf || (l9 = false), n9 = n9.next, o9 += 1; + i8.allBuffers = l9, x5(e12, t9, true, t9.length, i8, "", a8.finish), t9.pendingcb++, t9.lastBufferedRequest = null, a8.next ? (t9.corkedRequestsFree = a8.next, a8.next = null) : t9.corkedRequestsFree = new s7(t9), t9.bufferedRequestCount = 0; + } else { + for (; n9; ) { + var d7 = n9.chunk, u9 = n9.encoding, f10 = n9.callback; + if (x5(e12, t9, false, t9.objectMode ? 1 : d7.length, d7, u9, f10), n9 = n9.next, t9.bufferedRequestCount--, t9.writing) + break; + } + null === n9 && (t9.lastBufferedRequest = null); + } + t9.bufferedRequest = n9, t9.bufferProcessing = false; + } + function C5(e12) { + return e12.ending && 0 === e12.length && null === e12.bufferedRequest && !e12.finished && !e12.writing; + } + function A5(e12, t9) { + e12._final(function(n9) { + t9.pendingcb--, n9 && j5(e12, n9), t9.prefinished = true, e12.emit("prefinish"), q4(e12, t9); + }); + } + function q4(e12, t9) { + var n9 = C5(t9); + if (n9 && (!function(e13, t10) { + t10.prefinished || t10.finalCalled || ("function" != typeof e13._final || t10.destroyed ? (t10.prefinished = true, e13.emit("prefinish")) : (t10.pendingcb++, t10.finalCalled = true, r10.nextTick(A5, e13, t10))); + }(e12, t9), 0 === t9.pendingcb && (t9.finished = true, e12.emit("finish"), t9.autoDestroy))) { + var i8 = e12._readableState; + (!i8 || i8.autoDestroy && i8.endEmitted) && e12.destroy(); + } + return n9; + } + return t$2(P5, u8), T6.prototype.getBuffer = function() { + for (var e12 = this.bufferedRequest, t9 = []; e12; ) + t9.push(e12), e12 = e12.next; + return t9; + }, function() { + try { + Object.defineProperty(T6.prototype, "buffer", { get: l8.deprecate(function() { + return this.getBuffer(); + }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003") }); + } catch (e12) { + } + }(), "function" == typeof Symbol && Symbol.hasInstance && "function" == typeof Function.prototype[Symbol.hasInstance] ? (c8 = Function.prototype[Symbol.hasInstance], Object.defineProperty(P5, Symbol.hasInstance, { value: function(e12) { + return !!c8.call(this, e12) || this === P5 && (e12 && e12._writableState instanceof T6); + } })) : c8 = function(e12) { + return e12 instanceof this; + }, P5.prototype.pipe = function() { + j5(this, new _5()); + }, P5.prototype.write = function(e12, t9, n9) { + var i8, a8 = this._writableState, o9 = false, s8 = !a8.objectMode && (i8 = e12, f9.isBuffer(i8) || i8 instanceof h9); + return s8 && !f9.isBuffer(e12) && (e12 = function(e13) { + return f9.from(e13); + }(e12)), "function" == typeof t9 && (n9 = t9, t9 = null), s8 ? t9 = "buffer" : t9 || (t9 = a8.defaultEncoding), "function" != typeof n9 && (n9 = O6), a8.ending ? function(e13, t10) { + var n10 = new E5(); + j5(e13, n10), r10.nextTick(t10, n10); + }(this, n9) : (s8 || function(e13, t10, n10, i9) { + var a9; + return null === n10 ? a9 = new k5() : "string" == typeof n10 || t10.objectMode || (a9 = new y7("chunk", ["string", "Buffer"], n10)), !a9 || (j5(e13, a9), r10.nextTick(i9, a9), false); + }(this, a8, e12, n9)) && (a8.pendingcb++, o9 = function(e13, t10, n10, r11, i9, a9) { + if (!n10) { + var o10 = function(e14, t11, n11) { + e14.objectMode || false === e14.decodeStrings || "string" != typeof t11 || (t11 = f9.from(t11, n11)); + return t11; + }(t10, r11, i9); + r11 !== o10 && (n10 = true, i9 = "buffer", r11 = o10); + } + var s9 = t10.objectMode ? 1 : r11.length; + t10.length += s9; + var l9 = t10.length < t10.highWaterMark; + l9 || (t10.needDrain = true); + if (t10.writing || t10.corked) { + var d7 = t10.lastBufferedRequest; + t10.lastBufferedRequest = { chunk: r11, encoding: i9, isBuf: n10, callback: a9, next: null }, d7 ? d7.next = t10.lastBufferedRequest : t10.bufferedRequest = t10.lastBufferedRequest, t10.bufferedRequestCount += 1; + } else + x5(e13, t10, false, s9, r11, i9, a9); + return l9; + }(this, a8, s8, e12, t9, n9)), o9; + }, P5.prototype.cork = function() { + this._writableState.corked++; + }, P5.prototype.uncork = function() { + var e12 = this._writableState; + e12.corked && (e12.corked--, e12.writing || e12.corked || e12.bufferProcessing || !e12.bufferedRequest || D5(this, e12)); + }, P5.prototype.setDefaultEncoding = function(e12) { + if ("string" == typeof e12 && (e12 = e12.toLowerCase()), !(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((e12 + "").toLowerCase()) > -1)) + throw new M5(e12); + return this._writableState.defaultEncoding = e12, this; + }, Object.defineProperty(P5.prototype, "writableBuffer", { enumerable: false, get: function() { + return this._writableState && this._writableState.getBuffer(); + } }), Object.defineProperty(P5.prototype, "writableHighWaterMark", { enumerable: false, get: function() { + return this._writableState.highWaterMark; + } }), P5.prototype._write = function(e12, t9, n9) { + n9(new w5("_write()")); + }, P5.prototype._writev = null, P5.prototype.end = function(e12, t9, n9) { + var i8 = this._writableState; + return "function" == typeof e12 ? (n9 = e12, e12 = null, t9 = null) : "function" == typeof t9 && (n9 = t9, t9 = null), null != e12 && this.write(e12, t9), i8.corked && (i8.corked = 1, this.uncork()), i8.ending || function(e13, t10, n10) { + t10.ending = true, q4(e13, t10), n10 && (t10.finished ? r10.nextTick(n10) : e13.once("finish", n10)); + t10.ended = true, e13.writable = false; + }(this, i8, n9), this; + }, Object.defineProperty(P5.prototype, "writableLength", { enumerable: false, get: function() { + return this._writableState.length; + } }), Object.defineProperty(P5.prototype, "destroyed", { enumerable: false, get: function() { + return void 0 !== this._writableState && this._writableState.destroyed; + }, set: function(e12) { + this._writableState && (this._writableState.destroyed = e12); + } }), P5.prototype.destroy = b6.destroy, P5.prototype._undestroy = b6.undestroy, P5.prototype._destroy = function(e12, t9) { + t9(e12); + }, z$9; + } + var Z$3 = {}; + var $$3 = false; + function ee$1() { + if ($$3) + return Z$3; + $$3 = true; + var e12 = T, t9 = Object.keys || function(e13) { + var t10 = []; + for (var n10 in e13) + t10.push(n10); + return t10; + }; + Z$3 = d7; + var n9 = K$8(), r10 = X$4(); + t$2(d7, n9); + for (var a8 = t9(r10.prototype), s7 = 0; s7 < a8.length; s7++) { + var l8 = a8[s7]; + d7.prototype[l8] || (d7.prototype[l8] = r10.prototype[l8]); + } + function d7(e13) { + if (!(this instanceof d7)) + return new d7(e13); + n9.call(this, e13), r10.call(this, e13), this.allowHalfOpen = true, e13 && (false === e13.readable && (this.readable = false), false === e13.writable && (this.writable = false), false === e13.allowHalfOpen && (this.allowHalfOpen = false, this.once("end", u8))); + } + function u8() { + this._writableState.ended || e12.nextTick(f9, this); + } + function f9(e13) { + e13.end(); + } + return Object.defineProperty(d7.prototype, "writableHighWaterMark", { enumerable: false, get: function() { + return this._writableState.highWaterMark; + } }), Object.defineProperty(d7.prototype, "writableBuffer", { enumerable: false, get: function() { + return this._writableState && this._writableState.getBuffer(); + } }), Object.defineProperty(d7.prototype, "writableLength", { enumerable: false, get: function() { + return this._writableState.length; + } }), Object.defineProperty(d7.prototype, "destroyed", { enumerable: false, get: function() { + return void 0 !== this._readableState && void 0 !== this._writableState && (this._readableState.destroyed && this._writableState.destroyed); + }, set: function(e13) { + void 0 !== this._readableState && void 0 !== this._writableState && (this._readableState.destroyed = e13, this._writableState.destroyed = e13); + } }), Z$3; + } + var t$2$1 = K$8(); + var r$3$1 = e$1$12.codes.ERR_STREAM_PREMATURE_CLOSE; + function t$3$1() { + } + var n$1$12 = function e6(n9, o9, a8) { + if ("function" == typeof o9) + return e6(n9, null, o9); + o9 || (o9 = {}), a8 = function(e12) { + var r10 = false; + return function() { + if (!r10) { + r10 = true; + for (var t9 = arguments.length, n10 = new Array(t9), o10 = 0; o10 < t9; o10++) + n10[o10] = arguments[o10]; + e12.apply(this, n10); + } + }; + }(a8 || t$3$1); + var i8 = o9.readable || false !== o9.readable && n9.readable, l8 = o9.writable || false !== o9.writable && n9.writable, c8 = function() { + n9.writable || s7(); + }, f9 = n9._writableState && n9._writableState.finished, s7 = function() { + l8 = false, f9 = true, i8 || a8.call(n9); + }, u8 = n9._readableState && n9._readableState.endEmitted, d7 = function() { + i8 = false, u8 = true, l8 || a8.call(n9); + }, b6 = function(e12) { + a8.call(n9, e12); + }, v7 = function() { + var e12; + return i8 && !u8 ? (n9._readableState && n9._readableState.ended || (e12 = new r$3$1()), a8.call(n9, e12)) : l8 && !f9 ? (n9._writableState && n9._writableState.ended || (e12 = new r$3$1()), a8.call(n9, e12)) : void 0; + }, m7 = function() { + n9.req.on("finish", s7); + }; + return !function(e12) { + return e12.setHeader && "function" == typeof e12.abort; + }(n9) ? l8 && !n9._writableState && (n9.on("end", c8), n9.on("close", c8)) : (n9.on("complete", s7), n9.on("abort", v7), n9.req ? m7() : n9.on("request", m7)), n9.on("end", d7), n9.on("finish", s7), false !== o9.error && n9.on("error", b6), n9.on("close", v7), function() { + n9.removeListener("complete", s7), n9.removeListener("abort", v7), n9.removeListener("request", m7), n9.req && n9.req.removeListener("finish", s7), n9.removeListener("end", c8), n9.removeListener("close", c8), n9.removeListener("finish", s7), n9.removeListener("end", d7), n9.removeListener("error", b6), n9.removeListener("close", v7); + }; + }; + function f$1$1(e12, t9) { + var n9 = Object.keys(e12); + if (Object.getOwnPropertySymbols) { + var r10 = Object.getOwnPropertySymbols(e12); + t9 && (r10 = r10.filter(function(t10) { + return Object.getOwnPropertyDescriptor(e12, t10).enumerable; + })), n9.push.apply(n9, r10); + } + return n9; + } + function h$1$12(e12, t9, n9) { + return t9 in e12 ? Object.defineProperty(e12, t9, { value: n9, enumerable: true, configurable: true, writable: true }) : e12[t9] = n9, e12; + } + function c$1$12(e12, t9) { + for (var n9 = 0; n9 < t9.length; n9++) { + var r10 = t9[n9]; + r10.enumerable = r10.enumerable || false, r10.configurable = true, "value" in r10 && (r10.writable = true), Object.defineProperty(e12, r10.key, r10); + } + } + var b$1$1 = e$1$1.Buffer; + var p$1$1 = X.inspect; + var g$1$1 = p$1$1 && p$1$1.custom || "inspect"; + var y$1$1 = function() { + function e12() { + !function(e13, t10) { + if (!(e13 instanceof t10)) + throw new TypeError("Cannot call a class as a function"); + }(this, e12), this.head = null, this.tail = null, this.length = 0; + } + var t9, n9; + return t9 = e12, (n9 = [{ key: "push", value: function(e13) { + var t10 = { data: e13, next: null }; + this.length > 0 ? this.tail.next = t10 : this.head = t10, this.tail = t10, ++this.length; + } }, { key: "unshift", value: function(e13) { + var t10 = { data: e13, next: this.head }; + 0 === this.length && (this.tail = t10), this.head = t10, ++this.length; + } }, { key: "shift", value: function() { + if (0 !== this.length) { + var e13 = this.head.data; + return 1 === this.length ? this.head = this.tail = null : this.head = this.head.next, --this.length, e13; + } + } }, { key: "clear", value: function() { + this.head = this.tail = null, this.length = 0; + } }, { key: "join", value: function(e13) { + if (0 === this.length) + return ""; + for (var t10 = this.head, n10 = "" + t10.data; t10 = t10.next; ) + n10 += e13 + t10.data; + return n10; + } }, { key: "concat", value: function(e13) { + if (0 === this.length) + return b$1$1.alloc(0); + for (var t10, n10, r10, i8 = b$1$1.allocUnsafe(e13 >>> 0), a8 = this.head, o9 = 0; a8; ) + t10 = a8.data, n10 = i8, r10 = o9, void b$1$1.prototype.copy.call(t10, n10, r10), o9 += a8.data.length, a8 = a8.next; + return i8; + } }, { key: "consume", value: function(e13, t10) { + var n10; + return e13 < this.head.data.length ? (n10 = this.head.data.slice(0, e13), this.head.data = this.head.data.slice(e13)) : n10 = e13 === this.head.data.length ? this.shift() : t10 ? this._getString(e13) : this._getBuffer(e13), n10; + } }, { key: "first", value: function() { + return this.head.data; + } }, { key: "_getString", value: function(e13) { + var t10 = this.head, n10 = 1, r10 = t10.data; + for (e13 -= r10.length; t10 = t10.next; ) { + var i8 = t10.data, a8 = e13 > i8.length ? i8.length : e13; + if (a8 === i8.length ? r10 += i8 : r10 += i8.slice(0, e13), 0 == (e13 -= a8)) { + a8 === i8.length ? (++n10, t10.next ? this.head = t10.next : this.head = this.tail = null) : (this.head = t10, t10.data = i8.slice(a8)); + break; + } + ++n10; + } + return this.length -= n10, r10; + } }, { key: "_getBuffer", value: function(e13) { + var t10 = b$1$1.allocUnsafe(e13), n10 = this.head, r10 = 1; + for (n10.data.copy(t10), e13 -= n10.data.length; n10 = n10.next; ) { + var i8 = n10.data, a8 = e13 > i8.length ? i8.length : e13; + if (i8.copy(t10, t10.length - e13, 0, a8), 0 == (e13 -= a8)) { + a8 === i8.length ? (++r10, n10.next ? this.head = n10.next : this.head = this.tail = null) : (this.head = n10, n10.data = i8.slice(a8)); + break; + } + ++r10; + } + return this.length -= r10, t10; + } }, { key: g$1$1, value: function(e13, t10) { + return p$1$1(this, function(e14) { + for (var t11 = 1; t11 < arguments.length; t11++) { + var n10 = null != arguments[t11] ? arguments[t11] : {}; + t11 % 2 ? f$1$1(Object(n10), true).forEach(function(t12) { + h$1$12(e14, t12, n10[t12]); + }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e14, Object.getOwnPropertyDescriptors(n10)) : f$1$1(Object(n10)).forEach(function(t12) { + Object.defineProperty(e14, t12, Object.getOwnPropertyDescriptor(n10, t12)); + }); + } + return e14; + }({}, t10, { depth: 0, customInspect: false })); + } }]) && c$1$12(t9.prototype, n9), e12; + }(); + var w$1$1 = T; + function _$1$1(e12, t9) { + m$1$1(e12, t9), v$1$1(e12); + } + function v$1$1(e12) { + e12._writableState && !e12._writableState.emitClose || e12._readableState && !e12._readableState.emitClose || e12.emit("close"); + } + function m$1$1(e12, t9) { + e12.emit("error", t9); + } + var S$1$1 = { destroy: function(e12, t9) { + var n9 = this, r10 = this._readableState && this._readableState.destroyed, i8 = this._writableState && this._writableState.destroyed; + return r10 || i8 ? (t9 ? t9(e12) : e12 && (this._writableState ? this._writableState.errorEmitted || (this._writableState.errorEmitted = true, w$1$1.nextTick(m$1$1, this, e12)) : w$1$1.nextTick(m$1$1, this, e12)), this) : (this._readableState && (this._readableState.destroyed = true), this._writableState && (this._writableState.destroyed = true), this._destroy(e12 || null, function(e13) { + !t9 && e13 ? n9._writableState ? n9._writableState.errorEmitted ? w$1$1.nextTick(v$1$1, n9) : (n9._writableState.errorEmitted = true, w$1$1.nextTick(_$1$1, n9, e13)) : w$1$1.nextTick(_$1$1, n9, e13) : t9 ? (w$1$1.nextTick(v$1$1, n9), t9(e13)) : w$1$1.nextTick(v$1$1, n9); + }), this); + }, undestroy: function() { + this._readableState && (this._readableState.destroyed = false, this._readableState.reading = false, this._readableState.ended = false, this._readableState.endEmitted = false), this._writableState && (this._writableState.destroyed = false, this._writableState.ended = false, this._writableState.ending = false, this._writableState.finalCalled = false, this._writableState.prefinished = false, this._writableState.finished = false, this._writableState.errorEmitted = false); + }, errorOrDestroy: function(e12, t9) { + var n9 = e12._readableState, r10 = e12._writableState; + n9 && n9.autoDestroy || r10 && r10.autoDestroy ? e12.destroy(t9) : e12.emit("error", t9); + } }; + var R$1$1 = e$1$12.codes.ERR_INVALID_OPT_VALUE; + var k$1$1; + var E$1$1 = { getHighWaterMark: function(e12, t9, n9, r10) { + var i8 = function(e13, t10, n10) { + return null != e13.highWaterMark ? e13.highWaterMark : t10 ? e13[n10] : null; + }(t9, r10, n9); + if (null != i8) { + if (!isFinite(i8) || Math.floor(i8) !== i8 || i8 < 0) + throw new R$1$1(r10 ? n9 : "highWaterMark", i8); + return Math.floor(i8); + } + return e12.objectMode ? 16 : 16384; + } }; + var M$1$1 = T; + function j$1$1(e12, t9, n9) { + return t9 in e12 ? Object.defineProperty(e12, t9, { value: n9, enumerable: true, configurable: true, writable: true }) : e12[t9] = n9, e12; + } + var O$1$1 = n$1$12; + var T$1$1 = Symbol("lastResolve"); + var x$1$1 = Symbol("lastReject"); + var P$1$1 = Symbol("error"); + var D$1$1 = Symbol("ended"); + var L$1$1 = Symbol("lastPromise"); + var C$1$1 = Symbol("handlePromise"); + var A$1$1 = Symbol("stream"); + function W$1$1(e12, t9) { + return { value: e12, done: t9 }; + } + function B$1$1(e12) { + var t9 = e12[T$1$1]; + if (null !== t9) { + var n9 = e12[A$1$1].read(); + null !== n9 && (e12[L$1$1] = null, e12[T$1$1] = null, e12[x$1$1] = null, t9(W$1$1(n9, false))); + } + } + function q$1$1(e12) { + M$1$1.nextTick(B$1$1, e12); + } + var I$1$1 = Object.getPrototypeOf(function() { + }); + var N$1$1 = Object.setPrototypeOf((j$1$1(k$1$1 = { get stream() { + return this[A$1$1]; + }, next: function() { + var e12 = this, t9 = this[P$1$1]; + if (null !== t9) + return Promise.reject(t9); + if (this[D$1$1]) + return Promise.resolve(W$1$1(void 0, true)); + if (this[A$1$1].destroyed) + return new Promise(function(t10, n10) { + M$1$1.nextTick(function() { + e12[P$1$1] ? n10(e12[P$1$1]) : t10(W$1$1(void 0, true)); + }); + }); + var n9, r10 = this[L$1$1]; + if (r10) + n9 = new Promise(function(e13, t10) { + return function(n10, r11) { + e13.then(function() { + if (t10[D$1$1]) + return n10(W$1$1(void 0, true)), void 0; + t10[C$1$1](n10, r11); + }, r11); + }; + }(r10, this)); + else { + var i8 = this[A$1$1].read(); + if (null !== i8) + return Promise.resolve(W$1$1(i8, false)); + n9 = new Promise(this[C$1$1]); + } + return this[L$1$1] = n9, n9; + } }, Symbol.asyncIterator, function() { + return this; + }), j$1$1(k$1$1, "return", function() { + var e12 = this; + return new Promise(function(t9, n9) { + e12[A$1$1].destroy(null, function(e13) { + if (e13) + return n9(e13), void 0; + t9(W$1$1(void 0, true)); + }); + }); + }), k$1$1), I$1$1); + var U$1$1 = function(e12) { + var t9, n9 = Object.create(N$1$1, (j$1$1(t9 = {}, A$1$1, { value: e12, writable: true }), j$1$1(t9, T$1$1, { value: null, writable: true }), j$1$1(t9, x$1$1, { value: null, writable: true }), j$1$1(t9, P$1$1, { value: null, writable: true }), j$1$1(t9, D$1$1, { value: e12._readableState.endEmitted, writable: true }), j$1$1(t9, C$1$1, { value: function(e13, t10) { + var r10 = n9[A$1$1].read(); + r10 ? (n9[L$1$1] = null, n9[T$1$1] = null, n9[x$1$1] = null, e13(W$1$1(r10, false))) : (n9[T$1$1] = e13, n9[x$1$1] = t10); + }, writable: true }), t9)); + return n9[L$1$1] = null, O$1$1(e12, function(e13) { + if (e13 && "ERR_STREAM_PREMATURE_CLOSE" !== e13.code) { + var t10 = n9[x$1$1]; + return null !== t10 && (n9[L$1$1] = null, n9[T$1$1] = null, n9[x$1$1] = null, t10(e13)), n9[P$1$1] = e13, void 0; + } + var r10 = n9[T$1$1]; + null !== r10 && (n9[L$1$1] = null, n9[T$1$1] = null, n9[x$1$1] = null, r10(W$1$1(void 0, true))), n9[D$1$1] = true; + }), e12.on("readable", q$1$1.bind(null, n9)), n9; + }; + var H$1$1 = {}; + var F$1$1 = false; + var V$1$1 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + function G$1$1() { + if (F$1$1) + return H$1$1; + F$1$1 = true; + var l8, u8 = T; + H$1$1 = C5, C5.ReadableState = L5; + y.EventEmitter; + var f9 = function(e12, t9) { + return e12.listeners(t9).length; + }, h9 = e$g, c8 = e$1$1.Buffer, b6 = V$1$1.Uint8Array || function() { + }; + var p8, g6 = X; + p8 = g6 && g6.debuglog ? g6.debuglog("stream") : function() { + }; + var w5, _5, v7, m7 = y$1$1, R5 = S$1$1, k5 = E$1$1.getHighWaterMark, M5 = e$1$12.codes, j5 = M5.ERR_INVALID_ARG_TYPE, O6 = M5.ERR_STREAM_PUSH_AFTER_EOF, T6 = M5.ERR_METHOD_NOT_IMPLEMENTED, x5 = M5.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; + t$2(C5, h9); + var P5 = R5.errorOrDestroy, D5 = ["error", "close", "destroy", "pause", "resume"]; + function L5(e12, t9, n9) { + l8 = l8 || Z$1$1(), e12 = e12 || {}, "boolean" != typeof n9 && (n9 = t9 instanceof l8), this.objectMode = !!e12.objectMode, n9 && (this.objectMode = this.objectMode || !!e12.readableObjectMode), this.highWaterMark = k5(this, e12, "readableHighWaterMark", n9), this.buffer = new m7(), this.length = 0, this.pipes = null, this.pipesCount = 0, this.flowing = null, this.ended = false, this.endEmitted = false, this.reading = false, this.sync = true, this.needReadable = false, this.emittedReadable = false, this.readableListening = false, this.resumeScheduled = false, this.paused = true, this.emitClose = false !== e12.emitClose, this.autoDestroy = !!e12.autoDestroy, this.destroyed = false, this.defaultEncoding = e12.defaultEncoding || "utf8", this.awaitDrain = 0, this.readingMore = false, this.decoder = null, this.encoding = null, e12.encoding && (w5 || (w5 = e$12.StringDecoder), this.decoder = new w5(e12.encoding), this.encoding = e12.encoding); + } + function C5(e12) { + if (l8 = l8 || Z$1$1(), !(this instanceof C5)) + return new C5(e12); + var t9 = this instanceof l8; + this._readableState = new L5(e12, this, t9), this.readable = true, e12 && ("function" == typeof e12.read && (this._read = e12.read), "function" == typeof e12.destroy && (this._destroy = e12.destroy)), h9.call(this); + } + function A5(e12, t9, n9, r10, i8) { + p8("readableAddChunk", t9); + var a8, o9 = e12._readableState; + if (null === t9) + o9.reading = false, function(e13, t10) { + if (p8("onEofChunk"), t10.ended) + return; + if (t10.decoder) { + var n10 = t10.decoder.end(); + n10 && n10.length && (t10.buffer.push(n10), t10.length += t10.objectMode ? 1 : n10.length); + } + t10.ended = true, t10.sync ? q4(e13) : (t10.needReadable = false, t10.emittedReadable || (t10.emittedReadable = true, I5(e13))); + }(e12, o9); + else if (i8 || (a8 = function(e13, t10) { + var n10; + r11 = t10, c8.isBuffer(r11) || r11 instanceof b6 || "string" == typeof t10 || void 0 === t10 || e13.objectMode || (n10 = new j5("chunk", ["string", "Buffer", "Uint8Array"], t10)); + var r11; + return n10; + }(o9, t9)), a8) + P5(e12, a8); + else if (o9.objectMode || t9 && t9.length > 0) + if ("string" == typeof t9 || o9.objectMode || Object.getPrototypeOf(t9) === c8.prototype || (t9 = function(e13) { + return c8.from(e13); + }(t9)), r10) + o9.endEmitted ? P5(e12, new x5()) : W4(e12, o9, t9, true); + else if (o9.ended) + P5(e12, new O6()); + else { + if (o9.destroyed) + return false; + o9.reading = false, o9.decoder && !n9 ? (t9 = o9.decoder.write(t9), o9.objectMode || 0 !== t9.length ? W4(e12, o9, t9, false) : N14(e12, o9)) : W4(e12, o9, t9, false); + } + else + r10 || (o9.reading = false, N14(e12, o9)); + return !o9.ended && (o9.length < o9.highWaterMark || 0 === o9.length); + } + function W4(e12, t9, n9, r10) { + t9.flowing && 0 === t9.length && !t9.sync ? (t9.awaitDrain = 0, e12.emit("data", n9)) : (t9.length += t9.objectMode ? 1 : n9.length, r10 ? t9.buffer.unshift(n9) : t9.buffer.push(n9), t9.needReadable && q4(e12)), N14(e12, t9); + } + Object.defineProperty(C5.prototype, "destroyed", { enumerable: false, get: function() { + return void 0 !== this._readableState && this._readableState.destroyed; + }, set: function(e12) { + this._readableState && (this._readableState.destroyed = e12); + } }), C5.prototype.destroy = R5.destroy, C5.prototype._undestroy = R5.undestroy, C5.prototype._destroy = function(e12, t9) { + t9(e12); + }, C5.prototype.push = function(e12, t9) { + var n9, r10 = this._readableState; + return r10.objectMode ? n9 = true : "string" == typeof e12 && ((t9 = t9 || r10.defaultEncoding) !== r10.encoding && (e12 = c8.from(e12, t9), t9 = ""), n9 = true), A5(this, e12, t9, false, n9); + }, C5.prototype.unshift = function(e12) { + return A5(this, e12, null, true, false); + }, C5.prototype.isPaused = function() { + return false === this._readableState.flowing; + }, C5.prototype.setEncoding = function(e12) { + w5 || (w5 = e$12.StringDecoder); + var t9 = new w5(e12); + this._readableState.decoder = t9, this._readableState.encoding = this._readableState.decoder.encoding; + for (var n9 = this._readableState.buffer.head, r10 = ""; null !== n9; ) + r10 += t9.write(n9.data), n9 = n9.next; + return this._readableState.buffer.clear(), "" !== r10 && this._readableState.buffer.push(r10), this._readableState.length = r10.length, this; + }; + function B5(e12, t9) { + return e12 <= 0 || 0 === t9.length && t9.ended ? 0 : t9.objectMode ? 1 : e12 != e12 ? t9.flowing && t9.length ? t9.buffer.head.data.length : t9.length : (e12 > t9.highWaterMark && (t9.highWaterMark = function(e13) { + return e13 >= 1073741824 ? e13 = 1073741824 : (e13--, e13 |= e13 >>> 1, e13 |= e13 >>> 2, e13 |= e13 >>> 4, e13 |= e13 >>> 8, e13 |= e13 >>> 16, e13++), e13; + }(e12)), e12 <= t9.length ? e12 : t9.ended ? t9.length : (t9.needReadable = true, 0)); + } + function q4(e12) { + var t9 = e12._readableState; + p8("emitReadable", t9.needReadable, t9.emittedReadable), t9.needReadable = false, t9.emittedReadable || (p8("emitReadable", t9.flowing), t9.emittedReadable = true, u8.nextTick(I5, e12)); + } + function I5(e12) { + var t9 = e12._readableState; + p8("emitReadable_", t9.destroyed, t9.length, t9.ended), t9.destroyed || !t9.length && !t9.ended || (e12.emit("readable"), t9.emittedReadable = false), t9.needReadable = !t9.flowing && !t9.ended && t9.length <= t9.highWaterMark, J4(e12); + } + function N14(e12, t9) { + t9.readingMore || (t9.readingMore = true, u8.nextTick(G4, e12, t9)); + } + function G4(e12, t9) { + for (; !t9.reading && !t9.ended && (t9.length < t9.highWaterMark || t9.flowing && 0 === t9.length); ) { + var n9 = t9.length; + if (p8("maybeReadMore read 0"), e12.read(0), n9 === t9.length) + break; + } + t9.readingMore = false; + } + function Y5(e12) { + var t9 = e12._readableState; + t9.readableListening = e12.listenerCount("readable") > 0, t9.resumeScheduled && !t9.paused ? t9.flowing = true : e12.listenerCount("data") > 0 && e12.resume(); + } + function K4(e12) { + p8("readable nexttick read 0"), e12.read(0); + } + function z6(e12, t9) { + p8("resume", t9.reading), t9.reading || e12.read(0), t9.resumeScheduled = false, e12.emit("resume"), J4(e12), t9.flowing && !t9.reading && e12.read(0); + } + function J4(e12) { + var t9 = e12._readableState; + for (p8("flow", t9.flowing); t9.flowing && null !== e12.read(); ) + ; + } + function Q4(e12, t9) { + return 0 === t9.length ? null : (t9.objectMode ? n9 = t9.buffer.shift() : !e12 || e12 >= t9.length ? (n9 = t9.decoder ? t9.buffer.join("") : 1 === t9.buffer.length ? t9.buffer.first() : t9.buffer.concat(t9.length), t9.buffer.clear()) : n9 = t9.buffer.consume(e12, t9.decoder), n9); + var n9; + } + function X4(e12) { + var t9 = e12._readableState; + p8("endReadable", t9.endEmitted), t9.endEmitted || (t9.ended = true, u8.nextTick($4, t9, e12)); + } + function $4(e12, t9) { + if (p8("endReadableNT", e12.endEmitted, e12.length), !e12.endEmitted && 0 === e12.length && (e12.endEmitted = true, t9.readable = false, t9.emit("end"), e12.autoDestroy)) { + var n9 = t9._writableState; + (!n9 || n9.autoDestroy && n9.finished) && t9.destroy(); + } + } + function ee3(e12, t9) { + for (var n9 = 0, r10 = e12.length; n9 < r10; n9++) + if (e12[n9] === t9) + return n9; + return -1; + } + return C5.prototype.read = function(e12) { + p8("read", e12), e12 = parseInt(e12, 10); + var t9 = this._readableState, n9 = e12; + if (0 !== e12 && (t9.emittedReadable = false), 0 === e12 && t9.needReadable && ((0 !== t9.highWaterMark ? t9.length >= t9.highWaterMark : t9.length > 0) || t9.ended)) + return p8("read: emitReadable", t9.length, t9.ended), 0 === t9.length && t9.ended ? X4(this) : q4(this), null; + if (0 === (e12 = B5(e12, t9)) && t9.ended) + return 0 === t9.length && X4(this), null; + var r10, i8 = t9.needReadable; + return p8("need readable", i8), (0 === t9.length || t9.length - e12 < t9.highWaterMark) && p8("length less than watermark", i8 = true), t9.ended || t9.reading ? p8("reading or ended", i8 = false) : i8 && (p8("do read"), t9.reading = true, t9.sync = true, 0 === t9.length && (t9.needReadable = true), this._read(t9.highWaterMark), t9.sync = false, t9.reading || (e12 = B5(n9, t9))), null === (r10 = e12 > 0 ? Q4(e12, t9) : null) ? (t9.needReadable = t9.length <= t9.highWaterMark, e12 = 0) : (t9.length -= e12, t9.awaitDrain = 0), 0 === t9.length && (t9.ended || (t9.needReadable = true), n9 !== e12 && t9.ended && X4(this)), null !== r10 && this.emit("data", r10), r10; + }, C5.prototype._read = function(e12) { + P5(this, new T6("_read()")); + }, C5.prototype.pipe = function(e12, t9) { + var n9 = this, r10 = this._readableState; + switch (r10.pipesCount) { + case 0: + r10.pipes = e12; + break; + case 1: + r10.pipes = [r10.pipes, e12]; + break; + default: + r10.pipes.push(e12); + } + r10.pipesCount += 1, p8("pipe count=%d opts=%j", r10.pipesCount, t9); + var i8 = (!t9 || false !== t9.end) && e12 !== u8.stdout && e12 !== u8.stderr ? o9 : g7; + function a8(t10, i9) { + p8("onunpipe"), t10 === n9 && i9 && false === i9.hasUnpiped && (i9.hasUnpiped = true, p8("cleanup"), e12.removeListener("close", c9), e12.removeListener("finish", b7), e12.removeListener("drain", s7), e12.removeListener("error", h10), e12.removeListener("unpipe", a8), n9.removeListener("end", o9), n9.removeListener("end", g7), n9.removeListener("data", d7), l9 = true, !r10.awaitDrain || e12._writableState && !e12._writableState.needDrain || s7()); + } + function o9() { + p8("onend"), e12.end(); + } + r10.endEmitted ? u8.nextTick(i8) : n9.once("end", i8), e12.on("unpipe", a8); + var s7 = function(e13) { + return function() { + var t10 = e13._readableState; + p8("pipeOnDrain", t10.awaitDrain), t10.awaitDrain && t10.awaitDrain--, 0 === t10.awaitDrain && f9(e13, "data") && (t10.flowing = true, J4(e13)); + }; + }(n9); + e12.on("drain", s7); + var l9 = false; + function d7(t10) { + p8("ondata"); + var i9 = e12.write(t10); + p8("dest.write", i9), false === i9 && ((1 === r10.pipesCount && r10.pipes === e12 || r10.pipesCount > 1 && -1 !== ee3(r10.pipes, e12)) && !l9 && (p8("false write response, pause", r10.awaitDrain), r10.awaitDrain++), n9.pause()); + } + function h10(t10) { + p8("onerror", t10), g7(), e12.removeListener("error", h10), 0 === f9(e12, "error") && P5(e12, t10); + } + function c9() { + e12.removeListener("finish", b7), g7(); + } + function b7() { + p8("onfinish"), e12.removeListener("close", c9), g7(); + } + function g7() { + p8("unpipe"), n9.unpipe(e12); + } + return n9.on("data", d7), function(e13, t10, n10) { + if ("function" == typeof e13.prependListener) + return e13.prependListener(t10, n10); + e13._events && e13._events[t10] ? Array.isArray(e13._events[t10]) ? e13._events[t10].unshift(n10) : e13._events[t10] = [n10, e13._events[t10]] : e13.on(t10, n10); + }(e12, "error", h10), e12.once("close", c9), e12.once("finish", b7), e12.emit("pipe", n9), r10.flowing || (p8("pipe resume"), n9.resume()), e12; + }, C5.prototype.unpipe = function(e12) { + var t9 = this._readableState, n9 = { hasUnpiped: false }; + if (0 === t9.pipesCount) + return this; + if (1 === t9.pipesCount) + return e12 && e12 !== t9.pipes || (e12 || (e12 = t9.pipes), t9.pipes = null, t9.pipesCount = 0, t9.flowing = false, e12 && e12.emit("unpipe", this, n9)), this; + if (!e12) { + var r10 = t9.pipes, i8 = t9.pipesCount; + t9.pipes = null, t9.pipesCount = 0, t9.flowing = false; + for (var a8 = 0; a8 < i8; a8++) + r10[a8].emit("unpipe", this, { hasUnpiped: false }); + return this; + } + var o9 = ee3(t9.pipes, e12); + return -1 === o9 || (t9.pipes.splice(o9, 1), t9.pipesCount -= 1, 1 === t9.pipesCount && (t9.pipes = t9.pipes[0]), e12.emit("unpipe", this, n9)), this; + }, C5.prototype.on = function(e12, t9) { + var n9 = h9.prototype.on.call(this, e12, t9), r10 = this._readableState; + return "data" === e12 ? (r10.readableListening = this.listenerCount("readable") > 0, false !== r10.flowing && this.resume()) : "readable" === e12 && (r10.endEmitted || r10.readableListening || (r10.readableListening = r10.needReadable = true, r10.flowing = false, r10.emittedReadable = false, p8("on readable", r10.length, r10.reading), r10.length ? q4(this) : r10.reading || u8.nextTick(K4, this))), n9; + }, C5.prototype.addListener = C5.prototype.on, C5.prototype.removeListener = function(e12, t9) { + var n9 = h9.prototype.removeListener.call(this, e12, t9); + return "readable" === e12 && u8.nextTick(Y5, this), n9; + }, C5.prototype.removeAllListeners = function(e12) { + var t9 = h9.prototype.removeAllListeners.apply(this, arguments); + return "readable" !== e12 && void 0 !== e12 || u8.nextTick(Y5, this), t9; + }, C5.prototype.resume = function() { + var e12 = this._readableState; + return e12.flowing || (p8("resume"), e12.flowing = !e12.readableListening, function(e13, t9) { + t9.resumeScheduled || (t9.resumeScheduled = true, u8.nextTick(z6, e13, t9)); + }(this, e12)), e12.paused = false, this; + }, C5.prototype.pause = function() { + return p8("call pause flowing=%j", this._readableState.flowing), false !== this._readableState.flowing && (p8("pause"), this._readableState.flowing = false, this.emit("pause")), this._readableState.paused = true, this; + }, C5.prototype.wrap = function(e12) { + var t9 = this, n9 = this._readableState, r10 = false; + for (var i8 in e12.on("end", function() { + if (p8("wrapped end"), n9.decoder && !n9.ended) { + var e13 = n9.decoder.end(); + e13 && e13.length && t9.push(e13); + } + t9.push(null); + }), e12.on("data", function(i9) { + (p8("wrapped data"), n9.decoder && (i9 = n9.decoder.write(i9)), n9.objectMode && null == i9) || (n9.objectMode || i9 && i9.length) && (t9.push(i9) || (r10 = true, e12.pause())); + }), e12) + void 0 === this[i8] && "function" == typeof e12[i8] && (this[i8] = function(t10) { + return function() { + return e12[t10].apply(e12, arguments); + }; + }(i8)); + for (var a8 = 0; a8 < D5.length; a8++) + e12.on(D5[a8], this.emit.bind(this, D5[a8])); + return this._read = function(t10) { + p8("wrapped _read", t10), r10 && (r10 = false, e12.resume()); + }, this; + }, "function" == typeof Symbol && (C5.prototype[Symbol.asyncIterator] = function() { + return void 0 === _5 && (_5 = U$1$1), _5(this); + }), Object.defineProperty(C5.prototype, "readableHighWaterMark", { enumerable: false, get: function() { + return this._readableState.highWaterMark; + } }), Object.defineProperty(C5.prototype, "readableBuffer", { enumerable: false, get: function() { + return this._readableState && this._readableState.buffer; + } }), Object.defineProperty(C5.prototype, "readableFlowing", { enumerable: false, get: function() { + return this._readableState.flowing; + }, set: function(e12) { + this._readableState && (this._readableState.flowing = e12); + } }), C5._fromList = Q4, Object.defineProperty(C5.prototype, "readableLength", { enumerable: false, get: function() { + return this._readableState.length; + } }), "function" == typeof Symbol && (C5.from = function(e12, t9) { + return void 0 === v7 && (v7 = r$1$1), v7(C5, e12, t9); + }), H$1$1; + } + var Y$1$1 = {}; + var K$1$1 = false; + var z$1$1 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + function J$1$1() { + if (K$1$1) + return Y$1$1; + K$1$1 = true; + var e$23, r10 = T; + function s7(e12) { + var t9 = this; + this.next = null, this.entry = null, this.finish = function() { + !function(e13, t10, n9) { + var r11 = e13.entry; + e13.entry = null; + for (; r11; ) { + var i8 = r11.callback; + t10.pendingcb--, i8(n9), r11 = r11.next; + } + t10.corkedRequestsFree.next = e13; + }(t9, e12); + }; + } + Y$1$1 = x5, x5.WritableState = T6; + var l8 = { deprecate: t$1$1 }, d7 = e$g, f9 = e$1$1.Buffer, h9 = z$1$1.Uint8Array || function() { + }; + var c8, b6 = S$1$1, p8 = E$1$1.getHighWaterMark, g6 = e$1$12.codes, y7 = g6.ERR_INVALID_ARG_TYPE, w5 = g6.ERR_METHOD_NOT_IMPLEMENTED, _5 = g6.ERR_MULTIPLE_CALLBACK, v7 = g6.ERR_STREAM_CANNOT_PIPE, m7 = g6.ERR_STREAM_DESTROYED, R5 = g6.ERR_STREAM_NULL_VALUES, k5 = g6.ERR_STREAM_WRITE_AFTER_END, M5 = g6.ERR_UNKNOWN_ENCODING, j5 = b6.errorOrDestroy; + function O6() { + } + function T6(t9, n9, i8) { + e$23 = e$23 || Z$1$1(), t9 = t9 || {}, "boolean" != typeof i8 && (i8 = n9 instanceof e$23), this.objectMode = !!t9.objectMode, i8 && (this.objectMode = this.objectMode || !!t9.writableObjectMode), this.highWaterMark = p8(this, t9, "writableHighWaterMark", i8), this.finalCalled = false, this.needDrain = false, this.ending = false, this.ended = false, this.finished = false, this.destroyed = false; + var a8 = false === t9.decodeStrings; + this.decodeStrings = !a8, this.defaultEncoding = t9.defaultEncoding || "utf8", this.length = 0, this.writing = false, this.corked = 0, this.sync = true, this.bufferProcessing = false, this.onwrite = function(e12) { + !function(e13, t10) { + var n10 = e13._writableState, i9 = n10.sync, a9 = n10.writecb; + if ("function" != typeof a9) + throw new _5(); + if (function(e14) { + e14.writing = false, e14.writecb = null, e14.length -= e14.writelen, e14.writelen = 0; + }(n10), t10) + !function(e14, t11, n11, i10, a10) { + --t11.pendingcb, n11 ? (r10.nextTick(a10, i10), r10.nextTick(W4, e14, t11), e14._writableState.errorEmitted = true, j5(e14, i10)) : (a10(i10), e14._writableState.errorEmitted = true, j5(e14, i10), W4(e14, t11)); + }(e13, n10, i9, t10, a9); + else { + var o9 = C5(n10) || e13.destroyed; + o9 || n10.corked || n10.bufferProcessing || !n10.bufferedRequest || L5(e13, n10), i9 ? r10.nextTick(D5, e13, n10, o9, a9) : D5(e13, n10, o9, a9); + } + }(n9, e12); + }, this.writecb = null, this.writelen = 0, this.bufferedRequest = null, this.lastBufferedRequest = null, this.pendingcb = 0, this.prefinished = false, this.errorEmitted = false, this.emitClose = false !== t9.emitClose, this.autoDestroy = !!t9.autoDestroy, this.bufferedRequestCount = 0, this.corkedRequestsFree = new s7(this); + } + function x5(t9) { + var n9 = this instanceof (e$23 = e$23 || Z$1$1()); + if (!n9 && !c8.call(x5, this)) + return new x5(t9); + this._writableState = new T6(t9, this, n9), this.writable = true, t9 && ("function" == typeof t9.write && (this._write = t9.write), "function" == typeof t9.writev && (this._writev = t9.writev), "function" == typeof t9.destroy && (this._destroy = t9.destroy), "function" == typeof t9.final && (this._final = t9.final)), d7.call(this); + } + function P5(e12, t9, n9, r11, i8, a8, o9) { + t9.writelen = r11, t9.writecb = o9, t9.writing = true, t9.sync = true, t9.destroyed ? t9.onwrite(new m7("write")) : n9 ? e12._writev(i8, t9.onwrite) : e12._write(i8, a8, t9.onwrite), t9.sync = false; + } + function D5(e12, t9, n9, r11) { + n9 || !function(e13, t10) { + 0 === t10.length && t10.needDrain && (t10.needDrain = false, e13.emit("drain")); + }(e12, t9), t9.pendingcb--, r11(), W4(e12, t9); + } + function L5(e12, t9) { + t9.bufferProcessing = true; + var n9 = t9.bufferedRequest; + if (e12._writev && n9 && n9.next) { + var r11 = t9.bufferedRequestCount, i8 = new Array(r11), a8 = t9.corkedRequestsFree; + a8.entry = n9; + for (var o9 = 0, l9 = true; n9; ) + i8[o9] = n9, n9.isBuf || (l9 = false), n9 = n9.next, o9 += 1; + i8.allBuffers = l9, P5(e12, t9, true, t9.length, i8, "", a8.finish), t9.pendingcb++, t9.lastBufferedRequest = null, a8.next ? (t9.corkedRequestsFree = a8.next, a8.next = null) : t9.corkedRequestsFree = new s7(t9), t9.bufferedRequestCount = 0; + } else { + for (; n9; ) { + var d8 = n9.chunk, u8 = n9.encoding, f10 = n9.callback; + if (P5(e12, t9, false, t9.objectMode ? 1 : d8.length, d8, u8, f10), n9 = n9.next, t9.bufferedRequestCount--, t9.writing) + break; + } + null === n9 && (t9.lastBufferedRequest = null); + } + t9.bufferedRequest = n9, t9.bufferProcessing = false; + } + function C5(e12) { + return e12.ending && 0 === e12.length && null === e12.bufferedRequest && !e12.finished && !e12.writing; + } + function A5(e12, t9) { + e12._final(function(n9) { + t9.pendingcb--, n9 && j5(e12, n9), t9.prefinished = true, e12.emit("prefinish"), W4(e12, t9); + }); + } + function W4(e12, t9) { + var n9 = C5(t9); + if (n9 && (!function(e13, t10) { + t10.prefinished || t10.finalCalled || ("function" != typeof e13._final || t10.destroyed ? (t10.prefinished = true, e13.emit("prefinish")) : (t10.pendingcb++, t10.finalCalled = true, r10.nextTick(A5, e13, t10))); + }(e12, t9), 0 === t9.pendingcb && (t9.finished = true, e12.emit("finish"), t9.autoDestroy))) { + var i8 = e12._readableState; + (!i8 || i8.autoDestroy && i8.endEmitted) && e12.destroy(); + } + return n9; + } + return t$2(x5, d7), T6.prototype.getBuffer = function() { + for (var e12 = this.bufferedRequest, t9 = []; e12; ) + t9.push(e12), e12 = e12.next; + return t9; + }, function() { + try { + Object.defineProperty(T6.prototype, "buffer", { get: l8.deprecate(function() { + return this.getBuffer(); + }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003") }); + } catch (e12) { + } + }(), "function" == typeof Symbol && Symbol.hasInstance && "function" == typeof Function.prototype[Symbol.hasInstance] ? (c8 = Function.prototype[Symbol.hasInstance], Object.defineProperty(x5, Symbol.hasInstance, { value: function(e12) { + return !!c8.call(this, e12) || this === x5 && (e12 && e12._writableState instanceof T6); + } })) : c8 = function(e12) { + return e12 instanceof this; + }, x5.prototype.pipe = function() { + j5(this, new v7()); + }, x5.prototype.write = function(e12, t9, n9) { + var i8, a8 = this._writableState, o9 = false, s8 = !a8.objectMode && (i8 = e12, f9.isBuffer(i8) || i8 instanceof h9); + return s8 && !f9.isBuffer(e12) && (e12 = function(e13) { + return f9.from(e13); + }(e12)), "function" == typeof t9 && (n9 = t9, t9 = null), s8 ? t9 = "buffer" : t9 || (t9 = a8.defaultEncoding), "function" != typeof n9 && (n9 = O6), a8.ending ? function(e13, t10) { + var n10 = new k5(); + j5(e13, n10), r10.nextTick(t10, n10); + }(this, n9) : (s8 || function(e13, t10, n10, i9) { + var a9; + return null === n10 ? a9 = new R5() : "string" == typeof n10 || t10.objectMode || (a9 = new y7("chunk", ["string", "Buffer"], n10)), !a9 || (j5(e13, a9), r10.nextTick(i9, a9), false); + }(this, a8, e12, n9)) && (a8.pendingcb++, o9 = function(e13, t10, n10, r11, i9, a9) { + if (!n10) { + var o10 = function(e14, t11, n11) { + e14.objectMode || false === e14.decodeStrings || "string" != typeof t11 || (t11 = f9.from(t11, n11)); + return t11; + }(t10, r11, i9); + r11 !== o10 && (n10 = true, i9 = "buffer", r11 = o10); + } + var s9 = t10.objectMode ? 1 : r11.length; + t10.length += s9; + var l9 = t10.length < t10.highWaterMark; + l9 || (t10.needDrain = true); + if (t10.writing || t10.corked) { + var d8 = t10.lastBufferedRequest; + t10.lastBufferedRequest = { chunk: r11, encoding: i9, isBuf: n10, callback: a9, next: null }, d8 ? d8.next = t10.lastBufferedRequest : t10.bufferedRequest = t10.lastBufferedRequest, t10.bufferedRequestCount += 1; + } else + P5(e13, t10, false, s9, r11, i9, a9); + return l9; + }(this, a8, s8, e12, t9, n9)), o9; + }, x5.prototype.cork = function() { + this._writableState.corked++; + }, x5.prototype.uncork = function() { + var e12 = this._writableState; + e12.corked && (e12.corked--, e12.writing || e12.corked || e12.bufferProcessing || !e12.bufferedRequest || L5(this, e12)); + }, x5.prototype.setDefaultEncoding = function(e12) { + if ("string" == typeof e12 && (e12 = e12.toLowerCase()), !(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((e12 + "").toLowerCase()) > -1)) + throw new M5(e12); + return this._writableState.defaultEncoding = e12, this; + }, Object.defineProperty(x5.prototype, "writableBuffer", { enumerable: false, get: function() { + return this._writableState && this._writableState.getBuffer(); + } }), Object.defineProperty(x5.prototype, "writableHighWaterMark", { enumerable: false, get: function() { + return this._writableState.highWaterMark; + } }), x5.prototype._write = function(e12, t9, n9) { + n9(new w5("_write()")); + }, x5.prototype._writev = null, x5.prototype.end = function(e12, t9, n9) { + var i8 = this._writableState; + return "function" == typeof e12 ? (n9 = e12, e12 = null, t9 = null) : "function" == typeof t9 && (n9 = t9, t9 = null), null != e12 && this.write(e12, t9), i8.corked && (i8.corked = 1, this.uncork()), i8.ending || function(e13, t10, n10) { + t10.ending = true, W4(e13, t10), n10 && (t10.finished ? r10.nextTick(n10) : e13.once("finish", n10)); + t10.ended = true, e13.writable = false; + }(this, i8, n9), this; + }, Object.defineProperty(x5.prototype, "writableLength", { enumerable: false, get: function() { + return this._writableState.length; + } }), Object.defineProperty(x5.prototype, "destroyed", { enumerable: false, get: function() { + return void 0 !== this._writableState && this._writableState.destroyed; + }, set: function(e12) { + this._writableState && (this._writableState.destroyed = e12); + } }), x5.prototype.destroy = b6.destroy, x5.prototype._undestroy = b6.undestroy, x5.prototype._destroy = function(e12, t9) { + t9(e12); + }, Y$1$1; + } + var Q$1$1 = {}; + var X$1$1 = false; + function Z$1$1() { + if (X$1$1) + return Q$1$1; + X$1$1 = true; + var e12 = T, t9 = Object.keys || function(e13) { + var t10 = []; + for (var n10 in e13) + t10.push(n10); + return t10; + }; + Q$1$1 = d7; + var n9 = G$1$1(), r10 = J$1$1(); + t$2(d7, n9); + for (var a8 = t9(r10.prototype), s7 = 0; s7 < a8.length; s7++) { + var l8 = a8[s7]; + d7.prototype[l8] || (d7.prototype[l8] = r10.prototype[l8]); + } + function d7(e13) { + if (!(this instanceof d7)) + return new d7(e13); + n9.call(this, e13), r10.call(this, e13), this.allowHalfOpen = true, e13 && (false === e13.readable && (this.readable = false), false === e13.writable && (this.writable = false), false === e13.allowHalfOpen && (this.allowHalfOpen = false, this.once("end", u8))); + } + function u8() { + this._writableState.ended || e12.nextTick(f9, this); + } + function f9(e13) { + e13.end(); + } + return Object.defineProperty(d7.prototype, "writableHighWaterMark", { enumerable: false, get: function() { + return this._writableState.highWaterMark; + } }), Object.defineProperty(d7.prototype, "writableBuffer", { enumerable: false, get: function() { + return this._writableState && this._writableState.getBuffer(); + } }), Object.defineProperty(d7.prototype, "writableLength", { enumerable: false, get: function() { + return this._writableState.length; + } }), Object.defineProperty(d7.prototype, "destroyed", { enumerable: false, get: function() { + return void 0 !== this._readableState && void 0 !== this._writableState && (this._readableState.destroyed && this._writableState.destroyed); + }, set: function(e13) { + void 0 !== this._readableState && void 0 !== this._writableState && (this._readableState.destroyed = e13, this._writableState.destroyed = e13); + } }), Q$1$1; + } + var t$4$1 = J$1$1(); + var t$5$1 = ee$1(); + var n$2$1; + n$2$1 = u$1$12; + var i$e = e$1$12.codes; + var a$p = i$e.ERR_METHOD_NOT_IMPLEMENTED; + var o$s = i$e.ERR_MULTIPLE_CALLBACK; + var s$q = i$e.ERR_TRANSFORM_ALREADY_TRANSFORMING; + var f$2$1 = i$e.ERR_TRANSFORM_WITH_LENGTH_0; + var h$2$1 = t$5$1; + function l$s(t9, r10) { + var e12 = this._transformState; + e12.transforming = false; + var n9 = e12.writecb; + if (null === n9) + return this.emit("error", new o$s()); + e12.writechunk = null, e12.writecb = null, null != r10 && this.push(r10), n9(t9); + var i8 = this._readableState; + i8.reading = false, (i8.needReadable || i8.length < i8.highWaterMark) && this._read(i8.highWaterMark); + } + function u$1$12(t9) { + if (!(this instanceof u$1$12)) + return new u$1$12(t9); + h$2$1.call(this, t9), this._transformState = { afterTransform: l$s.bind(this), needTransform: false, transforming: false, writecb: null, writechunk: null, writeencoding: null }, this._readableState.needReadable = true, this._readableState.sync = false, t9 && ("function" == typeof t9.transform && (this._transform = t9.transform), "function" == typeof t9.flush && (this._flush = t9.flush)), this.on("prefinish", m$2$1); + } + function m$2$1() { + var t9 = this; + "function" != typeof this._flush || this._readableState.destroyed ? _$2$1(this, null, null) : this._flush(function(r10, e12) { + _$2$1(t9, r10, e12); + }); + } + function _$2$1(t9, r10, e12) { + if (r10) + return t9.emit("error", r10); + if (null != e12 && t9.push(e12), t9._writableState.length) + throw new f$2$1(); + if (t9._transformState.transforming) + throw new s$q(); + return t9.push(null); + } + t$2(u$1$12, h$2$1), u$1$12.prototype.push = function(t9, r10) { + return this._transformState.needTransform = false, h$2$1.prototype.push.call(this, t9, r10); + }, u$1$12.prototype._transform = function(t9, r10, e12) { + e12(new a$p("_transform()")); + }, u$1$12.prototype._write = function(t9, r10, e12) { + var n9 = this._transformState; + if (n9.writecb = e12, n9.writechunk = t9, n9.writeencoding = r10, !n9.transforming) { + var i8 = this._readableState; + (n9.needTransform || i8.needReadable || i8.length < i8.highWaterMark) && this._read(i8.highWaterMark); + } + }, u$1$12.prototype._read = function(t9) { + var r10 = this._transformState; + null === r10.writechunk || r10.transforming ? r10.needTransform = true : (r10.transforming = true, this._transform(r10.writechunk, r10.writeencoding, r10.afterTransform)); + }, u$1$12.prototype._destroy = function(t9, r10) { + h$2$1.prototype._destroy.call(this, t9, function(t10) { + r10(t10); + }); + }; + var p$2$1 = n$2$1; + var o$1$12; + o$1$12 = i$1$1; + var e$3$1 = p$2$1; + function i$1$1(r10) { + if (!(this instanceof i$1$1)) + return new i$1$1(r10); + e$3$1.call(this, r10); + } + t$2(i$1$1, e$3$1), i$1$1.prototype._transform = function(r10, t9, o9) { + o9(null, r10); + }; + var s$1$1 = o$1$12; + var t$6$1; + var o$2$1 = e$1$12.codes; + var e$4$1 = o$2$1.ERR_MISSING_ARGS; + var f$3$1 = o$2$1.ERR_STREAM_DESTROYED; + function i$2$1(r10) { + if (r10) + throw r10; + } + function u$2$1(r10, o9, e12, i8) { + i8 = function(r11) { + var n9 = false; + return function() { + n9 || (n9 = true, r11.apply(void 0, arguments)); + }; + }(i8); + var u8 = false; + r10.on("close", function() { + u8 = true; + }), void 0 === t$6$1 && (t$6$1 = n$1$12), t$6$1(r10, { readable: o9, writable: e12 }, function(r11) { + if (r11) + return i8(r11); + u8 = true, i8(); + }); + var a8 = false; + return function(n9) { + if (!u8 && !a8) + return a8 = true, function(r11) { + return r11.setHeader && "function" == typeof r11.abort; + }(r10) ? r10.abort() : "function" == typeof r10.destroy ? r10.destroy() : (i8(n9 || new f$3$1("pipe")), void 0); + }; + } + function a$1$12(r10) { + r10(); + } + function c$2$1(r10, n9) { + return r10.pipe(n9); + } + function p$3$1(r10) { + return r10.length ? "function" != typeof r10[r10.length - 1] ? i$2$1 : r10.pop() : i$2$1; + } + var v$2$1 = function() { + for (var r10 = arguments.length, n9 = new Array(r10), t9 = 0; t9 < r10; t9++) + n9[t9] = arguments[t9]; + var o9, f9 = p$3$1(n9); + if (Array.isArray(n9[0]) && (n9 = n9[0]), n9.length < 2) + throw new e$4$1("streams"); + var i8 = n9.map(function(r11, t10) { + var e12 = t10 < n9.length - 1; + return u$2$1(r11, e12, t10 > 0, function(r12) { + o9 || (o9 = r12), r12 && i8.forEach(a$1$12), e12 || (i8.forEach(a$1$12), f9(o9)); + }); + }); + return n9.reduce(c$2$1); + }; + var l$r; + var d$n = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + l$r = p$r; + var f$u = y.EventEmitter; + function p$r() { + f$u.call(this || d$n); + } + t$2(p$r, f$u), p$r.Readable = t$2$1, p$r.Writable = t$4$1, p$r.Duplex = t$5$1, p$r.Transform = p$2$1, p$r.PassThrough = s$1$1, p$r.finished = n$1$12, p$r.pipeline = v$2$1, p$r.Stream = p$r, p$r.prototype.pipe = function(e12, r10) { + var t9 = this || d$n; + function o9(r11) { + e12.writable && false === e12.write(r11) && t9.pause && t9.pause(); + } + function i8() { + t9.readable && t9.resume && t9.resume(); + } + t9.on("data", o9), e12.on("drain", i8), e12._isStdio || r10 && false === r10.end || (t9.on("end", a8), t9.on("close", s7)); + var n9 = false; + function a8() { + n9 || (n9 = true, e12.end()); + } + function s7() { + n9 || (n9 = true, "function" == typeof e12.destroy && e12.destroy()); + } + function m7(e13) { + if (l8(), 0 === f$u.listenerCount(this || d$n, "error")) + throw e13; + } + function l8() { + t9.removeListener("data", o9), e12.removeListener("drain", i8), t9.removeListener("end", a8), t9.removeListener("close", s7), t9.removeListener("error", m7), e12.removeListener("error", m7), t9.removeListener("end", l8), t9.removeListener("close", l8), e12.removeListener("close", l8); + } + return t9.on("error", m7), e12.on("error", m7), t9.on("end", l8), t9.on("close", l8), e12.on("close", l8), e12.emit("pipe", t9), e12; + }; + var b$i = l$r; + b$i.Readable; + b$i.Writable; + b$i.Duplex; + b$i.Transform; + b$i.PassThrough; + b$i.finished; + b$i.pipeline; + b$i.Stream; + var exports$1H = {}; + var _dewExec$1G = false; + var _global$o = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1G() { + if (_dewExec$1G) + return exports$1H; + _dewExec$1G = true; + var Buffer2 = dew$1T().Buffer; + var Transform2 = b$i.Transform; + var StringDecoder = e$12.StringDecoder; + var inherits3 = dew$f$2(); + function CipherBase(hashMode) { + Transform2.call(this || _global$o); + (this || _global$o).hashMode = typeof hashMode === "string"; + if ((this || _global$o).hashMode) { + (this || _global$o)[hashMode] = (this || _global$o)._finalOrDigest; + } else { + (this || _global$o).final = (this || _global$o)._finalOrDigest; + } + if ((this || _global$o)._final) { + (this || _global$o).__final = (this || _global$o)._final; + (this || _global$o)._final = null; + } + (this || _global$o)._decoder = null; + (this || _global$o)._encoding = null; + } + inherits3(CipherBase, Transform2); + CipherBase.prototype.update = function(data, inputEnc, outputEnc) { + if (typeof data === "string") { + data = Buffer2.from(data, inputEnc); + } + var outData = this._update(data); + if ((this || _global$o).hashMode) + return this || _global$o; + if (outputEnc) { + outData = this._toString(outData, outputEnc); + } + return outData; + }; + CipherBase.prototype.setAutoPadding = function() { + }; + CipherBase.prototype.getAuthTag = function() { + throw new Error("trying to get auth tag in unsupported state"); + }; + CipherBase.prototype.setAuthTag = function() { + throw new Error("trying to set auth tag in unsupported state"); + }; + CipherBase.prototype.setAAD = function() { + throw new Error("trying to set aad in unsupported state"); + }; + CipherBase.prototype._transform = function(data, _5, next) { + var err; + try { + if ((this || _global$o).hashMode) { + this._update(data); + } else { + this.push(this._update(data)); + } + } catch (e12) { + err = e12; + } finally { + next(err); + } + }; + CipherBase.prototype._flush = function(done) { + var err; + try { + this.push(this.__final()); + } catch (e12) { + err = e12; + } + done(err); + }; + CipherBase.prototype._finalOrDigest = function(outputEnc) { + var outData = this.__final() || Buffer2.alloc(0); + if (outputEnc) { + outData = this._toString(outData, outputEnc, true); + } + return outData; + }; + CipherBase.prototype._toString = function(value, enc, fin) { + if (!(this || _global$o)._decoder) { + (this || _global$o)._decoder = new StringDecoder(enc); + (this || _global$o)._encoding = enc; + } + if ((this || _global$o)._encoding !== enc) + throw new Error("can't switch encodings"); + var out = (this || _global$o)._decoder.write(value); + if (fin) { + out += (this || _global$o)._decoder.end(); + } + return out; + }; + exports$1H = CipherBase; + return exports$1H; + } + var exports$1G = {}; + var _dewExec$1F = false; + function dew$1F() { + if (_dewExec$1F) + return exports$1G; + _dewExec$1F = true; + var inherits3 = dew$f$2(); + var MD5 = dew$1Q(); + var RIPEMD160 = dew$1P(); + var sha3 = dew$1H(); + var Base2 = dew$1G(); + function Hash2(hash) { + Base2.call(this, "digest"); + this._hash = hash; + } + inherits3(Hash2, Base2); + Hash2.prototype._update = function(data) { + this._hash.update(data); + }; + Hash2.prototype._final = function() { + return this._hash.digest(); + }; + exports$1G = function createHash2(alg) { + alg = alg.toLowerCase(); + if (alg === "md5") + return new MD5(); + if (alg === "rmd160" || alg === "ripemd160") + return new RIPEMD160(); + return new Hash2(sha3(alg)); + }; + return exports$1G; + } + var exports$1F = {}; + var _dewExec$1E = false; + function dew$1E() { + if (_dewExec$1E) + return exports$1F; + _dewExec$1E = true; + var inherits3 = dew$f$2(); + var Buffer2 = dew$1T().Buffer; + var Base2 = dew$1G(); + var ZEROS = Buffer2.alloc(128); + var blocksize = 64; + function Hmac2(alg, key) { + Base2.call(this, "digest"); + if (typeof key === "string") { + key = Buffer2.from(key); + } + this._alg = alg; + this._key = key; + if (key.length > blocksize) { + key = alg(key); + } else if (key.length < blocksize) { + key = Buffer2.concat([key, ZEROS], blocksize); + } + var ipad = this._ipad = Buffer2.allocUnsafe(blocksize); + var opad = this._opad = Buffer2.allocUnsafe(blocksize); + for (var i8 = 0; i8 < blocksize; i8++) { + ipad[i8] = key[i8] ^ 54; + opad[i8] = key[i8] ^ 92; + } + this._hash = [ipad]; + } + inherits3(Hmac2, Base2); + Hmac2.prototype._update = function(data) { + this._hash.push(data); + }; + Hmac2.prototype._final = function() { + var h9 = this._alg(Buffer2.concat(this._hash)); + return this._alg(Buffer2.concat([this._opad, h9])); + }; + exports$1F = Hmac2; + return exports$1F; + } + var exports$1E = {}; + var _dewExec$1D = false; + function dew$1D() { + if (_dewExec$1D) + return exports$1E; + _dewExec$1D = true; + var MD5 = dew$1Q(); + exports$1E = function(buffer4) { + return new MD5().update(buffer4).digest(); + }; + return exports$1E; + } + var exports$1D = {}; + var _dewExec$1C = false; + function dew$1C() { + if (_dewExec$1C) + return exports$1D; + _dewExec$1C = true; + var inherits3 = dew$f$2(); + var Legacy = dew$1E(); + var Base2 = dew$1G(); + var Buffer2 = dew$1T().Buffer; + var md5 = dew$1D(); + var RIPEMD160 = dew$1P(); + var sha3 = dew$1H(); + var ZEROS = Buffer2.alloc(128); + function Hmac2(alg, key) { + Base2.call(this, "digest"); + if (typeof key === "string") { + key = Buffer2.from(key); + } + var blocksize = alg === "sha512" || alg === "sha384" ? 128 : 64; + this._alg = alg; + this._key = key; + if (key.length > blocksize) { + var hash = alg === "rmd160" ? new RIPEMD160() : sha3(alg); + key = hash.update(key).digest(); + } else if (key.length < blocksize) { + key = Buffer2.concat([key, ZEROS], blocksize); + } + var ipad = this._ipad = Buffer2.allocUnsafe(blocksize); + var opad = this._opad = Buffer2.allocUnsafe(blocksize); + for (var i8 = 0; i8 < blocksize; i8++) { + ipad[i8] = key[i8] ^ 54; + opad[i8] = key[i8] ^ 92; + } + this._hash = alg === "rmd160" ? new RIPEMD160() : sha3(alg); + this._hash.update(ipad); + } + inherits3(Hmac2, Base2); + Hmac2.prototype._update = function(data) { + this._hash.update(data); + }; + Hmac2.prototype._final = function() { + var h9 = this._hash.digest(); + var hash = this._alg === "rmd160" ? new RIPEMD160() : sha3(this._alg); + return hash.update(this._opad).update(h9).digest(); + }; + exports$1D = function createHmac2(alg, key) { + alg = alg.toLowerCase(); + if (alg === "rmd160" || alg === "ripemd160") { + return new Hmac2("rmd160", key); + } + if (alg === "md5") { + return new Legacy(md5, key); + } + return new Hmac2(alg, key); + }; + return exports$1D; + } + var _algorithms = { + "sha224WithRSAEncryption": { + "sign": "rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "RSA-SHA224": { + "sign": "ecdsa/rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "sha256WithRSAEncryption": { + "sign": "rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "RSA-SHA256": { + "sign": "ecdsa/rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "sha384WithRSAEncryption": { + "sign": "rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "RSA-SHA384": { + "sign": "ecdsa/rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "sha512WithRSAEncryption": { + "sign": "rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA512": { + "sign": "ecdsa/rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA1": { + "sign": "rsa", + "hash": "sha1", + "id": "3021300906052b0e03021a05000414" + }, + "ecdsa-with-SHA1": { + "sign": "ecdsa", + "hash": "sha1", + "id": "" + }, + "sha256": { + "sign": "ecdsa", + "hash": "sha256", + "id": "" + }, + "sha224": { + "sign": "ecdsa", + "hash": "sha224", + "id": "" + }, + "sha384": { + "sign": "ecdsa", + "hash": "sha384", + "id": "" + }, + "sha512": { + "sign": "ecdsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-SHA1": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-WITH-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-WITH-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-WITH-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-WITH-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-RIPEMD160": { + "sign": "dsa", + "hash": "rmd160", + "id": "" + }, + "ripemd160WithRSA": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "RSA-RIPEMD160": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "md5WithRSAEncryption": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + }, + "RSA-MD5": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + } + }; + var exports$1C = {}; + var _dewExec$1B = false; + function dew$1B() { + if (_dewExec$1B) + return exports$1C; + _dewExec$1B = true; + exports$1C = _algorithms; + return exports$1C; + } + var exports$1B = {}; + var _dewExec$1A = false; + function dew$1A() { + if (_dewExec$1A) + return exports$1B; + _dewExec$1A = true; + var MAX_ALLOC = Math.pow(2, 30) - 1; + exports$1B = function(iterations, keylen) { + if (typeof iterations !== "number") { + throw new TypeError("Iterations not a number"); + } + if (iterations < 0) { + throw new TypeError("Bad iterations"); + } + if (typeof keylen !== "number") { + throw new TypeError("Key length not a number"); + } + if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { + throw new TypeError("Bad key length"); + } + }; + return exports$1B; + } + var exports$1A = {}; + var _dewExec$1z = false; + var _global$n = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1z() { + if (_dewExec$1z) + return exports$1A; + _dewExec$1z = true; + var process3 = T; + var defaultEncoding; + if (_global$n.process && _global$n.process.browser) { + defaultEncoding = "utf-8"; + } else if (_global$n.process && _global$n.process.version) { + var pVersionMajor = parseInt(process3.version.split(".")[0].slice(1), 10); + defaultEncoding = pVersionMajor >= 6 ? "utf-8" : "binary"; + } else { + defaultEncoding = "utf-8"; + } + exports$1A = defaultEncoding; + return exports$1A; + } + var exports$1z = {}; + var _dewExec$1y = false; + function dew$1y() { + if (_dewExec$1y) + return exports$1z; + _dewExec$1y = true; + var Buffer2 = dew$1T().Buffer; + exports$1z = function(thing, encoding, name15) { + if (Buffer2.isBuffer(thing)) { + return thing; + } else if (typeof thing === "string") { + return Buffer2.from(thing, encoding); + } else if (ArrayBuffer.isView(thing)) { + return Buffer2.from(thing.buffer); + } else { + throw new TypeError(name15 + " must be a string, a Buffer, a typed array or a DataView"); + } + }; + return exports$1z; + } + var exports$1y = {}; + var _dewExec$1x = false; + var _global$m = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1x() { + if (_dewExec$1x) + return exports$1y; + _dewExec$1x = true; + var md5 = dew$1D(); + var RIPEMD160 = dew$1P(); + var sha3 = dew$1H(); + var Buffer2 = dew$1T().Buffer; + var checkParameters = dew$1A(); + var defaultEncoding = dew$1z(); + var toBuffer = dew$1y(); + var ZEROS = Buffer2.alloc(128); + var sizes = { + md5: 16, + sha1: 20, + sha224: 28, + sha256: 32, + sha384: 48, + sha512: 64, + rmd160: 20, + ripemd160: 20 + }; + function Hmac2(alg, key, saltLen) { + var hash = getDigest(alg); + var blocksize = alg === "sha512" || alg === "sha384" ? 128 : 64; + if (key.length > blocksize) { + key = hash(key); + } else if (key.length < blocksize) { + key = Buffer2.concat([key, ZEROS], blocksize); + } + var ipad = Buffer2.allocUnsafe(blocksize + sizes[alg]); + var opad = Buffer2.allocUnsafe(blocksize + sizes[alg]); + for (var i8 = 0; i8 < blocksize; i8++) { + ipad[i8] = key[i8] ^ 54; + opad[i8] = key[i8] ^ 92; + } + var ipad1 = Buffer2.allocUnsafe(blocksize + saltLen + 4); + ipad.copy(ipad1, 0, 0, blocksize); + (this || _global$m).ipad1 = ipad1; + (this || _global$m).ipad2 = ipad; + (this || _global$m).opad = opad; + (this || _global$m).alg = alg; + (this || _global$m).blocksize = blocksize; + (this || _global$m).hash = hash; + (this || _global$m).size = sizes[alg]; + } + Hmac2.prototype.run = function(data, ipad) { + data.copy(ipad, (this || _global$m).blocksize); + var h9 = this.hash(ipad); + h9.copy((this || _global$m).opad, (this || _global$m).blocksize); + return this.hash((this || _global$m).opad); + }; + function getDigest(alg) { + function shaFunc(data) { + return sha3(alg).update(data).digest(); + } + function rmd160Func(data) { + return new RIPEMD160().update(data).digest(); + } + if (alg === "rmd160" || alg === "ripemd160") + return rmd160Func; + if (alg === "md5") + return md5; + return shaFunc; + } + function pbkdf22(password, salt, iterations, keylen, digest3) { + checkParameters(iterations, keylen); + password = toBuffer(password, defaultEncoding, "Password"); + salt = toBuffer(salt, defaultEncoding, "Salt"); + digest3 = digest3 || "sha1"; + var hmac = new Hmac2(digest3, password, salt.length); + var DK = Buffer2.allocUnsafe(keylen); + var block1 = Buffer2.allocUnsafe(salt.length + 4); + salt.copy(block1, 0, 0, salt.length); + var destPos = 0; + var hLen = sizes[digest3]; + var l8 = Math.ceil(keylen / hLen); + for (var i8 = 1; i8 <= l8; i8++) { + block1.writeUInt32BE(i8, salt.length); + var T6 = hmac.run(block1, hmac.ipad1); + var U5 = T6; + for (var j5 = 1; j5 < iterations; j5++) { + U5 = hmac.run(U5, hmac.ipad2); + for (var k5 = 0; k5 < hLen; k5++) + T6[k5] ^= U5[k5]; + } + T6.copy(DK, destPos); + destPos += hLen; + } + return DK; + } + exports$1y = pbkdf22; + return exports$1y; + } + var exports$1x = {}; + var _dewExec$1w = false; + var _global$l = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1w() { + if (_dewExec$1w) + return exports$1x; + _dewExec$1w = true; + var Buffer2 = dew$1T().Buffer; + var checkParameters = dew$1A(); + var defaultEncoding = dew$1z(); + var sync = dew$1x(); + var toBuffer = dew$1y(); + var ZERO_BUF; + var subtle = _global$l.crypto && _global$l.crypto.subtle; + var toBrowser = { + sha: "SHA-1", + "sha-1": "SHA-1", + sha1: "SHA-1", + sha256: "SHA-256", + "sha-256": "SHA-256", + sha384: "SHA-384", + "sha-384": "SHA-384", + "sha-512": "SHA-512", + sha512: "SHA-512" + }; + var checks = []; + function checkNative(algo) { + if (_global$l.process && !_global$l.process.browser) { + return Promise.resolve(false); + } + if (!subtle || !subtle.importKey || !subtle.deriveBits) { + return Promise.resolve(false); + } + if (checks[algo] !== void 0) { + return checks[algo]; + } + ZERO_BUF = ZERO_BUF || Buffer2.alloc(8); + var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo).then(function() { + return true; + }).catch(function() { + return false; + }); + checks[algo] = prom; + return prom; + } + var nextTick; + function getNextTick() { + if (nextTick) { + return nextTick; + } + if (_global$l.process && _global$l.process.nextTick) { + nextTick = _global$l.process.nextTick; + } else if (_global$l.queueMicrotask) { + nextTick = _global$l.queueMicrotask; + } else if (_global$l.setImmediate) { + nextTick = _global$l.setImmediate; + } else { + nextTick = _global$l.setTimeout; + } + return nextTick; + } + function browserPbkdf2(password, salt, iterations, length3, algo) { + return subtle.importKey("raw", password, { + name: "PBKDF2" + }, false, ["deriveBits"]).then(function(key) { + return subtle.deriveBits({ + name: "PBKDF2", + salt, + iterations, + hash: { + name: algo + } + }, key, length3 << 3); + }).then(function(res) { + return Buffer2.from(res); + }); + } + function resolvePromise(promise, callback) { + promise.then(function(out) { + getNextTick()(function() { + callback(null, out); + }); + }, function(e12) { + getNextTick()(function() { + callback(e12); + }); + }); + } + exports$1x = function(password, salt, iterations, keylen, digest3, callback) { + if (typeof digest3 === "function") { + callback = digest3; + digest3 = void 0; + } + digest3 = digest3 || "sha1"; + var algo = toBrowser[digest3.toLowerCase()]; + if (!algo || typeof _global$l.Promise !== "function") { + getNextTick()(function() { + var out; + try { + out = sync(password, salt, iterations, keylen, digest3); + } catch (e12) { + return callback(e12); + } + callback(null, out); + }); + return; + } + checkParameters(iterations, keylen); + password = toBuffer(password, defaultEncoding, "Password"); + salt = toBuffer(salt, defaultEncoding, "Salt"); + if (typeof callback !== "function") + throw new Error("No callback provided to pbkdf2"); + resolvePromise(checkNative(algo).then(function(resp) { + if (resp) + return browserPbkdf2(password, salt, iterations, keylen, algo); + return sync(password, salt, iterations, keylen, digest3); + }), callback); + }; + return exports$1x; + } + var exports$1w = {}; + var _dewExec$1v = false; + function dew$1v() { + if (_dewExec$1v) + return exports$1w; + _dewExec$1v = true; + exports$1w.pbkdf2 = dew$1w(); + exports$1w.pbkdf2Sync = dew$1x(); + return exports$1w; + } + var exports$1v = {}; + var _dewExec$1u = false; + function dew$1u() { + if (_dewExec$1u) + return exports$1v; + _dewExec$1u = true; + exports$1v.readUInt32BE = function readUInt32BE(bytes2, off) { + var res = bytes2[0 + off] << 24 | bytes2[1 + off] << 16 | bytes2[2 + off] << 8 | bytes2[3 + off]; + return res >>> 0; + }; + exports$1v.writeUInt32BE = function writeUInt32BE(bytes2, value, off) { + bytes2[0 + off] = value >>> 24; + bytes2[1 + off] = value >>> 16 & 255; + bytes2[2 + off] = value >>> 8 & 255; + bytes2[3 + off] = value & 255; + }; + exports$1v.ip = function ip(inL, inR, out, off) { + var outL = 0; + var outR = 0; + for (var i8 = 6; i8 >= 0; i8 -= 2) { + for (var j5 = 0; j5 <= 24; j5 += 8) { + outL <<= 1; + outL |= inR >>> j5 + i8 & 1; + } + for (var j5 = 0; j5 <= 24; j5 += 8) { + outL <<= 1; + outL |= inL >>> j5 + i8 & 1; + } + } + for (var i8 = 6; i8 >= 0; i8 -= 2) { + for (var j5 = 1; j5 <= 25; j5 += 8) { + outR <<= 1; + outR |= inR >>> j5 + i8 & 1; + } + for (var j5 = 1; j5 <= 25; j5 += 8) { + outR <<= 1; + outR |= inL >>> j5 + i8 & 1; + } + } + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + exports$1v.rip = function rip(inL, inR, out, off) { + var outL = 0; + var outR = 0; + for (var i8 = 0; i8 < 4; i8++) { + for (var j5 = 24; j5 >= 0; j5 -= 8) { + outL <<= 1; + outL |= inR >>> j5 + i8 & 1; + outL <<= 1; + outL |= inL >>> j5 + i8 & 1; + } + } + for (var i8 = 4; i8 < 8; i8++) { + for (var j5 = 24; j5 >= 0; j5 -= 8) { + outR <<= 1; + outR |= inR >>> j5 + i8 & 1; + outR <<= 1; + outR |= inL >>> j5 + i8 & 1; + } + } + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + exports$1v.pc1 = function pc1(inL, inR, out, off) { + var outL = 0; + var outR = 0; + for (var i8 = 7; i8 >= 5; i8--) { + for (var j5 = 0; j5 <= 24; j5 += 8) { + outL <<= 1; + outL |= inR >> j5 + i8 & 1; + } + for (var j5 = 0; j5 <= 24; j5 += 8) { + outL <<= 1; + outL |= inL >> j5 + i8 & 1; + } + } + for (var j5 = 0; j5 <= 24; j5 += 8) { + outL <<= 1; + outL |= inR >> j5 + i8 & 1; + } + for (var i8 = 1; i8 <= 3; i8++) { + for (var j5 = 0; j5 <= 24; j5 += 8) { + outR <<= 1; + outR |= inR >> j5 + i8 & 1; + } + for (var j5 = 0; j5 <= 24; j5 += 8) { + outR <<= 1; + outR |= inL >> j5 + i8 & 1; + } + } + for (var j5 = 0; j5 <= 24; j5 += 8) { + outR <<= 1; + outR |= inL >> j5 + i8 & 1; + } + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + exports$1v.r28shl = function r28shl(num, shift) { + return num << shift & 268435455 | num >>> 28 - shift; + }; + var pc2table = [ + // inL => outL + 14, + 11, + 17, + 4, + 27, + 23, + 25, + 0, + 13, + 22, + 7, + 18, + 5, + 9, + 16, + 24, + 2, + 20, + 12, + 21, + 1, + 8, + 15, + 26, + // inR => outR + 15, + 4, + 25, + 19, + 9, + 1, + 26, + 16, + 5, + 11, + 23, + 8, + 12, + 7, + 17, + 0, + 22, + 3, + 10, + 14, + 6, + 20, + 27, + 24 + ]; + exports$1v.pc2 = function pc2(inL, inR, out, off) { + var outL = 0; + var outR = 0; + var len = pc2table.length >>> 1; + for (var i8 = 0; i8 < len; i8++) { + outL <<= 1; + outL |= inL >>> pc2table[i8] & 1; + } + for (var i8 = len; i8 < pc2table.length; i8++) { + outR <<= 1; + outR |= inR >>> pc2table[i8] & 1; + } + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + exports$1v.expand = function expand(r10, out, off) { + var outL = 0; + var outR = 0; + outL = (r10 & 1) << 5 | r10 >>> 27; + for (var i8 = 23; i8 >= 15; i8 -= 4) { + outL <<= 6; + outL |= r10 >>> i8 & 63; + } + for (var i8 = 11; i8 >= 3; i8 -= 4) { + outR |= r10 >>> i8 & 63; + outR <<= 6; + } + outR |= (r10 & 31) << 1 | r10 >>> 31; + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; + }; + var sTable = [14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11]; + exports$1v.substitute = function substitute(inL, inR) { + var out = 0; + for (var i8 = 0; i8 < 4; i8++) { + var b6 = inL >>> 18 - i8 * 6 & 63; + var sb = sTable[i8 * 64 + b6]; + out <<= 4; + out |= sb; + } + for (var i8 = 0; i8 < 4; i8++) { + var b6 = inR >>> 18 - i8 * 6 & 63; + var sb = sTable[4 * 64 + i8 * 64 + b6]; + out <<= 4; + out |= sb; + } + return out >>> 0; + }; + var permuteTable = [16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7]; + exports$1v.permute = function permute(num) { + var out = 0; + for (var i8 = 0; i8 < permuteTable.length; i8++) { + out <<= 1; + out |= num >>> permuteTable[i8] & 1; + } + return out >>> 0; + }; + exports$1v.padSplit = function padSplit(num, size4, group2) { + var str = num.toString(2); + while (str.length < size4) + str = "0" + str; + var out = []; + for (var i8 = 0; i8 < size4; i8 += group2) + out.push(str.slice(i8, i8 + group2)); + return out.join(" "); + }; + return exports$1v; + } + var exports$1u = {}; + var _dewExec$1t = false; + function dew$1t() { + if (_dewExec$1t) + return exports$1u; + _dewExec$1t = true; + exports$1u = assert; + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + assert.equal = function assertEqual(l8, r10, msg) { + if (l8 != r10) + throw new Error(msg || "Assertion failed: " + l8 + " != " + r10); + }; + return exports$1u; + } + var exports$1t = {}; + var _dewExec$1s = false; + function dew$1s() { + if (_dewExec$1s) + return exports$1t; + _dewExec$1s = true; + var assert = dew$1t(); + function Cipher2(options) { + this.options = options; + this.type = this.options.type; + this.blockSize = 8; + this._init(); + this.buffer = new Array(this.blockSize); + this.bufferOff = 0; + } + exports$1t = Cipher2; + Cipher2.prototype._init = function _init() { + }; + Cipher2.prototype.update = function update2(data) { + if (data.length === 0) + return []; + if (this.type === "decrypt") + return this._updateDecrypt(data); + else + return this._updateEncrypt(data); + }; + Cipher2.prototype._buffer = function _buffer(data, off) { + var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); + for (var i8 = 0; i8 < min; i8++) + this.buffer[this.bufferOff + i8] = data[off + i8]; + this.bufferOff += min; + return min; + }; + Cipher2.prototype._flushBuffer = function _flushBuffer(out, off) { + this._update(this.buffer, 0, out, off); + this.bufferOff = 0; + return this.blockSize; + }; + Cipher2.prototype._updateEncrypt = function _updateEncrypt(data) { + var inputOff = 0; + var outputOff = 0; + var count = (this.bufferOff + data.length) / this.blockSize | 0; + var out = new Array(count * this.blockSize); + if (this.bufferOff !== 0) { + inputOff += this._buffer(data, inputOff); + if (this.bufferOff === this.buffer.length) + outputOff += this._flushBuffer(out, outputOff); + } + var max = data.length - (data.length - inputOff) % this.blockSize; + for (; inputOff < max; inputOff += this.blockSize) { + this._update(data, inputOff, out, outputOff); + outputOff += this.blockSize; + } + for (; inputOff < data.length; inputOff++, this.bufferOff++) + this.buffer[this.bufferOff] = data[inputOff]; + return out; + }; + Cipher2.prototype._updateDecrypt = function _updateDecrypt(data) { + var inputOff = 0; + var outputOff = 0; + var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; + var out = new Array(count * this.blockSize); + for (; count > 0; count--) { + inputOff += this._buffer(data, inputOff); + outputOff += this._flushBuffer(out, outputOff); + } + inputOff += this._buffer(data, inputOff); + return out; + }; + Cipher2.prototype.final = function final(buffer4) { + var first; + if (buffer4) + first = this.update(buffer4); + var last2; + if (this.type === "encrypt") + last2 = this._finalEncrypt(); + else + last2 = this._finalDecrypt(); + if (first) + return first.concat(last2); + else + return last2; + }; + Cipher2.prototype._pad = function _pad(buffer4, off) { + if (off === 0) + return false; + while (off < buffer4.length) + buffer4[off++] = 0; + return true; + }; + Cipher2.prototype._finalEncrypt = function _finalEncrypt() { + if (!this._pad(this.buffer, this.bufferOff)) + return []; + var out = new Array(this.blockSize); + this._update(this.buffer, 0, out, 0); + return out; + }; + Cipher2.prototype._unpad = function _unpad(buffer4) { + return buffer4; + }; + Cipher2.prototype._finalDecrypt = function _finalDecrypt() { + assert.equal(this.bufferOff, this.blockSize, "Not enough data to decrypt"); + var out = new Array(this.blockSize); + this._flushBuffer(out, 0); + return this._unpad(out); + }; + return exports$1t; + } + var exports$1s = {}; + var _dewExec$1r = false; + function dew$1r() { + if (_dewExec$1r) + return exports$1s; + _dewExec$1r = true; + var assert = dew$1t(); + var inherits3 = dew$f$2(); + var utils2 = dew$1u(); + var Cipher2 = dew$1s(); + function DESState() { + this.tmp = new Array(2); + this.keys = null; + } + function DES(options) { + Cipher2.call(this, options); + var state = new DESState(); + this._desState = state; + this.deriveKeys(state, options.key); + } + inherits3(DES, Cipher2); + exports$1s = DES; + DES.create = function create21(options) { + return new DES(options); + }; + var shiftTable = [1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1]; + DES.prototype.deriveKeys = function deriveKeys(state, key) { + state.keys = new Array(16 * 2); + assert.equal(key.length, this.blockSize, "Invalid key length"); + var kL = utils2.readUInt32BE(key, 0); + var kR = utils2.readUInt32BE(key, 4); + utils2.pc1(kL, kR, state.tmp, 0); + kL = state.tmp[0]; + kR = state.tmp[1]; + for (var i8 = 0; i8 < state.keys.length; i8 += 2) { + var shift = shiftTable[i8 >>> 1]; + kL = utils2.r28shl(kL, shift); + kR = utils2.r28shl(kR, shift); + utils2.pc2(kL, kR, state.keys, i8); + } + }; + DES.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._desState; + var l8 = utils2.readUInt32BE(inp, inOff); + var r10 = utils2.readUInt32BE(inp, inOff + 4); + utils2.ip(l8, r10, state.tmp, 0); + l8 = state.tmp[0]; + r10 = state.tmp[1]; + if (this.type === "encrypt") + this._encrypt(state, l8, r10, state.tmp, 0); + else + this._decrypt(state, l8, r10, state.tmp, 0); + l8 = state.tmp[0]; + r10 = state.tmp[1]; + utils2.writeUInt32BE(out, l8, outOff); + utils2.writeUInt32BE(out, r10, outOff + 4); + }; + DES.prototype._pad = function _pad(buffer4, off) { + var value = buffer4.length - off; + for (var i8 = off; i8 < buffer4.length; i8++) + buffer4[i8] = value; + return true; + }; + DES.prototype._unpad = function _unpad(buffer4) { + var pad = buffer4[buffer4.length - 1]; + for (var i8 = buffer4.length - pad; i8 < buffer4.length; i8++) + assert.equal(buffer4[i8], pad); + return buffer4.slice(0, buffer4.length - pad); + }; + DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { + var l8 = lStart; + var r10 = rStart; + for (var i8 = 0; i8 < state.keys.length; i8 += 2) { + var keyL = state.keys[i8]; + var keyR = state.keys[i8 + 1]; + utils2.expand(r10, state.tmp, 0); + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s7 = utils2.substitute(keyL, keyR); + var f9 = utils2.permute(s7); + var t9 = r10; + r10 = (l8 ^ f9) >>> 0; + l8 = t9; + } + utils2.rip(r10, l8, out, off); + }; + DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { + var l8 = rStart; + var r10 = lStart; + for (var i8 = state.keys.length - 2; i8 >= 0; i8 -= 2) { + var keyL = state.keys[i8]; + var keyR = state.keys[i8 + 1]; + utils2.expand(l8, state.tmp, 0); + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s7 = utils2.substitute(keyL, keyR); + var f9 = utils2.permute(s7); + var t9 = l8; + l8 = (r10 ^ f9) >>> 0; + r10 = t9; + } + utils2.rip(l8, r10, out, off); + }; + return exports$1s; + } + var exports$1r = {}; + var _dewExec$1q = false; + function dew$1q() { + if (_dewExec$1q) + return exports$1r; + _dewExec$1q = true; + var assert = dew$1t(); + var inherits3 = dew$f$2(); + var proto = {}; + function CBCState(iv) { + assert.equal(iv.length, 8, "Invalid IV length"); + this.iv = new Array(8); + for (var i8 = 0; i8 < this.iv.length; i8++) + this.iv[i8] = iv[i8]; + } + function instantiate(Base2) { + function CBC(options) { + Base2.call(this, options); + this._cbcInit(); + } + inherits3(CBC, Base2); + var keys2 = Object.keys(proto); + for (var i8 = 0; i8 < keys2.length; i8++) { + var key = keys2[i8]; + CBC.prototype[key] = proto[key]; + } + CBC.create = function create21(options) { + return new CBC(options); + }; + return CBC; + } + exports$1r.instantiate = instantiate; + proto._cbcInit = function _cbcInit() { + var state = new CBCState(this.options.iv); + this._cbcState = state; + }; + proto._update = function _update(inp, inOff, out, outOff) { + var state = this._cbcState; + var superProto = this.constructor.super_.prototype; + var iv = state.iv; + if (this.type === "encrypt") { + for (var i8 = 0; i8 < this.blockSize; i8++) + iv[i8] ^= inp[inOff + i8]; + superProto._update.call(this, iv, 0, out, outOff); + for (var i8 = 0; i8 < this.blockSize; i8++) + iv[i8] = out[outOff + i8]; + } else { + superProto._update.call(this, inp, inOff, out, outOff); + for (var i8 = 0; i8 < this.blockSize; i8++) + out[outOff + i8] ^= iv[i8]; + for (var i8 = 0; i8 < this.blockSize; i8++) + iv[i8] = inp[inOff + i8]; + } + }; + return exports$1r; + } + var exports$1q = {}; + var _dewExec$1p = false; + function dew$1p() { + if (_dewExec$1p) + return exports$1q; + _dewExec$1p = true; + var assert = dew$1t(); + var inherits3 = dew$f$2(); + var Cipher2 = dew$1s(); + var DES = dew$1r(); + function EDEState(type3, key) { + assert.equal(key.length, 24, "Invalid key length"); + var k1 = key.slice(0, 8); + var k22 = key.slice(8, 16); + var k32 = key.slice(16, 24); + if (type3 === "encrypt") { + this.ciphers = [DES.create({ + type: "encrypt", + key: k1 + }), DES.create({ + type: "decrypt", + key: k22 + }), DES.create({ + type: "encrypt", + key: k32 + })]; + } else { + this.ciphers = [DES.create({ + type: "decrypt", + key: k32 + }), DES.create({ + type: "encrypt", + key: k22 + }), DES.create({ + type: "decrypt", + key: k1 + })]; + } + } + function EDE(options) { + Cipher2.call(this, options); + var state = new EDEState(this.type, this.options.key); + this._edeState = state; + } + inherits3(EDE, Cipher2); + exports$1q = EDE; + EDE.create = function create21(options) { + return new EDE(options); + }; + EDE.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._edeState; + state.ciphers[0]._update(inp, inOff, out, outOff); + state.ciphers[1]._update(out, outOff, out, outOff); + state.ciphers[2]._update(out, outOff, out, outOff); + }; + EDE.prototype._pad = DES.prototype._pad; + EDE.prototype._unpad = DES.prototype._unpad; + return exports$1q; + } + var exports$1p = {}; + var _dewExec$1o = false; + function dew$1o() { + if (_dewExec$1o) + return exports$1p; + _dewExec$1o = true; + exports$1p.utils = dew$1u(); + exports$1p.Cipher = dew$1s(); + exports$1p.DES = dew$1r(); + exports$1p.CBC = dew$1q(); + exports$1p.EDE = dew$1p(); + return exports$1p; + } + var exports$1o = {}; + var _dewExec$1n = false; + var _global$k = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1n() { + if (_dewExec$1n) + return exports$1o; + _dewExec$1n = true; + var CipherBase = dew$1G(); + var des = dew$1o(); + var inherits3 = dew$f$2(); + var Buffer2 = dew$1T().Buffer; + var modes = { + "des-ede3-cbc": des.CBC.instantiate(des.EDE), + "des-ede3": des.EDE, + "des-ede-cbc": des.CBC.instantiate(des.EDE), + "des-ede": des.EDE, + "des-cbc": des.CBC.instantiate(des.DES), + "des-ecb": des.DES + }; + modes.des = modes["des-cbc"]; + modes.des3 = modes["des-ede3-cbc"]; + exports$1o = DES; + inherits3(DES, CipherBase); + function DES(opts) { + CipherBase.call(this || _global$k); + var modeName = opts.mode.toLowerCase(); + var mode = modes[modeName]; + var type3; + if (opts.decrypt) { + type3 = "decrypt"; + } else { + type3 = "encrypt"; + } + var key = opts.key; + if (!Buffer2.isBuffer(key)) { + key = Buffer2.from(key); + } + if (modeName === "des-ede" || modeName === "des-ede-cbc") { + key = Buffer2.concat([key, key.slice(0, 8)]); + } + var iv = opts.iv; + if (!Buffer2.isBuffer(iv)) { + iv = Buffer2.from(iv); + } + (this || _global$k)._des = mode.create({ + key, + iv, + type: type3 + }); + } + DES.prototype._update = function(data) { + return Buffer2.from((this || _global$k)._des.update(data)); + }; + DES.prototype._final = function() { + return Buffer2.from((this || _global$k)._des.final()); + }; + return exports$1o; + } + var exports$1n = {}; + var _dewExec$1m = false; + function dew$1m() { + if (_dewExec$1m) + return exports$1n; + _dewExec$1m = true; + exports$1n.encrypt = function(self2, block) { + return self2._cipher.encryptBlock(block); + }; + exports$1n.decrypt = function(self2, block) { + return self2._cipher.decryptBlock(block); + }; + return exports$1n; + } + var exports$1m = {}; + var _dewExec$1l = false; + function dew$1l() { + if (_dewExec$1l) + return exports$1m; + _dewExec$1l = true; + var Buffer2 = e$1$1.Buffer; + exports$1m = function xor3(a8, b6) { + var length3 = Math.min(a8.length, b6.length); + var buffer4 = new Buffer2(length3); + for (var i8 = 0; i8 < length3; ++i8) { + buffer4[i8] = a8[i8] ^ b6[i8]; + } + return buffer4; + }; + return exports$1m; + } + var exports$1l = {}; + var _dewExec$1k = false; + function dew$1k() { + if (_dewExec$1k) + return exports$1l; + _dewExec$1k = true; + var xor3 = dew$1l(); + exports$1l.encrypt = function(self2, block) { + var data = xor3(block, self2._prev); + self2._prev = self2._cipher.encryptBlock(data); + return self2._prev; + }; + exports$1l.decrypt = function(self2, block) { + var pad = self2._prev; + self2._prev = block; + var out = self2._cipher.decryptBlock(block); + return xor3(out, pad); + }; + return exports$1l; + } + var exports$1k = {}; + var _dewExec$1j = false; + function dew$1j() { + if (_dewExec$1j) + return exports$1k; + _dewExec$1j = true; + var Buffer2 = dew$1T().Buffer; + var xor3 = dew$1l(); + function encryptStart(self2, data, decrypt3) { + var len = data.length; + var out = xor3(data, self2._cache); + self2._cache = self2._cache.slice(len); + self2._prev = Buffer2.concat([self2._prev, decrypt3 ? data : out]); + return out; + } + exports$1k.encrypt = function(self2, data, decrypt3) { + var out = Buffer2.allocUnsafe(0); + var len; + while (data.length) { + if (self2._cache.length === 0) { + self2._cache = self2._cipher.encryptBlock(self2._prev); + self2._prev = Buffer2.allocUnsafe(0); + } + if (self2._cache.length <= data.length) { + len = self2._cache.length; + out = Buffer2.concat([out, encryptStart(self2, data.slice(0, len), decrypt3)]); + data = data.slice(len); + } else { + out = Buffer2.concat([out, encryptStart(self2, data, decrypt3)]); + break; + } + } + return out; + }; + return exports$1k; + } + var exports$1j = {}; + var _dewExec$1i = false; + function dew$1i() { + if (_dewExec$1i) + return exports$1j; + _dewExec$1i = true; + var Buffer2 = dew$1T().Buffer; + function encryptByte(self2, byteParam, decrypt3) { + var pad = self2._cipher.encryptBlock(self2._prev); + var out = pad[0] ^ byteParam; + self2._prev = Buffer2.concat([self2._prev.slice(1), Buffer2.from([decrypt3 ? byteParam : out])]); + return out; + } + exports$1j.encrypt = function(self2, chunk, decrypt3) { + var len = chunk.length; + var out = Buffer2.allocUnsafe(len); + var i8 = -1; + while (++i8 < len) { + out[i8] = encryptByte(self2, chunk[i8], decrypt3); + } + return out; + }; + return exports$1j; + } + var exports$1i = {}; + var _dewExec$1h = false; + function dew$1h() { + if (_dewExec$1h) + return exports$1i; + _dewExec$1h = true; + var Buffer2 = dew$1T().Buffer; + function encryptByte(self2, byteParam, decrypt3) { + var pad; + var i8 = -1; + var len = 8; + var out = 0; + var bit, value; + while (++i8 < len) { + pad = self2._cipher.encryptBlock(self2._prev); + bit = byteParam & 1 << 7 - i8 ? 128 : 0; + value = pad[0] ^ bit; + out += (value & 128) >> i8 % 8; + self2._prev = shiftIn(self2._prev, decrypt3 ? bit : value); + } + return out; + } + function shiftIn(buffer4, value) { + var len = buffer4.length; + var i8 = -1; + var out = Buffer2.allocUnsafe(buffer4.length); + buffer4 = Buffer2.concat([buffer4, Buffer2.from([value])]); + while (++i8 < len) { + out[i8] = buffer4[i8] << 1 | buffer4[i8 + 1] >> 7; + } + return out; + } + exports$1i.encrypt = function(self2, chunk, decrypt3) { + var len = chunk.length; + var out = Buffer2.allocUnsafe(len); + var i8 = -1; + while (++i8 < len) { + out[i8] = encryptByte(self2, chunk[i8], decrypt3); + } + return out; + }; + return exports$1i; + } + var exports$1h = {}; + var _dewExec$1g = false; + function dew$1g() { + if (_dewExec$1g) + return exports$1h; + _dewExec$1g = true; + var Buffer2 = e$1$1.Buffer; + var xor3 = dew$1l(); + function getBlock(self2) { + self2._prev = self2._cipher.encryptBlock(self2._prev); + return self2._prev; + } + exports$1h.encrypt = function(self2, chunk) { + while (self2._cache.length < chunk.length) { + self2._cache = Buffer2.concat([self2._cache, getBlock(self2)]); + } + var pad = self2._cache.slice(0, chunk.length); + self2._cache = self2._cache.slice(chunk.length); + return xor3(chunk, pad); + }; + return exports$1h; + } + var exports$1g = {}; + var _dewExec$1f = false; + function dew$1f() { + if (_dewExec$1f) + return exports$1g; + _dewExec$1f = true; + function incr32(iv) { + var len = iv.length; + var item; + while (len--) { + item = iv.readUInt8(len); + if (item === 255) { + iv.writeUInt8(0, len); + } else { + item++; + iv.writeUInt8(item, len); + break; + } + } + } + exports$1g = incr32; + return exports$1g; + } + var exports$1f = {}; + var _dewExec$1e = false; + function dew$1e() { + if (_dewExec$1e) + return exports$1f; + _dewExec$1e = true; + var xor3 = dew$1l(); + var Buffer2 = dew$1T().Buffer; + var incr32 = dew$1f(); + function getBlock(self2) { + var out = self2._cipher.encryptBlockRaw(self2._prev); + incr32(self2._prev); + return out; + } + var blockSize2 = 16; + exports$1f.encrypt = function(self2, chunk) { + var chunkNum = Math.ceil(chunk.length / blockSize2); + var start = self2._cache.length; + self2._cache = Buffer2.concat([self2._cache, Buffer2.allocUnsafe(chunkNum * blockSize2)]); + for (var i8 = 0; i8 < chunkNum; i8++) { + var out = getBlock(self2); + var offset2 = start + i8 * blockSize2; + self2._cache.writeUInt32BE(out[0], offset2 + 0); + self2._cache.writeUInt32BE(out[1], offset2 + 4); + self2._cache.writeUInt32BE(out[2], offset2 + 8); + self2._cache.writeUInt32BE(out[3], offset2 + 12); + } + var pad = self2._cache.slice(0, chunk.length); + self2._cache = self2._cache.slice(chunk.length); + return xor3(chunk, pad); + }; + return exports$1f; + } + var _list = { + "aes-128-ecb": { + "cipher": "AES", + "key": 128, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-192-ecb": { + "cipher": "AES", + "key": 192, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-256-ecb": { + "cipher": "AES", + "key": 256, + "iv": 0, + "mode": "ECB", + "type": "block" + }, + "aes-128-cbc": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-192-cbc": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-256-cbc": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes128": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes192": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes256": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CBC", + "type": "block" + }, + "aes-128-cfb": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-192-cfb": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-256-cfb": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB", + "type": "stream" + }, + "aes-128-cfb8": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-192-cfb8": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-256-cfb8": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB8", + "type": "stream" + }, + "aes-128-cfb1": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-192-cfb1": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-256-cfb1": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CFB1", + "type": "stream" + }, + "aes-128-ofb": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-192-ofb": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-256-ofb": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "OFB", + "type": "stream" + }, + "aes-128-ctr": { + "cipher": "AES", + "key": 128, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-192-ctr": { + "cipher": "AES", + "key": 192, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-256-ctr": { + "cipher": "AES", + "key": 256, + "iv": 16, + "mode": "CTR", + "type": "stream" + }, + "aes-128-gcm": { + "cipher": "AES", + "key": 128, + "iv": 12, + "mode": "GCM", + "type": "auth" + }, + "aes-192-gcm": { + "cipher": "AES", + "key": 192, + "iv": 12, + "mode": "GCM", + "type": "auth" + }, + "aes-256-gcm": { + "cipher": "AES", + "key": 256, + "iv": 12, + "mode": "GCM", + "type": "auth" + } + }; + var exports$1e = {}; + var _dewExec$1d = false; + function dew$1d() { + if (_dewExec$1d) + return exports$1e; + _dewExec$1d = true; + var modeModules = { + ECB: dew$1m(), + CBC: dew$1k(), + CFB: dew$1j(), + CFB8: dew$1i(), + CFB1: dew$1h(), + OFB: dew$1g(), + CTR: dew$1e(), + GCM: dew$1e() + }; + var modes = _list; + for (var key in modes) { + modes[key].module = modeModules[modes[key].mode]; + } + exports$1e = modes; + return exports$1e; + } + var exports$1d = {}; + var _dewExec$1c = false; + var _global$j = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1c() { + if (_dewExec$1c) + return exports$1d; + _dewExec$1c = true; + var Buffer2 = dew$1T().Buffer; + function asUInt32Array(buf3) { + if (!Buffer2.isBuffer(buf3)) + buf3 = Buffer2.from(buf3); + var len = buf3.length / 4 | 0; + var out = new Array(len); + for (var i8 = 0; i8 < len; i8++) { + out[i8] = buf3.readUInt32BE(i8 * 4); + } + return out; + } + function scrubVec(v7) { + for (var i8 = 0; i8 < v7.length; v7++) { + v7[i8] = 0; + } + } + function cryptBlock(M5, keySchedule, SUB_MIX, SBOX, nRounds) { + var SUB_MIX0 = SUB_MIX[0]; + var SUB_MIX1 = SUB_MIX[1]; + var SUB_MIX2 = SUB_MIX[2]; + var SUB_MIX3 = SUB_MIX[3]; + var s0 = M5[0] ^ keySchedule[0]; + var s1 = M5[1] ^ keySchedule[1]; + var s22 = M5[2] ^ keySchedule[2]; + var s32 = M5[3] ^ keySchedule[3]; + var t0, t1, t22, t32; + var ksRow = 4; + for (var round = 1; round < nRounds; round++) { + t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[s1 >>> 16 & 255] ^ SUB_MIX2[s22 >>> 8 & 255] ^ SUB_MIX3[s32 & 255] ^ keySchedule[ksRow++]; + t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[s22 >>> 16 & 255] ^ SUB_MIX2[s32 >>> 8 & 255] ^ SUB_MIX3[s0 & 255] ^ keySchedule[ksRow++]; + t22 = SUB_MIX0[s22 >>> 24] ^ SUB_MIX1[s32 >>> 16 & 255] ^ SUB_MIX2[s0 >>> 8 & 255] ^ SUB_MIX3[s1 & 255] ^ keySchedule[ksRow++]; + t32 = SUB_MIX0[s32 >>> 24] ^ SUB_MIX1[s0 >>> 16 & 255] ^ SUB_MIX2[s1 >>> 8 & 255] ^ SUB_MIX3[s22 & 255] ^ keySchedule[ksRow++]; + s0 = t0; + s1 = t1; + s22 = t22; + s32 = t32; + } + t0 = (SBOX[s0 >>> 24] << 24 | SBOX[s1 >>> 16 & 255] << 16 | SBOX[s22 >>> 8 & 255] << 8 | SBOX[s32 & 255]) ^ keySchedule[ksRow++]; + t1 = (SBOX[s1 >>> 24] << 24 | SBOX[s22 >>> 16 & 255] << 16 | SBOX[s32 >>> 8 & 255] << 8 | SBOX[s0 & 255]) ^ keySchedule[ksRow++]; + t22 = (SBOX[s22 >>> 24] << 24 | SBOX[s32 >>> 16 & 255] << 16 | SBOX[s0 >>> 8 & 255] << 8 | SBOX[s1 & 255]) ^ keySchedule[ksRow++]; + t32 = (SBOX[s32 >>> 24] << 24 | SBOX[s0 >>> 16 & 255] << 16 | SBOX[s1 >>> 8 & 255] << 8 | SBOX[s22 & 255]) ^ keySchedule[ksRow++]; + t0 = t0 >>> 0; + t1 = t1 >>> 0; + t22 = t22 >>> 0; + t32 = t32 >>> 0; + return [t0, t1, t22, t32]; + } + var RCON = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54]; + var G4 = function() { + var d7 = new Array(256); + for (var j5 = 0; j5 < 256; j5++) { + if (j5 < 128) { + d7[j5] = j5 << 1; + } else { + d7[j5] = j5 << 1 ^ 283; + } + } + var SBOX = []; + var INV_SBOX = []; + var SUB_MIX = [[], [], [], []]; + var INV_SUB_MIX = [[], [], [], []]; + var x5 = 0; + var xi = 0; + for (var i8 = 0; i8 < 256; ++i8) { + var sx = xi ^ xi << 1 ^ xi << 2 ^ xi << 3 ^ xi << 4; + sx = sx >>> 8 ^ sx & 255 ^ 99; + SBOX[x5] = sx; + INV_SBOX[sx] = x5; + var x22 = d7[x5]; + var x42 = d7[x22]; + var x8 = d7[x42]; + var t9 = d7[sx] * 257 ^ sx * 16843008; + SUB_MIX[0][x5] = t9 << 24 | t9 >>> 8; + SUB_MIX[1][x5] = t9 << 16 | t9 >>> 16; + SUB_MIX[2][x5] = t9 << 8 | t9 >>> 24; + SUB_MIX[3][x5] = t9; + t9 = x8 * 16843009 ^ x42 * 65537 ^ x22 * 257 ^ x5 * 16843008; + INV_SUB_MIX[0][sx] = t9 << 24 | t9 >>> 8; + INV_SUB_MIX[1][sx] = t9 << 16 | t9 >>> 16; + INV_SUB_MIX[2][sx] = t9 << 8 | t9 >>> 24; + INV_SUB_MIX[3][sx] = t9; + if (x5 === 0) { + x5 = xi = 1; + } else { + x5 = x22 ^ d7[d7[d7[x8 ^ x22]]]; + xi ^= d7[d7[xi]]; + } + } + return { + SBOX, + INV_SBOX, + SUB_MIX, + INV_SUB_MIX + }; + }(); + function AES(key) { + (this || _global$j)._key = asUInt32Array(key); + this._reset(); + } + AES.blockSize = 4 * 4; + AES.keySize = 256 / 8; + AES.prototype.blockSize = AES.blockSize; + AES.prototype.keySize = AES.keySize; + AES.prototype._reset = function() { + var keyWords = (this || _global$j)._key; + var keySize = keyWords.length; + var nRounds = keySize + 6; + var ksRows = (nRounds + 1) * 4; + var keySchedule = []; + for (var k5 = 0; k5 < keySize; k5++) { + keySchedule[k5] = keyWords[k5]; + } + for (k5 = keySize; k5 < ksRows; k5++) { + var t9 = keySchedule[k5 - 1]; + if (k5 % keySize === 0) { + t9 = t9 << 8 | t9 >>> 24; + t9 = G4.SBOX[t9 >>> 24] << 24 | G4.SBOX[t9 >>> 16 & 255] << 16 | G4.SBOX[t9 >>> 8 & 255] << 8 | G4.SBOX[t9 & 255]; + t9 ^= RCON[k5 / keySize | 0] << 24; + } else if (keySize > 6 && k5 % keySize === 4) { + t9 = G4.SBOX[t9 >>> 24] << 24 | G4.SBOX[t9 >>> 16 & 255] << 16 | G4.SBOX[t9 >>> 8 & 255] << 8 | G4.SBOX[t9 & 255]; + } + keySchedule[k5] = keySchedule[k5 - keySize] ^ t9; + } + var invKeySchedule = []; + for (var ik = 0; ik < ksRows; ik++) { + var ksR = ksRows - ik; + var tt3 = keySchedule[ksR - (ik % 4 ? 0 : 4)]; + if (ik < 4 || ksR <= 4) { + invKeySchedule[ik] = tt3; + } else { + invKeySchedule[ik] = G4.INV_SUB_MIX[0][G4.SBOX[tt3 >>> 24]] ^ G4.INV_SUB_MIX[1][G4.SBOX[tt3 >>> 16 & 255]] ^ G4.INV_SUB_MIX[2][G4.SBOX[tt3 >>> 8 & 255]] ^ G4.INV_SUB_MIX[3][G4.SBOX[tt3 & 255]]; + } + } + (this || _global$j)._nRounds = nRounds; + (this || _global$j)._keySchedule = keySchedule; + (this || _global$j)._invKeySchedule = invKeySchedule; + }; + AES.prototype.encryptBlockRaw = function(M5) { + M5 = asUInt32Array(M5); + return cryptBlock(M5, (this || _global$j)._keySchedule, G4.SUB_MIX, G4.SBOX, (this || _global$j)._nRounds); + }; + AES.prototype.encryptBlock = function(M5) { + var out = this.encryptBlockRaw(M5); + var buf3 = Buffer2.allocUnsafe(16); + buf3.writeUInt32BE(out[0], 0); + buf3.writeUInt32BE(out[1], 4); + buf3.writeUInt32BE(out[2], 8); + buf3.writeUInt32BE(out[3], 12); + return buf3; + }; + AES.prototype.decryptBlock = function(M5) { + M5 = asUInt32Array(M5); + var m1 = M5[1]; + M5[1] = M5[3]; + M5[3] = m1; + var out = cryptBlock(M5, (this || _global$j)._invKeySchedule, G4.INV_SUB_MIX, G4.INV_SBOX, (this || _global$j)._nRounds); + var buf3 = Buffer2.allocUnsafe(16); + buf3.writeUInt32BE(out[0], 0); + buf3.writeUInt32BE(out[3], 4); + buf3.writeUInt32BE(out[2], 8); + buf3.writeUInt32BE(out[1], 12); + return buf3; + }; + AES.prototype.scrub = function() { + scrubVec((this || _global$j)._keySchedule); + scrubVec((this || _global$j)._invKeySchedule); + scrubVec((this || _global$j)._key); + }; + exports$1d.AES = AES; + return exports$1d; + } + var exports$1c = {}; + var _dewExec$1b = false; + var _global$i = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1b() { + if (_dewExec$1b) + return exports$1c; + _dewExec$1b = true; + var Buffer2 = dew$1T().Buffer; + var ZEROES = Buffer2.alloc(16, 0); + function toArray(buf3) { + return [buf3.readUInt32BE(0), buf3.readUInt32BE(4), buf3.readUInt32BE(8), buf3.readUInt32BE(12)]; + } + function fromArray3(out) { + var buf3 = Buffer2.allocUnsafe(16); + buf3.writeUInt32BE(out[0] >>> 0, 0); + buf3.writeUInt32BE(out[1] >>> 0, 4); + buf3.writeUInt32BE(out[2] >>> 0, 8); + buf3.writeUInt32BE(out[3] >>> 0, 12); + return buf3; + } + function GHASH(key) { + (this || _global$i).h = key; + (this || _global$i).state = Buffer2.alloc(16, 0); + (this || _global$i).cache = Buffer2.allocUnsafe(0); + } + GHASH.prototype.ghash = function(block) { + var i8 = -1; + while (++i8 < block.length) { + (this || _global$i).state[i8] ^= block[i8]; + } + this._multiply(); + }; + GHASH.prototype._multiply = function() { + var Vi = toArray((this || _global$i).h); + var Zi = [0, 0, 0, 0]; + var j5, xi, lsbVi; + var i8 = -1; + while (++i8 < 128) { + xi = ((this || _global$i).state[~~(i8 / 8)] & 1 << 7 - i8 % 8) !== 0; + if (xi) { + Zi[0] ^= Vi[0]; + Zi[1] ^= Vi[1]; + Zi[2] ^= Vi[2]; + Zi[3] ^= Vi[3]; + } + lsbVi = (Vi[3] & 1) !== 0; + for (j5 = 3; j5 > 0; j5--) { + Vi[j5] = Vi[j5] >>> 1 | (Vi[j5 - 1] & 1) << 31; + } + Vi[0] = Vi[0] >>> 1; + if (lsbVi) { + Vi[0] = Vi[0] ^ 225 << 24; + } + } + (this || _global$i).state = fromArray3(Zi); + }; + GHASH.prototype.update = function(buf3) { + (this || _global$i).cache = Buffer2.concat([(this || _global$i).cache, buf3]); + var chunk; + while ((this || _global$i).cache.length >= 16) { + chunk = (this || _global$i).cache.slice(0, 16); + (this || _global$i).cache = (this || _global$i).cache.slice(16); + this.ghash(chunk); + } + }; + GHASH.prototype.final = function(abl, bl) { + if ((this || _global$i).cache.length) { + this.ghash(Buffer2.concat([(this || _global$i).cache, ZEROES], 16)); + } + this.ghash(fromArray3([0, abl, 0, bl])); + return (this || _global$i).state; + }; + exports$1c = GHASH; + return exports$1c; + } + var exports$1b = {}; + var _dewExec$1a = false; + var _global$h = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1a() { + if (_dewExec$1a) + return exports$1b; + _dewExec$1a = true; + var aes2 = dew$1c(); + var Buffer2 = dew$1T().Buffer; + var Transform2 = dew$1G(); + var inherits3 = dew$f$2(); + var GHASH = dew$1b(); + var xor3 = dew$1l(); + var incr32 = dew$1f(); + function xorTest(a8, b6) { + var out = 0; + if (a8.length !== b6.length) + out++; + var len = Math.min(a8.length, b6.length); + for (var i8 = 0; i8 < len; ++i8) { + out += a8[i8] ^ b6[i8]; + } + return out; + } + function calcIv(self2, iv, ck) { + if (iv.length === 12) { + self2._finID = Buffer2.concat([iv, Buffer2.from([0, 0, 0, 1])]); + return Buffer2.concat([iv, Buffer2.from([0, 0, 0, 2])]); + } + var ghash = new GHASH(ck); + var len = iv.length; + var toPad = len % 16; + ghash.update(iv); + if (toPad) { + toPad = 16 - toPad; + ghash.update(Buffer2.alloc(toPad, 0)); + } + ghash.update(Buffer2.alloc(8, 0)); + var ivBits = len * 8; + var tail = Buffer2.alloc(8); + tail.writeUIntBE(ivBits, 0, 8); + ghash.update(tail); + self2._finID = ghash.state; + var out = Buffer2.from(self2._finID); + incr32(out); + return out; + } + function StreamCipher(mode, key, iv, decrypt3) { + Transform2.call(this || _global$h); + var h9 = Buffer2.alloc(4, 0); + (this || _global$h)._cipher = new aes2.AES(key); + var ck = (this || _global$h)._cipher.encryptBlock(h9); + (this || _global$h)._ghash = new GHASH(ck); + iv = calcIv(this || _global$h, iv, ck); + (this || _global$h)._prev = Buffer2.from(iv); + (this || _global$h)._cache = Buffer2.allocUnsafe(0); + (this || _global$h)._secCache = Buffer2.allocUnsafe(0); + (this || _global$h)._decrypt = decrypt3; + (this || _global$h)._alen = 0; + (this || _global$h)._len = 0; + (this || _global$h)._mode = mode; + (this || _global$h)._authTag = null; + (this || _global$h)._called = false; + } + inherits3(StreamCipher, Transform2); + StreamCipher.prototype._update = function(chunk) { + if (!(this || _global$h)._called && (this || _global$h)._alen) { + var rump = 16 - (this || _global$h)._alen % 16; + if (rump < 16) { + rump = Buffer2.alloc(rump, 0); + (this || _global$h)._ghash.update(rump); + } + } + (this || _global$h)._called = true; + var out = (this || _global$h)._mode.encrypt(this || _global$h, chunk); + if ((this || _global$h)._decrypt) { + (this || _global$h)._ghash.update(chunk); + } else { + (this || _global$h)._ghash.update(out); + } + (this || _global$h)._len += chunk.length; + return out; + }; + StreamCipher.prototype._final = function() { + if ((this || _global$h)._decrypt && !(this || _global$h)._authTag) + throw new Error("Unsupported state or unable to authenticate data"); + var tag2 = xor3((this || _global$h)._ghash.final((this || _global$h)._alen * 8, (this || _global$h)._len * 8), (this || _global$h)._cipher.encryptBlock((this || _global$h)._finID)); + if ((this || _global$h)._decrypt && xorTest(tag2, (this || _global$h)._authTag)) + throw new Error("Unsupported state or unable to authenticate data"); + (this || _global$h)._authTag = tag2; + (this || _global$h)._cipher.scrub(); + }; + StreamCipher.prototype.getAuthTag = function getAuthTag() { + if ((this || _global$h)._decrypt || !Buffer2.isBuffer((this || _global$h)._authTag)) + throw new Error("Attempting to get auth tag in unsupported state"); + return (this || _global$h)._authTag; + }; + StreamCipher.prototype.setAuthTag = function setAuthTag(tag2) { + if (!(this || _global$h)._decrypt) + throw new Error("Attempting to set auth tag in unsupported state"); + (this || _global$h)._authTag = tag2; + }; + StreamCipher.prototype.setAAD = function setAAD(buf3) { + if ((this || _global$h)._called) + throw new Error("Attempting to set AAD in unsupported state"); + (this || _global$h)._ghash.update(buf3); + (this || _global$h)._alen += buf3.length; + }; + exports$1b = StreamCipher; + return exports$1b; + } + var exports$1a = {}; + var _dewExec$19 = false; + var _global$g = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$19() { + if (_dewExec$19) + return exports$1a; + _dewExec$19 = true; + var aes2 = dew$1c(); + var Buffer2 = dew$1T().Buffer; + var Transform2 = dew$1G(); + var inherits3 = dew$f$2(); + function StreamCipher(mode, key, iv, decrypt3) { + Transform2.call(this || _global$g); + (this || _global$g)._cipher = new aes2.AES(key); + (this || _global$g)._prev = Buffer2.from(iv); + (this || _global$g)._cache = Buffer2.allocUnsafe(0); + (this || _global$g)._secCache = Buffer2.allocUnsafe(0); + (this || _global$g)._decrypt = decrypt3; + (this || _global$g)._mode = mode; + } + inherits3(StreamCipher, Transform2); + StreamCipher.prototype._update = function(chunk) { + return (this || _global$g)._mode.encrypt(this || _global$g, chunk, (this || _global$g)._decrypt); + }; + StreamCipher.prototype._final = function() { + (this || _global$g)._cipher.scrub(); + }; + exports$1a = StreamCipher; + return exports$1a; + } + var exports$19 = {}; + var _dewExec$18 = false; + function dew$18() { + if (_dewExec$18) + return exports$19; + _dewExec$18 = true; + var Buffer2 = dew$1T().Buffer; + var MD5 = dew$1Q(); + function EVP_BytesToKey(password, salt, keyBits, ivLen) { + if (!Buffer2.isBuffer(password)) + password = Buffer2.from(password, "binary"); + if (salt) { + if (!Buffer2.isBuffer(salt)) + salt = Buffer2.from(salt, "binary"); + if (salt.length !== 8) + throw new RangeError("salt should be Buffer with 8 byte length"); + } + var keyLen = keyBits / 8; + var key = Buffer2.alloc(keyLen); + var iv = Buffer2.alloc(ivLen || 0); + var tmp = Buffer2.alloc(0); + while (keyLen > 0 || ivLen > 0) { + var hash = new MD5(); + hash.update(tmp); + hash.update(password); + if (salt) + hash.update(salt); + tmp = hash.digest(); + var used = 0; + if (keyLen > 0) { + var keyStart = key.length - keyLen; + used = Math.min(keyLen, tmp.length); + tmp.copy(key, keyStart, 0, used); + keyLen -= used; + } + if (used < tmp.length && ivLen > 0) { + var ivStart = iv.length - ivLen; + var length3 = Math.min(ivLen, tmp.length - used); + tmp.copy(iv, ivStart, used, used + length3); + ivLen -= length3; + } + } + tmp.fill(0); + return { + key, + iv + }; + } + exports$19 = EVP_BytesToKey; + return exports$19; + } + var exports$18 = {}; + var _dewExec$17 = false; + var _global$f = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$17() { + if (_dewExec$17) + return exports$18; + _dewExec$17 = true; + var MODES = dew$1d(); + var AuthCipher = dew$1a(); + var Buffer2 = dew$1T().Buffer; + var StreamCipher = dew$19(); + var Transform2 = dew$1G(); + var aes2 = dew$1c(); + var ebtk = dew$18(); + var inherits3 = dew$f$2(); + function Cipher2(mode, key, iv) { + Transform2.call(this || _global$f); + (this || _global$f)._cache = new Splitter(); + (this || _global$f)._cipher = new aes2.AES(key); + (this || _global$f)._prev = Buffer2.from(iv); + (this || _global$f)._mode = mode; + (this || _global$f)._autopadding = true; + } + inherits3(Cipher2, Transform2); + Cipher2.prototype._update = function(data) { + (this || _global$f)._cache.add(data); + var chunk; + var thing; + var out = []; + while (chunk = (this || _global$f)._cache.get()) { + thing = (this || _global$f)._mode.encrypt(this || _global$f, chunk); + out.push(thing); + } + return Buffer2.concat(out); + }; + var PADDING = Buffer2.alloc(16, 16); + Cipher2.prototype._final = function() { + var chunk = (this || _global$f)._cache.flush(); + if ((this || _global$f)._autopadding) { + chunk = (this || _global$f)._mode.encrypt(this || _global$f, chunk); + (this || _global$f)._cipher.scrub(); + return chunk; + } + if (!chunk.equals(PADDING)) { + (this || _global$f)._cipher.scrub(); + throw new Error("data not multiple of block length"); + } + }; + Cipher2.prototype.setAutoPadding = function(setTo) { + (this || _global$f)._autopadding = !!setTo; + return this || _global$f; + }; + function Splitter() { + (this || _global$f).cache = Buffer2.allocUnsafe(0); + } + Splitter.prototype.add = function(data) { + (this || _global$f).cache = Buffer2.concat([(this || _global$f).cache, data]); + }; + Splitter.prototype.get = function() { + if ((this || _global$f).cache.length > 15) { + var out = (this || _global$f).cache.slice(0, 16); + (this || _global$f).cache = (this || _global$f).cache.slice(16); + return out; + } + return null; + }; + Splitter.prototype.flush = function() { + var len = 16 - (this || _global$f).cache.length; + var padBuff = Buffer2.allocUnsafe(len); + var i8 = -1; + while (++i8 < len) { + padBuff.writeUInt8(len, i8); + } + return Buffer2.concat([(this || _global$f).cache, padBuff]); + }; + function createCipheriv2(suite, password, iv) { + var config2 = MODES[suite.toLowerCase()]; + if (!config2) + throw new TypeError("invalid suite type"); + if (typeof password === "string") + password = Buffer2.from(password); + if (password.length !== config2.key / 8) + throw new TypeError("invalid key length " + password.length); + if (typeof iv === "string") + iv = Buffer2.from(iv); + if (config2.mode !== "GCM" && iv.length !== config2.iv) + throw new TypeError("invalid iv length " + iv.length); + if (config2.type === "stream") { + return new StreamCipher(config2.module, password, iv); + } else if (config2.type === "auth") { + return new AuthCipher(config2.module, password, iv); + } + return new Cipher2(config2.module, password, iv); + } + function createCipher2(suite, password) { + var config2 = MODES[suite.toLowerCase()]; + if (!config2) + throw new TypeError("invalid suite type"); + var keys2 = ebtk(password, false, config2.key, config2.iv); + return createCipheriv2(suite, keys2.key, keys2.iv); + } + exports$18.createCipheriv = createCipheriv2; + exports$18.createCipher = createCipher2; + return exports$18; + } + var exports$17 = {}; + var _dewExec$16 = false; + var _global$e = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$16() { + if (_dewExec$16) + return exports$17; + _dewExec$16 = true; + var AuthCipher = dew$1a(); + var Buffer2 = dew$1T().Buffer; + var MODES = dew$1d(); + var StreamCipher = dew$19(); + var Transform2 = dew$1G(); + var aes2 = dew$1c(); + var ebtk = dew$18(); + var inherits3 = dew$f$2(); + function Decipher2(mode, key, iv) { + Transform2.call(this || _global$e); + (this || _global$e)._cache = new Splitter(); + (this || _global$e)._last = void 0; + (this || _global$e)._cipher = new aes2.AES(key); + (this || _global$e)._prev = Buffer2.from(iv); + (this || _global$e)._mode = mode; + (this || _global$e)._autopadding = true; + } + inherits3(Decipher2, Transform2); + Decipher2.prototype._update = function(data) { + (this || _global$e)._cache.add(data); + var chunk; + var thing; + var out = []; + while (chunk = (this || _global$e)._cache.get((this || _global$e)._autopadding)) { + thing = (this || _global$e)._mode.decrypt(this || _global$e, chunk); + out.push(thing); + } + return Buffer2.concat(out); + }; + Decipher2.prototype._final = function() { + var chunk = (this || _global$e)._cache.flush(); + if ((this || _global$e)._autopadding) { + return unpad((this || _global$e)._mode.decrypt(this || _global$e, chunk)); + } else if (chunk) { + throw new Error("data not multiple of block length"); + } + }; + Decipher2.prototype.setAutoPadding = function(setTo) { + (this || _global$e)._autopadding = !!setTo; + return this || _global$e; + }; + function Splitter() { + (this || _global$e).cache = Buffer2.allocUnsafe(0); + } + Splitter.prototype.add = function(data) { + (this || _global$e).cache = Buffer2.concat([(this || _global$e).cache, data]); + }; + Splitter.prototype.get = function(autoPadding) { + var out; + if (autoPadding) { + if ((this || _global$e).cache.length > 16) { + out = (this || _global$e).cache.slice(0, 16); + (this || _global$e).cache = (this || _global$e).cache.slice(16); + return out; + } + } else { + if ((this || _global$e).cache.length >= 16) { + out = (this || _global$e).cache.slice(0, 16); + (this || _global$e).cache = (this || _global$e).cache.slice(16); + return out; + } + } + return null; + }; + Splitter.prototype.flush = function() { + if ((this || _global$e).cache.length) + return (this || _global$e).cache; + }; + function unpad(last2) { + var padded = last2[15]; + if (padded < 1 || padded > 16) { + throw new Error("unable to decrypt data"); + } + var i8 = -1; + while (++i8 < padded) { + if (last2[i8 + (16 - padded)] !== padded) { + throw new Error("unable to decrypt data"); + } + } + if (padded === 16) + return; + return last2.slice(0, 16 - padded); + } + function createDecipheriv2(suite, password, iv) { + var config2 = MODES[suite.toLowerCase()]; + if (!config2) + throw new TypeError("invalid suite type"); + if (typeof iv === "string") + iv = Buffer2.from(iv); + if (config2.mode !== "GCM" && iv.length !== config2.iv) + throw new TypeError("invalid iv length " + iv.length); + if (typeof password === "string") + password = Buffer2.from(password); + if (password.length !== config2.key / 8) + throw new TypeError("invalid key length " + password.length); + if (config2.type === "stream") { + return new StreamCipher(config2.module, password, iv, true); + } else if (config2.type === "auth") { + return new AuthCipher(config2.module, password, iv, true); + } + return new Decipher2(config2.module, password, iv); + } + function createDecipher2(suite, password) { + var config2 = MODES[suite.toLowerCase()]; + if (!config2) + throw new TypeError("invalid suite type"); + var keys2 = ebtk(password, false, config2.key, config2.iv); + return createDecipheriv2(suite, keys2.key, keys2.iv); + } + exports$17.createDecipher = createDecipher2; + exports$17.createDecipheriv = createDecipheriv2; + return exports$17; + } + var exports$16 = {}; + var _dewExec$15 = false; + function dew$15() { + if (_dewExec$15) + return exports$16; + _dewExec$15 = true; + var ciphers = dew$17(); + var deciphers = dew$16(); + var modes = _list; + function getCiphers2() { + return Object.keys(modes); + } + exports$16.createCipher = exports$16.Cipher = ciphers.createCipher; + exports$16.createCipheriv = exports$16.Cipheriv = ciphers.createCipheriv; + exports$16.createDecipher = exports$16.Decipher = deciphers.createDecipher; + exports$16.createDecipheriv = exports$16.Decipheriv = deciphers.createDecipheriv; + exports$16.listCiphers = exports$16.getCiphers = getCiphers2; + return exports$16; + } + var exports$15 = {}; + var _dewExec$14 = false; + function dew$14() { + if (_dewExec$14) + return exports$15; + _dewExec$14 = true; + exports$15["des-ecb"] = { + key: 8, + iv: 0 + }; + exports$15["des-cbc"] = exports$15.des = { + key: 8, + iv: 8 + }; + exports$15["des-ede3-cbc"] = exports$15.des3 = { + key: 24, + iv: 8 + }; + exports$15["des-ede3"] = { + key: 24, + iv: 0 + }; + exports$15["des-ede-cbc"] = { + key: 16, + iv: 8 + }; + exports$15["des-ede"] = { + key: 16, + iv: 0 + }; + return exports$15; + } + var exports$14 = {}; + var _dewExec$13 = false; + function dew$13() { + if (_dewExec$13) + return exports$14; + _dewExec$13 = true; + var DES = dew$1n(); + var aes2 = dew$15(); + var aesModes = dew$1d(); + var desModes = dew$14(); + var ebtk = dew$18(); + function createCipher2(suite, password) { + suite = suite.toLowerCase(); + var keyLen, ivLen; + if (aesModes[suite]) { + keyLen = aesModes[suite].key; + ivLen = aesModes[suite].iv; + } else if (desModes[suite]) { + keyLen = desModes[suite].key * 8; + ivLen = desModes[suite].iv; + } else { + throw new TypeError("invalid suite type"); + } + var keys2 = ebtk(password, false, keyLen, ivLen); + return createCipheriv2(suite, keys2.key, keys2.iv); + } + function createDecipher2(suite, password) { + suite = suite.toLowerCase(); + var keyLen, ivLen; + if (aesModes[suite]) { + keyLen = aesModes[suite].key; + ivLen = aesModes[suite].iv; + } else if (desModes[suite]) { + keyLen = desModes[suite].key * 8; + ivLen = desModes[suite].iv; + } else { + throw new TypeError("invalid suite type"); + } + var keys2 = ebtk(password, false, keyLen, ivLen); + return createDecipheriv2(suite, keys2.key, keys2.iv); + } + function createCipheriv2(suite, key, iv) { + suite = suite.toLowerCase(); + if (aesModes[suite]) + return aes2.createCipheriv(suite, key, iv); + if (desModes[suite]) + return new DES({ + key, + iv, + mode: suite + }); + throw new TypeError("invalid suite type"); + } + function createDecipheriv2(suite, key, iv) { + suite = suite.toLowerCase(); + if (aesModes[suite]) + return aes2.createDecipheriv(suite, key, iv); + if (desModes[suite]) + return new DES({ + key, + iv, + mode: suite, + decrypt: true + }); + throw new TypeError("invalid suite type"); + } + function getCiphers2() { + return Object.keys(desModes).concat(aes2.getCiphers()); + } + exports$14.createCipher = exports$14.Cipher = createCipher2; + exports$14.createCipheriv = exports$14.Cipheriv = createCipheriv2; + exports$14.createDecipher = exports$14.Decipher = createDecipher2; + exports$14.createDecipheriv = exports$14.Decipheriv = createDecipheriv2; + exports$14.listCiphers = exports$14.getCiphers = getCiphers2; + return exports$14; + } + var exports$13 = {}; + var _dewExec$122 = false; + var module$6 = { + exports: exports$13 + }; + var _global$d = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$122() { + if (_dewExec$122) + return module$6.exports; + _dewExec$122 = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$d).negative = 0; + (this || _global$d).words = null; + (this || _global$d).length = 0; + (this || _global$d).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = e$1$1.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$d).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$d).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$d).words = [number3 & 67108863]; + (this || _global$d).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$d).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$d).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$d).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$d).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$d).words = [0]; + (this || _global$d).length = 1; + return this || _global$d; + } + (this || _global$d).length = Math.ceil(number3.length / 3); + (this || _global$d).words = new Array((this || _global$d).length); + for (var i8 = 0; i8 < (this || _global$d).length; i8++) { + (this || _global$d).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$d).words[j5] |= w5 << off & 67108863; + (this || _global$d).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$d).words[j5] |= w5 << off & 67108863; + (this || _global$d).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$d).length = Math.ceil((number3.length - start) / 6); + (this || _global$d).words = new Array((this || _global$d).length); + for (var i8 = 0; i8 < (this || _global$d).length; i8++) { + (this || _global$d).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$d).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$d).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$d).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$d).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$d).words = [0]; + (this || _global$d).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$d).words[0] + word < 67108864) { + (this || _global$d).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$d).words[0] + word < 67108864) { + (this || _global$d).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$d).length); + for (var i8 = 0; i8 < (this || _global$d).length; i8++) { + dest.words[i8] = (this || _global$d).words[i8]; + } + dest.length = (this || _global$d).length; + dest.negative = (this || _global$d).negative; + dest.red = (this || _global$d).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$d).length < size4) { + (this || _global$d).words[(this || _global$d).length++] = 0; + } + return this || _global$d; + }; + BN.prototype.strip = function strip() { + while ((this || _global$d).length > 1 && (this || _global$d).words[(this || _global$d).length - 1] === 0) { + (this || _global$d).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$d).length === 1 && (this || _global$d).words[0] === 0) { + (this || _global$d).negative = 0; + } + return this || _global$d; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$d).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$d).length; i8++) { + var w5 = (this || _global$d).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$d).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$d).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$d).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$d).words[0]; + if ((this || _global$d).length === 2) { + ret += (this || _global$d).words[1] * 67108864; + } else if ((this || _global$d).length === 3 && (this || _global$d).words[2] === 1) { + ret += 4503599627370496 + (this || _global$d).words[1] * 67108864; + } else if ((this || _global$d).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$d).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$d).words[(this || _global$d).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$d).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$d).length; i8++) { + var b6 = this._zeroBits((this || _global$d).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$d).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$d).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$d).negative ^= 1; + } + return this || _global$d; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$d).length < num.length) { + (this || _global$d).words[(this || _global$d).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$d).words[i8] = (this || _global$d).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$d).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$d).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$d); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$d).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$d); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$d).length > num.length) { + b6 = num; + } else { + b6 = this || _global$d; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$d).words[i8] = (this || _global$d).words[i8] & num.words[i8]; + } + (this || _global$d).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$d).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$d).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$d); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$d).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$d); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$d).length > num.length) { + a8 = this || _global$d; + b6 = num; + } else { + a8 = num; + b6 = this || _global$d; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$d).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$d) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$d).words[i8] = a8.words[i8]; + } + } + (this || _global$d).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$d).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$d).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$d); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$d).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$d); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$d).words[i8] = ~(this || _global$d).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$d).words[i8] = ~(this || _global$d).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$d).words[off] = (this || _global$d).words[off] | 1 << wbit; + } else { + (this || _global$d).words[off] = (this || _global$d).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$d).negative !== 0 && num.negative === 0) { + (this || _global$d).negative = 0; + r10 = this.isub(num); + (this || _global$d).negative ^= 1; + return this._normSign(); + } else if ((this || _global$d).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$d).length > num.length) { + a8 = this || _global$d; + b6 = num; + } else { + a8 = num; + b6 = this || _global$d; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$d).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$d).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$d).length = a8.length; + if (carry !== 0) { + (this || _global$d).words[(this || _global$d).length] = carry; + (this || _global$d).length++; + } else if (a8 !== (this || _global$d)) { + for (; i8 < a8.length; i8++) { + (this || _global$d).words[i8] = a8.words[i8]; + } + } + return this || _global$d; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$d).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$d).negative !== 0) { + (this || _global$d).negative = 0; + res = num.sub(this || _global$d); + (this || _global$d).negative = 1; + return res; + } + if ((this || _global$d).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$d); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$d).negative !== 0) { + (this || _global$d).negative = 0; + this.iadd(num); + (this || _global$d).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$d).negative = 0; + (this || _global$d).length = 1; + (this || _global$d).words[0] = 0; + return this || _global$d; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$d; + b6 = num; + } else { + a8 = num; + b6 = this || _global$d; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$d).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$d).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$d)) { + for (; i8 < a8.length; i8++) { + (this || _global$d).words[i8] = a8.words[i8]; + } + } + (this || _global$d).length = Math.max((this || _global$d).length, i8); + if (a8 !== (this || _global$d)) { + (this || _global$d).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$d).length + num.length; + if ((this || _global$d).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$d, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$d, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$d, num, out); + } else { + res = jumboMulTo(this || _global$d, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$d).x = x5; + (this || _global$d).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$d).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$d).length + num.length); + return jumboMulTo(this || _global$d, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$d); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$d).length; i8++) { + var w5 = ((this || _global$d).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$d).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$d).words[i8] = carry; + (this || _global$d).length++; + } + return this || _global$d; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$d); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$d; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$d).length; i8++) { + var newCarry = (this || _global$d).words[i8] & carryMask; + var c8 = ((this || _global$d).words[i8] | 0) - newCarry << r10; + (this || _global$d).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$d).words[i8] = carry; + (this || _global$d).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$d).length - 1; i8 >= 0; i8--) { + (this || _global$d).words[i8 + s7] = (this || _global$d).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$d).words[i8] = 0; + } + (this || _global$d).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$d).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$d).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$d).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$d).length > s7) { + (this || _global$d).length -= s7; + for (i8 = 0; i8 < (this || _global$d).length; i8++) { + (this || _global$d).words[i8] = (this || _global$d).words[i8 + s7]; + } + } else { + (this || _global$d).words[0] = 0; + (this || _global$d).length = 1; + } + var carry = 0; + for (i8 = (this || _global$d).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$d).words[i8] | 0; + (this || _global$d).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$d).length === 0) { + (this || _global$d).words[0] = 0; + (this || _global$d).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$d).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$d).length <= s7) + return false; + var w5 = (this || _global$d).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$d).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$d).length <= s7) { + return this || _global$d; + } + if (r10 !== 0) { + s7++; + } + (this || _global$d).length = Math.min(s7, (this || _global$d).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$d).words[(this || _global$d).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$d).negative !== 0) { + if ((this || _global$d).length === 1 && ((this || _global$d).words[0] | 0) < num) { + (this || _global$d).words[0] = num - ((this || _global$d).words[0] | 0); + (this || _global$d).negative = 0; + return this || _global$d; + } + (this || _global$d).negative = 0; + this.isubn(num); + (this || _global$d).negative = 1; + return this || _global$d; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$d).words[0] += num; + for (var i8 = 0; i8 < (this || _global$d).length && (this || _global$d).words[i8] >= 67108864; i8++) { + (this || _global$d).words[i8] -= 67108864; + if (i8 === (this || _global$d).length - 1) { + (this || _global$d).words[i8 + 1] = 1; + } else { + (this || _global$d).words[i8 + 1]++; + } + } + (this || _global$d).length = Math.max((this || _global$d).length, i8 + 1); + return this || _global$d; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$d).negative !== 0) { + (this || _global$d).negative = 0; + this.iaddn(num); + (this || _global$d).negative = 1; + return this || _global$d; + } + (this || _global$d).words[0] -= num; + if ((this || _global$d).length === 1 && (this || _global$d).words[0] < 0) { + (this || _global$d).words[0] = -(this || _global$d).words[0]; + (this || _global$d).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$d).length && (this || _global$d).words[i8] < 0; i8++) { + (this || _global$d).words[i8] += 67108864; + (this || _global$d).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$d).negative = 0; + return this || _global$d; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$d).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$d).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$d).length - shift; i8++) { + w5 = ((this || _global$d).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$d).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$d).length; i8++) { + w5 = -((this || _global$d).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$d).words[i8] = w5 & 67108863; + } + (this || _global$d).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$d).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$d).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$d).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$d).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$d).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$d + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$d).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$d).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$d).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$d).words[i8] | 0) + carry * 67108864; + (this || _global$d).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$d; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$d; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$d).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$d).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$d).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$d).length <= s7) { + this._expand(s7 + 1); + (this || _global$d).words[s7] |= q4; + return this || _global$d; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$d).length; i8++) { + var w5 = (this || _global$d).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$d).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$d).words[i8] = carry; + (this || _global$d).length++; + } + return this || _global$d; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$d).length === 1 && (this || _global$d).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$d).negative !== 0 && !negative) + return -1; + if ((this || _global$d).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$d).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$d).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$d).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$d).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$d).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$d).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$d).length > num.length) + return 1; + if ((this || _global$d).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$d).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$d).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$d).red, "Already a number in reduction context"); + assert((this || _global$d).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$d)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$d).red, "fromRed works only with numbers in reduction context"); + return (this || _global$d).red.convertFrom(this || _global$d); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$d).red = ctx; + return this || _global$d; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$d).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$d).red, "redAdd works only with red numbers"); + return (this || _global$d).red.add(this || _global$d, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$d).red, "redIAdd works only with red numbers"); + return (this || _global$d).red.iadd(this || _global$d, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$d).red, "redSub works only with red numbers"); + return (this || _global$d).red.sub(this || _global$d, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$d).red, "redISub works only with red numbers"); + return (this || _global$d).red.isub(this || _global$d, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$d).red, "redShl works only with red numbers"); + return (this || _global$d).red.shl(this || _global$d, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$d).red, "redMul works only with red numbers"); + (this || _global$d).red._verify2(this || _global$d, num); + return (this || _global$d).red.mul(this || _global$d, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$d).red, "redMul works only with red numbers"); + (this || _global$d).red._verify2(this || _global$d, num); + return (this || _global$d).red.imul(this || _global$d, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$d).red, "redSqr works only with red numbers"); + (this || _global$d).red._verify1(this || _global$d); + return (this || _global$d).red.sqr(this || _global$d); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$d).red, "redISqr works only with red numbers"); + (this || _global$d).red._verify1(this || _global$d); + return (this || _global$d).red.isqr(this || _global$d); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$d).red, "redSqrt works only with red numbers"); + (this || _global$d).red._verify1(this || _global$d); + return (this || _global$d).red.sqrt(this || _global$d); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$d).red, "redInvm works only with red numbers"); + (this || _global$d).red._verify1(this || _global$d); + return (this || _global$d).red.invm(this || _global$d); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$d).red, "redNeg works only with red numbers"); + (this || _global$d).red._verify1(this || _global$d); + return (this || _global$d).red.neg(this || _global$d); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$d).red && !num.red, "redPow(normalNum)"); + (this || _global$d).red._verify1(this || _global$d); + return (this || _global$d).red.pow(this || _global$d, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$d).name = name15; + (this || _global$d).p = new BN(p8, 16); + (this || _global$d).n = (this || _global$d).p.bitLength(); + (this || _global$d).k = new BN(1).iushln((this || _global$d).n).isub((this || _global$d).p); + (this || _global$d).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$d).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$d).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$d).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$d).n); + var cmp = rlen < (this || _global$d).n ? -1 : r10.ucmp((this || _global$d).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$d).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$d).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$d).k); + }; + function K256() { + MPrime.call(this || _global$d, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$d, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$d, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$d, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$d).m = prime.p; + (this || _global$d).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$d).m = m7; + (this || _global$d).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$d).prime) + return (this || _global$d).prime.ireduce(a8)._forceRed(this || _global$d); + return a8.umod((this || _global$d).m)._forceRed(this || _global$d); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$d).m.sub(a8)._forceRed(this || _global$d); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$d).m) >= 0) { + res.isub((this || _global$d).m); + } + return res._forceRed(this || _global$d); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$d).m) >= 0) { + res.isub((this || _global$d).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$d).m); + } + return res._forceRed(this || _global$d); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$d).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$d).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$d).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$d).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$d); + var nOne = one.redNeg(); + var lpow = (this || _global$d).m.subn(1).iushrn(1); + var z6 = (this || _global$d).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$d); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$d).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$d); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$d); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$d).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$d, m7); + (this || _global$d).shift = (this || _global$d).m.bitLength(); + if ((this || _global$d).shift % 26 !== 0) { + (this || _global$d).shift += 26 - (this || _global$d).shift % 26; + } + (this || _global$d).r = new BN(1).iushln((this || _global$d).shift); + (this || _global$d).r2 = this.imod((this || _global$d).r.sqr()); + (this || _global$d).rinv = (this || _global$d).r._invmp((this || _global$d).m); + (this || _global$d).minv = (this || _global$d).rinv.mul((this || _global$d).r).isubn(1).div((this || _global$d).m); + (this || _global$d).minv = (this || _global$d).minv.umod((this || _global$d).r); + (this || _global$d).minv = (this || _global$d).r.sub((this || _global$d).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$d).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$d).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$d).shift).mul((this || _global$d).minv).imaskn((this || _global$d).shift).mul((this || _global$d).m); + var u8 = t9.isub(c8).iushrn((this || _global$d).shift); + var res = u8; + if (u8.cmp((this || _global$d).m) >= 0) { + res = u8.isub((this || _global$d).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$d).m); + } + return res._forceRed(this || _global$d); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$d); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$d).shift).mul((this || _global$d).minv).imaskn((this || _global$d).shift).mul((this || _global$d).m); + var u8 = t9.isub(c8).iushrn((this || _global$d).shift); + var res = u8; + if (u8.cmp((this || _global$d).m) >= 0) { + res = u8.isub((this || _global$d).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$d).m); + } + return res._forceRed(this || _global$d); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$d).m).mul((this || _global$d).r2)); + return res._forceRed(this || _global$d); + }; + })(module$6, exports$13); + return module$6.exports; + } + var exports$12$1 = {}; + var _dewExec$11$1 = false; + var module$5 = { + exports: exports$12$1 + }; + var _global$c = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$11$1() { + if (_dewExec$11$1) + return module$5.exports; + _dewExec$11$1 = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$c).negative = 0; + (this || _global$c).words = null; + (this || _global$c).length = 0; + (this || _global$c).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = e$1$1.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$c).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$c).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$c).words = [number3 & 67108863]; + (this || _global$c).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$c).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$c).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$c).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$c).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$c).words = [0]; + (this || _global$c).length = 1; + return this || _global$c; + } + (this || _global$c).length = Math.ceil(number3.length / 3); + (this || _global$c).words = new Array((this || _global$c).length); + for (var i8 = 0; i8 < (this || _global$c).length; i8++) { + (this || _global$c).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$c).words[j5] |= w5 << off & 67108863; + (this || _global$c).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$c).words[j5] |= w5 << off & 67108863; + (this || _global$c).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$c).length = Math.ceil((number3.length - start) / 6); + (this || _global$c).words = new Array((this || _global$c).length); + for (var i8 = 0; i8 < (this || _global$c).length; i8++) { + (this || _global$c).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$c).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$c).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$c).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$c).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$c).words = [0]; + (this || _global$c).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$c).words[0] + word < 67108864) { + (this || _global$c).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$c).words[0] + word < 67108864) { + (this || _global$c).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$c).length); + for (var i8 = 0; i8 < (this || _global$c).length; i8++) { + dest.words[i8] = (this || _global$c).words[i8]; + } + dest.length = (this || _global$c).length; + dest.negative = (this || _global$c).negative; + dest.red = (this || _global$c).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$c).length < size4) { + (this || _global$c).words[(this || _global$c).length++] = 0; + } + return this || _global$c; + }; + BN.prototype.strip = function strip() { + while ((this || _global$c).length > 1 && (this || _global$c).words[(this || _global$c).length - 1] === 0) { + (this || _global$c).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$c).length === 1 && (this || _global$c).words[0] === 0) { + (this || _global$c).negative = 0; + } + return this || _global$c; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$c).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$c).length; i8++) { + var w5 = (this || _global$c).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$c).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$c).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$c).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$c).words[0]; + if ((this || _global$c).length === 2) { + ret += (this || _global$c).words[1] * 67108864; + } else if ((this || _global$c).length === 3 && (this || _global$c).words[2] === 1) { + ret += 4503599627370496 + (this || _global$c).words[1] * 67108864; + } else if ((this || _global$c).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$c).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$c).words[(this || _global$c).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$c).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$c).length; i8++) { + var b6 = this._zeroBits((this || _global$c).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$c).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$c).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$c).negative ^= 1; + } + return this || _global$c; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$c).length < num.length) { + (this || _global$c).words[(this || _global$c).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$c).words[i8] = (this || _global$c).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$c).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$c).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$c); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$c).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$c); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$c).length > num.length) { + b6 = num; + } else { + b6 = this || _global$c; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$c).words[i8] = (this || _global$c).words[i8] & num.words[i8]; + } + (this || _global$c).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$c).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$c).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$c); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$c).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$c); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$c).length > num.length) { + a8 = this || _global$c; + b6 = num; + } else { + a8 = num; + b6 = this || _global$c; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$c).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$c) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$c).words[i8] = a8.words[i8]; + } + } + (this || _global$c).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$c).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$c).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$c); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$c).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$c); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$c).words[i8] = ~(this || _global$c).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$c).words[i8] = ~(this || _global$c).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$c).words[off] = (this || _global$c).words[off] | 1 << wbit; + } else { + (this || _global$c).words[off] = (this || _global$c).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$c).negative !== 0 && num.negative === 0) { + (this || _global$c).negative = 0; + r10 = this.isub(num); + (this || _global$c).negative ^= 1; + return this._normSign(); + } else if ((this || _global$c).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$c).length > num.length) { + a8 = this || _global$c; + b6 = num; + } else { + a8 = num; + b6 = this || _global$c; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$c).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$c).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$c).length = a8.length; + if (carry !== 0) { + (this || _global$c).words[(this || _global$c).length] = carry; + (this || _global$c).length++; + } else if (a8 !== (this || _global$c)) { + for (; i8 < a8.length; i8++) { + (this || _global$c).words[i8] = a8.words[i8]; + } + } + return this || _global$c; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$c).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$c).negative !== 0) { + (this || _global$c).negative = 0; + res = num.sub(this || _global$c); + (this || _global$c).negative = 1; + return res; + } + if ((this || _global$c).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$c); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$c).negative !== 0) { + (this || _global$c).negative = 0; + this.iadd(num); + (this || _global$c).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$c).negative = 0; + (this || _global$c).length = 1; + (this || _global$c).words[0] = 0; + return this || _global$c; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$c; + b6 = num; + } else { + a8 = num; + b6 = this || _global$c; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$c).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$c).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$c)) { + for (; i8 < a8.length; i8++) { + (this || _global$c).words[i8] = a8.words[i8]; + } + } + (this || _global$c).length = Math.max((this || _global$c).length, i8); + if (a8 !== (this || _global$c)) { + (this || _global$c).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$c).length + num.length; + if ((this || _global$c).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$c, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$c, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$c, num, out); + } else { + res = jumboMulTo(this || _global$c, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$c).x = x5; + (this || _global$c).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$c).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$c).length + num.length); + return jumboMulTo(this || _global$c, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$c); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$c).length; i8++) { + var w5 = ((this || _global$c).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$c).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$c).words[i8] = carry; + (this || _global$c).length++; + } + return this || _global$c; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$c); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$c; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$c).length; i8++) { + var newCarry = (this || _global$c).words[i8] & carryMask; + var c8 = ((this || _global$c).words[i8] | 0) - newCarry << r10; + (this || _global$c).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$c).words[i8] = carry; + (this || _global$c).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$c).length - 1; i8 >= 0; i8--) { + (this || _global$c).words[i8 + s7] = (this || _global$c).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$c).words[i8] = 0; + } + (this || _global$c).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$c).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$c).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$c).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$c).length > s7) { + (this || _global$c).length -= s7; + for (i8 = 0; i8 < (this || _global$c).length; i8++) { + (this || _global$c).words[i8] = (this || _global$c).words[i8 + s7]; + } + } else { + (this || _global$c).words[0] = 0; + (this || _global$c).length = 1; + } + var carry = 0; + for (i8 = (this || _global$c).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$c).words[i8] | 0; + (this || _global$c).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$c).length === 0) { + (this || _global$c).words[0] = 0; + (this || _global$c).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$c).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$c).length <= s7) + return false; + var w5 = (this || _global$c).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$c).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$c).length <= s7) { + return this || _global$c; + } + if (r10 !== 0) { + s7++; + } + (this || _global$c).length = Math.min(s7, (this || _global$c).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$c).words[(this || _global$c).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$c).negative !== 0) { + if ((this || _global$c).length === 1 && ((this || _global$c).words[0] | 0) < num) { + (this || _global$c).words[0] = num - ((this || _global$c).words[0] | 0); + (this || _global$c).negative = 0; + return this || _global$c; + } + (this || _global$c).negative = 0; + this.isubn(num); + (this || _global$c).negative = 1; + return this || _global$c; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$c).words[0] += num; + for (var i8 = 0; i8 < (this || _global$c).length && (this || _global$c).words[i8] >= 67108864; i8++) { + (this || _global$c).words[i8] -= 67108864; + if (i8 === (this || _global$c).length - 1) { + (this || _global$c).words[i8 + 1] = 1; + } else { + (this || _global$c).words[i8 + 1]++; + } + } + (this || _global$c).length = Math.max((this || _global$c).length, i8 + 1); + return this || _global$c; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$c).negative !== 0) { + (this || _global$c).negative = 0; + this.iaddn(num); + (this || _global$c).negative = 1; + return this || _global$c; + } + (this || _global$c).words[0] -= num; + if ((this || _global$c).length === 1 && (this || _global$c).words[0] < 0) { + (this || _global$c).words[0] = -(this || _global$c).words[0]; + (this || _global$c).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$c).length && (this || _global$c).words[i8] < 0; i8++) { + (this || _global$c).words[i8] += 67108864; + (this || _global$c).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$c).negative = 0; + return this || _global$c; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$c).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$c).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$c).length - shift; i8++) { + w5 = ((this || _global$c).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$c).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$c).length; i8++) { + w5 = -((this || _global$c).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$c).words[i8] = w5 & 67108863; + } + (this || _global$c).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$c).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$c).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$c).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$c).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$c).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$c + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$c).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$c).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$c).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$c).words[i8] | 0) + carry * 67108864; + (this || _global$c).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$c; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$c; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$c).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$c).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$c).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$c).length <= s7) { + this._expand(s7 + 1); + (this || _global$c).words[s7] |= q4; + return this || _global$c; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$c).length; i8++) { + var w5 = (this || _global$c).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$c).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$c).words[i8] = carry; + (this || _global$c).length++; + } + return this || _global$c; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$c).length === 1 && (this || _global$c).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$c).negative !== 0 && !negative) + return -1; + if ((this || _global$c).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$c).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$c).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$c).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$c).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$c).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$c).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$c).length > num.length) + return 1; + if ((this || _global$c).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$c).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$c).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$c).red, "Already a number in reduction context"); + assert((this || _global$c).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$c)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$c).red, "fromRed works only with numbers in reduction context"); + return (this || _global$c).red.convertFrom(this || _global$c); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$c).red = ctx; + return this || _global$c; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$c).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$c).red, "redAdd works only with red numbers"); + return (this || _global$c).red.add(this || _global$c, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$c).red, "redIAdd works only with red numbers"); + return (this || _global$c).red.iadd(this || _global$c, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$c).red, "redSub works only with red numbers"); + return (this || _global$c).red.sub(this || _global$c, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$c).red, "redISub works only with red numbers"); + return (this || _global$c).red.isub(this || _global$c, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$c).red, "redShl works only with red numbers"); + return (this || _global$c).red.shl(this || _global$c, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$c).red, "redMul works only with red numbers"); + (this || _global$c).red._verify2(this || _global$c, num); + return (this || _global$c).red.mul(this || _global$c, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$c).red, "redMul works only with red numbers"); + (this || _global$c).red._verify2(this || _global$c, num); + return (this || _global$c).red.imul(this || _global$c, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$c).red, "redSqr works only with red numbers"); + (this || _global$c).red._verify1(this || _global$c); + return (this || _global$c).red.sqr(this || _global$c); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$c).red, "redISqr works only with red numbers"); + (this || _global$c).red._verify1(this || _global$c); + return (this || _global$c).red.isqr(this || _global$c); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$c).red, "redSqrt works only with red numbers"); + (this || _global$c).red._verify1(this || _global$c); + return (this || _global$c).red.sqrt(this || _global$c); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$c).red, "redInvm works only with red numbers"); + (this || _global$c).red._verify1(this || _global$c); + return (this || _global$c).red.invm(this || _global$c); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$c).red, "redNeg works only with red numbers"); + (this || _global$c).red._verify1(this || _global$c); + return (this || _global$c).red.neg(this || _global$c); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$c).red && !num.red, "redPow(normalNum)"); + (this || _global$c).red._verify1(this || _global$c); + return (this || _global$c).red.pow(this || _global$c, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$c).name = name15; + (this || _global$c).p = new BN(p8, 16); + (this || _global$c).n = (this || _global$c).p.bitLength(); + (this || _global$c).k = new BN(1).iushln((this || _global$c).n).isub((this || _global$c).p); + (this || _global$c).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$c).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$c).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$c).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$c).n); + var cmp = rlen < (this || _global$c).n ? -1 : r10.ucmp((this || _global$c).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$c).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$c).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$c).k); + }; + function K256() { + MPrime.call(this || _global$c, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$c, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$c, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$c, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$c).m = prime.p; + (this || _global$c).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$c).m = m7; + (this || _global$c).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$c).prime) + return (this || _global$c).prime.ireduce(a8)._forceRed(this || _global$c); + return a8.umod((this || _global$c).m)._forceRed(this || _global$c); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$c).m.sub(a8)._forceRed(this || _global$c); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$c).m) >= 0) { + res.isub((this || _global$c).m); + } + return res._forceRed(this || _global$c); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$c).m) >= 0) { + res.isub((this || _global$c).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$c).m); + } + return res._forceRed(this || _global$c); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$c).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$c).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$c).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$c).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$c); + var nOne = one.redNeg(); + var lpow = (this || _global$c).m.subn(1).iushrn(1); + var z6 = (this || _global$c).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$c); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$c).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$c); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$c); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$c).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$c, m7); + (this || _global$c).shift = (this || _global$c).m.bitLength(); + if ((this || _global$c).shift % 26 !== 0) { + (this || _global$c).shift += 26 - (this || _global$c).shift % 26; + } + (this || _global$c).r = new BN(1).iushln((this || _global$c).shift); + (this || _global$c).r2 = this.imod((this || _global$c).r.sqr()); + (this || _global$c).rinv = (this || _global$c).r._invmp((this || _global$c).m); + (this || _global$c).minv = (this || _global$c).rinv.mul((this || _global$c).r).isubn(1).div((this || _global$c).m); + (this || _global$c).minv = (this || _global$c).minv.umod((this || _global$c).r); + (this || _global$c).minv = (this || _global$c).r.sub((this || _global$c).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$c).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$c).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$c).shift).mul((this || _global$c).minv).imaskn((this || _global$c).shift).mul((this || _global$c).m); + var u8 = t9.isub(c8).iushrn((this || _global$c).shift); + var res = u8; + if (u8.cmp((this || _global$c).m) >= 0) { + res = u8.isub((this || _global$c).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$c).m); + } + return res._forceRed(this || _global$c); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$c); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$c).shift).mul((this || _global$c).minv).imaskn((this || _global$c).shift).mul((this || _global$c).m); + var u8 = t9.isub(c8).iushrn((this || _global$c).shift); + var res = u8; + if (u8.cmp((this || _global$c).m) >= 0) { + res = u8.isub((this || _global$c).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$c).m); + } + return res._forceRed(this || _global$c); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$c).m).mul((this || _global$c).r2)); + return res._forceRed(this || _global$c); + }; + })(module$5, exports$12$1); + return module$5.exports; + } + var _global$b = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var exports$11$1 = {}; + var indexOf = function(e12, t9) { + if (e12.indexOf) + return e12.indexOf(t9); + for (var n9 = 0; n9 < e12.length; n9++) + if (e12[n9] === t9) + return n9; + return -1; + }; + var Object_keys = function(e12) { + if (Object.keys) + return Object.keys(e12); + var t9 = []; + for (var n9 in e12) + t9.push(n9); + return t9; + }; + var forEach = function(e12, t9) { + if (e12.forEach) + return e12.forEach(t9); + for (var n9 = 0; n9 < e12.length; n9++) + t9(e12[n9], n9, e12); + }; + var defineProp = function() { + try { + return Object.defineProperty({}, "_", {}), function(e12, t9, n9) { + Object.defineProperty(e12, t9, { writable: true, enumerable: false, configurable: true, value: n9 }); + }; + } catch (e12) { + return function(e13, t9, n9) { + e13[t9] = n9; + }; + } + }(); + var globals = ["Array", "Boolean", "Date", "Error", "EvalError", "Function", "Infinity", "JSON", "Math", "NaN", "Number", "Object", "RangeError", "ReferenceError", "RegExp", "String", "SyntaxError", "TypeError", "URIError", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "eval", "isFinite", "isNaN", "parseFloat", "parseInt", "undefined", "unescape"]; + function Context() { + } + Context.prototype = {}; + var Script = exports$11$1.Script = function(e12) { + if (!((this || _global$b) instanceof Script)) + return new Script(e12); + (this || _global$b).code = e12; + }; + Script.prototype.runInContext = function(e12) { + if (!(e12 instanceof Context)) + throw new TypeError("needs a 'context' argument."); + var t9 = document.createElement("iframe"); + t9.style || (t9.style = {}), t9.style.display = "none", document.body.appendChild(t9); + var n9 = t9.contentWindow, r10 = n9.eval, o9 = n9.execScript; + !r10 && o9 && (o9.call(n9, "null"), r10 = n9.eval), forEach(Object_keys(e12), function(t10) { + n9[t10] = e12[t10]; + }), forEach(globals, function(t10) { + e12[t10] && (n9[t10] = e12[t10]); + }); + var c8 = Object_keys(n9), i8 = r10.call(n9, (this || _global$b).code); + return forEach(Object_keys(n9), function(t10) { + (t10 in e12 || -1 === indexOf(c8, t10)) && (e12[t10] = n9[t10]); + }), forEach(globals, function(t10) { + t10 in e12 || defineProp(e12, t10, n9[t10]); + }), document.body.removeChild(t9), i8; + }, Script.prototype.runInThisContext = function() { + return eval((this || _global$b).code); + }, Script.prototype.runInNewContext = function(e12) { + var t9 = Script.createContext(e12), n9 = this.runInContext(t9); + return e12 && forEach(Object_keys(t9), function(n10) { + e12[n10] = t9[n10]; + }), n9; + }, forEach(Object_keys(Script.prototype), function(e12) { + exports$11$1[e12] = Script[e12] = function(t9) { + var n9 = Script(t9); + return n9[e12].apply(n9, [].slice.call(arguments, 1)); + }; + }), exports$11$1.isContext = function(e12) { + return e12 instanceof Context; + }, exports$11$1.createScript = function(e12) { + return exports$11$1.Script(e12); + }, exports$11$1.createContext = Script.createContext = function(e12) { + var t9 = new Context(); + return "object" == typeof e12 && forEach(Object_keys(e12), function(n9) { + t9[n9] = e12[n9]; + }), t9; + }; + exports$11$1.Script; + exports$11$1.createContext; + exports$11$1.createScript; + exports$11$1.isContext; + exports$11$1.runInContext; + exports$11$1.runInNewContext; + exports$11$1.runInThisContext; + var o5 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var n5 = T; + var t5 = u4.Buffer; + var f5 = o5.crypto || o5.msCrypto; + var a5 = f5 && f5.getRandomValues ? function(e12, r10) { + if (e12 > 4294967295) + throw new RangeError("requested too many random bytes"); + var o9 = t5.allocUnsafe(e12); + if (e12 > 0) + if (e12 > 65536) + for (var a8 = 0; a8 < e12; a8 += 65536) + f5.getRandomValues(o9.slice(a8, a8 + 65536)); + else + f5.getRandomValues(o9); + if ("function" == typeof r10) + return n5.nextTick(function() { + r10(null, o9); + }); + return o9; + } : function() { + throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11"); + }; + var e7 = u4.Buffer; + var o$13 = b$i.Transform; + function s5(t9) { + o$13.call(this), this._block = e7.allocUnsafe(t9), this._blockSize = t9, this._blockOffset = 0, this._length = [0, 0, 0, 0], this._finalized = false; + } + t$2(s5, o$13), s5.prototype._transform = function(t9, i8, r10) { + var e12 = null; + try { + this.update(t9, i8); + } catch (t10) { + e12 = t10; + } + r10(e12); + }, s5.prototype._flush = function(t9) { + var i8 = null; + try { + this.push(this.digest()); + } catch (t10) { + i8 = t10; + } + t9(i8); + }, s5.prototype.update = function(t9, i8) { + if (!function(t10, i9) { + if (!e7.isBuffer(t10) && "string" != typeof t10) + throw new TypeError(i9 + " must be a string or a buffer"); + }(t9, "Data"), this._finalized) + throw new Error("Digest already called"); + e7.isBuffer(t9) || (t9 = e7.from(t9, i8)); + for (var r10 = this._block, o9 = 0; this._blockOffset + t9.length - o9 >= this._blockSize; ) { + for (var s7 = this._blockOffset; s7 < this._blockSize; ) + r10[s7++] = t9[o9++]; + this._update(), this._blockOffset = 0; + } + for (; o9 < t9.length; ) + r10[this._blockOffset++] = t9[o9++]; + for (var f9 = 0, n9 = 8 * t9.length; n9 > 0; ++f9) + this._length[f9] += n9, (n9 = this._length[f9] / 4294967296 | 0) > 0 && (this._length[f9] -= 4294967296 * n9); + return this; + }, s5.prototype._update = function() { + throw new Error("_update is not implemented"); + }, s5.prototype.digest = function(t9) { + if (this._finalized) + throw new Error("Digest already called"); + this._finalized = true; + var i8 = this._digest(); + void 0 !== t9 && (i8 = i8.toString(t9)), this._block.fill(0), this._blockOffset = 0; + for (var r10 = 0; r10 < 4; ++r10) + this._length[r10] = 0; + return i8; + }, s5.prototype._digest = function() { + throw new Error("_digest is not implemented"); + }; + var f$12 = s5; + var h5 = t$2; + var r5 = f$12; + var _3 = u4.Buffer; + var e$13 = new Array(16); + function n$13() { + r5.call(this, 64), this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878; + } + function o$22(t9, i8) { + return t9 << i8 | t9 >>> 32 - i8; + } + function f$22(t9, i8, s7, h9, r10, _5, e12) { + return o$22(t9 + (i8 & s7 | ~i8 & h9) + r10 + _5 | 0, e12) + i8 | 0; + } + function c5(t9, i8, s7, h9, r10, _5, e12) { + return o$22(t9 + (i8 & h9 | s7 & ~h9) + r10 + _5 | 0, e12) + i8 | 0; + } + function a$1(t9, i8, s7, h9, r10, _5, e12) { + return o$22(t9 + (i8 ^ s7 ^ h9) + r10 + _5 | 0, e12) + i8 | 0; + } + function l5(t9, i8, s7, h9, r10, _5, e12) { + return o$22(t9 + (s7 ^ (i8 | ~h9)) + r10 + _5 | 0, e12) + i8 | 0; + } + h5(n$13, r5), n$13.prototype._update = function() { + for (var t9 = e$13, i8 = 0; i8 < 16; ++i8) + t9[i8] = this._block.readInt32LE(4 * i8); + var s7 = this._a, h9 = this._b, r10 = this._c, _5 = this._d; + s7 = f$22(s7, h9, r10, _5, t9[0], 3614090360, 7), _5 = f$22(_5, s7, h9, r10, t9[1], 3905402710, 12), r10 = f$22(r10, _5, s7, h9, t9[2], 606105819, 17), h9 = f$22(h9, r10, _5, s7, t9[3], 3250441966, 22), s7 = f$22(s7, h9, r10, _5, t9[4], 4118548399, 7), _5 = f$22(_5, s7, h9, r10, t9[5], 1200080426, 12), r10 = f$22(r10, _5, s7, h9, t9[6], 2821735955, 17), h9 = f$22(h9, r10, _5, s7, t9[7], 4249261313, 22), s7 = f$22(s7, h9, r10, _5, t9[8], 1770035416, 7), _5 = f$22(_5, s7, h9, r10, t9[9], 2336552879, 12), r10 = f$22(r10, _5, s7, h9, t9[10], 4294925233, 17), h9 = f$22(h9, r10, _5, s7, t9[11], 2304563134, 22), s7 = f$22(s7, h9, r10, _5, t9[12], 1804603682, 7), _5 = f$22(_5, s7, h9, r10, t9[13], 4254626195, 12), r10 = f$22(r10, _5, s7, h9, t9[14], 2792965006, 17), s7 = c5(s7, h9 = f$22(h9, r10, _5, s7, t9[15], 1236535329, 22), r10, _5, t9[1], 4129170786, 5), _5 = c5(_5, s7, h9, r10, t9[6], 3225465664, 9), r10 = c5(r10, _5, s7, h9, t9[11], 643717713, 14), h9 = c5(h9, r10, _5, s7, t9[0], 3921069994, 20), s7 = c5(s7, h9, r10, _5, t9[5], 3593408605, 5), _5 = c5(_5, s7, h9, r10, t9[10], 38016083, 9), r10 = c5(r10, _5, s7, h9, t9[15], 3634488961, 14), h9 = c5(h9, r10, _5, s7, t9[4], 3889429448, 20), s7 = c5(s7, h9, r10, _5, t9[9], 568446438, 5), _5 = c5(_5, s7, h9, r10, t9[14], 3275163606, 9), r10 = c5(r10, _5, s7, h9, t9[3], 4107603335, 14), h9 = c5(h9, r10, _5, s7, t9[8], 1163531501, 20), s7 = c5(s7, h9, r10, _5, t9[13], 2850285829, 5), _5 = c5(_5, s7, h9, r10, t9[2], 4243563512, 9), r10 = c5(r10, _5, s7, h9, t9[7], 1735328473, 14), s7 = a$1(s7, h9 = c5(h9, r10, _5, s7, t9[12], 2368359562, 20), r10, _5, t9[5], 4294588738, 4), _5 = a$1(_5, s7, h9, r10, t9[8], 2272392833, 11), r10 = a$1(r10, _5, s7, h9, t9[11], 1839030562, 16), h9 = a$1(h9, r10, _5, s7, t9[14], 4259657740, 23), s7 = a$1(s7, h9, r10, _5, t9[1], 2763975236, 4), _5 = a$1(_5, s7, h9, r10, t9[4], 1272893353, 11), r10 = a$1(r10, _5, s7, h9, t9[7], 4139469664, 16), h9 = a$1(h9, r10, _5, s7, t9[10], 3200236656, 23), s7 = a$1(s7, h9, r10, _5, t9[13], 681279174, 4), _5 = a$1(_5, s7, h9, r10, t9[0], 3936430074, 11), r10 = a$1(r10, _5, s7, h9, t9[3], 3572445317, 16), h9 = a$1(h9, r10, _5, s7, t9[6], 76029189, 23), s7 = a$1(s7, h9, r10, _5, t9[9], 3654602809, 4), _5 = a$1(_5, s7, h9, r10, t9[12], 3873151461, 11), r10 = a$1(r10, _5, s7, h9, t9[15], 530742520, 16), s7 = l5(s7, h9 = a$1(h9, r10, _5, s7, t9[2], 3299628645, 23), r10, _5, t9[0], 4096336452, 6), _5 = l5(_5, s7, h9, r10, t9[7], 1126891415, 10), r10 = l5(r10, _5, s7, h9, t9[14], 2878612391, 15), h9 = l5(h9, r10, _5, s7, t9[5], 4237533241, 21), s7 = l5(s7, h9, r10, _5, t9[12], 1700485571, 6), _5 = l5(_5, s7, h9, r10, t9[3], 2399980690, 10), r10 = l5(r10, _5, s7, h9, t9[10], 4293915773, 15), h9 = l5(h9, r10, _5, s7, t9[1], 2240044497, 21), s7 = l5(s7, h9, r10, _5, t9[8], 1873313359, 6), _5 = l5(_5, s7, h9, r10, t9[15], 4264355552, 10), r10 = l5(r10, _5, s7, h9, t9[6], 2734768916, 15), h9 = l5(h9, r10, _5, s7, t9[13], 1309151649, 21), s7 = l5(s7, h9, r10, _5, t9[4], 4149444226, 6), _5 = l5(_5, s7, h9, r10, t9[11], 3174756917, 10), r10 = l5(r10, _5, s7, h9, t9[2], 718787259, 15), h9 = l5(h9, r10, _5, s7, t9[9], 3951481745, 21), this._a = this._a + s7 | 0, this._b = this._b + h9 | 0, this._c = this._c + r10 | 0, this._d = this._d + _5 | 0; + }, n$13.prototype._digest = function() { + this._block[this._blockOffset++] = 128, this._blockOffset > 56 && (this._block.fill(0, this._blockOffset, 64), this._update(), this._blockOffset = 0), this._block.fill(0, this._blockOffset, 56), this._block.writeUInt32LE(this._length[0], 56), this._block.writeUInt32LE(this._length[1], 60), this._update(); + var t9 = _3.allocUnsafe(16); + return t9.writeInt32LE(this._a, 0), t9.writeInt32LE(this._b, 4), t9.writeInt32LE(this._c, 8), t9.writeInt32LE(this._d, 12), t9; + }; + var u5 = n$13; + var h$1 = e$1$1.Buffer; + var _$1 = t$2; + var r$12 = f$12; + var e$2 = new Array(16); + var n$2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]; + var o$3 = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]; + var f$3 = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]; + var c$13 = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]; + var a$22 = [0, 1518500249, 1859775393, 2400959708, 2840853838]; + var l$13 = [1352829926, 1548603684, 1836072691, 2053994217, 0]; + function u$13() { + r$12.call(this, 64), this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520; + } + function b3(t9, i8) { + return t9 << i8 | t9 >>> 32 - i8; + } + function d4(t9, i8, s7, h9, _5, r10, e12, n9) { + return b3(t9 + (i8 ^ s7 ^ h9) + r10 + e12 | 0, n9) + _5 | 0; + } + function k3(t9, i8, s7, h9, _5, r10, e12, n9) { + return b3(t9 + (i8 & s7 | ~i8 & h9) + r10 + e12 | 0, n9) + _5 | 0; + } + function p5(t9, i8, s7, h9, _5, r10, e12, n9) { + return b3(t9 + ((i8 | ~s7) ^ h9) + r10 + e12 | 0, n9) + _5 | 0; + } + function w3(t9, i8, s7, h9, _5, r10, e12, n9) { + return b3(t9 + (i8 & h9 | s7 & ~h9) + r10 + e12 | 0, n9) + _5 | 0; + } + function E3(t9, i8, s7, h9, _5, r10, e12, n9) { + return b3(t9 + (i8 ^ (s7 | ~h9)) + r10 + e12 | 0, n9) + _5 | 0; + } + _$1(u$13, r$12), u$13.prototype._update = function() { + for (var t9 = e$2, i8 = 0; i8 < 16; ++i8) + t9[i8] = this._block.readInt32LE(4 * i8); + for (var s7 = 0 | this._a, h9 = 0 | this._b, _5 = 0 | this._c, r10 = 0 | this._d, u8 = 0 | this._e, I5 = 0 | this._a, L5 = 0 | this._b, v7 = 0 | this._c, m7 = 0 | this._d, O6 = 0 | this._e, g6 = 0; g6 < 80; g6 += 1) { + var y7, U5; + g6 < 16 ? (y7 = d4(s7, h9, _5, r10, u8, t9[n$2[g6]], a$22[0], f$3[g6]), U5 = E3(I5, L5, v7, m7, O6, t9[o$3[g6]], l$13[0], c$13[g6])) : g6 < 32 ? (y7 = k3(s7, h9, _5, r10, u8, t9[n$2[g6]], a$22[1], f$3[g6]), U5 = w3(I5, L5, v7, m7, O6, t9[o$3[g6]], l$13[1], c$13[g6])) : g6 < 48 ? (y7 = p5(s7, h9, _5, r10, u8, t9[n$2[g6]], a$22[2], f$3[g6]), U5 = p5(I5, L5, v7, m7, O6, t9[o$3[g6]], l$13[2], c$13[g6])) : g6 < 64 ? (y7 = w3(s7, h9, _5, r10, u8, t9[n$2[g6]], a$22[3], f$3[g6]), U5 = k3(I5, L5, v7, m7, O6, t9[o$3[g6]], l$13[3], c$13[g6])) : (y7 = E3(s7, h9, _5, r10, u8, t9[n$2[g6]], a$22[4], f$3[g6]), U5 = d4(I5, L5, v7, m7, O6, t9[o$3[g6]], l$13[4], c$13[g6])), s7 = u8, u8 = r10, r10 = b3(_5, 10), _5 = h9, h9 = y7, I5 = O6, O6 = m7, m7 = b3(v7, 10), v7 = L5, L5 = U5; + } + var x5 = this._b + _5 + m7 | 0; + this._b = this._c + r10 + O6 | 0, this._c = this._d + u8 + I5 | 0, this._d = this._e + s7 + L5 | 0, this._e = this._a + h9 + v7 | 0, this._a = x5; + }, u$13.prototype._digest = function() { + this._block[this._blockOffset++] = 128, this._blockOffset > 56 && (this._block.fill(0, this._blockOffset, 64), this._update(), this._blockOffset = 0), this._block.fill(0, this._blockOffset, 56), this._block.writeUInt32LE(this._length[0], 56), this._block.writeUInt32LE(this._length[1], 60), this._update(); + var t9 = h$1.alloc ? h$1.alloc(20) : new h$1(20); + return t9.writeInt32LE(this._a, 0), t9.writeInt32LE(this._b, 4), t9.writeInt32LE(this._c, 8), t9.writeInt32LE(this._d, 12), t9.writeInt32LE(this._e, 16), t9; + }; + var I3 = u$13; + var s$12 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var h$2 = u4.Buffer; + function e$3(t9, i8) { + (this || s$12)._block = h$2.alloc(t9), (this || s$12)._finalSize = i8, (this || s$12)._blockSize = t9, (this || s$12)._len = 0; + } + e$3.prototype.update = function(t9, i8) { + "string" == typeof t9 && (i8 = i8 || "utf8", t9 = h$2.from(t9, i8)); + for (var e12 = (this || s$12)._block, _5 = (this || s$12)._blockSize, n9 = t9.length, r10 = (this || s$12)._len, o9 = 0; o9 < n9; ) { + for (var f9 = r10 % _5, l8 = Math.min(n9 - o9, _5 - f9), a8 = 0; a8 < l8; a8++) + e12[f9 + a8] = t9[o9 + a8]; + o9 += l8, (r10 += l8) % _5 == 0 && this._update(e12); + } + return (this || s$12)._len += n9, this || s$12; + }, e$3.prototype.digest = function(t9) { + var i8 = (this || s$12)._len % (this || s$12)._blockSize; + (this || s$12)._block[i8] = 128, (this || s$12)._block.fill(0, i8 + 1), i8 >= (this || s$12)._finalSize && (this._update((this || s$12)._block), (this || s$12)._block.fill(0)); + var h9 = 8 * (this || s$12)._len; + if (h9 <= 4294967295) + (this || s$12)._block.writeUInt32BE(h9, (this || s$12)._blockSize - 4); + else { + var e12 = (4294967295 & h9) >>> 0, _5 = (h9 - e12) / 4294967296; + (this || s$12)._block.writeUInt32BE(_5, (this || s$12)._blockSize - 8), (this || s$12)._block.writeUInt32BE(e12, (this || s$12)._blockSize - 4); + } + this._update((this || s$12)._block); + var n9 = this._hash(); + return t9 ? n9.toString(t9) : n9; + }, e$3.prototype._update = function() { + throw new Error("_update must be implemented by subclass"); + }; + var _$2 = e$3; + var n$3 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var r$2 = t$2; + var o$4 = _$2; + var f$4 = u4.Buffer; + var l$2 = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298]; + var a$3 = new Array(64); + function u$22() { + this.init(), (this || n$3)._w = a$3, o$4.call(this || n$3, 64, 56); + } + function c$2(t9, i8, s7) { + return s7 ^ t9 & (i8 ^ s7); + } + function b$1(t9, i8, s7) { + return t9 & i8 | s7 & (t9 | i8); + } + function p$1(t9) { + return (t9 >>> 2 | t9 << 30) ^ (t9 >>> 13 | t9 << 19) ^ (t9 >>> 22 | t9 << 10); + } + function d$1(t9) { + return (t9 >>> 6 | t9 << 26) ^ (t9 >>> 11 | t9 << 21) ^ (t9 >>> 25 | t9 << 7); + } + function k$1(t9) { + return (t9 >>> 7 | t9 << 25) ^ (t9 >>> 18 | t9 << 14) ^ t9 >>> 3; + } + r$2(u$22, o$4), u$22.prototype.init = function() { + return (this || n$3)._a = 1779033703, (this || n$3)._b = 3144134277, (this || n$3)._c = 1013904242, (this || n$3)._d = 2773480762, (this || n$3)._e = 1359893119, (this || n$3)._f = 2600822924, (this || n$3)._g = 528734635, (this || n$3)._h = 1541459225, this || n$3; + }, u$22.prototype._update = function(t9) { + for (var i8, s7 = (this || n$3)._w, h9 = 0 | (this || n$3)._a, e12 = 0 | (this || n$3)._b, _5 = 0 | (this || n$3)._c, r10 = 0 | (this || n$3)._d, o9 = 0 | (this || n$3)._e, f9 = 0 | (this || n$3)._f, a8 = 0 | (this || n$3)._g, u8 = 0 | (this || n$3)._h, w5 = 0; w5 < 16; ++w5) + s7[w5] = t9.readInt32BE(4 * w5); + for (; w5 < 64; ++w5) + s7[w5] = 0 | (((i8 = s7[w5 - 2]) >>> 17 | i8 << 15) ^ (i8 >>> 19 | i8 << 13) ^ i8 >>> 10) + s7[w5 - 7] + k$1(s7[w5 - 15]) + s7[w5 - 16]; + for (var g6 = 0; g6 < 64; ++g6) { + var B5 = u8 + d$1(o9) + c$2(o9, f9, a8) + l$2[g6] + s7[g6] | 0, v7 = p$1(h9) + b$1(h9, e12, _5) | 0; + u8 = a8, a8 = f9, f9 = o9, o9 = r10 + B5 | 0, r10 = _5, _5 = e12, e12 = h9, h9 = B5 + v7 | 0; + } + (this || n$3)._a = h9 + (this || n$3)._a | 0, (this || n$3)._b = e12 + (this || n$3)._b | 0, (this || n$3)._c = _5 + (this || n$3)._c | 0, (this || n$3)._d = r10 + (this || n$3)._d | 0, (this || n$3)._e = o9 + (this || n$3)._e | 0, (this || n$3)._f = f9 + (this || n$3)._f | 0, (this || n$3)._g = a8 + (this || n$3)._g | 0, (this || n$3)._h = u8 + (this || n$3)._h | 0; + }, u$22.prototype._hash = function() { + var t9 = f$4.allocUnsafe(32); + return t9.writeInt32BE((this || n$3)._a, 0), t9.writeInt32BE((this || n$3)._b, 4), t9.writeInt32BE((this || n$3)._c, 8), t9.writeInt32BE((this || n$3)._d, 12), t9.writeInt32BE((this || n$3)._e, 16), t9.writeInt32BE((this || n$3)._f, 20), t9.writeInt32BE((this || n$3)._g, 24), t9.writeInt32BE((this || n$3)._h, 28), t9; + }; + var w$1 = u$22; + var _$3 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var e$4 = t$2; + var n$4 = _$2; + var r$3 = u4.Buffer; + var l$3 = [1518500249, 1859775393, -1894007588, -899497514]; + var o$5 = new Array(80); + function f$5() { + this.init(), (this || _$3)._w = o$5, n$4.call(this || _$3, 64, 56); + } + function a$4(t9) { + return t9 << 30 | t9 >>> 2; + } + function u$3(t9, i8, h9, s7) { + return 0 === t9 ? i8 & h9 | ~i8 & s7 : 2 === t9 ? i8 & h9 | i8 & s7 | h9 & s7 : i8 ^ h9 ^ s7; + } + e$4(f$5, n$4), f$5.prototype.init = function() { + return (this || _$3)._a = 1732584193, (this || _$3)._b = 4023233417, (this || _$3)._c = 2562383102, (this || _$3)._d = 271733878, (this || _$3)._e = 3285377520, this || _$3; + }, f$5.prototype._update = function(t9) { + for (var i8, h9 = (this || _$3)._w, s7 = 0 | (this || _$3)._a, e12 = 0 | (this || _$3)._b, n9 = 0 | (this || _$3)._c, r10 = 0 | (this || _$3)._d, o9 = 0 | (this || _$3)._e, f9 = 0; f9 < 16; ++f9) + h9[f9] = t9.readInt32BE(4 * f9); + for (; f9 < 80; ++f9) + h9[f9] = h9[f9 - 3] ^ h9[f9 - 8] ^ h9[f9 - 14] ^ h9[f9 - 16]; + for (var c8 = 0; c8 < 80; ++c8) { + var d7 = ~~(c8 / 20), p8 = 0 | ((i8 = s7) << 5 | i8 >>> 27) + u$3(d7, e12, n9, r10) + o9 + h9[c8] + l$3[d7]; + o9 = r10, r10 = n9, n9 = a$4(e12), e12 = s7, s7 = p8; + } + (this || _$3)._a = s7 + (this || _$3)._a | 0, (this || _$3)._b = e12 + (this || _$3)._b | 0, (this || _$3)._c = n9 + (this || _$3)._c | 0, (this || _$3)._d = r10 + (this || _$3)._d | 0, (this || _$3)._e = o9 + (this || _$3)._e | 0; + }, f$5.prototype._hash = function() { + var t9 = r$3.allocUnsafe(20); + return t9.writeInt32BE(0 | (this || _$3)._a, 0), t9.writeInt32BE(0 | (this || _$3)._b, 4), t9.writeInt32BE(0 | (this || _$3)._c, 8), t9.writeInt32BE(0 | (this || _$3)._d, 12), t9.writeInt32BE(0 | (this || _$3)._e, 16), t9; + }; + var c$3 = f$5; + var d$2 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var p$2 = t$2; + var b$2 = _$2; + var w$2 = u4.Buffer; + var g3 = [1518500249, 1859775393, -1894007588, -899497514]; + var B3 = new Array(80); + function y4() { + this.init(), (this || d$2)._w = B3, b$2.call(this || d$2, 64, 56); + } + function E$1(t9) { + return t9 << 5 | t9 >>> 27; + } + function I$1(t9) { + return t9 << 30 | t9 >>> 2; + } + function v4(t9, i8, h9, s7) { + return 0 === t9 ? i8 & h9 | ~i8 & s7 : 2 === t9 ? i8 & h9 | i8 & s7 | h9 & s7 : i8 ^ h9 ^ s7; + } + p$2(y4, b$2), y4.prototype.init = function() { + return (this || d$2)._a = 1732584193, (this || d$2)._b = 4023233417, (this || d$2)._c = 2562383102, (this || d$2)._d = 271733878, (this || d$2)._e = 3285377520, this || d$2; + }, y4.prototype._update = function(t9) { + for (var i8, h9 = (this || d$2)._w, s7 = 0 | (this || d$2)._a, _5 = 0 | (this || d$2)._b, e12 = 0 | (this || d$2)._c, n9 = 0 | (this || d$2)._d, r10 = 0 | (this || d$2)._e, l8 = 0; l8 < 16; ++l8) + h9[l8] = t9.readInt32BE(4 * l8); + for (; l8 < 80; ++l8) + h9[l8] = (i8 = h9[l8 - 3] ^ h9[l8 - 8] ^ h9[l8 - 14] ^ h9[l8 - 16]) << 1 | i8 >>> 31; + for (var o9 = 0; o9 < 80; ++o9) { + var f9 = ~~(o9 / 20), a8 = E$1(s7) + v4(f9, _5, e12, n9) + r10 + h9[o9] + g3[f9] | 0; + r10 = n9, n9 = e12, e12 = I$1(_5), _5 = s7, s7 = a8; + } + (this || d$2)._a = s7 + (this || d$2)._a | 0, (this || d$2)._b = _5 + (this || d$2)._b | 0, (this || d$2)._c = e12 + (this || d$2)._c | 0, (this || d$2)._d = n9 + (this || d$2)._d | 0, (this || d$2)._e = r10 + (this || d$2)._e | 0; + }, y4.prototype._hash = function() { + var t9 = w$2.allocUnsafe(20); + return t9.writeInt32BE(0 | (this || d$2)._a, 0), t9.writeInt32BE(0 | (this || d$2)._b, 4), t9.writeInt32BE(0 | (this || d$2)._c, 8), t9.writeInt32BE(0 | (this || d$2)._d, 12), t9.writeInt32BE(0 | (this || d$2)._e, 16), t9; + }; + var T4 = y4; + var m4 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var A3 = t$2; + var U3 = w$1; + var x3 = _$2; + var j3 = u4.Buffer; + var q2 = new Array(64); + function C3() { + this.init(), (this || m4)._w = q2, x3.call(this || m4, 64, 56); + } + A3(C3, U3), C3.prototype.init = function() { + return (this || m4)._a = 3238371032, (this || m4)._b = 914150663, (this || m4)._c = 812702999, (this || m4)._d = 4144912697, (this || m4)._e = 4290775857, (this || m4)._f = 1750603025, (this || m4)._g = 1694076839, (this || m4)._h = 3204075428, this || m4; + }, C3.prototype._hash = function() { + var t9 = j3.allocUnsafe(28); + return t9.writeInt32BE((this || m4)._a, 0), t9.writeInt32BE((this || m4)._b, 4), t9.writeInt32BE((this || m4)._c, 8), t9.writeInt32BE((this || m4)._d, 12), t9.writeInt32BE((this || m4)._e, 16), t9.writeInt32BE((this || m4)._f, 20), t9.writeInt32BE((this || m4)._g, 24), t9; + }; + var L3 = C3; + var k$2 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var z3 = t$2; + var D3 = _$2; + var F3 = u4.Buffer; + var G2 = [1116352408, 3609767458, 1899447441, 602891725, 3049323471, 3964484399, 3921009573, 2173295548, 961987163, 4081628472, 1508970993, 3053834265, 2453635748, 2937671579, 2870763221, 3664609560, 3624381080, 2734883394, 310598401, 1164996542, 607225278, 1323610764, 1426881987, 3590304994, 1925078388, 4068182383, 2162078206, 991336113, 2614888103, 633803317, 3248222580, 3479774868, 3835390401, 2666613458, 4022224774, 944711139, 264347078, 2341262773, 604807628, 2007800933, 770255983, 1495990901, 1249150122, 1856431235, 1555081692, 3175218132, 1996064986, 2198950837, 2554220882, 3999719339, 2821834349, 766784016, 2952996808, 2566594879, 3210313671, 3203337956, 3336571891, 1034457026, 3584528711, 2466948901, 113926993, 3758326383, 338241895, 168717936, 666307205, 1188179964, 773529912, 1546045734, 1294757372, 1522805485, 1396182291, 2643833823, 1695183700, 2343527390, 1986661051, 1014477480, 2177026350, 1206759142, 2456956037, 344077627, 2730485921, 1290863460, 2820302411, 3158454273, 3259730800, 3505952657, 3345764771, 106217008, 3516065817, 3606008344, 3600352804, 1432725776, 4094571909, 1467031594, 275423344, 851169720, 430227734, 3100823752, 506948616, 1363258195, 659060556, 3750685593, 883997877, 3785050280, 958139571, 3318307427, 1322822218, 3812723403, 1537002063, 2003034995, 1747873779, 3602036899, 1955562222, 1575990012, 2024104815, 1125592928, 2227730452, 2716904306, 2361852424, 442776044, 2428436474, 593698344, 2756734187, 3733110249, 3204031479, 2999351573, 3329325298, 3815920427, 3391569614, 3928383900, 3515267271, 566280711, 3940187606, 3454069534, 4118630271, 4000239992, 116418474, 1914138554, 174292421, 2731055270, 289380356, 3203993006, 460393269, 320620315, 685471733, 587496836, 852142971, 1086792851, 1017036298, 365543100, 1126000580, 2618297676, 1288033470, 3409855158, 1501505948, 4234509866, 1607167915, 987167468, 1816402316, 1246189591]; + var H2 = new Array(160); + function J2() { + this.init(), (this || k$2)._w = H2, D3.call(this || k$2, 128, 112); + } + function K2(t9, i8, h9) { + return h9 ^ t9 & (i8 ^ h9); + } + function M3(t9, i8, h9) { + return t9 & i8 | h9 & (t9 | i8); + } + function N11(t9, i8) { + return (t9 >>> 28 | i8 << 4) ^ (i8 >>> 2 | t9 << 30) ^ (i8 >>> 7 | t9 << 25); + } + function O3(t9, i8) { + return (t9 >>> 14 | i8 << 18) ^ (t9 >>> 18 | i8 << 14) ^ (i8 >>> 9 | t9 << 23); + } + function P3(t9, i8) { + return (t9 >>> 1 | i8 << 31) ^ (t9 >>> 8 | i8 << 24) ^ t9 >>> 7; + } + function Q2(t9, i8) { + return (t9 >>> 1 | i8 << 31) ^ (t9 >>> 8 | i8 << 24) ^ (t9 >>> 7 | i8 << 25); + } + function R3(t9, i8) { + return (t9 >>> 19 | i8 << 13) ^ (i8 >>> 29 | t9 << 3) ^ t9 >>> 6; + } + function S3(t9, i8) { + return (t9 >>> 19 | i8 << 13) ^ (i8 >>> 29 | t9 << 3) ^ (t9 >>> 6 | i8 << 26); + } + function V2(t9, i8) { + return t9 >>> 0 < i8 >>> 0 ? 1 : 0; + } + z3(J2, D3), J2.prototype.init = function() { + return (this || k$2)._ah = 1779033703, (this || k$2)._bh = 3144134277, (this || k$2)._ch = 1013904242, (this || k$2)._dh = 2773480762, (this || k$2)._eh = 1359893119, (this || k$2)._fh = 2600822924, (this || k$2)._gh = 528734635, (this || k$2)._hh = 1541459225, (this || k$2)._al = 4089235720, (this || k$2)._bl = 2227873595, (this || k$2)._cl = 4271175723, (this || k$2)._dl = 1595750129, (this || k$2)._el = 2917565137, (this || k$2)._fl = 725511199, (this || k$2)._gl = 4215389547, (this || k$2)._hl = 327033209, this || k$2; + }, J2.prototype._update = function(t9) { + for (var i8 = (this || k$2)._w, h9 = 0 | (this || k$2)._ah, s7 = 0 | (this || k$2)._bh, _5 = 0 | (this || k$2)._ch, e12 = 0 | (this || k$2)._dh, n9 = 0 | (this || k$2)._eh, r10 = 0 | (this || k$2)._fh, l8 = 0 | (this || k$2)._gh, o9 = 0 | (this || k$2)._hh, f9 = 0 | (this || k$2)._al, a8 = 0 | (this || k$2)._bl, u8 = 0 | (this || k$2)._cl, c8 = 0 | (this || k$2)._dl, d7 = 0 | (this || k$2)._el, p8 = 0 | (this || k$2)._fl, b6 = 0 | (this || k$2)._gl, w5 = 0 | (this || k$2)._hl, g6 = 0; g6 < 32; g6 += 2) + i8[g6] = t9.readInt32BE(4 * g6), i8[g6 + 1] = t9.readInt32BE(4 * g6 + 4); + for (; g6 < 160; g6 += 2) { + var B5 = i8[g6 - 30], y7 = i8[g6 - 30 + 1], E5 = P3(B5, y7), I5 = Q2(y7, B5), v7 = R3(B5 = i8[g6 - 4], y7 = i8[g6 - 4 + 1]), T6 = S3(y7, B5), m7 = i8[g6 - 14], A5 = i8[g6 - 14 + 1], U5 = i8[g6 - 32], x5 = i8[g6 - 32 + 1], j5 = I5 + A5 | 0, q4 = E5 + m7 + V2(j5, I5) | 0; + q4 = (q4 = q4 + v7 + V2(j5 = j5 + T6 | 0, T6) | 0) + U5 + V2(j5 = j5 + x5 | 0, x5) | 0, i8[g6] = q4, i8[g6 + 1] = j5; + } + for (var C5 = 0; C5 < 160; C5 += 2) { + q4 = i8[C5], j5 = i8[C5 + 1]; + var L5 = M3(h9, s7, _5), z6 = M3(f9, a8, u8), D5 = N11(h9, f9), F5 = N11(f9, h9), H4 = O3(n9, d7), J4 = O3(d7, n9), W4 = G2[C5], X4 = G2[C5 + 1], Y5 = K2(n9, r10, l8), Z4 = K2(d7, p8, b6), $4 = w5 + J4 | 0, tt3 = o9 + H4 + V2($4, w5) | 0; + tt3 = (tt3 = (tt3 = tt3 + Y5 + V2($4 = $4 + Z4 | 0, Z4) | 0) + W4 + V2($4 = $4 + X4 | 0, X4) | 0) + q4 + V2($4 = $4 + j5 | 0, j5) | 0; + var it4 = F5 + z6 | 0, ht2 = D5 + L5 + V2(it4, F5) | 0; + o9 = l8, w5 = b6, l8 = r10, b6 = p8, r10 = n9, p8 = d7, n9 = e12 + tt3 + V2(d7 = c8 + $4 | 0, c8) | 0, e12 = _5, c8 = u8, _5 = s7, u8 = a8, s7 = h9, a8 = f9, h9 = tt3 + ht2 + V2(f9 = $4 + it4 | 0, $4) | 0; + } + (this || k$2)._al = (this || k$2)._al + f9 | 0, (this || k$2)._bl = (this || k$2)._bl + a8 | 0, (this || k$2)._cl = (this || k$2)._cl + u8 | 0, (this || k$2)._dl = (this || k$2)._dl + c8 | 0, (this || k$2)._el = (this || k$2)._el + d7 | 0, (this || k$2)._fl = (this || k$2)._fl + p8 | 0, (this || k$2)._gl = (this || k$2)._gl + b6 | 0, (this || k$2)._hl = (this || k$2)._hl + w5 | 0, (this || k$2)._ah = (this || k$2)._ah + h9 + V2((this || k$2)._al, f9) | 0, (this || k$2)._bh = (this || k$2)._bh + s7 + V2((this || k$2)._bl, a8) | 0, (this || k$2)._ch = (this || k$2)._ch + _5 + V2((this || k$2)._cl, u8) | 0, (this || k$2)._dh = (this || k$2)._dh + e12 + V2((this || k$2)._dl, c8) | 0, (this || k$2)._eh = (this || k$2)._eh + n9 + V2((this || k$2)._el, d7) | 0, (this || k$2)._fh = (this || k$2)._fh + r10 + V2((this || k$2)._fl, p8) | 0, (this || k$2)._gh = (this || k$2)._gh + l8 + V2((this || k$2)._gl, b6) | 0, (this || k$2)._hh = (this || k$2)._hh + o9 + V2((this || k$2)._hl, w5) | 0; + }, J2.prototype._hash = function() { + var t9 = F3.allocUnsafe(64); + function i8(i9, h9, s7) { + t9.writeInt32BE(i9, s7), t9.writeInt32BE(h9, s7 + 4); + } + return i8((this || k$2)._ah, (this || k$2)._al, 0), i8((this || k$2)._bh, (this || k$2)._bl, 8), i8((this || k$2)._ch, (this || k$2)._cl, 16), i8((this || k$2)._dh, (this || k$2)._dl, 24), i8((this || k$2)._eh, (this || k$2)._el, 32), i8((this || k$2)._fh, (this || k$2)._fl, 40), i8((this || k$2)._gh, (this || k$2)._gl, 48), i8((this || k$2)._hh, (this || k$2)._hl, 56), t9; + }; + var W2 = J2; + var X2 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var Y3 = t$2; + var Z2 = W2; + var $2 = _$2; + var tt = u4.Buffer; + var it2 = new Array(160); + function ht() { + this.init(), (this || X2)._w = it2, $2.call(this || X2, 128, 112); + } + Y3(ht, Z2), ht.prototype.init = function() { + return (this || X2)._ah = 3418070365, (this || X2)._bh = 1654270250, (this || X2)._ch = 2438529370, (this || X2)._dh = 355462360, (this || X2)._eh = 1731405415, (this || X2)._fh = 2394180231, (this || X2)._gh = 3675008525, (this || X2)._hh = 1203062813, (this || X2)._al = 3238371032, (this || X2)._bl = 914150663, (this || X2)._cl = 812702999, (this || X2)._dl = 4144912697, (this || X2)._el = 4290775857, (this || X2)._fl = 1750603025, (this || X2)._gl = 1694076839, (this || X2)._hl = 3204075428, this || X2; + }, ht.prototype._hash = function() { + var t9 = tt.allocUnsafe(48); + function i8(i9, h9, s7) { + t9.writeInt32BE(i9, s7), t9.writeInt32BE(h9, s7 + 4); + } + return i8((this || X2)._ah, (this || X2)._al, 0), i8((this || X2)._bh, (this || X2)._bl, 8), i8((this || X2)._ch, (this || X2)._cl, 16), i8((this || X2)._dh, (this || X2)._dl, 24), i8((this || X2)._eh, (this || X2)._el, 32), i8((this || X2)._fh, (this || X2)._fl, 40), t9; + }; + var st; + var _t = ht; + var et = { exports: st = {} }; + (st = et.exports = function(t9) { + t9 = t9.toLowerCase(); + var i8 = st[t9]; + if (!i8) + throw new Error(t9 + " is not supported (we accept pull requests)"); + return new i8(); + }).sha = c$3, st.sha1 = T4, st.sha224 = L3, st.sha256 = w$1, st.sha384 = _t, st.sha512 = W2; + var nt = et.exports; + var e$5 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var n$5 = u4.Buffer; + var s$2 = b$i.Transform; + var h$3 = e$12.StringDecoder; + function a$5(t9) { + s$2.call(this || e$5), (this || e$5).hashMode = "string" == typeof t9, (this || e$5).hashMode ? (this || e$5)[t9] = (this || e$5)._finalOrDigest : (this || e$5).final = (this || e$5)._finalOrDigest, (this || e$5)._final && ((this || e$5).__final = (this || e$5)._final, (this || e$5)._final = null), (this || e$5)._decoder = null, (this || e$5)._encoding = null; + } + t$2(a$5, s$2), a$5.prototype.update = function(t9, i8, r10) { + "string" == typeof t9 && (t9 = n$5.from(t9, i8)); + var o9 = this._update(t9); + return (this || e$5).hashMode ? this || e$5 : (r10 && (o9 = this._toString(o9, r10)), o9); + }, a$5.prototype.setAutoPadding = function() { + }, a$5.prototype.getAuthTag = function() { + throw new Error("trying to get auth tag in unsupported state"); + }, a$5.prototype.setAuthTag = function() { + throw new Error("trying to set auth tag in unsupported state"); + }, a$5.prototype.setAAD = function() { + throw new Error("trying to set aad in unsupported state"); + }, a$5.prototype._transform = function(t9, i8, r10) { + var o9; + try { + (this || e$5).hashMode ? this._update(t9) : this.push(this._update(t9)); + } catch (t10) { + o9 = t10; + } finally { + r10(o9); + } + }, a$5.prototype._flush = function(t9) { + var i8; + try { + this.push(this.__final()); + } catch (t10) { + i8 = t10; + } + t9(i8); + }, a$5.prototype._finalOrDigest = function(t9) { + var i8 = this.__final() || n$5.alloc(0); + return t9 && (i8 = this._toString(i8, t9, true)), i8; + }, a$5.prototype._toString = function(t9, i8, r10) { + if ((this || e$5)._decoder || ((this || e$5)._decoder = new h$3(i8), (this || e$5)._encoding = i8), (this || e$5)._encoding !== i8) + throw new Error("can't switch encodings"); + var o9 = (this || e$5)._decoder.write(t9); + return r10 && (o9 += (this || e$5)._decoder.end()), o9; + }; + var f$6 = a$5; + var m$1 = u5; + var n$6 = I3; + var p$3 = nt; + var s$3 = f$6; + function a$6(t9) { + s$3.call(this, "digest"), this._hash = t9; + } + t$2(a$6, s$3), a$6.prototype._update = function(t9) { + this._hash.update(t9); + }, a$6.prototype._final = function() { + return this._hash.digest(); + }; + var h$4 = function(t9) { + return "md5" === (t9 = t9.toLowerCase()) ? new m$1() : "rmd160" === t9 || "ripemd160" === t9 ? new n$6() : new a$6(p$3(t9)); + }; + var e$6 = u5; + var r$4 = function(t9) { + return new e$6().update(t9).digest(); + }; + var o$6 = t$2; + var h$5 = u4.Buffer; + var n$7 = f$6; + var p$4 = h$5.alloc(128); + function f$7(t9, a8) { + n$7.call(this, "digest"), "string" == typeof a8 && (a8 = h$5.from(a8)), this._alg = t9, this._key = a8, a8.length > 64 ? a8 = t9(a8) : a8.length < 64 && (a8 = h$5.concat([a8, p$4], 64)); + for (var e12 = this._ipad = h$5.allocUnsafe(64), i8 = this._opad = h$5.allocUnsafe(64), r10 = 0; r10 < 64; r10++) + e12[r10] = 54 ^ a8[r10], i8[r10] = 92 ^ a8[r10]; + this._hash = [e12]; + } + o$6(f$7, n$7), f$7.prototype._update = function(t9) { + this._hash.push(t9); + }, f$7.prototype._final = function() { + var t9 = this._alg(h$5.concat(this._hash)); + return this._alg(h$5.concat([this._opad, t9])); + }; + var l$4 = t$2; + var d$3 = f$7; + var c$4 = f$6; + var _$4 = u4.Buffer; + var m$2 = r$4; + var u$4 = I3; + var g$1 = nt; + var v$1 = _$4.alloc(128); + function y$1(t9, a8) { + c$4.call(this, "digest"), "string" == typeof a8 && (a8 = _$4.from(a8)); + var e12 = "sha512" === t9 || "sha384" === t9 ? 128 : 64; + (this._alg = t9, this._key = a8, a8.length > e12) ? a8 = ("rmd160" === t9 ? new u$4() : g$1(t9)).update(a8).digest() : a8.length < e12 && (a8 = _$4.concat([a8, v$1], e12)); + for (var i8 = this._ipad = _$4.allocUnsafe(e12), r10 = this._opad = _$4.allocUnsafe(e12), s7 = 0; s7 < e12; s7++) + i8[s7] = 54 ^ a8[s7], r10[s7] = 92 ^ a8[s7]; + this._hash = "rmd160" === t9 ? new u$4() : g$1(t9), this._hash.update(i8); + } + l$4(y$1, c$4), y$1.prototype._update = function(t9) { + this._hash.update(t9); + }, y$1.prototype._final = function() { + var t9 = this._hash.digest(); + return ("rmd160" === this._alg ? new u$4() : g$1(this._alg)).update(this._opad).update(t9).digest(); + }; + var w$3 = function(t9, a8) { + return "rmd160" === (t9 = t9.toLowerCase()) || "ripemd160" === t9 ? new y$1("rmd160", a8) : "md5" === t9 ? new d$3(m$2, a8) : new y$1(t9, a8); + }; + var s$4 = { sha224WithRSAEncryption: { sign: "rsa", hash: "sha224", id: "302d300d06096086480165030402040500041c" }, "RSA-SHA224": { sign: "ecdsa/rsa", hash: "sha224", id: "302d300d06096086480165030402040500041c" }, sha256WithRSAEncryption: { sign: "rsa", hash: "sha256", id: "3031300d060960864801650304020105000420" }, "RSA-SHA256": { sign: "ecdsa/rsa", hash: "sha256", id: "3031300d060960864801650304020105000420" }, sha384WithRSAEncryption: { sign: "rsa", hash: "sha384", id: "3041300d060960864801650304020205000430" }, "RSA-SHA384": { sign: "ecdsa/rsa", hash: "sha384", id: "3041300d060960864801650304020205000430" }, sha512WithRSAEncryption: { sign: "rsa", hash: "sha512", id: "3051300d060960864801650304020305000440" }, "RSA-SHA512": { sign: "ecdsa/rsa", hash: "sha512", id: "3051300d060960864801650304020305000440" }, "RSA-SHA1": { sign: "rsa", hash: "sha1", id: "3021300906052b0e03021a05000414" }, "ecdsa-with-SHA1": { sign: "ecdsa", hash: "sha1", id: "" }, sha256: { sign: "ecdsa", hash: "sha256", id: "" }, sha224: { sign: "ecdsa", hash: "sha224", id: "" }, sha384: { sign: "ecdsa", hash: "sha384", id: "" }, sha512: { sign: "ecdsa", hash: "sha512", id: "" }, "DSA-SHA": { sign: "dsa", hash: "sha1", id: "" }, "DSA-SHA1": { sign: "dsa", hash: "sha1", id: "" }, DSA: { sign: "dsa", hash: "sha1", id: "" }, "DSA-WITH-SHA224": { sign: "dsa", hash: "sha224", id: "" }, "DSA-SHA224": { sign: "dsa", hash: "sha224", id: "" }, "DSA-WITH-SHA256": { sign: "dsa", hash: "sha256", id: "" }, "DSA-SHA256": { sign: "dsa", hash: "sha256", id: "" }, "DSA-WITH-SHA384": { sign: "dsa", hash: "sha384", id: "" }, "DSA-SHA384": { sign: "dsa", hash: "sha384", id: "" }, "DSA-WITH-SHA512": { sign: "dsa", hash: "sha512", id: "" }, "DSA-SHA512": { sign: "dsa", hash: "sha512", id: "" }, "DSA-RIPEMD160": { sign: "dsa", hash: "rmd160", id: "" }, ripemd160WithRSA: { sign: "rsa", hash: "rmd160", id: "3021300906052b2403020105000414" }, "RSA-RIPEMD160": { sign: "rsa", hash: "rmd160", id: "3021300906052b2403020105000414" }, md5WithRSAEncryption: { sign: "rsa", hash: "md5", id: "3020300c06082a864886f70d020505000410" }, "RSA-MD5": { sign: "rsa", hash: "md5", id: "3020300c06082a864886f70d020505000410" } }; + var f$8 = e$1$1.Buffer; + var a$7 = Math.pow(2, 30) - 1; + function s$5(r10, e12) { + if ("string" != typeof r10 && !f$8.isBuffer(r10)) + throw new TypeError(e12 + " must be a buffer or string"); + } + var u$5; + var h$6 = function(r10, e12, t9, n9) { + if (s$5(r10, "Password"), s$5(e12, "Salt"), "number" != typeof t9) + throw new TypeError("Iterations not a number"); + if (t9 < 0) + throw new TypeError("Bad iterations"); + if ("number" != typeof n9) + throw new TypeError("Key length not a number"); + if (n9 < 0 || n9 > a$7 || n9 != n9) + throw new TypeError("Bad key length"); + }; + var c$5 = T; + c$5.browser ? u$5 = "utf-8" : u$5 = parseInt(c$5.version.split(".")[0].slice(1), 10) >= 6 ? "utf-8" : "binary"; + var l$5 = u$5; + var p$5 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var d$4 = r$4; + var m$3 = I3; + var y$2 = nt; + var b$3 = h$6; + var v$2 = l$5; + var w$4 = u4.Buffer; + var g$2 = w$4.alloc(128); + var B$1 = { md5: 16, sha1: 20, sha224: 28, sha256: 32, sha384: 48, sha512: 64, rmd160: 20, ripemd160: 20 }; + function T$1(r10, e12, t9) { + var n9 = function(r11) { + function e13(e14) { + return y$2(r11).update(e14).digest(); + } + return "rmd160" === r11 || "ripemd160" === r11 ? function(r12) { + return new m$3().update(r12).digest(); + } : "md5" === r11 ? d$4 : e13; + }(r10), o9 = "sha512" === r10 || "sha384" === r10 ? 128 : 64; + e12.length > o9 ? e12 = n9(e12) : e12.length < o9 && (e12 = w$4.concat([e12, g$2], o9)); + for (var i8 = w$4.allocUnsafe(o9 + B$1[r10]), f9 = w$4.allocUnsafe(o9 + B$1[r10]), a8 = 0; a8 < o9; a8++) + i8[a8] = 54 ^ e12[a8], f9[a8] = 92 ^ e12[a8]; + var s7 = w$4.allocUnsafe(o9 + t9 + 4); + i8.copy(s7, 0, 0, o9), (this || p$5).ipad1 = s7, (this || p$5).ipad2 = i8, (this || p$5).opad = f9, (this || p$5).alg = r10, (this || p$5).blocksize = o9, (this || p$5).hash = n9, (this || p$5).size = B$1[r10]; + } + T$1.prototype.run = function(r10, e12) { + return r10.copy(e12, (this || p$5).blocksize), this.hash(e12).copy((this || p$5).opad, (this || p$5).blocksize), this.hash((this || p$5).opad); + }; + var k$3; + var S$1 = function(r10, e12, t9, n9, o9) { + b$3(r10, e12, t9, n9), w$4.isBuffer(r10) || (r10 = w$4.from(r10, v$2)), w$4.isBuffer(e12) || (e12 = w$4.from(e12, v$2)); + var i8 = new T$1(o9 = o9 || "sha1", r10, e12.length), f9 = w$4.allocUnsafe(n9), a8 = w$4.allocUnsafe(e12.length + 4); + e12.copy(a8, 0, 0, e12.length); + for (var s7 = 0, u8 = B$1[o9], h9 = Math.ceil(n9 / u8), c8 = 1; c8 <= h9; c8++) { + a8.writeUInt32BE(c8, e12.length); + for (var l8 = i8.run(a8, i8.ipad1), p8 = l8, d7 = 1; d7 < t9; d7++) { + p8 = i8.run(p8, i8.ipad2); + for (var m7 = 0; m7 < u8; m7++) + l8[m7] ^= p8[m7]; + } + l8.copy(f9, s7), s7 += u8; + } + return f9; + }; + var A$1 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var H$1 = T; + var E$2 = h$6; + var P$1 = l$5; + var U$1 = S$1; + var K$1 = u4.Buffer; + var x$1 = A$1.crypto && A$1.crypto.subtle; + var z$1 = { sha: "SHA-1", "sha-1": "SHA-1", sha1: "SHA-1", sha256: "SHA-256", "sha-256": "SHA-256", sha384: "SHA-384", "sha-384": "SHA-384", "sha-512": "SHA-512", sha512: "SHA-512" }; + var I$2 = []; + function D$1(r10, e12, t9, n9, o9) { + return x$1.importKey("raw", r10, { name: "PBKDF2" }, false, ["deriveBits"]).then(function(r11) { + return x$1.deriveBits({ name: "PBKDF2", salt: e12, iterations: t9, hash: { name: o9 } }, r11, n9 << 3); + }).then(function(r11) { + return K$1.from(r11); + }); + } + var F$1 = function(r10, e12, t9, n9, o9, i8) { + "function" == typeof o9 && (i8 = o9, o9 = void 0); + var f9 = z$1[(o9 = o9 || "sha1").toLowerCase()]; + if (!f9 || "function" != typeof A$1.Promise) + return H$1.nextTick(function() { + var f10; + try { + f10 = U$1(r10, e12, t9, n9, o9); + } catch (r11) { + return i8(r11); + } + i8(null, f10); + }); + if (E$2(r10, e12, t9, n9), "function" != typeof i8) + throw new Error("No callback provided to pbkdf2"); + K$1.isBuffer(r10) || (r10 = K$1.from(r10, P$1)), K$1.isBuffer(e12) || (e12 = K$1.from(e12, P$1)), function(r11, e13) { + r11.then(function(r12) { + H$1.nextTick(function() { + e13(null, r12); + }); + }, function(r12) { + H$1.nextTick(function() { + e13(r12); + }); + }); + }(function(r11) { + if (A$1.process && !A$1.process.browser) + return Promise.resolve(false); + if (!x$1 || !x$1.importKey || !x$1.deriveBits) + return Promise.resolve(false); + if (void 0 !== I$2[r11]) + return I$2[r11]; + var e13 = D$1(k$3 = k$3 || K$1.alloc(8), k$3, 10, 128, r11).then(function() { + return true; + }).catch(function() { + return false; + }); + return I$2[r11] = e13, e13; + }(f9).then(function(i9) { + return i9 ? D$1(r10, e12, t9, n9, f9) : U$1(r10, e12, t9, n9, o9); + }), i8); + }; + var M$1 = {}; + M$1.pbkdf2 = F$1, M$1.pbkdf2Sync = S$1; + var r$5; + function e$7(r10, e12) { + if (!r10) + throw new Error(e12 || "Assertion failed"); + } + r$5 = e$7, e$7.equal = function(r10, e12, o9) { + if (r10 != e12) + throw new Error(o9 || "Assertion failed: " + r10 + " != " + e12); + }; + var o$7 = r$5; + var r$6 = { readUInt32BE: function(t9, e12) { + return (t9[0 + e12] << 24 | t9[1 + e12] << 16 | t9[2 + e12] << 8 | t9[3 + e12]) >>> 0; + }, writeUInt32BE: function(t9, e12, r10) { + t9[0 + r10] = e12 >>> 24, t9[1 + r10] = e12 >>> 16 & 255, t9[2 + r10] = e12 >>> 8 & 255, t9[3 + r10] = 255 & e12; + }, ip: function(t9, e12, r10, i8) { + for (var n9 = 0, f9 = 0, o9 = 6; o9 >= 0; o9 -= 2) { + for (var p8 = 0; p8 <= 24; p8 += 8) + n9 <<= 1, n9 |= e12 >>> p8 + o9 & 1; + for (p8 = 0; p8 <= 24; p8 += 8) + n9 <<= 1, n9 |= t9 >>> p8 + o9 & 1; + } + for (o9 = 6; o9 >= 0; o9 -= 2) { + for (p8 = 1; p8 <= 25; p8 += 8) + f9 <<= 1, f9 |= e12 >>> p8 + o9 & 1; + for (p8 = 1; p8 <= 25; p8 += 8) + f9 <<= 1, f9 |= t9 >>> p8 + o9 & 1; + } + r10[i8 + 0] = n9 >>> 0, r10[i8 + 1] = f9 >>> 0; + }, rip: function(t9, e12, r10, i8) { + for (var n9 = 0, f9 = 0, o9 = 0; o9 < 4; o9++) + for (var p8 = 24; p8 >= 0; p8 -= 8) + n9 <<= 1, n9 |= e12 >>> p8 + o9 & 1, n9 <<= 1, n9 |= t9 >>> p8 + o9 & 1; + for (o9 = 4; o9 < 8; o9++) + for (p8 = 24; p8 >= 0; p8 -= 8) + f9 <<= 1, f9 |= e12 >>> p8 + o9 & 1, f9 <<= 1, f9 |= t9 >>> p8 + o9 & 1; + r10[i8 + 0] = n9 >>> 0, r10[i8 + 1] = f9 >>> 0; + }, pc1: function(t9, e12, r10, i8) { + for (var n9 = 0, f9 = 0, o9 = 7; o9 >= 5; o9--) { + for (var p8 = 0; p8 <= 24; p8 += 8) + n9 <<= 1, n9 |= e12 >> p8 + o9 & 1; + for (p8 = 0; p8 <= 24; p8 += 8) + n9 <<= 1, n9 |= t9 >> p8 + o9 & 1; + } + for (p8 = 0; p8 <= 24; p8 += 8) + n9 <<= 1, n9 |= e12 >> p8 + o9 & 1; + for (o9 = 1; o9 <= 3; o9++) { + for (p8 = 0; p8 <= 24; p8 += 8) + f9 <<= 1, f9 |= e12 >> p8 + o9 & 1; + for (p8 = 0; p8 <= 24; p8 += 8) + f9 <<= 1, f9 |= t9 >> p8 + o9 & 1; + } + for (p8 = 0; p8 <= 24; p8 += 8) + f9 <<= 1, f9 |= t9 >> p8 + o9 & 1; + r10[i8 + 0] = n9 >>> 0, r10[i8 + 1] = f9 >>> 0; + }, r28shl: function(t9, e12) { + return t9 << e12 & 268435455 | t9 >>> 28 - e12; + } }; + var i5 = [14, 11, 17, 4, 27, 23, 25, 0, 13, 22, 7, 18, 5, 9, 16, 24, 2, 20, 12, 21, 1, 8, 15, 26, 15, 4, 25, 19, 9, 1, 26, 16, 5, 11, 23, 8, 12, 7, 17, 0, 22, 3, 10, 14, 6, 20, 27, 24]; + r$6.pc2 = function(t9, e12, r10, n9) { + for (var f9 = 0, o9 = 0, p8 = i5.length >>> 1, u8 = 0; u8 < p8; u8++) + f9 <<= 1, f9 |= t9 >>> i5[u8] & 1; + for (u8 = p8; u8 < i5.length; u8++) + o9 <<= 1, o9 |= e12 >>> i5[u8] & 1; + r10[n9 + 0] = f9 >>> 0, r10[n9 + 1] = o9 >>> 0; + }, r$6.expand = function(t9, e12, r10) { + var i8 = 0, n9 = 0; + i8 = (1 & t9) << 5 | t9 >>> 27; + for (var f9 = 23; f9 >= 15; f9 -= 4) + i8 <<= 6, i8 |= t9 >>> f9 & 63; + for (f9 = 11; f9 >= 3; f9 -= 4) + n9 |= t9 >>> f9 & 63, n9 <<= 6; + n9 |= (31 & t9) << 1 | t9 >>> 31, e12[r10 + 0] = i8 >>> 0, e12[r10 + 1] = n9 >>> 0; + }; + var n$8 = [14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11]; + r$6.substitute = function(t9, e12) { + for (var r10 = 0, i8 = 0; i8 < 4; i8++) { + r10 <<= 4, r10 |= n$8[64 * i8 + (t9 >>> 18 - 6 * i8 & 63)]; + } + for (i8 = 0; i8 < 4; i8++) { + r10 <<= 4, r10 |= n$8[256 + 64 * i8 + (e12 >>> 18 - 6 * i8 & 63)]; + } + return r10 >>> 0; + }; + var f$9 = [16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7]; + r$6.permute = function(t9) { + for (var e12 = 0, r10 = 0; r10 < f$9.length; r10++) + e12 <<= 1, e12 |= t9 >>> f$9[r10] & 1; + return e12 >>> 0; + }, r$6.padSplit = function(t9, e12, r10) { + for (var i8 = t9.toString(2); i8.length < e12; ) + i8 = "0" + i8; + for (var n9 = [], f9 = 0; f9 < e12; f9 += r10) + n9.push(i8.slice(f9, f9 + r10)); + return n9.join(" "); + }; + var o$8; + var p$6 = o$7; + function u$6(t9) { + this.options = t9, this.type = this.options.type, this.blockSize = 8, this._init(), this.buffer = new Array(this.blockSize), this.bufferOff = 0; + } + o$8 = u$6, u$6.prototype._init = function() { + }, u$6.prototype.update = function(t9) { + return 0 === t9.length ? [] : "decrypt" === this.type ? this._updateDecrypt(t9) : this._updateEncrypt(t9); + }, u$6.prototype._buffer = function(t9, e12) { + for (var r10 = Math.min(this.buffer.length - this.bufferOff, t9.length - e12), i8 = 0; i8 < r10; i8++) + this.buffer[this.bufferOff + i8] = t9[e12 + i8]; + return this.bufferOff += r10, r10; + }, u$6.prototype._flushBuffer = function(t9, e12) { + return this._update(this.buffer, 0, t9, e12), this.bufferOff = 0, this.blockSize; + }, u$6.prototype._updateEncrypt = function(t9) { + var e12 = 0, r10 = 0, i8 = (this.bufferOff + t9.length) / this.blockSize | 0, n9 = new Array(i8 * this.blockSize); + 0 !== this.bufferOff && (e12 += this._buffer(t9, e12), this.bufferOff === this.buffer.length && (r10 += this._flushBuffer(n9, r10))); + for (var f9 = t9.length - (t9.length - e12) % this.blockSize; e12 < f9; e12 += this.blockSize) + this._update(t9, e12, n9, r10), r10 += this.blockSize; + for (; e12 < t9.length; e12++, this.bufferOff++) + this.buffer[this.bufferOff] = t9[e12]; + return n9; + }, u$6.prototype._updateDecrypt = function(t9) { + for (var e12 = 0, r10 = 0, i8 = Math.ceil((this.bufferOff + t9.length) / this.blockSize) - 1, n9 = new Array(i8 * this.blockSize); i8 > 0; i8--) + e12 += this._buffer(t9, e12), r10 += this._flushBuffer(n9, r10); + return e12 += this._buffer(t9, e12), n9; + }, u$6.prototype.final = function(t9) { + var e12, r10; + return t9 && (e12 = this.update(t9)), r10 = "encrypt" === this.type ? this._finalEncrypt() : this._finalDecrypt(), e12 ? e12.concat(r10) : r10; + }, u$6.prototype._pad = function(t9, e12) { + if (0 === e12) + return false; + for (; e12 < t9.length; ) + t9[e12++] = 0; + return true; + }, u$6.prototype._finalEncrypt = function() { + if (!this._pad(this.buffer, this.bufferOff)) + return []; + var t9 = new Array(this.blockSize); + return this._update(this.buffer, 0, t9, 0), t9; + }, u$6.prototype._unpad = function(t9) { + return t9; + }, u$6.prototype._finalDecrypt = function() { + p$6.equal(this.bufferOff, this.blockSize, "Not enough data to decrypt"); + var t9 = new Array(this.blockSize); + return this._flushBuffer(t9, 0), this._unpad(t9); + }; + var s$6; + var a$8 = o$8; + var h$7 = o$7; + var c$6 = r$6; + var l$6 = a$8; + function y$3() { + this.tmp = new Array(2), this.keys = null; + } + function v$3(t9) { + l$6.call(this, t9); + var e12 = new y$3(); + this._desState = e12, this.deriveKeys(e12, t9.key); + } + t$2(v$3, l$6), s$6 = v$3, v$3.create = function(t9) { + return new v$3(t9); + }; + var d$5 = [1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1]; + v$3.prototype.deriveKeys = function(t9, e12) { + t9.keys = new Array(32), h$7.equal(e12.length, this.blockSize, "Invalid key length"); + var r10 = c$6.readUInt32BE(e12, 0), i8 = c$6.readUInt32BE(e12, 4); + c$6.pc1(r10, i8, t9.tmp, 0), r10 = t9.tmp[0], i8 = t9.tmp[1]; + for (var n9 = 0; n9 < t9.keys.length; n9 += 2) { + var f9 = d$5[n9 >>> 1]; + r10 = c$6.r28shl(r10, f9), i8 = c$6.r28shl(i8, f9), c$6.pc2(r10, i8, t9.keys, n9); + } + }, v$3.prototype._update = function(t9, e12, r10, i8) { + var n9 = this._desState, f9 = c$6.readUInt32BE(t9, e12), o9 = c$6.readUInt32BE(t9, e12 + 4); + c$6.ip(f9, o9, n9.tmp, 0), f9 = n9.tmp[0], o9 = n9.tmp[1], "encrypt" === this.type ? this._encrypt(n9, f9, o9, n9.tmp, 0) : this._decrypt(n9, f9, o9, n9.tmp, 0), f9 = n9.tmp[0], o9 = n9.tmp[1], c$6.writeUInt32BE(r10, f9, i8), c$6.writeUInt32BE(r10, o9, i8 + 4); + }, v$3.prototype._pad = function(t9, e12) { + for (var r10 = t9.length - e12, i8 = e12; i8 < t9.length; i8++) + t9[i8] = r10; + return true; + }, v$3.prototype._unpad = function(t9) { + for (var e12 = t9[t9.length - 1], r10 = t9.length - e12; r10 < t9.length; r10++) + h$7.equal(t9[r10], e12); + return t9.slice(0, t9.length - e12); + }, v$3.prototype._encrypt = function(t9, e12, r10, i8, n9) { + for (var f9 = e12, o9 = r10, p8 = 0; p8 < t9.keys.length; p8 += 2) { + var u8 = t9.keys[p8], s7 = t9.keys[p8 + 1]; + c$6.expand(o9, t9.tmp, 0), u8 ^= t9.tmp[0], s7 ^= t9.tmp[1]; + var a8 = c$6.substitute(u8, s7), h9 = o9; + o9 = (f9 ^ c$6.permute(a8)) >>> 0, f9 = h9; + } + c$6.rip(o9, f9, i8, n9); + }, v$3.prototype._decrypt = function(t9, e12, r10, i8, n9) { + for (var f9 = r10, o9 = e12, p8 = t9.keys.length - 2; p8 >= 0; p8 -= 2) { + var u8 = t9.keys[p8], s7 = t9.keys[p8 + 1]; + c$6.expand(f9, t9.tmp, 0), u8 ^= t9.tmp[0], s7 ^= t9.tmp[1]; + var a8 = c$6.substitute(u8, s7), h9 = f9; + f9 = (o9 ^ c$6.permute(a8)) >>> 0, o9 = h9; + } + c$6.rip(f9, o9, i8, n9); + }; + var _$5 = s$6; + var b$4 = {}; + var k$4 = o$7; + var g$3 = t$2; + var m$4 = {}; + function S$2(t9) { + k$4.equal(t9.length, 8, "Invalid IV length"), this.iv = new Array(8); + for (var e12 = 0; e12 < this.iv.length; e12++) + this.iv[e12] = t9[e12]; + } + b$4.instantiate = function(t9) { + function e12(e13) { + t9.call(this, e13), this._cbcInit(); + } + g$3(e12, t9); + for (var r10 = Object.keys(m$4), i8 = 0; i8 < r10.length; i8++) { + var n9 = r10[i8]; + e12.prototype[n9] = m$4[n9]; + } + return e12.create = function(t10) { + return new e12(t10); + }, e12; + }, m$4._cbcInit = function() { + var t9 = new S$2(this.options.iv); + this._cbcState = t9; + }, m$4._update = function(t9, e12, r10, i8) { + var n9 = this._cbcState, f9 = this.constructor.super_.prototype, o9 = n9.iv; + if ("encrypt" === this.type) { + for (var p8 = 0; p8 < this.blockSize; p8++) + o9[p8] ^= t9[e12 + p8]; + f9._update.call(this, o9, 0, r10, i8); + for (p8 = 0; p8 < this.blockSize; p8++) + o9[p8] = r10[i8 + p8]; + } else { + f9._update.call(this, t9, e12, r10, i8); + for (p8 = 0; p8 < this.blockSize; p8++) + r10[i8 + p8] ^= o9[p8]; + for (p8 = 0; p8 < this.blockSize; p8++) + o9[p8] = t9[e12 + p8]; + } + }; + var z$2; + var w$5 = o$7; + var E$3 = a$8; + var I$3 = _$5; + function O$1(t9, e12) { + w$5.equal(e12.length, 24, "Invalid key length"); + var r10 = e12.slice(0, 8), i8 = e12.slice(8, 16), n9 = e12.slice(16, 24); + this.ciphers = "encrypt" === t9 ? [I$3.create({ type: "encrypt", key: r10 }), I$3.create({ type: "decrypt", key: i8 }), I$3.create({ type: "encrypt", key: n9 })] : [I$3.create({ type: "decrypt", key: n9 }), I$3.create({ type: "encrypt", key: i8 }), I$3.create({ type: "decrypt", key: r10 })]; + } + function B$2(t9) { + E$3.call(this, t9); + var e12 = new O$1(this.type, this.options.key); + this._edeState = e12; + } + t$2(B$2, E$3), z$2 = B$2, B$2.create = function(t9) { + return new B$2(t9); + }, B$2.prototype._update = function(t9, e12, r10, i8) { + var n9 = this._edeState; + n9.ciphers[0]._update(t9, e12, r10, i8), n9.ciphers[1]._update(r10, i8, r10, i8), n9.ciphers[2]._update(r10, i8, r10, i8); + }, B$2.prototype._pad = I$3.prototype._pad, B$2.prototype._unpad = I$3.prototype._unpad; + var A$2 = z$2; + var U$2 = {}; + U$2.utils = r$6, U$2.Cipher = a$8, U$2.DES = _$5, U$2.CBC = b$4, U$2.EDE = A$2; + var d$6; + var i$13 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var f$a = f$6; + var o$9 = U$2; + var a$9 = t$2; + var c$7 = u4.Buffer; + var n$9 = { "des-ede3-cbc": o$9.CBC.instantiate(o$9.EDE), "des-ede3": o$9.EDE, "des-ede-cbc": o$9.CBC.instantiate(o$9.EDE), "des-ede": o$9.EDE, "des-cbc": o$9.CBC.instantiate(o$9.DES), "des-ecb": o$9.DES }; + function p$7(e12) { + f$a.call(this || i$13); + var t9, r10 = e12.mode.toLowerCase(), s7 = n$9[r10]; + t9 = e12.decrypt ? "decrypt" : "encrypt"; + var d7 = e12.key; + c$7.isBuffer(d7) || (d7 = c$7.from(d7)), "des-ede" !== r10 && "des-ede-cbc" !== r10 || (d7 = c$7.concat([d7, d7.slice(0, 8)])); + var o9 = e12.iv; + c$7.isBuffer(o9) || (o9 = c$7.from(o9)), (this || i$13)._des = s7.create({ key: d7, iv: o9, type: t9 }); + } + n$9.des = n$9["des-cbc"], n$9.des3 = n$9["des-ede3-cbc"], d$6 = p$7, a$9(p$7, f$a), p$7.prototype._update = function(e12) { + return c$7.from((this || i$13)._des.update(e12)); + }, p$7.prototype._final = function() { + return c$7.from((this || i$13)._des.final()); + }; + var l$7 = d$6; + var e$8 = e$1$1.Buffer; + var f$b = function(r10, f9) { + for (var t9 = Math.min(r10.length, f9.length), n9 = new e$8(t9), o9 = 0; o9 < t9; ++o9) + n9[o9] = r10[o9] ^ f9[o9]; + return n9; + }; + var t$12 = function(e12) { + for (var c8, r10 = e12.length; r10--; ) { + if (255 !== (c8 = e12.readUInt8(r10))) { + c8++, e12.writeUInt8(c8, r10); + break; + } + e12.writeUInt8(0, r10); + } + }; + var a$a = { encrypt: function(e12, c8) { + return e12._cipher.encryptBlock(c8); + }, decrypt: function(e12, c8) { + return e12._cipher.decryptBlock(c8); + } }; + var p$8 = {}; + var n$a = f$b; + p$8.encrypt = function(e12, c8) { + var r10 = n$a(c8, e12._prev); + return e12._prev = e12._cipher.encryptBlock(r10), e12._prev; + }, p$8.decrypt = function(e12, c8) { + var r10 = e12._prev; + e12._prev = c8; + var t9 = e12._cipher.decryptBlock(c8); + return n$a(t9, r10); + }; + var i$2 = {}; + var o$a = u4.Buffer; + var h$8 = f$b; + function v$4(e12, c8, r10) { + var t9 = c8.length, a8 = h$8(c8, e12._cache); + return e12._cache = e12._cache.slice(t9), e12._prev = o$a.concat([e12._prev, r10 ? c8 : a8]), a8; + } + i$2.encrypt = function(e12, c8, r10) { + for (var t9, a8 = o$a.allocUnsafe(0); c8.length; ) { + if (0 === e12._cache.length && (e12._cache = e12._cipher.encryptBlock(e12._prev), e12._prev = o$a.allocUnsafe(0)), !(e12._cache.length <= c8.length)) { + a8 = o$a.concat([a8, v$4(e12, c8, r10)]); + break; + } + t9 = e12._cache.length, a8 = o$a.concat([a8, v$4(e12, c8.slice(0, t9), r10)]), c8 = c8.slice(t9); + } + return a8; + }; + var y$4 = {}; + var f$c = u4.Buffer; + function s$7(e12, c8, r10) { + var t9 = e12._cipher.encryptBlock(e12._prev)[0] ^ c8; + return e12._prev = f$c.concat([e12._prev.slice(1), f$c.from([r10 ? c8 : t9])]), t9; + } + y$4.encrypt = function(e12, c8, r10) { + for (var t9 = c8.length, a8 = f$c.allocUnsafe(t9), p8 = -1; ++p8 < t9; ) + a8[p8] = s$7(e12, c8[p8], r10); + return a8; + }; + var l$8 = {}; + var m$5 = u4.Buffer; + function _$6(e12, c8, r10) { + for (var t9, a8, p8 = -1, n9 = 0; ++p8 < 8; ) + t9 = c8 & 1 << 7 - p8 ? 128 : 0, n9 += (128 & (a8 = e12._cipher.encryptBlock(e12._prev)[0] ^ t9)) >> p8 % 8, e12._prev = k$5(e12._prev, r10 ? t9 : a8); + return n9; + } + function k$5(e12, c8) { + var r10 = e12.length, t9 = -1, a8 = m$5.allocUnsafe(e12.length); + for (e12 = m$5.concat([e12, m$5.from([c8])]); ++t9 < r10; ) + a8[t9] = e12[t9] << 1 | e12[t9 + 1] >> 7; + return a8; + } + l$8.encrypt = function(e12, c8, r10) { + for (var t9 = c8.length, a8 = m$5.allocUnsafe(t9), p8 = -1; ++p8 < t9; ) + a8[p8] = _$6(e12, c8[p8], r10); + return a8; + }; + var B$3 = {}; + var u$7 = e$1$1.Buffer; + var C$1 = f$b; + function E$4(e12) { + return e12._prev = e12._cipher.encryptBlock(e12._prev), e12._prev; + } + B$3.encrypt = function(e12, c8) { + for (; e12._cache.length < c8.length; ) + e12._cache = u$7.concat([e12._cache, E$4(e12)]); + var r10 = e12._cache.slice(0, c8.length); + return e12._cache = e12._cache.slice(c8.length), C$1(c8, r10); + }; + var d$7 = {}; + var b$5 = f$b; + var A$3 = u4.Buffer; + var S$3 = t$12; + function g$4(e12) { + var c8 = e12._cipher.encryptBlockRaw(e12._prev); + return S$3(e12._prev), c8; + } + d$7.encrypt = function(e12, c8) { + var r10 = Math.ceil(c8.length / 16), t9 = e12._cache.length; + e12._cache = A$3.concat([e12._cache, A$3.allocUnsafe(16 * r10)]); + for (var a8 = 0; a8 < r10; a8++) { + var p8 = g$4(e12), n9 = t9 + 16 * a8; + e12._cache.writeUInt32BE(p8[0], n9 + 0), e12._cache.writeUInt32BE(p8[1], n9 + 4), e12._cache.writeUInt32BE(p8[2], n9 + 8), e12._cache.writeUInt32BE(p8[3], n9 + 12); + } + var i8 = e12._cache.slice(0, c8.length); + return e12._cache = e12._cache.slice(c8.length), b$5(c8, i8); + }; + var F$2 = { "aes-128-ecb": { cipher: "AES", key: 128, iv: 0, mode: "ECB", type: "block" }, "aes-192-ecb": { cipher: "AES", key: 192, iv: 0, mode: "ECB", type: "block" }, "aes-256-ecb": { cipher: "AES", key: 256, iv: 0, mode: "ECB", type: "block" }, "aes-128-cbc": { cipher: "AES", key: 128, iv: 16, mode: "CBC", type: "block" }, "aes-192-cbc": { cipher: "AES", key: 192, iv: 16, mode: "CBC", type: "block" }, "aes-256-cbc": { cipher: "AES", key: 256, iv: 16, mode: "CBC", type: "block" }, aes128: { cipher: "AES", key: 128, iv: 16, mode: "CBC", type: "block" }, aes192: { cipher: "AES", key: 192, iv: 16, mode: "CBC", type: "block" }, aes256: { cipher: "AES", key: 256, iv: 16, mode: "CBC", type: "block" }, "aes-128-cfb": { cipher: "AES", key: 128, iv: 16, mode: "CFB", type: "stream" }, "aes-192-cfb": { cipher: "AES", key: 192, iv: 16, mode: "CFB", type: "stream" }, "aes-256-cfb": { cipher: "AES", key: 256, iv: 16, mode: "CFB", type: "stream" }, "aes-128-cfb8": { cipher: "AES", key: 128, iv: 16, mode: "CFB8", type: "stream" }, "aes-192-cfb8": { cipher: "AES", key: 192, iv: 16, mode: "CFB8", type: "stream" }, "aes-256-cfb8": { cipher: "AES", key: 256, iv: 16, mode: "CFB8", type: "stream" }, "aes-128-cfb1": { cipher: "AES", key: 128, iv: 16, mode: "CFB1", type: "stream" }, "aes-192-cfb1": { cipher: "AES", key: 192, iv: 16, mode: "CFB1", type: "stream" }, "aes-256-cfb1": { cipher: "AES", key: 256, iv: 16, mode: "CFB1", type: "stream" }, "aes-128-ofb": { cipher: "AES", key: 128, iv: 16, mode: "OFB", type: "stream" }, "aes-192-ofb": { cipher: "AES", key: 192, iv: 16, mode: "OFB", type: "stream" }, "aes-256-ofb": { cipher: "AES", key: 256, iv: 16, mode: "OFB", type: "stream" }, "aes-128-ctr": { cipher: "AES", key: 128, iv: 16, mode: "CTR", type: "stream" }, "aes-192-ctr": { cipher: "AES", key: 192, iv: 16, mode: "CTR", type: "stream" }, "aes-256-ctr": { cipher: "AES", key: 256, iv: 16, mode: "CTR", type: "stream" }, "aes-128-gcm": { cipher: "AES", key: 128, iv: 12, mode: "GCM", type: "auth" }, "aes-192-gcm": { cipher: "AES", key: 192, iv: 12, mode: "GCM", type: "auth" }, "aes-256-gcm": { cipher: "AES", key: 256, iv: 12, mode: "GCM", type: "auth" } }; + var U$3 = { ECB: a$a, CBC: p$8, CFB: i$2, CFB8: y$4, CFB1: l$8, OFB: B$3, CTR: d$7, GCM: d$7 }; + var w$6 = F$2; + for (I$4 in w$6) + w$6[I$4].module = U$3[w$6[I$4].mode]; + var I$4; + var M$2 = w$6; + var a$b = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var h$9 = {}; + var o$b = u4.Buffer; + function s$8(t9) { + o$b.isBuffer(t9) || (t9 = o$b.from(t9)); + for (var e12 = t9.length / 4 | 0, i8 = new Array(e12), r10 = 0; r10 < e12; r10++) + i8[r10] = t9.readUInt32BE(4 * r10); + return i8; + } + function c$8(t9) { + for (; 0 < t9.length; t9++) + t9[0] = 0; + } + function l$9(t9, e12, i8, r10, n9) { + for (var a8, h9, o9, s7, c8 = i8[0], l8 = i8[1], f9 = i8[2], u8 = i8[3], p8 = t9[0] ^ e12[0], _5 = t9[1] ^ e12[1], d7 = t9[2] ^ e12[2], y7 = t9[3] ^ e12[3], B5 = 4, g6 = 1; g6 < n9; g6++) + a8 = c8[p8 >>> 24] ^ l8[_5 >>> 16 & 255] ^ f9[d7 >>> 8 & 255] ^ u8[255 & y7] ^ e12[B5++], h9 = c8[_5 >>> 24] ^ l8[d7 >>> 16 & 255] ^ f9[y7 >>> 8 & 255] ^ u8[255 & p8] ^ e12[B5++], o9 = c8[d7 >>> 24] ^ l8[y7 >>> 16 & 255] ^ f9[p8 >>> 8 & 255] ^ u8[255 & _5] ^ e12[B5++], s7 = c8[y7 >>> 24] ^ l8[p8 >>> 16 & 255] ^ f9[_5 >>> 8 & 255] ^ u8[255 & d7] ^ e12[B5++], p8 = a8, _5 = h9, d7 = o9, y7 = s7; + return a8 = (r10[p8 >>> 24] << 24 | r10[_5 >>> 16 & 255] << 16 | r10[d7 >>> 8 & 255] << 8 | r10[255 & y7]) ^ e12[B5++], h9 = (r10[_5 >>> 24] << 24 | r10[d7 >>> 16 & 255] << 16 | r10[y7 >>> 8 & 255] << 8 | r10[255 & p8]) ^ e12[B5++], o9 = (r10[d7 >>> 24] << 24 | r10[y7 >>> 16 & 255] << 16 | r10[p8 >>> 8 & 255] << 8 | r10[255 & _5]) ^ e12[B5++], s7 = (r10[y7 >>> 24] << 24 | r10[p8 >>> 16 & 255] << 16 | r10[_5 >>> 8 & 255] << 8 | r10[255 & d7]) ^ e12[B5++], [a8 >>>= 0, h9 >>>= 0, o9 >>>= 0, s7 >>>= 0]; + } + var f$d = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54]; + var u$8 = function() { + for (var t9 = new Array(256), e12 = 0; e12 < 256; e12++) + t9[e12] = e12 < 128 ? e12 << 1 : e12 << 1 ^ 283; + for (var i8 = [], r10 = [], n9 = [[], [], [], []], a8 = [[], [], [], []], h9 = 0, o9 = 0, s7 = 0; s7 < 256; ++s7) { + var c8 = o9 ^ o9 << 1 ^ o9 << 2 ^ o9 << 3 ^ o9 << 4; + c8 = c8 >>> 8 ^ 255 & c8 ^ 99, i8[h9] = c8, r10[c8] = h9; + var l8 = t9[h9], f9 = t9[l8], u8 = t9[f9], p8 = 257 * t9[c8] ^ 16843008 * c8; + n9[0][h9] = p8 << 24 | p8 >>> 8, n9[1][h9] = p8 << 16 | p8 >>> 16, n9[2][h9] = p8 << 8 | p8 >>> 24, n9[3][h9] = p8, p8 = 16843009 * u8 ^ 65537 * f9 ^ 257 * l8 ^ 16843008 * h9, a8[0][c8] = p8 << 24 | p8 >>> 8, a8[1][c8] = p8 << 16 | p8 >>> 16, a8[2][c8] = p8 << 8 | p8 >>> 24, a8[3][c8] = p8, 0 === h9 ? h9 = o9 = 1 : (h9 = l8 ^ t9[t9[t9[u8 ^ l8]]], o9 ^= t9[t9[o9]]); + } + return { SBOX: i8, INV_SBOX: r10, SUB_MIX: n9, INV_SUB_MIX: a8 }; + }(); + function p$9(t9) { + (this || a$b)._key = s$8(t9), this._reset(); + } + p$9.blockSize = 16, p$9.keySize = 32, p$9.prototype.blockSize = p$9.blockSize, p$9.prototype.keySize = p$9.keySize, p$9.prototype._reset = function() { + for (var t9 = (this || a$b)._key, e12 = t9.length, i8 = e12 + 6, r10 = 4 * (i8 + 1), n9 = [], h9 = 0; h9 < e12; h9++) + n9[h9] = t9[h9]; + for (h9 = e12; h9 < r10; h9++) { + var o9 = n9[h9 - 1]; + h9 % e12 == 0 ? (o9 = o9 << 8 | o9 >>> 24, o9 = u$8.SBOX[o9 >>> 24] << 24 | u$8.SBOX[o9 >>> 16 & 255] << 16 | u$8.SBOX[o9 >>> 8 & 255] << 8 | u$8.SBOX[255 & o9], o9 ^= f$d[h9 / e12 | 0] << 24) : e12 > 6 && h9 % e12 == 4 && (o9 = u$8.SBOX[o9 >>> 24] << 24 | u$8.SBOX[o9 >>> 16 & 255] << 16 | u$8.SBOX[o9 >>> 8 & 255] << 8 | u$8.SBOX[255 & o9]), n9[h9] = n9[h9 - e12] ^ o9; + } + for (var s7 = [], c8 = 0; c8 < r10; c8++) { + var l8 = r10 - c8, p8 = n9[l8 - (c8 % 4 ? 0 : 4)]; + s7[c8] = c8 < 4 || l8 <= 4 ? p8 : u$8.INV_SUB_MIX[0][u$8.SBOX[p8 >>> 24]] ^ u$8.INV_SUB_MIX[1][u$8.SBOX[p8 >>> 16 & 255]] ^ u$8.INV_SUB_MIX[2][u$8.SBOX[p8 >>> 8 & 255]] ^ u$8.INV_SUB_MIX[3][u$8.SBOX[255 & p8]]; + } + (this || a$b)._nRounds = i8, (this || a$b)._keySchedule = n9, (this || a$b)._invKeySchedule = s7; + }, p$9.prototype.encryptBlockRaw = function(t9) { + return l$9(t9 = s$8(t9), (this || a$b)._keySchedule, u$8.SUB_MIX, u$8.SBOX, (this || a$b)._nRounds); + }, p$9.prototype.encryptBlock = function(t9) { + var e12 = this.encryptBlockRaw(t9), i8 = o$b.allocUnsafe(16); + return i8.writeUInt32BE(e12[0], 0), i8.writeUInt32BE(e12[1], 4), i8.writeUInt32BE(e12[2], 8), i8.writeUInt32BE(e12[3], 12), i8; + }, p$9.prototype.decryptBlock = function(t9) { + var e12 = (t9 = s$8(t9))[1]; + t9[1] = t9[3], t9[3] = e12; + var i8 = l$9(t9, (this || a$b)._invKeySchedule, u$8.INV_SUB_MIX, u$8.INV_SBOX, (this || a$b)._nRounds), r10 = o$b.allocUnsafe(16); + return r10.writeUInt32BE(i8[0], 0), r10.writeUInt32BE(i8[3], 4), r10.writeUInt32BE(i8[2], 8), r10.writeUInt32BE(i8[1], 12), r10; + }, p$9.prototype.scrub = function() { + c$8((this || a$b)._keySchedule), c$8((this || a$b)._invKeySchedule), c$8((this || a$b)._key); + }, h$9.AES = p$9; + var _$7 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var d$8 = u4.Buffer; + var y$5 = d$8.alloc(16, 0); + function B$4(t9) { + var e12 = d$8.allocUnsafe(16); + return e12.writeUInt32BE(t9[0] >>> 0, 0), e12.writeUInt32BE(t9[1] >>> 0, 4), e12.writeUInt32BE(t9[2] >>> 0, 8), e12.writeUInt32BE(t9[3] >>> 0, 12), e12; + } + function g$5(t9) { + (this || _$7).h = t9, (this || _$7).state = d$8.alloc(16, 0), (this || _$7).cache = d$8.allocUnsafe(0); + } + g$5.prototype.ghash = function(t9) { + for (var e12 = -1; ++e12 < t9.length; ) + (this || _$7).state[e12] ^= t9[e12]; + this._multiply(); + }, g$5.prototype._multiply = function() { + for (var t9, e12, i8, r10 = [(t9 = (this || _$7).h).readUInt32BE(0), t9.readUInt32BE(4), t9.readUInt32BE(8), t9.readUInt32BE(12)], n9 = [0, 0, 0, 0], a8 = -1; ++a8 < 128; ) { + for (0 != ((this || _$7).state[~~(a8 / 8)] & 1 << 7 - a8 % 8) && (n9[0] ^= r10[0], n9[1] ^= r10[1], n9[2] ^= r10[2], n9[3] ^= r10[3]), i8 = 0 != (1 & r10[3]), e12 = 3; e12 > 0; e12--) + r10[e12] = r10[e12] >>> 1 | (1 & r10[e12 - 1]) << 31; + r10[0] = r10[0] >>> 1, i8 && (r10[0] = r10[0] ^ 225 << 24); + } + (this || _$7).state = B$4(n9); + }, g$5.prototype.update = function(t9) { + var e12; + for ((this || _$7).cache = d$8.concat([(this || _$7).cache, t9]); (this || _$7).cache.length >= 16; ) + e12 = (this || _$7).cache.slice(0, 16), (this || _$7).cache = (this || _$7).cache.slice(16), this.ghash(e12); + }, g$5.prototype.final = function(t9, e12) { + return (this || _$7).cache.length && this.ghash(d$8.concat([(this || _$7).cache, y$5], 16)), this.ghash(B$4([0, t9, 0, e12])), (this || _$7).state; + }; + var S$4 = g$5; + var v$5 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var I$5 = h$9; + var U$4 = u4.Buffer; + var w$7 = f$6; + var m$6 = S$4; + var E$5 = f$b; + var b$6 = t$12; + function X$1(t9, e12, i8, r10) { + w$7.call(this || v$5); + var n9 = U$4.alloc(4, 0); + (this || v$5)._cipher = new I$5.AES(e12); + var a8 = (this || v$5)._cipher.encryptBlock(n9); + (this || v$5)._ghash = new m$6(a8), i8 = function(t10, e13, i9) { + if (12 === e13.length) + return t10._finID = U$4.concat([e13, U$4.from([0, 0, 0, 1])]), U$4.concat([e13, U$4.from([0, 0, 0, 2])]); + var r11 = new m$6(i9), n10 = e13.length, a9 = n10 % 16; + r11.update(e13), a9 && (a9 = 16 - a9, r11.update(U$4.alloc(a9, 0))), r11.update(U$4.alloc(8, 0)); + var h9 = 8 * n10, o9 = U$4.alloc(8); + o9.writeUIntBE(h9, 0, 8), r11.update(o9), t10._finID = r11.state; + var s7 = U$4.from(t10._finID); + return b$6(s7), s7; + }(this || v$5, i8, a8), (this || v$5)._prev = U$4.from(i8), (this || v$5)._cache = U$4.allocUnsafe(0), (this || v$5)._secCache = U$4.allocUnsafe(0), (this || v$5)._decrypt = r10, (this || v$5)._alen = 0, (this || v$5)._len = 0, (this || v$5)._mode = t9, (this || v$5)._authTag = null, (this || v$5)._called = false; + } + t$2(X$1, w$7), X$1.prototype._update = function(t9) { + if (!(this || v$5)._called && (this || v$5)._alen) { + var e12 = 16 - (this || v$5)._alen % 16; + e12 < 16 && (e12 = U$4.alloc(e12, 0), (this || v$5)._ghash.update(e12)); + } + (this || v$5)._called = true; + var i8 = (this || v$5)._mode.encrypt(this || v$5, t9); + return (this || v$5)._decrypt ? (this || v$5)._ghash.update(t9) : (this || v$5)._ghash.update(i8), (this || v$5)._len += t9.length, i8; + }, X$1.prototype._final = function() { + if ((this || v$5)._decrypt && !(this || v$5)._authTag) + throw new Error("Unsupported state or unable to authenticate data"); + var t9 = E$5((this || v$5)._ghash.final(8 * (this || v$5)._alen, 8 * (this || v$5)._len), (this || v$5)._cipher.encryptBlock((this || v$5)._finID)); + if ((this || v$5)._decrypt && function(t10, e12) { + var i8 = 0; + t10.length !== e12.length && i8++; + for (var r10 = Math.min(t10.length, e12.length), n9 = 0; n9 < r10; ++n9) + i8 += t10[n9] ^ e12[n9]; + return i8; + }(t9, (this || v$5)._authTag)) + throw new Error("Unsupported state or unable to authenticate data"); + (this || v$5)._authTag = t9, (this || v$5)._cipher.scrub(); + }, X$1.prototype.getAuthTag = function() { + if ((this || v$5)._decrypt || !U$4.isBuffer((this || v$5)._authTag)) + throw new Error("Attempting to get auth tag in unsupported state"); + return (this || v$5)._authTag; + }, X$1.prototype.setAuthTag = function(t9) { + if (!(this || v$5)._decrypt) + throw new Error("Attempting to set auth tag in unsupported state"); + (this || v$5)._authTag = t9; + }, X$1.prototype.setAAD = function(t9) { + if ((this || v$5)._called) + throw new Error("Attempting to set AAD in unsupported state"); + (this || v$5)._ghash.update(t9), (this || v$5)._alen += t9.length; + }; + var k$6 = X$1; + var T$2 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var O$2 = h$9; + var A$4 = u4.Buffer; + var M$3 = f$6; + function N$1(t9, e12, i8, r10) { + M$3.call(this || T$2), (this || T$2)._cipher = new O$2.AES(e12), (this || T$2)._prev = A$4.from(i8), (this || T$2)._cache = A$4.allocUnsafe(0), (this || T$2)._secCache = A$4.allocUnsafe(0), (this || T$2)._decrypt = r10, (this || T$2)._mode = t9; + } + t$2(N$1, M$3), N$1.prototype._update = function(t9) { + return (this || T$2)._mode.encrypt(this || T$2, t9, (this || T$2)._decrypt); + }, N$1.prototype._final = function() { + (this || T$2)._cipher.scrub(); + }; + var V$1 = N$1; + var t$22 = u4.Buffer; + var f$e = u5; + var a$c = function(r10, e12, a8, l8) { + if (t$22.isBuffer(r10) || (r10 = t$22.from(r10, "binary")), e12 && (t$22.isBuffer(e12) || (e12 = t$22.from(e12, "binary")), 8 !== e12.length)) + throw new RangeError("salt should be Buffer with 8 byte length"); + for (var n9 = a8 / 8, o9 = t$22.alloc(n9), i8 = t$22.alloc(l8 || 0), h9 = t$22.alloc(0); n9 > 0 || l8 > 0; ) { + var u8 = new f$e(); + u8.update(h9), u8.update(r10), e12 && u8.update(e12), h9 = u8.digest(); + var g6 = 0; + if (n9 > 0) { + var m7 = o9.length - n9; + g6 = Math.min(n9, h9.length), h9.copy(o9, m7, 0, g6), n9 -= g6; + } + if (g6 < h9.length && l8 > 0) { + var p8 = i8.length - l8, v7 = Math.min(l8, h9.length - g6); + h9.copy(i8, p8, g6, g6 + v7), l8 -= v7; + } + } + return h9.fill(0), { key: o9, iv: i8 }; + }; + var c$9 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var s$9 = {}; + var f$f = k$6; + var p$a = u4.Buffer; + var u$9 = M$2; + var l$a = V$1; + var d$9 = f$6; + var y$6 = h$9; + var m$7 = a$c; + function g$6(t9, e12, r10) { + d$9.call(this || c$9), (this || c$9)._cache = new v$6(), (this || c$9)._last = void 0, (this || c$9)._cipher = new y$6.AES(e12), (this || c$9)._prev = p$a.from(r10), (this || c$9)._mode = t9, (this || c$9)._autopadding = true; + } + function v$6() { + (this || c$9).cache = p$a.allocUnsafe(0); + } + function w$8(t9, e12, r10) { + var i8 = u$9[t9.toLowerCase()]; + if (!i8) + throw new TypeError("invalid suite type"); + if ("string" == typeof r10 && (r10 = p$a.from(r10)), "GCM" !== i8.mode && r10.length !== i8.iv) + throw new TypeError("invalid iv length " + r10.length); + if ("string" == typeof e12 && (e12 = p$a.from(e12)), e12.length !== i8.key / 8) + throw new TypeError("invalid key length " + e12.length); + return "stream" === i8.type ? new l$a(i8.module, e12, r10, true) : "auth" === i8.type ? new f$f(i8.module, e12, r10, true) : new g$6(i8.module, e12, r10); + } + t$2(g$6, d$9), g$6.prototype._update = function(t9) { + var e12, r10; + (this || c$9)._cache.add(t9); + for (var i8 = []; e12 = (this || c$9)._cache.get((this || c$9)._autopadding); ) + r10 = (this || c$9)._mode.decrypt(this || c$9, e12), i8.push(r10); + return p$a.concat(i8); + }, g$6.prototype._final = function() { + var t9 = (this || c$9)._cache.flush(); + if ((this || c$9)._autopadding) + return function(t10) { + var e12 = t10[15]; + if (e12 < 1 || e12 > 16) + throw new Error("unable to decrypt data"); + var r10 = -1; + for (; ++r10 < e12; ) + if (t10[r10 + (16 - e12)] !== e12) + throw new Error("unable to decrypt data"); + if (16 === e12) + return; + return t10.slice(0, 16 - e12); + }((this || c$9)._mode.decrypt(this || c$9, t9)); + if (t9) + throw new Error("data not multiple of block length"); + }, g$6.prototype.setAutoPadding = function(t9) { + return (this || c$9)._autopadding = !!t9, this || c$9; + }, v$6.prototype.add = function(t9) { + (this || c$9).cache = p$a.concat([(this || c$9).cache, t9]); + }, v$6.prototype.get = function(t9) { + var e12; + if (t9) { + if ((this || c$9).cache.length > 16) + return e12 = (this || c$9).cache.slice(0, 16), (this || c$9).cache = (this || c$9).cache.slice(16), e12; + } else if ((this || c$9).cache.length >= 16) + return e12 = (this || c$9).cache.slice(0, 16), (this || c$9).cache = (this || c$9).cache.slice(16), e12; + return null; + }, v$6.prototype.flush = function() { + if ((this || c$9).cache.length) + return (this || c$9).cache; + }, s$9.createDecipher = function(t9, e12) { + var r10 = u$9[t9.toLowerCase()]; + if (!r10) + throw new TypeError("invalid suite type"); + var i8 = m$7(e12, false, r10.key, r10.iv); + return w$8(t9, i8.key, i8.iv); + }, s$9.createDecipheriv = w$8; + var c$a = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var s$a = {}; + var f$g = M$2; + var p$b = k$6; + var l$b = u4.Buffer; + var u$a = V$1; + var d$a = f$6; + var m$8 = h$9; + var y$7 = a$c; + function v$7(t9, e12, r10) { + d$a.call(this || c$a), (this || c$a)._cache = new g$7(), (this || c$a)._cipher = new m$8.AES(e12), (this || c$a)._prev = l$b.from(r10), (this || c$a)._mode = t9, (this || c$a)._autopadding = true; + } + t$2(v$7, d$a), v$7.prototype._update = function(t9) { + var e12, r10; + (this || c$a)._cache.add(t9); + for (var i8 = []; e12 = (this || c$a)._cache.get(); ) + r10 = (this || c$a)._mode.encrypt(this || c$a, e12), i8.push(r10); + return l$b.concat(i8); + }; + var _$8 = l$b.alloc(16, 16); + function g$7() { + (this || c$a).cache = l$b.allocUnsafe(0); + } + function w$9(t9, e12, r10) { + var i8 = f$g[t9.toLowerCase()]; + if (!i8) + throw new TypeError("invalid suite type"); + if ("string" == typeof e12 && (e12 = l$b.from(e12)), e12.length !== i8.key / 8) + throw new TypeError("invalid key length " + e12.length); + if ("string" == typeof r10 && (r10 = l$b.from(r10)), "GCM" !== i8.mode && r10.length !== i8.iv) + throw new TypeError("invalid iv length " + r10.length); + return "stream" === i8.type ? new u$a(i8.module, e12, r10) : "auth" === i8.type ? new p$b(i8.module, e12, r10) : new v$7(i8.module, e12, r10); + } + v$7.prototype._final = function() { + var t9 = (this || c$a)._cache.flush(); + if ((this || c$a)._autopadding) + return t9 = (this || c$a)._mode.encrypt(this || c$a, t9), (this || c$a)._cipher.scrub(), t9; + if (!t9.equals(_$8)) + throw (this || c$a)._cipher.scrub(), new Error("data not multiple of block length"); + }, v$7.prototype.setAutoPadding = function(t9) { + return (this || c$a)._autopadding = !!t9, this || c$a; + }, g$7.prototype.add = function(t9) { + (this || c$a).cache = l$b.concat([(this || c$a).cache, t9]); + }, g$7.prototype.get = function() { + if ((this || c$a).cache.length > 15) { + var t9 = (this || c$a).cache.slice(0, 16); + return (this || c$a).cache = (this || c$a).cache.slice(16), t9; + } + return null; + }, g$7.prototype.flush = function() { + for (var t9 = 16 - (this || c$a).cache.length, e12 = l$b.allocUnsafe(t9), r10 = -1; ++r10 < t9; ) + e12.writeUInt8(t9, r10); + return l$b.concat([(this || c$a).cache, e12]); + }, s$a.createCipheriv = w$9, s$a.createCipher = function(t9, e12) { + var r10 = f$g[t9.toLowerCase()]; + if (!r10) + throw new TypeError("invalid suite type"); + var i8 = y$7(e12, false, r10.key, r10.iv); + return w$9(t9, i8.key, i8.iv); + }; + var t$3 = {}; + var p$c = s$a; + var c$b = s$9; + var o$c = F$2; + t$3.createCipher = t$3.Cipher = p$c.createCipher, t$3.createCipheriv = t$3.Cipheriv = p$c.createCipheriv, t$3.createDecipher = t$3.Decipher = c$b.createDecipher, t$3.createDecipheriv = t$3.Decipheriv = c$b.createDecipheriv, t$3.listCiphers = t$3.getCiphers = function() { + return Object.keys(o$c); + }; + var e$9 = { "des-ecb": { key: 8, iv: 0 } }; + e$9["des-cbc"] = e$9.des = { key: 8, iv: 8 }, e$9["des-ede3-cbc"] = e$9.des3 = { key: 24, iv: 8 }, e$9["des-ede3"] = { key: 24, iv: 0 }, e$9["des-ede-cbc"] = { key: 16, iv: 8 }, e$9["des-ede"] = { key: 16, iv: 0 }; + var p$d = {}; + var n$b = l$7; + var s$b = t$3; + var v$8 = M$2; + var y$8 = e$9; + var a$d = a$c; + function f$h(e12, r10, i8) { + if (e12 = e12.toLowerCase(), v$8[e12]) + return s$b.createCipheriv(e12, r10, i8); + if (y$8[e12]) + return new n$b({ key: r10, iv: i8, mode: e12 }); + throw new TypeError("invalid suite type"); + } + function c$c(e12, r10, i8) { + if (e12 = e12.toLowerCase(), v$8[e12]) + return s$b.createDecipheriv(e12, r10, i8); + if (y$8[e12]) + return new n$b({ key: r10, iv: i8, mode: e12, decrypt: true }); + throw new TypeError("invalid suite type"); + } + p$d.createCipher = p$d.Cipher = function(e12, r10) { + var i8, t9; + if (e12 = e12.toLowerCase(), v$8[e12]) + i8 = v$8[e12].key, t9 = v$8[e12].iv; + else { + if (!y$8[e12]) + throw new TypeError("invalid suite type"); + i8 = 8 * y$8[e12].key, t9 = y$8[e12].iv; + } + var o9 = a$d(r10, false, i8, t9); + return f$h(e12, o9.key, o9.iv); + }, p$d.createCipheriv = p$d.Cipheriv = f$h, p$d.createDecipher = p$d.Decipher = function(e12, r10) { + var i8, t9; + if (e12 = e12.toLowerCase(), v$8[e12]) + i8 = v$8[e12].key, t9 = v$8[e12].iv; + else { + if (!y$8[e12]) + throw new TypeError("invalid suite type"); + i8 = 8 * y$8[e12].key, t9 = y$8[e12].iv; + } + var o9 = a$d(r10, false, i8, t9); + return c$c(e12, o9.key, o9.iv); + }, p$d.createDecipheriv = p$d.Decipheriv = c$c, p$d.listCiphers = p$d.getCiphers = function() { + return Object.keys(y$8).concat(s$b.getCiphers()); + }; + var t$4 = Object.freeze({}); + var i$3 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var r$7 = {}; + var h$a = { exports: r$7 }; + !function(r10, h9) { + function n9(t9, i8) { + if (!t9) + throw new Error(i8 || "Assertion failed"); + } + function e12(t9, i8) { + t9.super_ = i8; + var r11 = function() { + }; + r11.prototype = i8.prototype, t9.prototype = new r11(), t9.prototype.constructor = t9; + } + function o9(t9, r11, h10) { + if (o9.isBN(t9)) + return t9; + (this || i$3).negative = 0, (this || i$3).words = null, (this || i$3).length = 0, (this || i$3).red = null, null !== t9 && ("le" !== r11 && "be" !== r11 || (h10 = r11, r11 = 10), this._init(t9 || 0, r11 || 10, h10 || "be")); + } + var s7; + "object" == typeof r10 ? r10.exports = o9 : h9.BN = o9, o9.BN = o9, o9.wordSize = 26; + try { + s7 = t$4.Buffer; + } catch (t9) { + } + function u8(t9, i8, r11) { + for (var h10 = 0, n10 = Math.min(t9.length, r11), e13 = i8; e13 < n10; e13++) { + var o10 = t9.charCodeAt(e13) - 48; + h10 <<= 4, h10 |= o10 >= 49 && o10 <= 54 ? o10 - 49 + 10 : o10 >= 17 && o10 <= 22 ? o10 - 17 + 10 : 15 & o10; + } + return h10; + } + function a8(t9, i8, r11, h10) { + for (var n10 = 0, e13 = Math.min(t9.length, r11), o10 = i8; o10 < e13; o10++) { + var s8 = t9.charCodeAt(o10) - 48; + n10 *= h10, n10 += s8 >= 49 ? s8 - 49 + 10 : s8 >= 17 ? s8 - 17 + 10 : s8; + } + return n10; + } + o9.isBN = function(t9) { + return t9 instanceof o9 || null !== t9 && "object" == typeof t9 && t9.constructor.wordSize === o9.wordSize && Array.isArray(t9.words); + }, o9.max = function(t9, i8) { + return t9.cmp(i8) > 0 ? t9 : i8; + }, o9.min = function(t9, i8) { + return t9.cmp(i8) < 0 ? t9 : i8; + }, o9.prototype._init = function(t9, r11, h10) { + if ("number" == typeof t9) + return this._initNumber(t9, r11, h10); + if ("object" == typeof t9) + return this._initArray(t9, r11, h10); + "hex" === r11 && (r11 = 16), n9(r11 === (0 | r11) && r11 >= 2 && r11 <= 36); + var e13 = 0; + "-" === (t9 = t9.toString().replace(/\s+/g, ""))[0] && e13++, 16 === r11 ? this._parseHex(t9, e13) : this._parseBase(t9, r11, e13), "-" === t9[0] && ((this || i$3).negative = 1), this.strip(), "le" === h10 && this._initArray(this.toArray(), r11, h10); + }, o9.prototype._initNumber = function(t9, r11, h10) { + t9 < 0 && ((this || i$3).negative = 1, t9 = -t9), t9 < 67108864 ? ((this || i$3).words = [67108863 & t9], (this || i$3).length = 1) : t9 < 4503599627370496 ? ((this || i$3).words = [67108863 & t9, t9 / 67108864 & 67108863], (this || i$3).length = 2) : (n9(t9 < 9007199254740992), (this || i$3).words = [67108863 & t9, t9 / 67108864 & 67108863, 1], (this || i$3).length = 3), "le" === h10 && this._initArray(this.toArray(), r11, h10); + }, o9.prototype._initArray = function(t9, r11, h10) { + if (n9("number" == typeof t9.length), t9.length <= 0) + return (this || i$3).words = [0], (this || i$3).length = 1, this || i$3; + (this || i$3).length = Math.ceil(t9.length / 3), (this || i$3).words = new Array((this || i$3).length); + for (var e13 = 0; e13 < (this || i$3).length; e13++) + (this || i$3).words[e13] = 0; + var o10, s8, u9 = 0; + if ("be" === h10) + for (e13 = t9.length - 1, o10 = 0; e13 >= 0; e13 -= 3) + s8 = t9[e13] | t9[e13 - 1] << 8 | t9[e13 - 2] << 16, (this || i$3).words[o10] |= s8 << u9 & 67108863, (this || i$3).words[o10 + 1] = s8 >>> 26 - u9 & 67108863, (u9 += 24) >= 26 && (u9 -= 26, o10++); + else if ("le" === h10) + for (e13 = 0, o10 = 0; e13 < t9.length; e13 += 3) + s8 = t9[e13] | t9[e13 + 1] << 8 | t9[e13 + 2] << 16, (this || i$3).words[o10] |= s8 << u9 & 67108863, (this || i$3).words[o10 + 1] = s8 >>> 26 - u9 & 67108863, (u9 += 24) >= 26 && (u9 -= 26, o10++); + return this.strip(); + }, o9.prototype._parseHex = function(t9, r11) { + (this || i$3).length = Math.ceil((t9.length - r11) / 6), (this || i$3).words = new Array((this || i$3).length); + for (var h10 = 0; h10 < (this || i$3).length; h10++) + (this || i$3).words[h10] = 0; + var n10, e13, o10 = 0; + for (h10 = t9.length - 6, n10 = 0; h10 >= r11; h10 -= 6) + e13 = u8(t9, h10, h10 + 6), (this || i$3).words[n10] |= e13 << o10 & 67108863, (this || i$3).words[n10 + 1] |= e13 >>> 26 - o10 & 4194303, (o10 += 24) >= 26 && (o10 -= 26, n10++); + h10 + 6 !== r11 && (e13 = u8(t9, r11, h10 + 6), (this || i$3).words[n10] |= e13 << o10 & 67108863, (this || i$3).words[n10 + 1] |= e13 >>> 26 - o10 & 4194303), this.strip(); + }, o9.prototype._parseBase = function(t9, r11, h10) { + (this || i$3).words = [0], (this || i$3).length = 1; + for (var n10 = 0, e13 = 1; e13 <= 67108863; e13 *= r11) + n10++; + n10--, e13 = e13 / r11 | 0; + for (var o10 = t9.length - h10, s8 = o10 % n10, u9 = Math.min(o10, o10 - s8) + h10, l9 = 0, m8 = h10; m8 < u9; m8 += n10) + l9 = a8(t9, m8, m8 + n10, r11), this.imuln(e13), (this || i$3).words[0] + l9 < 67108864 ? (this || i$3).words[0] += l9 : this._iaddn(l9); + if (0 !== s8) { + var f10 = 1; + for (l9 = a8(t9, m8, t9.length, r11), m8 = 0; m8 < s8; m8++) + f10 *= r11; + this.imuln(f10), (this || i$3).words[0] + l9 < 67108864 ? (this || i$3).words[0] += l9 : this._iaddn(l9); + } + }, o9.prototype.copy = function(t9) { + t9.words = new Array((this || i$3).length); + for (var r11 = 0; r11 < (this || i$3).length; r11++) + t9.words[r11] = (this || i$3).words[r11]; + t9.length = (this || i$3).length, t9.negative = (this || i$3).negative, t9.red = (this || i$3).red; + }, o9.prototype.clone = function() { + var t9 = new o9(null); + return this.copy(t9), t9; + }, o9.prototype._expand = function(t9) { + for (; (this || i$3).length < t9; ) + (this || i$3).words[(this || i$3).length++] = 0; + return this || i$3; + }, o9.prototype.strip = function() { + for (; (this || i$3).length > 1 && 0 === (this || i$3).words[(this || i$3).length - 1]; ) + (this || i$3).length--; + return this._normSign(); + }, o9.prototype._normSign = function() { + return 1 === (this || i$3).length && 0 === (this || i$3).words[0] && ((this || i$3).negative = 0), this || i$3; + }, o9.prototype.inspect = function() { + return ((this || i$3).red ? ""; + }; + var l8 = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"], m7 = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], f9 = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + function d7(t9, i8, r11) { + r11.negative = i8.negative ^ t9.negative; + var h10 = t9.length + i8.length | 0; + r11.length = h10, h10 = h10 - 1 | 0; + var n10 = 0 | t9.words[0], e13 = 0 | i8.words[0], o10 = n10 * e13, s8 = 67108863 & o10, u9 = o10 / 67108864 | 0; + r11.words[0] = s8; + for (var a9 = 1; a9 < h10; a9++) { + for (var l9 = u9 >>> 26, m8 = 67108863 & u9, f10 = Math.min(a9, i8.length - 1), d8 = Math.max(0, a9 - t9.length + 1); d8 <= f10; d8++) { + var p9 = a9 - d8 | 0; + l9 += (o10 = (n10 = 0 | t9.words[p9]) * (e13 = 0 | i8.words[d8]) + m8) / 67108864 | 0, m8 = 67108863 & o10; + } + r11.words[a9] = 0 | m8, u9 = 0 | l9; + } + return 0 !== u9 ? r11.words[a9] = 0 | u9 : r11.length--, r11.strip(); + } + o9.prototype.toString = function(t9, r11) { + var h10; + if (r11 = 0 | r11 || 1, 16 === (t9 = t9 || 10) || "hex" === t9) { + h10 = ""; + for (var e13 = 0, o10 = 0, s8 = 0; s8 < (this || i$3).length; s8++) { + var u9 = (this || i$3).words[s8], a9 = (16777215 & (u9 << e13 | o10)).toString(16); + h10 = 0 !== (o10 = u9 >>> 24 - e13 & 16777215) || s8 !== (this || i$3).length - 1 ? l8[6 - a9.length] + a9 + h10 : a9 + h10, (e13 += 2) >= 26 && (e13 -= 26, s8--); + } + for (0 !== o10 && (h10 = o10.toString(16) + h10); h10.length % r11 != 0; ) + h10 = "0" + h10; + return 0 !== (this || i$3).negative && (h10 = "-" + h10), h10; + } + if (t9 === (0 | t9) && t9 >= 2 && t9 <= 36) { + var d8 = m7[t9], p9 = f9[t9]; + h10 = ""; + var M6 = this.clone(); + for (M6.negative = 0; !M6.isZero(); ) { + var v8 = M6.modn(p9).toString(t9); + h10 = (M6 = M6.idivn(p9)).isZero() ? v8 + h10 : l8[d8 - v8.length] + v8 + h10; + } + for (this.isZero() && (h10 = "0" + h10); h10.length % r11 != 0; ) + h10 = "0" + h10; + return 0 !== (this || i$3).negative && (h10 = "-" + h10), h10; + } + n9(false, "Base should be between 2 and 36"); + }, o9.prototype.toNumber = function() { + var t9 = (this || i$3).words[0]; + return 2 === (this || i$3).length ? t9 += 67108864 * (this || i$3).words[1] : 3 === (this || i$3).length && 1 === (this || i$3).words[2] ? t9 += 4503599627370496 + 67108864 * (this || i$3).words[1] : (this || i$3).length > 2 && n9(false, "Number can only safely store up to 53 bits"), 0 !== (this || i$3).negative ? -t9 : t9; + }, o9.prototype.toJSON = function() { + return this.toString(16); + }, o9.prototype.toBuffer = function(t9, i8) { + return n9(void 0 !== s7), this.toArrayLike(s7, t9, i8); + }, o9.prototype.toArray = function(t9, i8) { + return this.toArrayLike(Array, t9, i8); + }, o9.prototype.toArrayLike = function(t9, i8, r11) { + var h10 = this.byteLength(), e13 = r11 || Math.max(1, h10); + n9(h10 <= e13, "byte array longer than desired length"), n9(e13 > 0, "Requested array length <= 0"), this.strip(); + var o10, s8, u9 = "le" === i8, a9 = new t9(e13), l9 = this.clone(); + if (u9) { + for (s8 = 0; !l9.isZero(); s8++) + o10 = l9.andln(255), l9.iushrn(8), a9[s8] = o10; + for (; s8 < e13; s8++) + a9[s8] = 0; + } else { + for (s8 = 0; s8 < e13 - h10; s8++) + a9[s8] = 0; + for (s8 = 0; !l9.isZero(); s8++) + o10 = l9.andln(255), l9.iushrn(8), a9[e13 - s8 - 1] = o10; + } + return a9; + }, Math.clz32 ? o9.prototype._countBits = function(t9) { + return 32 - Math.clz32(t9); + } : o9.prototype._countBits = function(t9) { + var i8 = t9, r11 = 0; + return i8 >= 4096 && (r11 += 13, i8 >>>= 13), i8 >= 64 && (r11 += 7, i8 >>>= 7), i8 >= 8 && (r11 += 4, i8 >>>= 4), i8 >= 2 && (r11 += 2, i8 >>>= 2), r11 + i8; + }, o9.prototype._zeroBits = function(t9) { + if (0 === t9) + return 26; + var i8 = t9, r11 = 0; + return 0 == (8191 & i8) && (r11 += 13, i8 >>>= 13), 0 == (127 & i8) && (r11 += 7, i8 >>>= 7), 0 == (15 & i8) && (r11 += 4, i8 >>>= 4), 0 == (3 & i8) && (r11 += 2, i8 >>>= 2), 0 == (1 & i8) && r11++, r11; + }, o9.prototype.bitLength = function() { + var t9 = (this || i$3).words[(this || i$3).length - 1], r11 = this._countBits(t9); + return 26 * ((this || i$3).length - 1) + r11; + }, o9.prototype.zeroBits = function() { + if (this.isZero()) + return 0; + for (var t9 = 0, r11 = 0; r11 < (this || i$3).length; r11++) { + var h10 = this._zeroBits((this || i$3).words[r11]); + if (t9 += h10, 26 !== h10) + break; + } + return t9; + }, o9.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, o9.prototype.toTwos = function(t9) { + return 0 !== (this || i$3).negative ? this.abs().inotn(t9).iaddn(1) : this.clone(); + }, o9.prototype.fromTwos = function(t9) { + return this.testn(t9 - 1) ? this.notn(t9).iaddn(1).ineg() : this.clone(); + }, o9.prototype.isNeg = function() { + return 0 !== (this || i$3).negative; + }, o9.prototype.neg = function() { + return this.clone().ineg(); + }, o9.prototype.ineg = function() { + return this.isZero() || ((this || i$3).negative ^= 1), this || i$3; + }, o9.prototype.iuor = function(t9) { + for (; (this || i$3).length < t9.length; ) + (this || i$3).words[(this || i$3).length++] = 0; + for (var r11 = 0; r11 < t9.length; r11++) + (this || i$3).words[r11] = (this || i$3).words[r11] | t9.words[r11]; + return this.strip(); + }, o9.prototype.ior = function(t9) { + return n9(0 == ((this || i$3).negative | t9.negative)), this.iuor(t9); + }, o9.prototype.or = function(t9) { + return (this || i$3).length > t9.length ? this.clone().ior(t9) : t9.clone().ior(this || i$3); + }, o9.prototype.uor = function(t9) { + return (this || i$3).length > t9.length ? this.clone().iuor(t9) : t9.clone().iuor(this || i$3); + }, o9.prototype.iuand = function(t9) { + var r11; + r11 = (this || i$3).length > t9.length ? t9 : this || i$3; + for (var h10 = 0; h10 < r11.length; h10++) + (this || i$3).words[h10] = (this || i$3).words[h10] & t9.words[h10]; + return (this || i$3).length = r11.length, this.strip(); + }, o9.prototype.iand = function(t9) { + return n9(0 == ((this || i$3).negative | t9.negative)), this.iuand(t9); + }, o9.prototype.and = function(t9) { + return (this || i$3).length > t9.length ? this.clone().iand(t9) : t9.clone().iand(this || i$3); + }, o9.prototype.uand = function(t9) { + return (this || i$3).length > t9.length ? this.clone().iuand(t9) : t9.clone().iuand(this || i$3); + }, o9.prototype.iuxor = function(t9) { + var r11, h10; + (this || i$3).length > t9.length ? (r11 = this || i$3, h10 = t9) : (r11 = t9, h10 = this || i$3); + for (var n10 = 0; n10 < h10.length; n10++) + (this || i$3).words[n10] = r11.words[n10] ^ h10.words[n10]; + if ((this || i$3) !== r11) + for (; n10 < r11.length; n10++) + (this || i$3).words[n10] = r11.words[n10]; + return (this || i$3).length = r11.length, this.strip(); + }, o9.prototype.ixor = function(t9) { + return n9(0 == ((this || i$3).negative | t9.negative)), this.iuxor(t9); + }, o9.prototype.xor = function(t9) { + return (this || i$3).length > t9.length ? this.clone().ixor(t9) : t9.clone().ixor(this || i$3); + }, o9.prototype.uxor = function(t9) { + return (this || i$3).length > t9.length ? this.clone().iuxor(t9) : t9.clone().iuxor(this || i$3); + }, o9.prototype.inotn = function(t9) { + n9("number" == typeof t9 && t9 >= 0); + var r11 = 0 | Math.ceil(t9 / 26), h10 = t9 % 26; + this._expand(r11), h10 > 0 && r11--; + for (var e13 = 0; e13 < r11; e13++) + (this || i$3).words[e13] = 67108863 & ~(this || i$3).words[e13]; + return h10 > 0 && ((this || i$3).words[e13] = ~(this || i$3).words[e13] & 67108863 >> 26 - h10), this.strip(); + }, o9.prototype.notn = function(t9) { + return this.clone().inotn(t9); + }, o9.prototype.setn = function(t9, r11) { + n9("number" == typeof t9 && t9 >= 0); + var h10 = t9 / 26 | 0, e13 = t9 % 26; + return this._expand(h10 + 1), (this || i$3).words[h10] = r11 ? (this || i$3).words[h10] | 1 << e13 : (this || i$3).words[h10] & ~(1 << e13), this.strip(); + }, o9.prototype.iadd = function(t9) { + var r11, h10, n10; + if (0 !== (this || i$3).negative && 0 === t9.negative) + return (this || i$3).negative = 0, r11 = this.isub(t9), (this || i$3).negative ^= 1, this._normSign(); + if (0 === (this || i$3).negative && 0 !== t9.negative) + return t9.negative = 0, r11 = this.isub(t9), t9.negative = 1, r11._normSign(); + (this || i$3).length > t9.length ? (h10 = this || i$3, n10 = t9) : (h10 = t9, n10 = this || i$3); + for (var e13 = 0, o10 = 0; o10 < n10.length; o10++) + r11 = (0 | h10.words[o10]) + (0 | n10.words[o10]) + e13, (this || i$3).words[o10] = 67108863 & r11, e13 = r11 >>> 26; + for (; 0 !== e13 && o10 < h10.length; o10++) + r11 = (0 | h10.words[o10]) + e13, (this || i$3).words[o10] = 67108863 & r11, e13 = r11 >>> 26; + if ((this || i$3).length = h10.length, 0 !== e13) + (this || i$3).words[(this || i$3).length] = e13, (this || i$3).length++; + else if (h10 !== (this || i$3)) + for (; o10 < h10.length; o10++) + (this || i$3).words[o10] = h10.words[o10]; + return this || i$3; + }, o9.prototype.add = function(t9) { + var r11; + return 0 !== t9.negative && 0 === (this || i$3).negative ? (t9.negative = 0, r11 = this.sub(t9), t9.negative ^= 1, r11) : 0 === t9.negative && 0 !== (this || i$3).negative ? ((this || i$3).negative = 0, r11 = t9.sub(this || i$3), (this || i$3).negative = 1, r11) : (this || i$3).length > t9.length ? this.clone().iadd(t9) : t9.clone().iadd(this || i$3); + }, o9.prototype.isub = function(t9) { + if (0 !== t9.negative) { + t9.negative = 0; + var r11 = this.iadd(t9); + return t9.negative = 1, r11._normSign(); + } + if (0 !== (this || i$3).negative) + return (this || i$3).negative = 0, this.iadd(t9), (this || i$3).negative = 1, this._normSign(); + var h10, n10, e13 = this.cmp(t9); + if (0 === e13) + return (this || i$3).negative = 0, (this || i$3).length = 1, (this || i$3).words[0] = 0, this || i$3; + e13 > 0 ? (h10 = this || i$3, n10 = t9) : (h10 = t9, n10 = this || i$3); + for (var o10 = 0, s8 = 0; s8 < n10.length; s8++) + o10 = (r11 = (0 | h10.words[s8]) - (0 | n10.words[s8]) + o10) >> 26, (this || i$3).words[s8] = 67108863 & r11; + for (; 0 !== o10 && s8 < h10.length; s8++) + o10 = (r11 = (0 | h10.words[s8]) + o10) >> 26, (this || i$3).words[s8] = 67108863 & r11; + if (0 === o10 && s8 < h10.length && h10 !== (this || i$3)) + for (; s8 < h10.length; s8++) + (this || i$3).words[s8] = h10.words[s8]; + return (this || i$3).length = Math.max((this || i$3).length, s8), h10 !== (this || i$3) && ((this || i$3).negative = 1), this.strip(); + }, o9.prototype.sub = function(t9) { + return this.clone().isub(t9); + }; + var p8 = function(t9, i8, r11) { + var h10, n10, e13, o10 = t9.words, s8 = i8.words, u9 = r11.words, a9 = 0, l9 = 0 | o10[0], m8 = 8191 & l9, f10 = l9 >>> 13, d8 = 0 | o10[1], p9 = 8191 & d8, M6 = d8 >>> 13, v8 = 0 | o10[2], g7 = 8191 & v8, c9 = v8 >>> 13, w6 = 0 | o10[3], y8 = 8191 & w6, b7 = w6 >>> 13, _6 = 0 | o10[4], k6 = 8191 & _6, A6 = _6 >>> 13, x5 = 0 | o10[5], S5 = 8191 & x5, Z4 = x5 >>> 13, R5 = 0 | o10[6], q4 = 8191 & R5, B5 = R5 >>> 13, N14 = 0 | o10[7], L5 = 8191 & N14, I5 = N14 >>> 13, T6 = 0 | o10[8], z6 = 8191 & T6, E5 = T6 >>> 13, O6 = 0 | o10[9], j5 = 8191 & O6, K4 = O6 >>> 13, P5 = 0 | s8[0], F5 = 8191 & P5, C5 = P5 >>> 13, D5 = 0 | s8[1], H4 = 8191 & D5, J4 = D5 >>> 13, U5 = 0 | s8[2], G4 = 8191 & U5, Q4 = U5 >>> 13, V4 = 0 | s8[3], W4 = 8191 & V4, X4 = V4 >>> 13, Y5 = 0 | s8[4], $4 = 8191 & Y5, tt3 = Y5 >>> 13, it4 = 0 | s8[5], rt = 8191 & it4, ht2 = it4 >>> 13, nt2 = 0 | s8[6], et3 = 8191 & nt2, ot = nt2 >>> 13, st2 = 0 | s8[7], ut = 8191 & st2, at2 = st2 >>> 13, lt = 0 | s8[8], mt = 8191 & lt, ft = lt >>> 13, dt = 0 | s8[9], pt = 8191 & dt, Mt = dt >>> 13; + r11.negative = t9.negative ^ i8.negative, r11.length = 19; + var vt = (a9 + (h10 = Math.imul(m8, F5)) | 0) + ((8191 & (n10 = (n10 = Math.imul(m8, C5)) + Math.imul(f10, F5) | 0)) << 13) | 0; + a9 = ((e13 = Math.imul(f10, C5)) + (n10 >>> 13) | 0) + (vt >>> 26) | 0, vt &= 67108863, h10 = Math.imul(p9, F5), n10 = (n10 = Math.imul(p9, C5)) + Math.imul(M6, F5) | 0, e13 = Math.imul(M6, C5); + var gt = (a9 + (h10 = h10 + Math.imul(m8, H4) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(m8, J4) | 0) + Math.imul(f10, H4) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(f10, J4) | 0) + (n10 >>> 13) | 0) + (gt >>> 26) | 0, gt &= 67108863, h10 = Math.imul(g7, F5), n10 = (n10 = Math.imul(g7, C5)) + Math.imul(c9, F5) | 0, e13 = Math.imul(c9, C5), h10 = h10 + Math.imul(p9, H4) | 0, n10 = (n10 = n10 + Math.imul(p9, J4) | 0) + Math.imul(M6, H4) | 0, e13 = e13 + Math.imul(M6, J4) | 0; + var ct = (a9 + (h10 = h10 + Math.imul(m8, G4) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(m8, Q4) | 0) + Math.imul(f10, G4) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(f10, Q4) | 0) + (n10 >>> 13) | 0) + (ct >>> 26) | 0, ct &= 67108863, h10 = Math.imul(y8, F5), n10 = (n10 = Math.imul(y8, C5)) + Math.imul(b7, F5) | 0, e13 = Math.imul(b7, C5), h10 = h10 + Math.imul(g7, H4) | 0, n10 = (n10 = n10 + Math.imul(g7, J4) | 0) + Math.imul(c9, H4) | 0, e13 = e13 + Math.imul(c9, J4) | 0, h10 = h10 + Math.imul(p9, G4) | 0, n10 = (n10 = n10 + Math.imul(p9, Q4) | 0) + Math.imul(M6, G4) | 0, e13 = e13 + Math.imul(M6, Q4) | 0; + var wt = (a9 + (h10 = h10 + Math.imul(m8, W4) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(m8, X4) | 0) + Math.imul(f10, W4) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(f10, X4) | 0) + (n10 >>> 13) | 0) + (wt >>> 26) | 0, wt &= 67108863, h10 = Math.imul(k6, F5), n10 = (n10 = Math.imul(k6, C5)) + Math.imul(A6, F5) | 0, e13 = Math.imul(A6, C5), h10 = h10 + Math.imul(y8, H4) | 0, n10 = (n10 = n10 + Math.imul(y8, J4) | 0) + Math.imul(b7, H4) | 0, e13 = e13 + Math.imul(b7, J4) | 0, h10 = h10 + Math.imul(g7, G4) | 0, n10 = (n10 = n10 + Math.imul(g7, Q4) | 0) + Math.imul(c9, G4) | 0, e13 = e13 + Math.imul(c9, Q4) | 0, h10 = h10 + Math.imul(p9, W4) | 0, n10 = (n10 = n10 + Math.imul(p9, X4) | 0) + Math.imul(M6, W4) | 0, e13 = e13 + Math.imul(M6, X4) | 0; + var yt = (a9 + (h10 = h10 + Math.imul(m8, $4) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(m8, tt3) | 0) + Math.imul(f10, $4) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(f10, tt3) | 0) + (n10 >>> 13) | 0) + (yt >>> 26) | 0, yt &= 67108863, h10 = Math.imul(S5, F5), n10 = (n10 = Math.imul(S5, C5)) + Math.imul(Z4, F5) | 0, e13 = Math.imul(Z4, C5), h10 = h10 + Math.imul(k6, H4) | 0, n10 = (n10 = n10 + Math.imul(k6, J4) | 0) + Math.imul(A6, H4) | 0, e13 = e13 + Math.imul(A6, J4) | 0, h10 = h10 + Math.imul(y8, G4) | 0, n10 = (n10 = n10 + Math.imul(y8, Q4) | 0) + Math.imul(b7, G4) | 0, e13 = e13 + Math.imul(b7, Q4) | 0, h10 = h10 + Math.imul(g7, W4) | 0, n10 = (n10 = n10 + Math.imul(g7, X4) | 0) + Math.imul(c9, W4) | 0, e13 = e13 + Math.imul(c9, X4) | 0, h10 = h10 + Math.imul(p9, $4) | 0, n10 = (n10 = n10 + Math.imul(p9, tt3) | 0) + Math.imul(M6, $4) | 0, e13 = e13 + Math.imul(M6, tt3) | 0; + var bt = (a9 + (h10 = h10 + Math.imul(m8, rt) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(m8, ht2) | 0) + Math.imul(f10, rt) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(f10, ht2) | 0) + (n10 >>> 13) | 0) + (bt >>> 26) | 0, bt &= 67108863, h10 = Math.imul(q4, F5), n10 = (n10 = Math.imul(q4, C5)) + Math.imul(B5, F5) | 0, e13 = Math.imul(B5, C5), h10 = h10 + Math.imul(S5, H4) | 0, n10 = (n10 = n10 + Math.imul(S5, J4) | 0) + Math.imul(Z4, H4) | 0, e13 = e13 + Math.imul(Z4, J4) | 0, h10 = h10 + Math.imul(k6, G4) | 0, n10 = (n10 = n10 + Math.imul(k6, Q4) | 0) + Math.imul(A6, G4) | 0, e13 = e13 + Math.imul(A6, Q4) | 0, h10 = h10 + Math.imul(y8, W4) | 0, n10 = (n10 = n10 + Math.imul(y8, X4) | 0) + Math.imul(b7, W4) | 0, e13 = e13 + Math.imul(b7, X4) | 0, h10 = h10 + Math.imul(g7, $4) | 0, n10 = (n10 = n10 + Math.imul(g7, tt3) | 0) + Math.imul(c9, $4) | 0, e13 = e13 + Math.imul(c9, tt3) | 0, h10 = h10 + Math.imul(p9, rt) | 0, n10 = (n10 = n10 + Math.imul(p9, ht2) | 0) + Math.imul(M6, rt) | 0, e13 = e13 + Math.imul(M6, ht2) | 0; + var _t2 = (a9 + (h10 = h10 + Math.imul(m8, et3) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(m8, ot) | 0) + Math.imul(f10, et3) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(f10, ot) | 0) + (n10 >>> 13) | 0) + (_t2 >>> 26) | 0, _t2 &= 67108863, h10 = Math.imul(L5, F5), n10 = (n10 = Math.imul(L5, C5)) + Math.imul(I5, F5) | 0, e13 = Math.imul(I5, C5), h10 = h10 + Math.imul(q4, H4) | 0, n10 = (n10 = n10 + Math.imul(q4, J4) | 0) + Math.imul(B5, H4) | 0, e13 = e13 + Math.imul(B5, J4) | 0, h10 = h10 + Math.imul(S5, G4) | 0, n10 = (n10 = n10 + Math.imul(S5, Q4) | 0) + Math.imul(Z4, G4) | 0, e13 = e13 + Math.imul(Z4, Q4) | 0, h10 = h10 + Math.imul(k6, W4) | 0, n10 = (n10 = n10 + Math.imul(k6, X4) | 0) + Math.imul(A6, W4) | 0, e13 = e13 + Math.imul(A6, X4) | 0, h10 = h10 + Math.imul(y8, $4) | 0, n10 = (n10 = n10 + Math.imul(y8, tt3) | 0) + Math.imul(b7, $4) | 0, e13 = e13 + Math.imul(b7, tt3) | 0, h10 = h10 + Math.imul(g7, rt) | 0, n10 = (n10 = n10 + Math.imul(g7, ht2) | 0) + Math.imul(c9, rt) | 0, e13 = e13 + Math.imul(c9, ht2) | 0, h10 = h10 + Math.imul(p9, et3) | 0, n10 = (n10 = n10 + Math.imul(p9, ot) | 0) + Math.imul(M6, et3) | 0, e13 = e13 + Math.imul(M6, ot) | 0; + var kt = (a9 + (h10 = h10 + Math.imul(m8, ut) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(m8, at2) | 0) + Math.imul(f10, ut) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(f10, at2) | 0) + (n10 >>> 13) | 0) + (kt >>> 26) | 0, kt &= 67108863, h10 = Math.imul(z6, F5), n10 = (n10 = Math.imul(z6, C5)) + Math.imul(E5, F5) | 0, e13 = Math.imul(E5, C5), h10 = h10 + Math.imul(L5, H4) | 0, n10 = (n10 = n10 + Math.imul(L5, J4) | 0) + Math.imul(I5, H4) | 0, e13 = e13 + Math.imul(I5, J4) | 0, h10 = h10 + Math.imul(q4, G4) | 0, n10 = (n10 = n10 + Math.imul(q4, Q4) | 0) + Math.imul(B5, G4) | 0, e13 = e13 + Math.imul(B5, Q4) | 0, h10 = h10 + Math.imul(S5, W4) | 0, n10 = (n10 = n10 + Math.imul(S5, X4) | 0) + Math.imul(Z4, W4) | 0, e13 = e13 + Math.imul(Z4, X4) | 0, h10 = h10 + Math.imul(k6, $4) | 0, n10 = (n10 = n10 + Math.imul(k6, tt3) | 0) + Math.imul(A6, $4) | 0, e13 = e13 + Math.imul(A6, tt3) | 0, h10 = h10 + Math.imul(y8, rt) | 0, n10 = (n10 = n10 + Math.imul(y8, ht2) | 0) + Math.imul(b7, rt) | 0, e13 = e13 + Math.imul(b7, ht2) | 0, h10 = h10 + Math.imul(g7, et3) | 0, n10 = (n10 = n10 + Math.imul(g7, ot) | 0) + Math.imul(c9, et3) | 0, e13 = e13 + Math.imul(c9, ot) | 0, h10 = h10 + Math.imul(p9, ut) | 0, n10 = (n10 = n10 + Math.imul(p9, at2) | 0) + Math.imul(M6, ut) | 0, e13 = e13 + Math.imul(M6, at2) | 0; + var At = (a9 + (h10 = h10 + Math.imul(m8, mt) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(m8, ft) | 0) + Math.imul(f10, mt) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(f10, ft) | 0) + (n10 >>> 13) | 0) + (At >>> 26) | 0, At &= 67108863, h10 = Math.imul(j5, F5), n10 = (n10 = Math.imul(j5, C5)) + Math.imul(K4, F5) | 0, e13 = Math.imul(K4, C5), h10 = h10 + Math.imul(z6, H4) | 0, n10 = (n10 = n10 + Math.imul(z6, J4) | 0) + Math.imul(E5, H4) | 0, e13 = e13 + Math.imul(E5, J4) | 0, h10 = h10 + Math.imul(L5, G4) | 0, n10 = (n10 = n10 + Math.imul(L5, Q4) | 0) + Math.imul(I5, G4) | 0, e13 = e13 + Math.imul(I5, Q4) | 0, h10 = h10 + Math.imul(q4, W4) | 0, n10 = (n10 = n10 + Math.imul(q4, X4) | 0) + Math.imul(B5, W4) | 0, e13 = e13 + Math.imul(B5, X4) | 0, h10 = h10 + Math.imul(S5, $4) | 0, n10 = (n10 = n10 + Math.imul(S5, tt3) | 0) + Math.imul(Z4, $4) | 0, e13 = e13 + Math.imul(Z4, tt3) | 0, h10 = h10 + Math.imul(k6, rt) | 0, n10 = (n10 = n10 + Math.imul(k6, ht2) | 0) + Math.imul(A6, rt) | 0, e13 = e13 + Math.imul(A6, ht2) | 0, h10 = h10 + Math.imul(y8, et3) | 0, n10 = (n10 = n10 + Math.imul(y8, ot) | 0) + Math.imul(b7, et3) | 0, e13 = e13 + Math.imul(b7, ot) | 0, h10 = h10 + Math.imul(g7, ut) | 0, n10 = (n10 = n10 + Math.imul(g7, at2) | 0) + Math.imul(c9, ut) | 0, e13 = e13 + Math.imul(c9, at2) | 0, h10 = h10 + Math.imul(p9, mt) | 0, n10 = (n10 = n10 + Math.imul(p9, ft) | 0) + Math.imul(M6, mt) | 0, e13 = e13 + Math.imul(M6, ft) | 0; + var xt = (a9 + (h10 = h10 + Math.imul(m8, pt) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(m8, Mt) | 0) + Math.imul(f10, pt) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(f10, Mt) | 0) + (n10 >>> 13) | 0) + (xt >>> 26) | 0, xt &= 67108863, h10 = Math.imul(j5, H4), n10 = (n10 = Math.imul(j5, J4)) + Math.imul(K4, H4) | 0, e13 = Math.imul(K4, J4), h10 = h10 + Math.imul(z6, G4) | 0, n10 = (n10 = n10 + Math.imul(z6, Q4) | 0) + Math.imul(E5, G4) | 0, e13 = e13 + Math.imul(E5, Q4) | 0, h10 = h10 + Math.imul(L5, W4) | 0, n10 = (n10 = n10 + Math.imul(L5, X4) | 0) + Math.imul(I5, W4) | 0, e13 = e13 + Math.imul(I5, X4) | 0, h10 = h10 + Math.imul(q4, $4) | 0, n10 = (n10 = n10 + Math.imul(q4, tt3) | 0) + Math.imul(B5, $4) | 0, e13 = e13 + Math.imul(B5, tt3) | 0, h10 = h10 + Math.imul(S5, rt) | 0, n10 = (n10 = n10 + Math.imul(S5, ht2) | 0) + Math.imul(Z4, rt) | 0, e13 = e13 + Math.imul(Z4, ht2) | 0, h10 = h10 + Math.imul(k6, et3) | 0, n10 = (n10 = n10 + Math.imul(k6, ot) | 0) + Math.imul(A6, et3) | 0, e13 = e13 + Math.imul(A6, ot) | 0, h10 = h10 + Math.imul(y8, ut) | 0, n10 = (n10 = n10 + Math.imul(y8, at2) | 0) + Math.imul(b7, ut) | 0, e13 = e13 + Math.imul(b7, at2) | 0, h10 = h10 + Math.imul(g7, mt) | 0, n10 = (n10 = n10 + Math.imul(g7, ft) | 0) + Math.imul(c9, mt) | 0, e13 = e13 + Math.imul(c9, ft) | 0; + var St = (a9 + (h10 = h10 + Math.imul(p9, pt) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(p9, Mt) | 0) + Math.imul(M6, pt) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(M6, Mt) | 0) + (n10 >>> 13) | 0) + (St >>> 26) | 0, St &= 67108863, h10 = Math.imul(j5, G4), n10 = (n10 = Math.imul(j5, Q4)) + Math.imul(K4, G4) | 0, e13 = Math.imul(K4, Q4), h10 = h10 + Math.imul(z6, W4) | 0, n10 = (n10 = n10 + Math.imul(z6, X4) | 0) + Math.imul(E5, W4) | 0, e13 = e13 + Math.imul(E5, X4) | 0, h10 = h10 + Math.imul(L5, $4) | 0, n10 = (n10 = n10 + Math.imul(L5, tt3) | 0) + Math.imul(I5, $4) | 0, e13 = e13 + Math.imul(I5, tt3) | 0, h10 = h10 + Math.imul(q4, rt) | 0, n10 = (n10 = n10 + Math.imul(q4, ht2) | 0) + Math.imul(B5, rt) | 0, e13 = e13 + Math.imul(B5, ht2) | 0, h10 = h10 + Math.imul(S5, et3) | 0, n10 = (n10 = n10 + Math.imul(S5, ot) | 0) + Math.imul(Z4, et3) | 0, e13 = e13 + Math.imul(Z4, ot) | 0, h10 = h10 + Math.imul(k6, ut) | 0, n10 = (n10 = n10 + Math.imul(k6, at2) | 0) + Math.imul(A6, ut) | 0, e13 = e13 + Math.imul(A6, at2) | 0, h10 = h10 + Math.imul(y8, mt) | 0, n10 = (n10 = n10 + Math.imul(y8, ft) | 0) + Math.imul(b7, mt) | 0, e13 = e13 + Math.imul(b7, ft) | 0; + var Zt = (a9 + (h10 = h10 + Math.imul(g7, pt) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(g7, Mt) | 0) + Math.imul(c9, pt) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(c9, Mt) | 0) + (n10 >>> 13) | 0) + (Zt >>> 26) | 0, Zt &= 67108863, h10 = Math.imul(j5, W4), n10 = (n10 = Math.imul(j5, X4)) + Math.imul(K4, W4) | 0, e13 = Math.imul(K4, X4), h10 = h10 + Math.imul(z6, $4) | 0, n10 = (n10 = n10 + Math.imul(z6, tt3) | 0) + Math.imul(E5, $4) | 0, e13 = e13 + Math.imul(E5, tt3) | 0, h10 = h10 + Math.imul(L5, rt) | 0, n10 = (n10 = n10 + Math.imul(L5, ht2) | 0) + Math.imul(I5, rt) | 0, e13 = e13 + Math.imul(I5, ht2) | 0, h10 = h10 + Math.imul(q4, et3) | 0, n10 = (n10 = n10 + Math.imul(q4, ot) | 0) + Math.imul(B5, et3) | 0, e13 = e13 + Math.imul(B5, ot) | 0, h10 = h10 + Math.imul(S5, ut) | 0, n10 = (n10 = n10 + Math.imul(S5, at2) | 0) + Math.imul(Z4, ut) | 0, e13 = e13 + Math.imul(Z4, at2) | 0, h10 = h10 + Math.imul(k6, mt) | 0, n10 = (n10 = n10 + Math.imul(k6, ft) | 0) + Math.imul(A6, mt) | 0, e13 = e13 + Math.imul(A6, ft) | 0; + var Rt = (a9 + (h10 = h10 + Math.imul(y8, pt) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(y8, Mt) | 0) + Math.imul(b7, pt) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(b7, Mt) | 0) + (n10 >>> 13) | 0) + (Rt >>> 26) | 0, Rt &= 67108863, h10 = Math.imul(j5, $4), n10 = (n10 = Math.imul(j5, tt3)) + Math.imul(K4, $4) | 0, e13 = Math.imul(K4, tt3), h10 = h10 + Math.imul(z6, rt) | 0, n10 = (n10 = n10 + Math.imul(z6, ht2) | 0) + Math.imul(E5, rt) | 0, e13 = e13 + Math.imul(E5, ht2) | 0, h10 = h10 + Math.imul(L5, et3) | 0, n10 = (n10 = n10 + Math.imul(L5, ot) | 0) + Math.imul(I5, et3) | 0, e13 = e13 + Math.imul(I5, ot) | 0, h10 = h10 + Math.imul(q4, ut) | 0, n10 = (n10 = n10 + Math.imul(q4, at2) | 0) + Math.imul(B5, ut) | 0, e13 = e13 + Math.imul(B5, at2) | 0, h10 = h10 + Math.imul(S5, mt) | 0, n10 = (n10 = n10 + Math.imul(S5, ft) | 0) + Math.imul(Z4, mt) | 0, e13 = e13 + Math.imul(Z4, ft) | 0; + var qt = (a9 + (h10 = h10 + Math.imul(k6, pt) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(k6, Mt) | 0) + Math.imul(A6, pt) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(A6, Mt) | 0) + (n10 >>> 13) | 0) + (qt >>> 26) | 0, qt &= 67108863, h10 = Math.imul(j5, rt), n10 = (n10 = Math.imul(j5, ht2)) + Math.imul(K4, rt) | 0, e13 = Math.imul(K4, ht2), h10 = h10 + Math.imul(z6, et3) | 0, n10 = (n10 = n10 + Math.imul(z6, ot) | 0) + Math.imul(E5, et3) | 0, e13 = e13 + Math.imul(E5, ot) | 0, h10 = h10 + Math.imul(L5, ut) | 0, n10 = (n10 = n10 + Math.imul(L5, at2) | 0) + Math.imul(I5, ut) | 0, e13 = e13 + Math.imul(I5, at2) | 0, h10 = h10 + Math.imul(q4, mt) | 0, n10 = (n10 = n10 + Math.imul(q4, ft) | 0) + Math.imul(B5, mt) | 0, e13 = e13 + Math.imul(B5, ft) | 0; + var Bt = (a9 + (h10 = h10 + Math.imul(S5, pt) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(S5, Mt) | 0) + Math.imul(Z4, pt) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(Z4, Mt) | 0) + (n10 >>> 13) | 0) + (Bt >>> 26) | 0, Bt &= 67108863, h10 = Math.imul(j5, et3), n10 = (n10 = Math.imul(j5, ot)) + Math.imul(K4, et3) | 0, e13 = Math.imul(K4, ot), h10 = h10 + Math.imul(z6, ut) | 0, n10 = (n10 = n10 + Math.imul(z6, at2) | 0) + Math.imul(E5, ut) | 0, e13 = e13 + Math.imul(E5, at2) | 0, h10 = h10 + Math.imul(L5, mt) | 0, n10 = (n10 = n10 + Math.imul(L5, ft) | 0) + Math.imul(I5, mt) | 0, e13 = e13 + Math.imul(I5, ft) | 0; + var Nt = (a9 + (h10 = h10 + Math.imul(q4, pt) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(q4, Mt) | 0) + Math.imul(B5, pt) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(B5, Mt) | 0) + (n10 >>> 13) | 0) + (Nt >>> 26) | 0, Nt &= 67108863, h10 = Math.imul(j5, ut), n10 = (n10 = Math.imul(j5, at2)) + Math.imul(K4, ut) | 0, e13 = Math.imul(K4, at2), h10 = h10 + Math.imul(z6, mt) | 0, n10 = (n10 = n10 + Math.imul(z6, ft) | 0) + Math.imul(E5, mt) | 0, e13 = e13 + Math.imul(E5, ft) | 0; + var Lt = (a9 + (h10 = h10 + Math.imul(L5, pt) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(L5, Mt) | 0) + Math.imul(I5, pt) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(I5, Mt) | 0) + (n10 >>> 13) | 0) + (Lt >>> 26) | 0, Lt &= 67108863, h10 = Math.imul(j5, mt), n10 = (n10 = Math.imul(j5, ft)) + Math.imul(K4, mt) | 0, e13 = Math.imul(K4, ft); + var It = (a9 + (h10 = h10 + Math.imul(z6, pt) | 0) | 0) + ((8191 & (n10 = (n10 = n10 + Math.imul(z6, Mt) | 0) + Math.imul(E5, pt) | 0)) << 13) | 0; + a9 = ((e13 = e13 + Math.imul(E5, Mt) | 0) + (n10 >>> 13) | 0) + (It >>> 26) | 0, It &= 67108863; + var Tt = (a9 + (h10 = Math.imul(j5, pt)) | 0) + ((8191 & (n10 = (n10 = Math.imul(j5, Mt)) + Math.imul(K4, pt) | 0)) << 13) | 0; + return a9 = ((e13 = Math.imul(K4, Mt)) + (n10 >>> 13) | 0) + (Tt >>> 26) | 0, Tt &= 67108863, u9[0] = vt, u9[1] = gt, u9[2] = ct, u9[3] = wt, u9[4] = yt, u9[5] = bt, u9[6] = _t2, u9[7] = kt, u9[8] = At, u9[9] = xt, u9[10] = St, u9[11] = Zt, u9[12] = Rt, u9[13] = qt, u9[14] = Bt, u9[15] = Nt, u9[16] = Lt, u9[17] = It, u9[18] = Tt, 0 !== a9 && (u9[19] = a9, r11.length++), r11; + }; + function M5(t9, i8, r11) { + return new v7().mulp(t9, i8, r11); + } + function v7(t9, r11) { + (this || i$3).x = t9, (this || i$3).y = r11; + } + Math.imul || (p8 = d7), o9.prototype.mulTo = function(t9, r11) { + var h10 = (this || i$3).length + t9.length; + return 10 === (this || i$3).length && 10 === t9.length ? p8(this || i$3, t9, r11) : h10 < 63 ? d7(this || i$3, t9, r11) : h10 < 1024 ? function(t10, i8, r12) { + r12.negative = i8.negative ^ t10.negative, r12.length = t10.length + i8.length; + for (var h11 = 0, n10 = 0, e13 = 0; e13 < r12.length - 1; e13++) { + var o10 = n10; + n10 = 0; + for (var s8 = 67108863 & h11, u9 = Math.min(e13, i8.length - 1), a9 = Math.max(0, e13 - t10.length + 1); a9 <= u9; a9++) { + var l9 = e13 - a9, m8 = (0 | t10.words[l9]) * (0 | i8.words[a9]), f10 = 67108863 & m8; + s8 = 67108863 & (f10 = f10 + s8 | 0), n10 += (o10 = (o10 = o10 + (m8 / 67108864 | 0) | 0) + (f10 >>> 26) | 0) >>> 26, o10 &= 67108863; + } + r12.words[e13] = s8, h11 = o10, o10 = n10; + } + return 0 !== h11 ? r12.words[e13] = h11 : r12.length--, r12.strip(); + }(this || i$3, t9, r11) : M5(this || i$3, t9, r11); + }, v7.prototype.makeRBT = function(t9) { + for (var i8 = new Array(t9), r11 = o9.prototype._countBits(t9) - 1, h10 = 0; h10 < t9; h10++) + i8[h10] = this.revBin(h10, r11, t9); + return i8; + }, v7.prototype.revBin = function(t9, i8, r11) { + if (0 === t9 || t9 === r11 - 1) + return t9; + for (var h10 = 0, n10 = 0; n10 < i8; n10++) + h10 |= (1 & t9) << i8 - n10 - 1, t9 >>= 1; + return h10; + }, v7.prototype.permute = function(t9, i8, r11, h10, n10, e13) { + for (var o10 = 0; o10 < e13; o10++) + h10[o10] = i8[t9[o10]], n10[o10] = r11[t9[o10]]; + }, v7.prototype.transform = function(t9, i8, r11, h10, n10, e13) { + this.permute(e13, t9, i8, r11, h10, n10); + for (var o10 = 1; o10 < n10; o10 <<= 1) + for (var s8 = o10 << 1, u9 = Math.cos(2 * Math.PI / s8), a9 = Math.sin(2 * Math.PI / s8), l9 = 0; l9 < n10; l9 += s8) + for (var m8 = u9, f10 = a9, d8 = 0; d8 < o10; d8++) { + var p9 = r11[l9 + d8], M6 = h10[l9 + d8], v8 = r11[l9 + d8 + o10], g7 = h10[l9 + d8 + o10], c9 = m8 * v8 - f10 * g7; + g7 = m8 * g7 + f10 * v8, v8 = c9, r11[l9 + d8] = p9 + v8, h10[l9 + d8] = M6 + g7, r11[l9 + d8 + o10] = p9 - v8, h10[l9 + d8 + o10] = M6 - g7, d8 !== s8 && (c9 = u9 * m8 - a9 * f10, f10 = u9 * f10 + a9 * m8, m8 = c9); + } + }, v7.prototype.guessLen13b = function(t9, i8) { + var r11 = 1 | Math.max(i8, t9), h10 = 1 & r11, n10 = 0; + for (r11 = r11 / 2 | 0; r11; r11 >>>= 1) + n10++; + return 1 << n10 + 1 + h10; + }, v7.prototype.conjugate = function(t9, i8, r11) { + if (!(r11 <= 1)) + for (var h10 = 0; h10 < r11 / 2; h10++) { + var n10 = t9[h10]; + t9[h10] = t9[r11 - h10 - 1], t9[r11 - h10 - 1] = n10, n10 = i8[h10], i8[h10] = -i8[r11 - h10 - 1], i8[r11 - h10 - 1] = -n10; + } + }, v7.prototype.normalize13b = function(t9, i8) { + for (var r11 = 0, h10 = 0; h10 < i8 / 2; h10++) { + var n10 = 8192 * Math.round(t9[2 * h10 + 1] / i8) + Math.round(t9[2 * h10] / i8) + r11; + t9[h10] = 67108863 & n10, r11 = n10 < 67108864 ? 0 : n10 / 67108864 | 0; + } + return t9; + }, v7.prototype.convert13b = function(t9, i8, r11, h10) { + for (var e13 = 0, o10 = 0; o10 < i8; o10++) + e13 += 0 | t9[o10], r11[2 * o10] = 8191 & e13, e13 >>>= 13, r11[2 * o10 + 1] = 8191 & e13, e13 >>>= 13; + for (o10 = 2 * i8; o10 < h10; ++o10) + r11[o10] = 0; + n9(0 === e13), n9(0 == (-8192 & e13)); + }, v7.prototype.stub = function(t9) { + for (var i8 = new Array(t9), r11 = 0; r11 < t9; r11++) + i8[r11] = 0; + return i8; + }, v7.prototype.mulp = function(t9, i8, r11) { + var h10 = 2 * this.guessLen13b(t9.length, i8.length), n10 = this.makeRBT(h10), e13 = this.stub(h10), o10 = new Array(h10), s8 = new Array(h10), u9 = new Array(h10), a9 = new Array(h10), l9 = new Array(h10), m8 = new Array(h10), f10 = r11.words; + f10.length = h10, this.convert13b(t9.words, t9.length, o10, h10), this.convert13b(i8.words, i8.length, a9, h10), this.transform(o10, e13, s8, u9, h10, n10), this.transform(a9, e13, l9, m8, h10, n10); + for (var d8 = 0; d8 < h10; d8++) { + var p9 = s8[d8] * l9[d8] - u9[d8] * m8[d8]; + u9[d8] = s8[d8] * m8[d8] + u9[d8] * l9[d8], s8[d8] = p9; + } + return this.conjugate(s8, u9, h10), this.transform(s8, u9, f10, e13, h10, n10), this.conjugate(f10, e13, h10), this.normalize13b(f10, h10), r11.negative = t9.negative ^ i8.negative, r11.length = t9.length + i8.length, r11.strip(); + }, o9.prototype.mul = function(t9) { + var r11 = new o9(null); + return r11.words = new Array((this || i$3).length + t9.length), this.mulTo(t9, r11); + }, o9.prototype.mulf = function(t9) { + var r11 = new o9(null); + return r11.words = new Array((this || i$3).length + t9.length), M5(this || i$3, t9, r11); + }, o9.prototype.imul = function(t9) { + return this.clone().mulTo(t9, this || i$3); + }, o9.prototype.imuln = function(t9) { + n9("number" == typeof t9), n9(t9 < 67108864); + for (var r11 = 0, h10 = 0; h10 < (this || i$3).length; h10++) { + var e13 = (0 | (this || i$3).words[h10]) * t9, o10 = (67108863 & e13) + (67108863 & r11); + r11 >>= 26, r11 += e13 / 67108864 | 0, r11 += o10 >>> 26, (this || i$3).words[h10] = 67108863 & o10; + } + return 0 !== r11 && ((this || i$3).words[h10] = r11, (this || i$3).length++), this || i$3; + }, o9.prototype.muln = function(t9) { + return this.clone().imuln(t9); + }, o9.prototype.sqr = function() { + return this.mul(this || i$3); + }, o9.prototype.isqr = function() { + return this.imul(this.clone()); + }, o9.prototype.pow = function(t9) { + var r11 = function(t10) { + for (var i8 = new Array(t10.bitLength()), r12 = 0; r12 < i8.length; r12++) { + var h11 = r12 / 26 | 0, n11 = r12 % 26; + i8[r12] = (t10.words[h11] & 1 << n11) >>> n11; + } + return i8; + }(t9); + if (0 === r11.length) + return new o9(1); + for (var h10 = this || i$3, n10 = 0; n10 < r11.length && 0 === r11[n10]; n10++, h10 = h10.sqr()) + ; + if (++n10 < r11.length) + for (var e13 = h10.sqr(); n10 < r11.length; n10++, e13 = e13.sqr()) + 0 !== r11[n10] && (h10 = h10.mul(e13)); + return h10; + }, o9.prototype.iushln = function(t9) { + n9("number" == typeof t9 && t9 >= 0); + var r11, h10 = t9 % 26, e13 = (t9 - h10) / 26, o10 = 67108863 >>> 26 - h10 << 26 - h10; + if (0 !== h10) { + var s8 = 0; + for (r11 = 0; r11 < (this || i$3).length; r11++) { + var u9 = (this || i$3).words[r11] & o10, a9 = (0 | (this || i$3).words[r11]) - u9 << h10; + (this || i$3).words[r11] = a9 | s8, s8 = u9 >>> 26 - h10; + } + s8 && ((this || i$3).words[r11] = s8, (this || i$3).length++); + } + if (0 !== e13) { + for (r11 = (this || i$3).length - 1; r11 >= 0; r11--) + (this || i$3).words[r11 + e13] = (this || i$3).words[r11]; + for (r11 = 0; r11 < e13; r11++) + (this || i$3).words[r11] = 0; + (this || i$3).length += e13; + } + return this.strip(); + }, o9.prototype.ishln = function(t9) { + return n9(0 === (this || i$3).negative), this.iushln(t9); + }, o9.prototype.iushrn = function(t9, r11, h10) { + var e13; + n9("number" == typeof t9 && t9 >= 0), e13 = r11 ? (r11 - r11 % 26) / 26 : 0; + var o10 = t9 % 26, s8 = Math.min((t9 - o10) / 26, (this || i$3).length), u9 = 67108863 ^ 67108863 >>> o10 << o10, a9 = h10; + if (e13 -= s8, e13 = Math.max(0, e13), a9) { + for (var l9 = 0; l9 < s8; l9++) + a9.words[l9] = (this || i$3).words[l9]; + a9.length = s8; + } + if (0 === s8) + ; + else if ((this || i$3).length > s8) + for ((this || i$3).length -= s8, l9 = 0; l9 < (this || i$3).length; l9++) + (this || i$3).words[l9] = (this || i$3).words[l9 + s8]; + else + (this || i$3).words[0] = 0, (this || i$3).length = 1; + var m8 = 0; + for (l9 = (this || i$3).length - 1; l9 >= 0 && (0 !== m8 || l9 >= e13); l9--) { + var f10 = 0 | (this || i$3).words[l9]; + (this || i$3).words[l9] = m8 << 26 - o10 | f10 >>> o10, m8 = f10 & u9; + } + return a9 && 0 !== m8 && (a9.words[a9.length++] = m8), 0 === (this || i$3).length && ((this || i$3).words[0] = 0, (this || i$3).length = 1), this.strip(); + }, o9.prototype.ishrn = function(t9, r11, h10) { + return n9(0 === (this || i$3).negative), this.iushrn(t9, r11, h10); + }, o9.prototype.shln = function(t9) { + return this.clone().ishln(t9); + }, o9.prototype.ushln = function(t9) { + return this.clone().iushln(t9); + }, o9.prototype.shrn = function(t9) { + return this.clone().ishrn(t9); + }, o9.prototype.ushrn = function(t9) { + return this.clone().iushrn(t9); + }, o9.prototype.testn = function(t9) { + n9("number" == typeof t9 && t9 >= 0); + var r11 = t9 % 26, h10 = (t9 - r11) / 26, e13 = 1 << r11; + return !((this || i$3).length <= h10) && !!((this || i$3).words[h10] & e13); + }, o9.prototype.imaskn = function(t9) { + n9("number" == typeof t9 && t9 >= 0); + var r11 = t9 % 26, h10 = (t9 - r11) / 26; + if (n9(0 === (this || i$3).negative, "imaskn works only with positive numbers"), (this || i$3).length <= h10) + return this || i$3; + if (0 !== r11 && h10++, (this || i$3).length = Math.min(h10, (this || i$3).length), 0 !== r11) { + var e13 = 67108863 ^ 67108863 >>> r11 << r11; + (this || i$3).words[(this || i$3).length - 1] &= e13; + } + return this.strip(); + }, o9.prototype.maskn = function(t9) { + return this.clone().imaskn(t9); + }, o9.prototype.iaddn = function(t9) { + return n9("number" == typeof t9), n9(t9 < 67108864), t9 < 0 ? this.isubn(-t9) : 0 !== (this || i$3).negative ? 1 === (this || i$3).length && (0 | (this || i$3).words[0]) < t9 ? ((this || i$3).words[0] = t9 - (0 | (this || i$3).words[0]), (this || i$3).negative = 0, this || i$3) : ((this || i$3).negative = 0, this.isubn(t9), (this || i$3).negative = 1, this || i$3) : this._iaddn(t9); + }, o9.prototype._iaddn = function(t9) { + (this || i$3).words[0] += t9; + for (var r11 = 0; r11 < (this || i$3).length && (this || i$3).words[r11] >= 67108864; r11++) + (this || i$3).words[r11] -= 67108864, r11 === (this || i$3).length - 1 ? (this || i$3).words[r11 + 1] = 1 : (this || i$3).words[r11 + 1]++; + return (this || i$3).length = Math.max((this || i$3).length, r11 + 1), this || i$3; + }, o9.prototype.isubn = function(t9) { + if (n9("number" == typeof t9), n9(t9 < 67108864), t9 < 0) + return this.iaddn(-t9); + if (0 !== (this || i$3).negative) + return (this || i$3).negative = 0, this.iaddn(t9), (this || i$3).negative = 1, this || i$3; + if ((this || i$3).words[0] -= t9, 1 === (this || i$3).length && (this || i$3).words[0] < 0) + (this || i$3).words[0] = -(this || i$3).words[0], (this || i$3).negative = 1; + else + for (var r11 = 0; r11 < (this || i$3).length && (this || i$3).words[r11] < 0; r11++) + (this || i$3).words[r11] += 67108864, (this || i$3).words[r11 + 1] -= 1; + return this.strip(); + }, o9.prototype.addn = function(t9) { + return this.clone().iaddn(t9); + }, o9.prototype.subn = function(t9) { + return this.clone().isubn(t9); + }, o9.prototype.iabs = function() { + return (this || i$3).negative = 0, this || i$3; + }, o9.prototype.abs = function() { + return this.clone().iabs(); + }, o9.prototype._ishlnsubmul = function(t9, r11, h10) { + var e13, o10, s8 = t9.length + h10; + this._expand(s8); + var u9 = 0; + for (e13 = 0; e13 < t9.length; e13++) { + o10 = (0 | (this || i$3).words[e13 + h10]) + u9; + var a9 = (0 | t9.words[e13]) * r11; + u9 = ((o10 -= 67108863 & a9) >> 26) - (a9 / 67108864 | 0), (this || i$3).words[e13 + h10] = 67108863 & o10; + } + for (; e13 < (this || i$3).length - h10; e13++) + u9 = (o10 = (0 | (this || i$3).words[e13 + h10]) + u9) >> 26, (this || i$3).words[e13 + h10] = 67108863 & o10; + if (0 === u9) + return this.strip(); + for (n9(-1 === u9), u9 = 0, e13 = 0; e13 < (this || i$3).length; e13++) + u9 = (o10 = -(0 | (this || i$3).words[e13]) + u9) >> 26, (this || i$3).words[e13] = 67108863 & o10; + return (this || i$3).negative = 1, this.strip(); + }, o9.prototype._wordDiv = function(t9, r11) { + var h10 = ((this || i$3).length, t9.length), n10 = this.clone(), e13 = t9, s8 = 0 | e13.words[e13.length - 1]; + 0 !== (h10 = 26 - this._countBits(s8)) && (e13 = e13.ushln(h10), n10.iushln(h10), s8 = 0 | e13.words[e13.length - 1]); + var u9, a9 = n10.length - e13.length; + if ("mod" !== r11) { + (u9 = new o9(null)).length = a9 + 1, u9.words = new Array(u9.length); + for (var l9 = 0; l9 < u9.length; l9++) + u9.words[l9] = 0; + } + var m8 = n10.clone()._ishlnsubmul(e13, 1, a9); + 0 === m8.negative && (n10 = m8, u9 && (u9.words[a9] = 1)); + for (var f10 = a9 - 1; f10 >= 0; f10--) { + var d8 = 67108864 * (0 | n10.words[e13.length + f10]) + (0 | n10.words[e13.length + f10 - 1]); + for (d8 = Math.min(d8 / s8 | 0, 67108863), n10._ishlnsubmul(e13, d8, f10); 0 !== n10.negative; ) + d8--, n10.negative = 0, n10._ishlnsubmul(e13, 1, f10), n10.isZero() || (n10.negative ^= 1); + u9 && (u9.words[f10] = d8); + } + return u9 && u9.strip(), n10.strip(), "div" !== r11 && 0 !== h10 && n10.iushrn(h10), { div: u9 || null, mod: n10 }; + }, o9.prototype.divmod = function(t9, r11, h10) { + return n9(!t9.isZero()), this.isZero() ? { div: new o9(0), mod: new o9(0) } : 0 !== (this || i$3).negative && 0 === t9.negative ? (u9 = this.neg().divmod(t9, r11), "mod" !== r11 && (e13 = u9.div.neg()), "div" !== r11 && (s8 = u9.mod.neg(), h10 && 0 !== s8.negative && s8.iadd(t9)), { div: e13, mod: s8 }) : 0 === (this || i$3).negative && 0 !== t9.negative ? (u9 = this.divmod(t9.neg(), r11), "mod" !== r11 && (e13 = u9.div.neg()), { div: e13, mod: u9.mod }) : 0 != ((this || i$3).negative & t9.negative) ? (u9 = this.neg().divmod(t9.neg(), r11), "div" !== r11 && (s8 = u9.mod.neg(), h10 && 0 !== s8.negative && s8.isub(t9)), { div: u9.div, mod: s8 }) : t9.length > (this || i$3).length || this.cmp(t9) < 0 ? { div: new o9(0), mod: this || i$3 } : 1 === t9.length ? "div" === r11 ? { div: this.divn(t9.words[0]), mod: null } : "mod" === r11 ? { div: null, mod: new o9(this.modn(t9.words[0])) } : { div: this.divn(t9.words[0]), mod: new o9(this.modn(t9.words[0])) } : this._wordDiv(t9, r11); + var e13, s8, u9; + }, o9.prototype.div = function(t9) { + return this.divmod(t9, "div", false).div; + }, o9.prototype.mod = function(t9) { + return this.divmod(t9, "mod", false).mod; + }, o9.prototype.umod = function(t9) { + return this.divmod(t9, "mod", true).mod; + }, o9.prototype.divRound = function(t9) { + var i8 = this.divmod(t9); + if (i8.mod.isZero()) + return i8.div; + var r11 = 0 !== i8.div.negative ? i8.mod.isub(t9) : i8.mod, h10 = t9.ushrn(1), n10 = t9.andln(1), e13 = r11.cmp(h10); + return e13 < 0 || 1 === n10 && 0 === e13 ? i8.div : 0 !== i8.div.negative ? i8.div.isubn(1) : i8.div.iaddn(1); + }, o9.prototype.modn = function(t9) { + n9(t9 <= 67108863); + for (var r11 = (1 << 26) % t9, h10 = 0, e13 = (this || i$3).length - 1; e13 >= 0; e13--) + h10 = (r11 * h10 + (0 | (this || i$3).words[e13])) % t9; + return h10; + }, o9.prototype.idivn = function(t9) { + n9(t9 <= 67108863); + for (var r11 = 0, h10 = (this || i$3).length - 1; h10 >= 0; h10--) { + var e13 = (0 | (this || i$3).words[h10]) + 67108864 * r11; + (this || i$3).words[h10] = e13 / t9 | 0, r11 = e13 % t9; + } + return this.strip(); + }, o9.prototype.divn = function(t9) { + return this.clone().idivn(t9); + }, o9.prototype.egcd = function(t9) { + n9(0 === t9.negative), n9(!t9.isZero()); + var r11 = this || i$3, h10 = t9.clone(); + r11 = 0 !== r11.negative ? r11.umod(t9) : r11.clone(); + for (var e13 = new o9(1), s8 = new o9(0), u9 = new o9(0), a9 = new o9(1), l9 = 0; r11.isEven() && h10.isEven(); ) + r11.iushrn(1), h10.iushrn(1), ++l9; + for (var m8 = h10.clone(), f10 = r11.clone(); !r11.isZero(); ) { + for (var d8 = 0, p9 = 1; 0 == (r11.words[0] & p9) && d8 < 26; ++d8, p9 <<= 1) + ; + if (d8 > 0) + for (r11.iushrn(d8); d8-- > 0; ) + (e13.isOdd() || s8.isOdd()) && (e13.iadd(m8), s8.isub(f10)), e13.iushrn(1), s8.iushrn(1); + for (var M6 = 0, v8 = 1; 0 == (h10.words[0] & v8) && M6 < 26; ++M6, v8 <<= 1) + ; + if (M6 > 0) + for (h10.iushrn(M6); M6-- > 0; ) + (u9.isOdd() || a9.isOdd()) && (u9.iadd(m8), a9.isub(f10)), u9.iushrn(1), a9.iushrn(1); + r11.cmp(h10) >= 0 ? (r11.isub(h10), e13.isub(u9), s8.isub(a9)) : (h10.isub(r11), u9.isub(e13), a9.isub(s8)); + } + return { a: u9, b: a9, gcd: h10.iushln(l9) }; + }, o9.prototype._invmp = function(t9) { + n9(0 === t9.negative), n9(!t9.isZero()); + var r11 = this || i$3, h10 = t9.clone(); + r11 = 0 !== r11.negative ? r11.umod(t9) : r11.clone(); + for (var e13, s8 = new o9(1), u9 = new o9(0), a9 = h10.clone(); r11.cmpn(1) > 0 && h10.cmpn(1) > 0; ) { + for (var l9 = 0, m8 = 1; 0 == (r11.words[0] & m8) && l9 < 26; ++l9, m8 <<= 1) + ; + if (l9 > 0) + for (r11.iushrn(l9); l9-- > 0; ) + s8.isOdd() && s8.iadd(a9), s8.iushrn(1); + for (var f10 = 0, d8 = 1; 0 == (h10.words[0] & d8) && f10 < 26; ++f10, d8 <<= 1) + ; + if (f10 > 0) + for (h10.iushrn(f10); f10-- > 0; ) + u9.isOdd() && u9.iadd(a9), u9.iushrn(1); + r11.cmp(h10) >= 0 ? (r11.isub(h10), s8.isub(u9)) : (h10.isub(r11), u9.isub(s8)); + } + return (e13 = 0 === r11.cmpn(1) ? s8 : u9).cmpn(0) < 0 && e13.iadd(t9), e13; + }, o9.prototype.gcd = function(t9) { + if (this.isZero()) + return t9.abs(); + if (t9.isZero()) + return this.abs(); + var i8 = this.clone(), r11 = t9.clone(); + i8.negative = 0, r11.negative = 0; + for (var h10 = 0; i8.isEven() && r11.isEven(); h10++) + i8.iushrn(1), r11.iushrn(1); + for (; ; ) { + for (; i8.isEven(); ) + i8.iushrn(1); + for (; r11.isEven(); ) + r11.iushrn(1); + var n10 = i8.cmp(r11); + if (n10 < 0) { + var e13 = i8; + i8 = r11, r11 = e13; + } else if (0 === n10 || 0 === r11.cmpn(1)) + break; + i8.isub(r11); + } + return r11.iushln(h10); + }, o9.prototype.invm = function(t9) { + return this.egcd(t9).a.umod(t9); + }, o9.prototype.isEven = function() { + return 0 == (1 & (this || i$3).words[0]); + }, o9.prototype.isOdd = function() { + return 1 == (1 & (this || i$3).words[0]); + }, o9.prototype.andln = function(t9) { + return (this || i$3).words[0] & t9; + }, o9.prototype.bincn = function(t9) { + n9("number" == typeof t9); + var r11 = t9 % 26, h10 = (t9 - r11) / 26, e13 = 1 << r11; + if ((this || i$3).length <= h10) + return this._expand(h10 + 1), (this || i$3).words[h10] |= e13, this || i$3; + for (var o10 = e13, s8 = h10; 0 !== o10 && s8 < (this || i$3).length; s8++) { + var u9 = 0 | (this || i$3).words[s8]; + o10 = (u9 += o10) >>> 26, u9 &= 67108863, (this || i$3).words[s8] = u9; + } + return 0 !== o10 && ((this || i$3).words[s8] = o10, (this || i$3).length++), this || i$3; + }, o9.prototype.isZero = function() { + return 1 === (this || i$3).length && 0 === (this || i$3).words[0]; + }, o9.prototype.cmpn = function(t9) { + var r11, h10 = t9 < 0; + if (0 !== (this || i$3).negative && !h10) + return -1; + if (0 === (this || i$3).negative && h10) + return 1; + if (this.strip(), (this || i$3).length > 1) + r11 = 1; + else { + h10 && (t9 = -t9), n9(t9 <= 67108863, "Number is too big"); + var e13 = 0 | (this || i$3).words[0]; + r11 = e13 === t9 ? 0 : e13 < t9 ? -1 : 1; + } + return 0 !== (this || i$3).negative ? 0 | -r11 : r11; + }, o9.prototype.cmp = function(t9) { + if (0 !== (this || i$3).negative && 0 === t9.negative) + return -1; + if (0 === (this || i$3).negative && 0 !== t9.negative) + return 1; + var r11 = this.ucmp(t9); + return 0 !== (this || i$3).negative ? 0 | -r11 : r11; + }, o9.prototype.ucmp = function(t9) { + if ((this || i$3).length > t9.length) + return 1; + if ((this || i$3).length < t9.length) + return -1; + for (var r11 = 0, h10 = (this || i$3).length - 1; h10 >= 0; h10--) { + var n10 = 0 | (this || i$3).words[h10], e13 = 0 | t9.words[h10]; + if (n10 !== e13) { + n10 < e13 ? r11 = -1 : n10 > e13 && (r11 = 1); + break; + } + } + return r11; + }, o9.prototype.gtn = function(t9) { + return 1 === this.cmpn(t9); + }, o9.prototype.gt = function(t9) { + return 1 === this.cmp(t9); + }, o9.prototype.gten = function(t9) { + return this.cmpn(t9) >= 0; + }, o9.prototype.gte = function(t9) { + return this.cmp(t9) >= 0; + }, o9.prototype.ltn = function(t9) { + return -1 === this.cmpn(t9); + }, o9.prototype.lt = function(t9) { + return -1 === this.cmp(t9); + }, o9.prototype.lten = function(t9) { + return this.cmpn(t9) <= 0; + }, o9.prototype.lte = function(t9) { + return this.cmp(t9) <= 0; + }, o9.prototype.eqn = function(t9) { + return 0 === this.cmpn(t9); + }, o9.prototype.eq = function(t9) { + return 0 === this.cmp(t9); + }, o9.red = function(t9) { + return new k5(t9); + }, o9.prototype.toRed = function(t9) { + return n9(!(this || i$3).red, "Already a number in reduction context"), n9(0 === (this || i$3).negative, "red works only with positives"), t9.convertTo(this || i$3)._forceRed(t9); + }, o9.prototype.fromRed = function() { + return n9((this || i$3).red, "fromRed works only with numbers in reduction context"), (this || i$3).red.convertFrom(this || i$3); + }, o9.prototype._forceRed = function(t9) { + return (this || i$3).red = t9, this || i$3; + }, o9.prototype.forceRed = function(t9) { + return n9(!(this || i$3).red, "Already a number in reduction context"), this._forceRed(t9); + }, o9.prototype.redAdd = function(t9) { + return n9((this || i$3).red, "redAdd works only with red numbers"), (this || i$3).red.add(this || i$3, t9); + }, o9.prototype.redIAdd = function(t9) { + return n9((this || i$3).red, "redIAdd works only with red numbers"), (this || i$3).red.iadd(this || i$3, t9); + }, o9.prototype.redSub = function(t9) { + return n9((this || i$3).red, "redSub works only with red numbers"), (this || i$3).red.sub(this || i$3, t9); + }, o9.prototype.redISub = function(t9) { + return n9((this || i$3).red, "redISub works only with red numbers"), (this || i$3).red.isub(this || i$3, t9); + }, o9.prototype.redShl = function(t9) { + return n9((this || i$3).red, "redShl works only with red numbers"), (this || i$3).red.shl(this || i$3, t9); + }, o9.prototype.redMul = function(t9) { + return n9((this || i$3).red, "redMul works only with red numbers"), (this || i$3).red._verify2(this || i$3, t9), (this || i$3).red.mul(this || i$3, t9); + }, o9.prototype.redIMul = function(t9) { + return n9((this || i$3).red, "redMul works only with red numbers"), (this || i$3).red._verify2(this || i$3, t9), (this || i$3).red.imul(this || i$3, t9); + }, o9.prototype.redSqr = function() { + return n9((this || i$3).red, "redSqr works only with red numbers"), (this || i$3).red._verify1(this || i$3), (this || i$3).red.sqr(this || i$3); + }, o9.prototype.redISqr = function() { + return n9((this || i$3).red, "redISqr works only with red numbers"), (this || i$3).red._verify1(this || i$3), (this || i$3).red.isqr(this || i$3); + }, o9.prototype.redSqrt = function() { + return n9((this || i$3).red, "redSqrt works only with red numbers"), (this || i$3).red._verify1(this || i$3), (this || i$3).red.sqrt(this || i$3); + }, o9.prototype.redInvm = function() { + return n9((this || i$3).red, "redInvm works only with red numbers"), (this || i$3).red._verify1(this || i$3), (this || i$3).red.invm(this || i$3); + }, o9.prototype.redNeg = function() { + return n9((this || i$3).red, "redNeg works only with red numbers"), (this || i$3).red._verify1(this || i$3), (this || i$3).red.neg(this || i$3); + }, o9.prototype.redPow = function(t9) { + return n9((this || i$3).red && !t9.red, "redPow(normalNum)"), (this || i$3).red._verify1(this || i$3), (this || i$3).red.pow(this || i$3, t9); + }; + var g6 = { k256: null, p224: null, p192: null, p25519: null }; + function c8(t9, r11) { + (this || i$3).name = t9, (this || i$3).p = new o9(r11, 16), (this || i$3).n = (this || i$3).p.bitLength(), (this || i$3).k = new o9(1).iushln((this || i$3).n).isub((this || i$3).p), (this || i$3).tmp = this._tmp(); + } + function w5() { + c8.call(this || i$3, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + function y7() { + c8.call(this || i$3, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + function b6() { + c8.call(this || i$3, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + function _5() { + c8.call(this || i$3, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + function k5(t9) { + if ("string" == typeof t9) { + var r11 = o9._prime(t9); + (this || i$3).m = r11.p, (this || i$3).prime = r11; + } else + n9(t9.gtn(1), "modulus must be greater than 1"), (this || i$3).m = t9, (this || i$3).prime = null; + } + function A5(t9) { + k5.call(this || i$3, t9), (this || i$3).shift = (this || i$3).m.bitLength(), (this || i$3).shift % 26 != 0 && ((this || i$3).shift += 26 - (this || i$3).shift % 26), (this || i$3).r = new o9(1).iushln((this || i$3).shift), (this || i$3).r2 = this.imod((this || i$3).r.sqr()), (this || i$3).rinv = (this || i$3).r._invmp((this || i$3).m), (this || i$3).minv = (this || i$3).rinv.mul((this || i$3).r).isubn(1).div((this || i$3).m), (this || i$3).minv = (this || i$3).minv.umod((this || i$3).r), (this || i$3).minv = (this || i$3).r.sub((this || i$3).minv); + } + c8.prototype._tmp = function() { + var t9 = new o9(null); + return t9.words = new Array(Math.ceil((this || i$3).n / 13)), t9; + }, c8.prototype.ireduce = function(t9) { + var r11, h10 = t9; + do { + this.split(h10, (this || i$3).tmp), r11 = (h10 = (h10 = this.imulK(h10)).iadd((this || i$3).tmp)).bitLength(); + } while (r11 > (this || i$3).n); + var n10 = r11 < (this || i$3).n ? -1 : h10.ucmp((this || i$3).p); + return 0 === n10 ? (h10.words[0] = 0, h10.length = 1) : n10 > 0 ? h10.isub((this || i$3).p) : h10.strip(), h10; + }, c8.prototype.split = function(t9, r11) { + t9.iushrn((this || i$3).n, 0, r11); + }, c8.prototype.imulK = function(t9) { + return t9.imul((this || i$3).k); + }, e12(w5, c8), w5.prototype.split = function(t9, i8) { + for (var r11 = Math.min(t9.length, 9), h10 = 0; h10 < r11; h10++) + i8.words[h10] = t9.words[h10]; + if (i8.length = r11, t9.length <= 9) + return t9.words[0] = 0, t9.length = 1, void 0; + var n10 = t9.words[9]; + for (i8.words[i8.length++] = 4194303 & n10, h10 = 10; h10 < t9.length; h10++) { + var e13 = 0 | t9.words[h10]; + t9.words[h10 - 10] = (4194303 & e13) << 4 | n10 >>> 22, n10 = e13; + } + n10 >>>= 22, t9.words[h10 - 10] = n10, 0 === n10 && t9.length > 10 ? t9.length -= 10 : t9.length -= 9; + }, w5.prototype.imulK = function(t9) { + t9.words[t9.length] = 0, t9.words[t9.length + 1] = 0, t9.length += 2; + for (var i8 = 0, r11 = 0; r11 < t9.length; r11++) { + var h10 = 0 | t9.words[r11]; + i8 += 977 * h10, t9.words[r11] = 67108863 & i8, i8 = 64 * h10 + (i8 / 67108864 | 0); + } + return 0 === t9.words[t9.length - 1] && (t9.length--, 0 === t9.words[t9.length - 1] && t9.length--), t9; + }, e12(y7, c8), e12(b6, c8), e12(_5, c8), _5.prototype.imulK = function(t9) { + for (var i8 = 0, r11 = 0; r11 < t9.length; r11++) { + var h10 = 19 * (0 | t9.words[r11]) + i8, n10 = 67108863 & h10; + h10 >>>= 26, t9.words[r11] = n10, i8 = h10; + } + return 0 !== i8 && (t9.words[t9.length++] = i8), t9; + }, o9._prime = function(t9) { + if (g6[t9]) + return g6[t9]; + var i8; + if ("k256" === t9) + i8 = new w5(); + else if ("p224" === t9) + i8 = new y7(); + else if ("p192" === t9) + i8 = new b6(); + else { + if ("p25519" !== t9) + throw new Error("Unknown prime " + t9); + i8 = new _5(); + } + return g6[t9] = i8, i8; + }, k5.prototype._verify1 = function(t9) { + n9(0 === t9.negative, "red works only with positives"), n9(t9.red, "red works only with red numbers"); + }, k5.prototype._verify2 = function(t9, i8) { + n9(0 == (t9.negative | i8.negative), "red works only with positives"), n9(t9.red && t9.red === i8.red, "red works only with red numbers"); + }, k5.prototype.imod = function(t9) { + return (this || i$3).prime ? (this || i$3).prime.ireduce(t9)._forceRed(this || i$3) : t9.umod((this || i$3).m)._forceRed(this || i$3); + }, k5.prototype.neg = function(t9) { + return t9.isZero() ? t9.clone() : (this || i$3).m.sub(t9)._forceRed(this || i$3); + }, k5.prototype.add = function(t9, r11) { + this._verify2(t9, r11); + var h10 = t9.add(r11); + return h10.cmp((this || i$3).m) >= 0 && h10.isub((this || i$3).m), h10._forceRed(this || i$3); + }, k5.prototype.iadd = function(t9, r11) { + this._verify2(t9, r11); + var h10 = t9.iadd(r11); + return h10.cmp((this || i$3).m) >= 0 && h10.isub((this || i$3).m), h10; + }, k5.prototype.sub = function(t9, r11) { + this._verify2(t9, r11); + var h10 = t9.sub(r11); + return h10.cmpn(0) < 0 && h10.iadd((this || i$3).m), h10._forceRed(this || i$3); + }, k5.prototype.isub = function(t9, r11) { + this._verify2(t9, r11); + var h10 = t9.isub(r11); + return h10.cmpn(0) < 0 && h10.iadd((this || i$3).m), h10; + }, k5.prototype.shl = function(t9, i8) { + return this._verify1(t9), this.imod(t9.ushln(i8)); + }, k5.prototype.imul = function(t9, i8) { + return this._verify2(t9, i8), this.imod(t9.imul(i8)); + }, k5.prototype.mul = function(t9, i8) { + return this._verify2(t9, i8), this.imod(t9.mul(i8)); + }, k5.prototype.isqr = function(t9) { + return this.imul(t9, t9.clone()); + }, k5.prototype.sqr = function(t9) { + return this.mul(t9, t9); + }, k5.prototype.sqrt = function(t9) { + if (t9.isZero()) + return t9.clone(); + var r11 = (this || i$3).m.andln(3); + if (n9(r11 % 2 == 1), 3 === r11) { + var h10 = (this || i$3).m.add(new o9(1)).iushrn(2); + return this.pow(t9, h10); + } + for (var e13 = (this || i$3).m.subn(1), s8 = 0; !e13.isZero() && 0 === e13.andln(1); ) + s8++, e13.iushrn(1); + n9(!e13.isZero()); + var u9 = new o9(1).toRed(this || i$3), a9 = u9.redNeg(), l9 = (this || i$3).m.subn(1).iushrn(1), m8 = (this || i$3).m.bitLength(); + for (m8 = new o9(2 * m8 * m8).toRed(this || i$3); 0 !== this.pow(m8, l9).cmp(a9); ) + m8.redIAdd(a9); + for (var f10 = this.pow(m8, e13), d8 = this.pow(t9, e13.addn(1).iushrn(1)), p9 = this.pow(t9, e13), M6 = s8; 0 !== p9.cmp(u9); ) { + for (var v8 = p9, g7 = 0; 0 !== v8.cmp(u9); g7++) + v8 = v8.redSqr(); + n9(g7 < M6); + var c9 = this.pow(f10, new o9(1).iushln(M6 - g7 - 1)); + d8 = d8.redMul(c9), f10 = c9.redSqr(), p9 = p9.redMul(f10), M6 = g7; + } + return d8; + }, k5.prototype.invm = function(t9) { + var r11 = t9._invmp((this || i$3).m); + return 0 !== r11.negative ? (r11.negative = 0, this.imod(r11).redNeg()) : this.imod(r11); + }, k5.prototype.pow = function(t9, r11) { + if (r11.isZero()) + return new o9(1).toRed(this || i$3); + if (0 === r11.cmpn(1)) + return t9.clone(); + var h10 = new Array(16); + h10[0] = new o9(1).toRed(this || i$3), h10[1] = t9; + for (var n10 = 2; n10 < h10.length; n10++) + h10[n10] = this.mul(h10[n10 - 1], t9); + var e13 = h10[0], s8 = 0, u9 = 0, a9 = r11.bitLength() % 26; + for (0 === a9 && (a9 = 26), n10 = r11.length - 1; n10 >= 0; n10--) { + for (var l9 = r11.words[n10], m8 = a9 - 1; m8 >= 0; m8--) { + var f10 = l9 >> m8 & 1; + e13 !== h10[0] && (e13 = this.sqr(e13)), 0 !== f10 || 0 !== s8 ? (s8 <<= 1, s8 |= f10, (4 === ++u9 || 0 === n10 && 0 === m8) && (e13 = this.mul(e13, h10[s8]), u9 = 0, s8 = 0)) : u9 = 0; + } + a9 = 26; + } + return e13; + }, k5.prototype.convertTo = function(t9) { + var r11 = t9.umod((this || i$3).m); + return r11 === t9 ? r11.clone() : r11; + }, k5.prototype.convertFrom = function(t9) { + var i8 = t9.clone(); + return i8.red = null, i8; + }, o9.mont = function(t9) { + return new A5(t9); + }, e12(A5, k5), A5.prototype.convertTo = function(t9) { + return this.imod(t9.ushln((this || i$3).shift)); + }, A5.prototype.convertFrom = function(t9) { + var r11 = this.imod(t9.mul((this || i$3).rinv)); + return r11.red = null, r11; + }, A5.prototype.imul = function(t9, r11) { + if (t9.isZero() || r11.isZero()) + return t9.words[0] = 0, t9.length = 1, t9; + var h10 = t9.imul(r11), n10 = h10.maskn((this || i$3).shift).mul((this || i$3).minv).imaskn((this || i$3).shift).mul((this || i$3).m), e13 = h10.isub(n10).iushrn((this || i$3).shift), o10 = e13; + return e13.cmp((this || i$3).m) >= 0 ? o10 = e13.isub((this || i$3).m) : e13.cmpn(0) < 0 && (o10 = e13.iadd((this || i$3).m)), o10._forceRed(this || i$3); + }, A5.prototype.mul = function(t9, r11) { + if (t9.isZero() || r11.isZero()) + return new o9(0)._forceRed(this || i$3); + var h10 = t9.mul(r11), n10 = h10.maskn((this || i$3).shift).mul((this || i$3).minv).imaskn((this || i$3).shift).mul((this || i$3).m), e13 = h10.isub(n10).iushrn((this || i$3).shift), s8 = e13; + return e13.cmp((this || i$3).m) >= 0 ? s8 = e13.isub((this || i$3).m) : e13.cmpn(0) < 0 && (s8 = e13.iadd((this || i$3).m)), s8._forceRed(this || i$3); + }, A5.prototype.invm = function(t9) { + return this.imod(t9._invmp((this || i$3).m).mul((this || i$3).r2))._forceRed(this || i$3); + }; + }(h$a, r$7); + var n$c = h$a.exports; + var t$5; + var e$a; + var r$8 = Object.freeze({}); + var n$d = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + function o$d(t9) { + (this || n$d).rand = t9; + } + if ((t$5 = function(t9) { + return e$a || (e$a = new o$d(null)), e$a.generate(t9); + }).Rand = o$d, o$d.prototype.generate = function(t9) { + return this._rand(t9); + }, o$d.prototype._rand = function(t9) { + if ((this || n$d).rand.getBytes) + return (this || n$d).rand.getBytes(t9); + for (var e12 = new Uint8Array(t9), r10 = 0; r10 < e12.length; r10++) + e12[r10] = (this || n$d).rand.getByte(); + return e12; + }, "object" == typeof self) + self.crypto && self.crypto.getRandomValues ? o$d.prototype._rand = function(t9) { + var e12 = new Uint8Array(t9); + return self.crypto.getRandomValues(e12), e12; + } : self.msCrypto && self.msCrypto.getRandomValues ? o$d.prototype._rand = function(t9) { + var e12 = new Uint8Array(t9); + return self.msCrypto.getRandomValues(e12), e12; + } : "object" == typeof window && (o$d.prototype._rand = function() { + throw new Error("Not implemented yet"); + }); + else + try { + a$e = r$8; + if ("function" != typeof a$e.randomBytes) + throw new Error("Not supported"); + o$d.prototype._rand = function(t9) { + return a$e.randomBytes(t9); + }; + } catch (t9) { + } + var a$e; + var f$i = t$5; + var n$e; + var t$6 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var o$e = n$c; + var a$f = f$i; + function d$b(r10) { + (this || t$6).rand = r10 || new a$f.Rand(); + } + n$e = d$b, d$b.create = function(r10) { + return new d$b(r10); + }, d$b.prototype._randbelow = function(r10) { + var e12 = r10.bitLength(), n9 = Math.ceil(e12 / 8); + do { + var a8 = new o$e((this || t$6).rand.generate(n9)); + } while (a8.cmp(r10) >= 0); + return a8; + }, d$b.prototype._randrange = function(r10, e12) { + var n9 = e12.sub(r10); + return r10.add(this._randbelow(n9)); + }, d$b.prototype.test = function(r10, e12, n9) { + var t9 = r10.bitLength(), a8 = o$e.mont(r10), d7 = new o$e(1).toRed(a8); + e12 || (e12 = Math.max(1, t9 / 48 | 0)); + for (var i8 = r10.subn(1), f9 = 0; !i8.testn(f9); f9++) + ; + for (var u8 = r10.shrn(f9), p8 = i8.toRed(a8); e12 > 0; e12--) { + var c8 = this._randrange(new o$e(2), i8); + n9 && n9(c8); + var s7 = c8.toRed(a8).redPow(u8); + if (0 !== s7.cmp(d7) && 0 !== s7.cmp(p8)) { + for (var m7 = 1; m7 < f9; m7++) { + if (0 === (s7 = s7.redSqr()).cmp(d7)) + return false; + if (0 === s7.cmp(p8)) + break; + } + if (m7 === f9) + return false; + } + } + return true; + }, d$b.prototype.getDivisor = function(r10, e12) { + var n9 = r10.bitLength(), t9 = o$e.mont(r10), a8 = new o$e(1).toRed(t9); + e12 || (e12 = Math.max(1, n9 / 48 | 0)); + for (var d7 = r10.subn(1), i8 = 0; !d7.testn(i8); i8++) + ; + for (var f9 = r10.shrn(i8), u8 = d7.toRed(t9); e12 > 0; e12--) { + var p8 = this._randrange(new o$e(2), d7), c8 = r10.gcd(p8); + if (0 !== c8.cmpn(1)) + return c8; + var s7 = p8.toRed(t9).redPow(f9); + if (0 !== s7.cmp(a8) && 0 !== s7.cmp(u8)) { + for (var m7 = 1; m7 < i8; m7++) { + if (0 === (s7 = s7.redSqr()).cmp(a8)) + return s7.fromRed().subn(1).gcd(r10); + if (0 === s7.cmp(u8)) + break; + } + if (m7 === i8) + return (s7 = s7.redSqr()).fromRed().subn(1).gcd(r10); + } + } + return false; + }; + var i$4 = n$e; + var b$7; + var d$c = a5; + b$7 = v$9, v$9.simpleSieve = _$9, v$9.fermatTest = g$8; + var r$9 = n$c; + var t$7 = new r$9(24); + var n$f = new i$4(); + var i$5 = new r$9(1); + var o$f = new r$9(2); + var p$e = new r$9(5); + var s$c = (new r$9(16), new r$9(8), new r$9(10)); + var m$9 = new r$9(3); + var u$b = (new r$9(7), new r$9(11)); + var h$b = new r$9(4); + var w$a = (new r$9(12), null); + function l$c() { + if (null !== w$a) + return w$a; + var f9 = []; + f9[0] = 2; + for (var e12 = 1, c8 = 3; c8 < 1048576; c8 += 2) { + for (var a8 = Math.ceil(Math.sqrt(c8)), b6 = 0; b6 < e12 && f9[b6] <= a8 && c8 % f9[b6] != 0; b6++) + ; + e12 !== b6 && f9[b6] <= a8 || (f9[e12++] = c8); + } + return w$a = f9, f9; + } + function _$9(f9) { + for (var e12 = l$c(), c8 = 0; c8 < e12.length; c8++) + if (0 === f9.modn(e12[c8])) + return 0 === f9.cmpn(e12[c8]); + return true; + } + function g$8(f9) { + var e12 = r$9.mont(f9); + return 0 === o$f.toRed(e12).redPow(f9.subn(1)).fromRed().cmpn(1); + } + function v$9(f9, e12) { + if (f9 < 16) + return new r$9(2 === e12 || 5 === e12 ? [140, 123] : [140, 39]); + var c8, a8; + for (e12 = new r$9(e12); ; ) { + for (c8 = new r$9(d$c(Math.ceil(f9 / 8))); c8.bitLength() > f9; ) + c8.ishrn(1); + if (c8.isEven() && c8.iadd(i$5), c8.testn(1) || c8.iadd(o$f), e12.cmp(o$f)) { + if (!e12.cmp(p$e)) + for (; c8.mod(s$c).cmp(m$9); ) + c8.iadd(h$b); + } else + for (; c8.mod(t$7).cmp(u$b); ) + c8.iadd(h$b); + if (_$9(a8 = c8.shrn(1)) && _$9(c8) && g$8(a8) && g$8(c8) && n$f.test(a8) && n$f.test(c8)) + return c8; + } + } + var y$9; + var P$2 = b$7; + var B$5 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var K$2 = e$1$1.Buffer; + var R$1 = n$c; + var S$5 = new i$4(); + var x$2 = new R$1(24); + var C$2 = new R$1(11); + var D$2 = new R$1(10); + var G$1 = new R$1(3); + var H$2 = new R$1(7); + var T$3 = P$2; + var j$1 = a5; + function E$6(f9, e12) { + return e12 = e12 || "utf8", K$2.isBuffer(f9) || (f9 = new K$2(f9, e12)), (this || B$5)._pub = new R$1(f9), this || B$5; + } + function L$1(f9, e12) { + return e12 = e12 || "utf8", K$2.isBuffer(f9) || (f9 = new K$2(f9, e12)), (this || B$5)._priv = new R$1(f9), this || B$5; + } + y$9 = k$7; + var M$4 = {}; + function k$7(f9, e12, c8) { + this.setGenerator(e12), (this || B$5).__prime = new R$1(f9), (this || B$5)._prime = R$1.mont((this || B$5).__prime), (this || B$5)._primeLen = f9.length, (this || B$5)._pub = void 0, (this || B$5)._priv = void 0, (this || B$5)._primeCode = void 0, c8 ? ((this || B$5).setPublicKey = E$6, (this || B$5).setPrivateKey = L$1) : (this || B$5)._primeCode = 8; + } + function A$5(f9, e12) { + var c8 = new K$2(f9.toArray()); + return e12 ? c8.toString(e12) : c8; + } + Object.defineProperty(k$7.prototype, "verifyError", { enumerable: true, get: function() { + return "number" != typeof (this || B$5)._primeCode && ((this || B$5)._primeCode = function(f9, e12) { + var c8 = e12.toString("hex"), a8 = [c8, f9.toString(16)].join("_"); + if (a8 in M$4) + return M$4[a8]; + var b6, d7 = 0; + if (f9.isEven() || !T$3.simpleSieve || !T$3.fermatTest(f9) || !S$5.test(f9)) + return d7 += 1, d7 += "02" === c8 || "05" === c8 ? 8 : 4, M$4[a8] = d7, d7; + switch (S$5.test(f9.shrn(1)) || (d7 += 2), c8) { + case "02": + f9.mod(x$2).cmp(C$2) && (d7 += 8); + break; + case "05": + (b6 = f9.mod(D$2)).cmp(G$1) && b6.cmp(H$2) && (d7 += 8); + break; + default: + d7 += 4; + } + return M$4[a8] = d7, d7; + }((this || B$5).__prime, (this || B$5).__gen)), (this || B$5)._primeCode; + } }), k$7.prototype.generateKeys = function() { + return (this || B$5)._priv || ((this || B$5)._priv = new R$1(j$1((this || B$5)._primeLen))), (this || B$5)._pub = (this || B$5)._gen.toRed((this || B$5)._prime).redPow((this || B$5)._priv).fromRed(), this.getPublicKey(); + }, k$7.prototype.computeSecret = function(f9) { + var e12 = (f9 = (f9 = new R$1(f9)).toRed((this || B$5)._prime)).redPow((this || B$5)._priv).fromRed(), c8 = new K$2(e12.toArray()), a8 = this.getPrime(); + if (c8.length < a8.length) { + var b6 = new K$2(a8.length - c8.length); + b6.fill(0), c8 = K$2.concat([b6, c8]); + } + return c8; + }, k$7.prototype.getPublicKey = function(f9) { + return A$5((this || B$5)._pub, f9); + }, k$7.prototype.getPrivateKey = function(f9) { + return A$5((this || B$5)._priv, f9); + }, k$7.prototype.getPrime = function(f9) { + return A$5((this || B$5).__prime, f9); + }, k$7.prototype.getGenerator = function(f9) { + return A$5((this || B$5)._gen, f9); + }, k$7.prototype.setGenerator = function(f9, e12) { + return e12 = e12 || "utf8", K$2.isBuffer(f9) || (f9 = new K$2(f9, e12)), (this || B$5).__gen = f9, (this || B$5)._gen = new R$1(f9), this || B$5; + }; + var q$1 = y$9; + var O$3 = {}; + var z$3 = e$1$1.Buffer; + var F$3 = P$2; + var I$6 = { modp1: { gen: "02", prime: "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" }, modp2: { gen: "02", prime: "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" }, modp5: { gen: "02", prime: "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" }, modp14: { gen: "02", prime: "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" }, modp15: { gen: "02", prime: "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" }, modp16: { gen: "02", prime: "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" }, modp17: { gen: "02", prime: "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" }, modp18: { gen: "02", prime: "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" } }; + var J$1 = q$1; + var N$2 = { binary: true, hex: true, base64: true }; + O$3.DiffieHellmanGroup = O$3.createDiffieHellmanGroup = O$3.getDiffieHellman = function(f9) { + var e12 = new z$3(I$6[f9].prime, "hex"), c8 = new z$3(I$6[f9].gen, "hex"); + return new J$1(e12, c8); + }, O$3.createDiffieHellman = O$3.DiffieHellman = function f6(e12, c8, a8, b6) { + return z$3.isBuffer(c8) || void 0 === N$2[c8] ? f6(e12, "binary", c8, a8) : (c8 = c8 || "binary", b6 = b6 || "binary", a8 = a8 || new z$3([2]), z$3.isBuffer(a8) || (a8 = new z$3(a8, b6)), "number" == typeof e12 ? new J$1(F$3(e12, a8), a8, true) : (z$3.isBuffer(e12) || (e12 = new z$3(e12, c8)), new J$1(e12, a8, true))); + }; + var m$a; + var u$c = e$1$1.Buffer; + var n$g = n$c; + var d$d = a5; + function t$8(e12, o9) { + var r10 = function(e13) { + var o10 = i$6(e13); + return { blinder: o10.toRed(n$g.mont(e13.modulus)).redPow(new n$g(e13.publicExponent)).fromRed(), unblinder: o10.invm(e13.modulus) }; + }(o9), m7 = o9.modulus.byteLength(), d7 = (n$g.mont(o9.modulus), new n$g(e12).mul(r10.blinder).umod(o9.modulus)), t9 = d7.toRed(n$g.mont(o9.prime1)), l8 = d7.toRed(n$g.mont(o9.prime2)), f9 = o9.coefficient, p8 = o9.prime1, b6 = o9.prime2, s7 = t9.redPow(o9.exponent1), a8 = l8.redPow(o9.exponent2); + s7 = s7.fromRed(), a8 = a8.fromRed(); + var w5 = s7.isub(a8).imul(f9).umod(p8); + return w5.imul(b6), a8.iadd(w5), new u$c(a8.imul(r10.unblinder).umod(o9.modulus).toArray(false, m7)); + } + function i$6(e12) { + for (var o9 = e12.modulus.byteLength(), r10 = new n$g(d$d(o9)); r10.cmp(e12.modulus) >= 0 || !r10.umod(e12.prime1) || !r10.umod(e12.prime2); ) + r10 = new n$g(d$d(o9)); + return r10; + } + m$a = t$8, t$8.getr = i$6; + var l$d = m$a; + var r$a = {}; + var e$b = r$a; + function t$9(r10) { + return 1 === r10.length ? "0" + r10 : r10; + } + function n$h(r10) { + for (var e12 = "", n9 = 0; n9 < r10.length; n9++) + e12 += t$9(r10[n9].toString(16)); + return e12; + } + e$b.toArray = function(r10, e12) { + if (Array.isArray(r10)) + return r10.slice(); + if (!r10) + return []; + var t9 = []; + if ("string" != typeof r10) { + for (var n9 = 0; n9 < r10.length; n9++) + t9[n9] = 0 | r10[n9]; + return t9; + } + if ("hex" === e12) { + (r10 = r10.replace(/[^a-z0-9]+/gi, "")).length % 2 != 0 && (r10 = "0" + r10); + for (n9 = 0; n9 < r10.length; n9 += 2) + t9.push(parseInt(r10[n9] + r10[n9 + 1], 16)); + } else + for (n9 = 0; n9 < r10.length; n9++) { + var o9 = r10.charCodeAt(n9), u8 = o9 >> 8, f9 = 255 & o9; + u8 ? t9.push(u8, f9) : t9.push(f9); + } + return t9; + }, e$b.zero2 = t$9, e$b.toHex = n$h, e$b.encode = function(r10, e12) { + return "hex" === e12 ? n$h(r10) : r10; + }; + var n$i = {}; + var a$g = n$i; + var i$7 = n$c; + var o$g = o$7; + var c$d = r$a; + a$g.assert = o$g, a$g.toArray = c$d.toArray, a$g.zero2 = c$d.zero2, a$g.toHex = c$d.toHex, a$g.encode = c$d.encode, a$g.getNAF = function(r10, t9, e12) { + var n9 = new Array(Math.max(r10.bitLength(), e12) + 1); + n9.fill(0); + for (var a8 = 1 << t9 + 1, i8 = r10.clone(), o9 = 0; o9 < n9.length; o9++) { + var c8, s7 = i8.andln(a8 - 1); + i8.isOdd() ? (c8 = s7 > (a8 >> 1) - 1 ? (a8 >> 1) - s7 : s7, i8.isubn(c8)) : c8 = 0, n9[o9] = c8, i8.iushrn(1); + } + return n9; + }, a$g.getJSF = function(r10, t9) { + var e12 = [[], []]; + r10 = r10.clone(), t9 = t9.clone(); + for (var n9 = 0, a8 = 0; r10.cmpn(-n9) > 0 || t9.cmpn(-a8) > 0; ) { + var i8, o9, c8, s7 = r10.andln(3) + n9 & 3, l8 = t9.andln(3) + a8 & 3; + if (3 === s7 && (s7 = -1), 3 === l8 && (l8 = -1), 0 == (1 & s7)) + i8 = 0; + else + i8 = 3 !== (c8 = r10.andln(7) + n9 & 7) && 5 !== c8 || 2 !== l8 ? s7 : -s7; + if (e12[0].push(i8), 0 == (1 & l8)) + o9 = 0; + else + o9 = 3 !== (c8 = t9.andln(7) + a8 & 7) && 5 !== c8 || 2 !== s7 ? l8 : -l8; + e12[1].push(o9), 2 * n9 === i8 + 1 && (n9 = 1 - n9), 2 * a8 === o9 + 1 && (a8 = 1 - a8), r10.iushrn(1), t9.iushrn(1); + } + return e12; + }, a$g.cachedProperty = function(r10, t9, e12) { + var n9 = "_" + t9; + r10.prototype[t9] = function() { + return void 0 !== this[n9] ? this[n9] : this[n9] = e12.call(this); + }; + }, a$g.parseBytes = function(r10) { + return "string" == typeof r10 ? a$g.toArray(r10, "hex") : r10; + }, a$g.intFromLE = function(r10) { + return new i$7(r10, "hex", "le"); + }; + var s$d; + var l$e = n$c; + var u$d = n$i; + var h$c = u$d.assert; + function p$f(r10, t9) { + if (r10 instanceof p$f) + return r10; + this._importDER(r10, t9) || (h$c(r10.r && r10.s, "Signature without r or s"), this.r = new l$e(r10.r, 16), this.s = new l$e(r10.s, 16), void 0 === r10.recoveryParam ? this.recoveryParam = null : this.recoveryParam = r10.recoveryParam); + } + function f$j() { + this.place = 0; + } + function v$a(r10, t9) { + var e12 = r10[t9.place++]; + if (!(128 & e12)) + return e12; + for (var n9 = 15 & e12, a8 = 0, i8 = 0, o9 = t9.place; i8 < n9; i8++, o9++) + a8 <<= 8, a8 |= r10[o9]; + return t9.place = o9, a8; + } + function m$b(r10) { + for (var t9 = 0, e12 = r10.length - 1; !r10[t9] && !(128 & r10[t9 + 1]) && t9 < e12; ) + t9++; + return 0 === t9 ? r10 : r10.slice(t9); + } + function y$a(r10, t9) { + if (t9 < 128) + return r10.push(t9), void 0; + var e12 = 1 + (Math.log(t9) / Math.LN2 >>> 3); + for (r10.push(128 | e12); --e12; ) + r10.push(t9 >>> (e12 << 3) & 255); + r10.push(t9); + } + s$d = p$f, p$f.prototype._importDER = function(r10, t9) { + r10 = u$d.toArray(r10, t9); + var e12 = new f$j(); + if (48 !== r10[e12.place++]) + return false; + if (v$a(r10, e12) + e12.place !== r10.length) + return false; + if (2 !== r10[e12.place++]) + return false; + var n9 = v$a(r10, e12), a8 = r10.slice(e12.place, n9 + e12.place); + if (e12.place += n9, 2 !== r10[e12.place++]) + return false; + var i8 = v$a(r10, e12); + if (r10.length !== i8 + e12.place) + return false; + var o9 = r10.slice(e12.place, i8 + e12.place); + return 0 === a8[0] && 128 & a8[1] && (a8 = a8.slice(1)), 0 === o9[0] && 128 & o9[1] && (o9 = o9.slice(1)), this.r = new l$e(a8), this.s = new l$e(o9), this.recoveryParam = null, true; + }, p$f.prototype.toDER = function(r10) { + var t9 = this.r.toArray(), e12 = this.s.toArray(); + for (128 & t9[0] && (t9 = [0].concat(t9)), 128 & e12[0] && (e12 = [0].concat(e12)), t9 = m$b(t9), e12 = m$b(e12); !(e12[0] || 128 & e12[1]); ) + e12 = e12.slice(1); + var n9 = [2]; + y$a(n9, t9.length), (n9 = n9.concat(t9)).push(2), y$a(n9, e12.length); + var a8 = n9.concat(e12), i8 = [48]; + return y$a(i8, a8.length), i8 = i8.concat(a8), u$d.encode(i8, r10); + }; + var d$e = s$d; + var r$b = {}; + var i$8 = o$7; + var e$c = t$2; + function h$d(t9, n9) { + return 55296 == (64512 & t9.charCodeAt(n9)) && (!(n9 < 0 || n9 + 1 >= t9.length) && 56320 == (64512 & t9.charCodeAt(n9 + 1))); + } + function o$h(t9) { + return (t9 >>> 24 | t9 >>> 8 & 65280 | t9 << 8 & 16711680 | (255 & t9) << 24) >>> 0; + } + function u$e(t9) { + return 1 === t9.length ? "0" + t9 : t9; + } + function s$e(t9) { + return 7 === t9.length ? "0" + t9 : 6 === t9.length ? "00" + t9 : 5 === t9.length ? "000" + t9 : 4 === t9.length ? "0000" + t9 : 3 === t9.length ? "00000" + t9 : 2 === t9.length ? "000000" + t9 : 1 === t9.length ? "0000000" + t9 : t9; + } + r$b.inherits = e$c, r$b.toArray = function(t9, n9) { + if (Array.isArray(t9)) + return t9.slice(); + if (!t9) + return []; + var r10 = []; + if ("string" == typeof t9) + if (n9) { + if ("hex" === n9) + for ((t9 = t9.replace(/[^a-z0-9]+/gi, "")).length % 2 != 0 && (t9 = "0" + t9), e12 = 0; e12 < t9.length; e12 += 2) + r10.push(parseInt(t9[e12] + t9[e12 + 1], 16)); + } else + for (var i8 = 0, e12 = 0; e12 < t9.length; e12++) { + var o9 = t9.charCodeAt(e12); + o9 < 128 ? r10[i8++] = o9 : o9 < 2048 ? (r10[i8++] = o9 >> 6 | 192, r10[i8++] = 63 & o9 | 128) : h$d(t9, e12) ? (o9 = 65536 + ((1023 & o9) << 10) + (1023 & t9.charCodeAt(++e12)), r10[i8++] = o9 >> 18 | 240, r10[i8++] = o9 >> 12 & 63 | 128, r10[i8++] = o9 >> 6 & 63 | 128, r10[i8++] = 63 & o9 | 128) : (r10[i8++] = o9 >> 12 | 224, r10[i8++] = o9 >> 6 & 63 | 128, r10[i8++] = 63 & o9 | 128); + } + else + for (e12 = 0; e12 < t9.length; e12++) + r10[e12] = 0 | t9[e12]; + return r10; + }, r$b.toHex = function(t9) { + for (var n9 = "", r10 = 0; r10 < t9.length; r10++) + n9 += u$e(t9[r10].toString(16)); + return n9; + }, r$b.htonl = o$h, r$b.toHex32 = function(t9, n9) { + for (var r10 = "", i8 = 0; i8 < t9.length; i8++) { + var e12 = t9[i8]; + "little" === n9 && (e12 = o$h(e12)), r10 += s$e(e12.toString(16)); + } + return r10; + }, r$b.zero2 = u$e, r$b.zero8 = s$e, r$b.join32 = function(t9, n9, r10, e12) { + var h9 = r10 - n9; + i$8(h9 % 4 == 0); + for (var o9 = new Array(h9 / 4), u8 = 0, s7 = n9; u8 < o9.length; u8++, s7 += 4) { + var a8; + a8 = "big" === e12 ? t9[s7] << 24 | t9[s7 + 1] << 16 | t9[s7 + 2] << 8 | t9[s7 + 3] : t9[s7 + 3] << 24 | t9[s7 + 2] << 16 | t9[s7 + 1] << 8 | t9[s7], o9[u8] = a8 >>> 0; + } + return o9; + }, r$b.split32 = function(t9, n9) { + for (var r10 = new Array(4 * t9.length), i8 = 0, e12 = 0; i8 < t9.length; i8++, e12 += 4) { + var h9 = t9[i8]; + "big" === n9 ? (r10[e12] = h9 >>> 24, r10[e12 + 1] = h9 >>> 16 & 255, r10[e12 + 2] = h9 >>> 8 & 255, r10[e12 + 3] = 255 & h9) : (r10[e12 + 3] = h9 >>> 24, r10[e12 + 2] = h9 >>> 16 & 255, r10[e12 + 1] = h9 >>> 8 & 255, r10[e12] = 255 & h9); + } + return r10; + }, r$b.rotr32 = function(t9, n9) { + return t9 >>> n9 | t9 << 32 - n9; + }, r$b.rotl32 = function(t9, n9) { + return t9 << n9 | t9 >>> 32 - n9; + }, r$b.sum32 = function(t9, n9) { + return t9 + n9 >>> 0; + }, r$b.sum32_3 = function(t9, n9, r10) { + return t9 + n9 + r10 >>> 0; + }, r$b.sum32_4 = function(t9, n9, r10, i8) { + return t9 + n9 + r10 + i8 >>> 0; + }, r$b.sum32_5 = function(t9, n9, r10, i8, e12) { + return t9 + n9 + r10 + i8 + e12 >>> 0; + }, r$b.sum64 = function(t9, n9, r10, i8) { + var e12 = t9[n9], h9 = i8 + t9[n9 + 1] >>> 0, o9 = (h9 < i8 ? 1 : 0) + r10 + e12; + t9[n9] = o9 >>> 0, t9[n9 + 1] = h9; + }, r$b.sum64_hi = function(t9, n9, r10, i8) { + return (n9 + i8 >>> 0 < n9 ? 1 : 0) + t9 + r10 >>> 0; + }, r$b.sum64_lo = function(t9, n9, r10, i8) { + return n9 + i8 >>> 0; + }, r$b.sum64_4_hi = function(t9, n9, r10, i8, e12, h9, o9, u8) { + var s7 = 0, a8 = n9; + return s7 += (a8 = a8 + i8 >>> 0) < n9 ? 1 : 0, s7 += (a8 = a8 + h9 >>> 0) < h9 ? 1 : 0, t9 + r10 + e12 + o9 + (s7 += (a8 = a8 + u8 >>> 0) < u8 ? 1 : 0) >>> 0; + }, r$b.sum64_4_lo = function(t9, n9, r10, i8, e12, h9, o9, u8) { + return n9 + i8 + h9 + u8 >>> 0; + }, r$b.sum64_5_hi = function(t9, n9, r10, i8, e12, h9, o9, u8, s7, a8) { + var l8 = 0, g6 = n9; + return l8 += (g6 = g6 + i8 >>> 0) < n9 ? 1 : 0, l8 += (g6 = g6 + h9 >>> 0) < h9 ? 1 : 0, l8 += (g6 = g6 + u8 >>> 0) < u8 ? 1 : 0, t9 + r10 + e12 + o9 + s7 + (l8 += (g6 = g6 + a8 >>> 0) < a8 ? 1 : 0) >>> 0; + }, r$b.sum64_5_lo = function(t9, n9, r10, i8, e12, h9, o9, u8, s7, a8) { + return n9 + i8 + h9 + u8 + a8 >>> 0; + }, r$b.rotr64_hi = function(t9, n9, r10) { + return (n9 << 32 - r10 | t9 >>> r10) >>> 0; + }, r$b.rotr64_lo = function(t9, n9, r10) { + return (t9 << 32 - r10 | n9 >>> r10) >>> 0; + }, r$b.shr64_hi = function(t9, n9, r10) { + return t9 >>> r10; + }, r$b.shr64_lo = function(t9, n9, r10) { + return (t9 << 32 - r10 | n9 >>> r10) >>> 0; + }; + var a$h = {}; + var l$f = r$b; + var g$9 = o$7; + function c$e() { + this.pending = null, this.pendingTotal = 0, this.blockSize = this.constructor.blockSize, this.outSize = this.constructor.outSize, this.hmacStrength = this.constructor.hmacStrength, this.padLength = this.constructor.padLength / 8, this.endian = "big", this._delta8 = this.blockSize / 8, this._delta32 = this.blockSize / 32; + } + a$h.BlockHash = c$e, c$e.prototype.update = function(t9, n9) { + if (t9 = l$f.toArray(t9, n9), this.pending ? this.pending = this.pending.concat(t9) : this.pending = t9, this.pendingTotal += t9.length, this.pending.length >= this._delta8) { + var r10 = (t9 = this.pending).length % this._delta8; + this.pending = t9.slice(t9.length - r10, t9.length), 0 === this.pending.length && (this.pending = null), t9 = l$f.join32(t9, 0, t9.length - r10, this.endian); + for (var i8 = 0; i8 < t9.length; i8 += this._delta32) + this._update(t9, i8, i8 + this._delta32); + } + return this; + }, c$e.prototype.digest = function(t9) { + return this.update(this._pad()), g$9(null === this.pending), this._digest(t9); + }, c$e.prototype._pad = function() { + var t9 = this.pendingTotal, n9 = this._delta8, r10 = n9 - (t9 + this.padLength) % n9, i8 = new Array(r10 + this.padLength); + i8[0] = 128; + for (var e12 = 1; e12 < r10; e12++) + i8[e12] = 0; + if (t9 <<= 3, "big" === this.endian) { + for (var h9 = 8; h9 < this.padLength; h9++) + i8[e12++] = 0; + i8[e12++] = 0, i8[e12++] = 0, i8[e12++] = 0, i8[e12++] = 0, i8[e12++] = t9 >>> 24 & 255, i8[e12++] = t9 >>> 16 & 255, i8[e12++] = t9 >>> 8 & 255, i8[e12++] = 255 & t9; + } else + for (i8[e12++] = 255 & t9, i8[e12++] = t9 >>> 8 & 255, i8[e12++] = t9 >>> 16 & 255, i8[e12++] = t9 >>> 24 & 255, i8[e12++] = 0, i8[e12++] = 0, i8[e12++] = 0, i8[e12++] = 0, h9 = 8; h9 < this.padLength; h9++) + i8[e12++] = 0; + return i8; + }; + var r$c; + var n$j = r$b; + var s$f = a$h; + var o$i = o$7; + var e$d = n$j.rotr64_hi; + var u$f = n$j.rotr64_lo; + var a$i = n$j.shr64_hi; + var c$f = n$j.shr64_lo; + var f$k = n$j.sum64; + var v$b = n$j.sum64_hi; + var _$a = n$j.sum64_lo; + var l$g = n$j.sum64_4_hi; + var p$g = n$j.sum64_4_lo; + var m$c = n$j.sum64_5_hi; + var g$a = n$j.sum64_5_lo; + var k$8 = s$f.BlockHash; + var d$f = [1116352408, 3609767458, 1899447441, 602891725, 3049323471, 3964484399, 3921009573, 2173295548, 961987163, 4081628472, 1508970993, 3053834265, 2453635748, 2937671579, 2870763221, 3664609560, 3624381080, 2734883394, 310598401, 1164996542, 607225278, 1323610764, 1426881987, 3590304994, 1925078388, 4068182383, 2162078206, 991336113, 2614888103, 633803317, 3248222580, 3479774868, 3835390401, 2666613458, 4022224774, 944711139, 264347078, 2341262773, 604807628, 2007800933, 770255983, 1495990901, 1249150122, 1856431235, 1555081692, 3175218132, 1996064986, 2198950837, 2554220882, 3999719339, 2821834349, 766784016, 2952996808, 2566594879, 3210313671, 3203337956, 3336571891, 1034457026, 3584528711, 2466948901, 113926993, 3758326383, 338241895, 168717936, 666307205, 1188179964, 773529912, 1546045734, 1294757372, 1522805485, 1396182291, 2643833823, 1695183700, 2343527390, 1986661051, 1014477480, 2177026350, 1206759142, 2456956037, 344077627, 2730485921, 1290863460, 2820302411, 3158454273, 3259730800, 3505952657, 3345764771, 106217008, 3516065817, 3606008344, 3600352804, 1432725776, 4094571909, 1467031594, 275423344, 851169720, 430227734, 3100823752, 506948616, 1363258195, 659060556, 3750685593, 883997877, 3785050280, 958139571, 3318307427, 1322822218, 3812723403, 1537002063, 2003034995, 1747873779, 3602036899, 1955562222, 1575990012, 2024104815, 1125592928, 2227730452, 2716904306, 2361852424, 442776044, 2428436474, 593698344, 2756734187, 3733110249, 3204031479, 2999351573, 3329325298, 3815920427, 3391569614, 3928383900, 3515267271, 566280711, 3940187606, 3454069534, 4118630271, 4000239992, 116418474, 1914138554, 174292421, 2731055270, 289380356, 3203993006, 460393269, 320620315, 685471733, 587496836, 852142971, 1086792851, 1017036298, 365543100, 1126000580, 2618297676, 1288033470, 3409855158, 1501505948, 4234509866, 1607167915, 987167468, 1816402316, 1246189591]; + function y$b() { + if (!(this instanceof y$b)) + return new y$b(); + k$8.call(this), this.h = [1779033703, 4089235720, 3144134277, 2227873595, 1013904242, 4271175723, 2773480762, 1595750129, 1359893119, 2917565137, 2600822924, 725511199, 528734635, 4215389547, 1541459225, 327033209], this.k = d$f, this.W = new Array(160); + } + function b$8(t9, h9, i8, r10, n9) { + var s7 = t9 & i8 ^ ~t9 & n9; + return s7 < 0 && (s7 += 4294967296), s7; + } + function x$3(t9, h9, i8, r10, n9, s7) { + var o9 = h9 & r10 ^ ~h9 & s7; + return o9 < 0 && (o9 += 4294967296), o9; + } + function B$6(t9, h9, i8, r10, n9) { + var s7 = t9 & i8 ^ t9 & n9 ^ i8 & n9; + return s7 < 0 && (s7 += 4294967296), s7; + } + function S$6(t9, h9, i8, r10, n9, s7) { + var o9 = h9 & r10 ^ h9 & s7 ^ r10 & s7; + return o9 < 0 && (o9 += 4294967296), o9; + } + function W$1(t9, h9) { + var i8 = e$d(t9, h9, 28) ^ e$d(h9, t9, 2) ^ e$d(h9, t9, 7); + return i8 < 0 && (i8 += 4294967296), i8; + } + function w$b(t9, h9) { + var i8 = u$f(t9, h9, 28) ^ u$f(h9, t9, 2) ^ u$f(h9, t9, 7); + return i8 < 0 && (i8 += 4294967296), i8; + } + function z$4(t9, h9) { + var i8 = e$d(t9, h9, 14) ^ e$d(t9, h9, 18) ^ e$d(h9, t9, 9); + return i8 < 0 && (i8 += 4294967296), i8; + } + function H$3(t9, h9) { + var i8 = u$f(t9, h9, 14) ^ u$f(t9, h9, 18) ^ u$f(h9, t9, 9); + return i8 < 0 && (i8 += 4294967296), i8; + } + function j$2(t9, h9) { + var i8 = e$d(t9, h9, 1) ^ e$d(t9, h9, 8) ^ a$i(t9, h9, 7); + return i8 < 0 && (i8 += 4294967296), i8; + } + function A$6(t9, h9) { + var i8 = u$f(t9, h9, 1) ^ u$f(t9, h9, 8) ^ c$f(t9, h9, 7); + return i8 < 0 && (i8 += 4294967296), i8; + } + function L$2(t9, h9) { + var i8 = e$d(t9, h9, 19) ^ e$d(h9, t9, 29) ^ a$i(t9, h9, 6); + return i8 < 0 && (i8 += 4294967296), i8; + } + function q$2(t9, h9) { + var i8 = u$f(t9, h9, 19) ^ u$f(h9, t9, 29) ^ c$f(t9, h9, 6); + return i8 < 0 && (i8 += 4294967296), i8; + } + n$j.inherits(y$b, k$8), r$c = y$b, y$b.blockSize = 1024, y$b.outSize = 512, y$b.hmacStrength = 192, y$b.padLength = 128, y$b.prototype._prepareBlock = function(t9, h9) { + for (var i8 = this.W, r10 = 0; r10 < 32; r10++) + i8[r10] = t9[h9 + r10]; + for (; r10 < i8.length; r10 += 2) { + var n9 = L$2(i8[r10 - 4], i8[r10 - 3]), s7 = q$2(i8[r10 - 4], i8[r10 - 3]), o9 = i8[r10 - 14], e12 = i8[r10 - 13], u8 = j$2(i8[r10 - 30], i8[r10 - 29]), a8 = A$6(i8[r10 - 30], i8[r10 - 29]), c8 = i8[r10 - 32], f9 = i8[r10 - 31]; + i8[r10] = l$g(n9, s7, o9, e12, u8, a8, c8, f9), i8[r10 + 1] = p$g(n9, s7, o9, e12, u8, a8, c8, f9); + } + }, y$b.prototype._update = function(t9, h9) { + this._prepareBlock(t9, h9); + var i8 = this.W, r10 = this.h[0], n9 = this.h[1], s7 = this.h[2], e12 = this.h[3], u8 = this.h[4], a8 = this.h[5], c8 = this.h[6], l8 = this.h[7], p8 = this.h[8], k5 = this.h[9], d7 = this.h[10], y7 = this.h[11], j5 = this.h[12], A5 = this.h[13], L5 = this.h[14], q4 = this.h[15]; + o$i(this.k.length === i8.length); + for (var C5 = 0; C5 < i8.length; C5 += 2) { + var D5 = L5, E5 = q4, F5 = z$4(p8, k5), G4 = H$3(p8, k5), I5 = b$8(p8, k5, d7, y7, j5), J4 = x$3(p8, k5, d7, y7, j5, A5), K4 = this.k[C5], M5 = this.k[C5 + 1], N14 = i8[C5], O6 = i8[C5 + 1], P5 = m$c(D5, E5, F5, G4, I5, J4, K4, M5, N14, O6), Q4 = g$a(D5, E5, F5, G4, I5, J4, K4, M5, N14, O6); + D5 = W$1(r10, n9), E5 = w$b(r10, n9), F5 = B$6(r10, n9, s7, e12, u8), G4 = S$6(r10, n9, s7, e12, u8, a8); + var R5 = v$b(D5, E5, F5, G4), T6 = _$a(D5, E5, F5, G4); + L5 = j5, q4 = A5, j5 = d7, A5 = y7, d7 = p8, y7 = k5, p8 = v$b(c8, l8, P5, Q4), k5 = _$a(l8, l8, P5, Q4), c8 = u8, l8 = a8, u8 = s7, a8 = e12, s7 = r10, e12 = n9, r10 = v$b(P5, Q4, R5, T6), n9 = _$a(P5, Q4, R5, T6); + } + f$k(this.h, 0, r10, n9), f$k(this.h, 2, s7, e12), f$k(this.h, 4, u8, a8), f$k(this.h, 6, c8, l8), f$k(this.h, 8, p8, k5), f$k(this.h, 10, d7, y7), f$k(this.h, 12, j5, A5), f$k(this.h, 14, L5, q4); + }, y$b.prototype._digest = function(t9) { + return "hex" === t9 ? n$j.toHex32(this.h, "big") : n$j.split32(this.h, "big"); + }; + var C$3 = r$c; + var s$g = {}; + var n$k = r$b.rotr32; + function r$d(t9, h9, i8) { + return t9 & h9 ^ ~t9 & i8; + } + function e$e(t9, h9, i8) { + return t9 & h9 ^ t9 & i8 ^ h9 & i8; + } + function o$j(t9, h9, i8) { + return t9 ^ h9 ^ i8; + } + s$g.ft_1 = function(t9, h9, i8, s7) { + return 0 === t9 ? r$d(h9, i8, s7) : 1 === t9 || 3 === t9 ? o$j(h9, i8, s7) : 2 === t9 ? e$e(h9, i8, s7) : void 0; + }, s$g.ch32 = r$d, s$g.maj32 = e$e, s$g.p32 = o$j, s$g.s0_256 = function(t9) { + return n$k(t9, 2) ^ n$k(t9, 13) ^ n$k(t9, 22); + }, s$g.s1_256 = function(t9) { + return n$k(t9, 6) ^ n$k(t9, 11) ^ n$k(t9, 25); + }, s$g.g0_256 = function(t9) { + return n$k(t9, 7) ^ n$k(t9, 18) ^ t9 >>> 3; + }, s$g.g1_256 = function(t9) { + return n$k(t9, 17) ^ n$k(t9, 19) ^ t9 >>> 10; + }; + var u$g; + var a$j = r$b; + var c$g = a$h; + var f$l = s$g; + var _$b = o$7; + var g$b = a$j.sum32; + var m$d = a$j.sum32_4; + var p$h = a$j.sum32_5; + var l$h = f$l.ch32; + var v$c = f$l.maj32; + var d$g = f$l.s0_256; + var k$9 = f$l.s1_256; + var b$9 = f$l.g0_256; + var j$3 = f$l.g1_256; + var x$4 = c$g.BlockHash; + var y$c = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298]; + function S$7() { + if (!(this instanceof S$7)) + return new S$7(); + x$4.call(this), this.h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], this.k = y$c, this.W = new Array(64); + } + a$j.inherits(S$7, x$4), u$g = S$7, S$7.blockSize = 512, S$7.outSize = 256, S$7.hmacStrength = 192, S$7.padLength = 64, S$7.prototype._update = function(t9, h9) { + for (var i8 = this.W, s7 = 0; s7 < 16; s7++) + i8[s7] = t9[h9 + s7]; + for (; s7 < i8.length; s7++) + i8[s7] = m$d(j$3(i8[s7 - 2]), i8[s7 - 7], b$9(i8[s7 - 15]), i8[s7 - 16]); + var n9 = this.h[0], r10 = this.h[1], e12 = this.h[2], o9 = this.h[3], u8 = this.h[4], a8 = this.h[5], c8 = this.h[6], f9 = this.h[7]; + for (_$b(this.k.length === i8.length), s7 = 0; s7 < i8.length; s7++) { + var x5 = p$h(f9, k$9(u8), l$h(u8, a8, c8), this.k[s7], i8[s7]), y7 = g$b(d$g(n9), v$c(n9, r10, e12)); + f9 = c8, c8 = a8, a8 = u8, u8 = g$b(o9, x5), o9 = e12, e12 = r10, r10 = n9, n9 = g$b(x5, y7); + } + this.h[0] = g$b(this.h[0], n9), this.h[1] = g$b(this.h[1], r10), this.h[2] = g$b(this.h[2], e12), this.h[3] = g$b(this.h[3], o9), this.h[4] = g$b(this.h[4], u8), this.h[5] = g$b(this.h[5], a8), this.h[6] = g$b(this.h[6], c8), this.h[7] = g$b(this.h[7], f9); + }, S$7.prototype._digest = function(t9) { + return "hex" === t9 ? a$j.toHex32(this.h, "big") : a$j.split32(this.h, "big"); + }; + var w$c = u$g; + var r$e; + var o$k = r$b; + var a$k = a$h; + var u$h = s$g; + var l$i = o$k.rotl32; + var c$h = o$k.sum32; + var p$i = o$k.sum32_5; + var f$m = u$h.ft_1; + var g$c = a$k.BlockHash; + var d$h = [1518500249, 1859775393, 2400959708, 3395469782]; + function m$e() { + if (!(this instanceof m$e)) + return new m$e(); + g$c.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.W = new Array(80); + } + o$k.inherits(m$e, g$c), r$e = m$e, m$e.blockSize = 512, m$e.outSize = 160, m$e.hmacStrength = 80, m$e.padLength = 64, m$e.prototype._update = function(t9, h9) { + for (var i8 = this.W, s7 = 0; s7 < 16; s7++) + i8[s7] = t9[h9 + s7]; + for (; s7 < i8.length; s7++) + i8[s7] = l$i(i8[s7 - 3] ^ i8[s7 - 8] ^ i8[s7 - 14] ^ i8[s7 - 16], 1); + var e12 = this.h[0], n9 = this.h[1], r10 = this.h[2], o9 = this.h[3], a8 = this.h[4]; + for (s7 = 0; s7 < i8.length; s7++) { + var u8 = ~~(s7 / 20), g6 = p$i(l$i(e12, 5), f$m(u8, n9, r10, o9), a8, i8[s7], d$h[u8]); + a8 = o9, o9 = r10, r10 = l$i(n9, 30), n9 = e12, e12 = g6; + } + this.h[0] = c$h(this.h[0], e12), this.h[1] = c$h(this.h[1], n9), this.h[2] = c$h(this.h[2], r10), this.h[3] = c$h(this.h[3], o9), this.h[4] = c$h(this.h[4], a8); + }, m$e.prototype._digest = function(t9) { + return "hex" === t9 ? o$k.toHex32(this.h, "big") : o$k.split32(this.h, "big"); + }; + var S$8; + var _$c = r$e; + var b$a = r$b; + var z$5 = w$c; + function v$d() { + if (!(this instanceof v$d)) + return new v$d(); + z$5.call(this), this.h = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]; + } + b$a.inherits(v$d, z$5), S$8 = v$d, v$d.blockSize = 512, v$d.outSize = 224, v$d.hmacStrength = 192, v$d.padLength = 64, v$d.prototype._digest = function(t9) { + return "hex" === t9 ? b$a.toHex32(this.h.slice(0, 7), "big") : b$a.split32(this.h.slice(0, 7), "big"); + }; + var k$a; + var y$d = S$8; + var H$4 = r$b; + var w$d = C$3; + function x$5() { + if (!(this instanceof x$5)) + return new x$5(); + w$d.call(this), this.h = [3418070365, 3238371032, 1654270250, 914150663, 2438529370, 812702999, 355462360, 4144912697, 1731405415, 4290775857, 2394180231, 1750603025, 3675008525, 1694076839, 1203062813, 3204075428]; + } + H$4.inherits(x$5, w$d), k$a = x$5, x$5.blockSize = 1024, x$5.outSize = 384, x$5.hmacStrength = 192, x$5.padLength = 128, x$5.prototype._digest = function(t9) { + return "hex" === t9 ? H$4.toHex32(this.h.slice(0, 12), "big") : H$4.split32(this.h.slice(0, 12), "big"); + }; + var L$3 = k$a; + var j$4 = {}; + j$4.sha1 = _$c, j$4.sha224 = y$d, j$4.sha256 = w$c, j$4.sha384 = L$3, j$4.sha512 = C$3; + var A$7 = {}; + var B$7 = r$b; + var W$2 = a$h; + var q$3 = B$7.rotl32; + var C$4 = B$7.sum32; + var D$3 = B$7.sum32_3; + var E$7 = B$7.sum32_4; + var F$4 = W$2.BlockHash; + function G$2() { + if (!(this instanceof G$2)) + return new G$2(); + F$4.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; + } + function I$7(t9, h9, i8, s7) { + return t9 <= 15 ? h9 ^ i8 ^ s7 : t9 <= 31 ? h9 & i8 | ~h9 & s7 : t9 <= 47 ? (h9 | ~i8) ^ s7 : t9 <= 63 ? h9 & s7 | i8 & ~s7 : h9 ^ (i8 | ~s7); + } + function J$2(t9) { + return t9 <= 15 ? 0 : t9 <= 31 ? 1518500249 : t9 <= 47 ? 1859775393 : t9 <= 63 ? 2400959708 : 2840853838; + } + function K$3(t9) { + return t9 <= 15 ? 1352829926 : t9 <= 31 ? 1548603684 : t9 <= 47 ? 1836072691 : t9 <= 63 ? 2053994217 : 0; + } + B$7.inherits(G$2, F$4), A$7.ripemd160 = G$2, G$2.blockSize = 512, G$2.outSize = 160, G$2.hmacStrength = 192, G$2.padLength = 64, G$2.prototype._update = function(t9, h9) { + for (var i8 = this.h[0], s7 = this.h[1], e12 = this.h[2], n9 = this.h[3], r10 = this.h[4], o9 = i8, a8 = s7, u8 = e12, l8 = n9, c8 = r10, p8 = 0; p8 < 80; p8++) { + var f9 = C$4(q$3(E$7(i8, I$7(p8, s7, e12, n9), t9[N$3[p8] + h9], J$2(p8)), P$3[p8]), r10); + i8 = r10, r10 = n9, n9 = q$3(e12, 10), e12 = s7, s7 = f9, f9 = C$4(q$3(E$7(o9, I$7(79 - p8, a8, u8, l8), t9[O$4[p8] + h9], K$3(p8)), Q$1[p8]), c8), o9 = c8, c8 = l8, l8 = q$3(u8, 10), u8 = a8, a8 = f9; + } + f9 = D$3(this.h[1], e12, l8), this.h[1] = D$3(this.h[2], n9, c8), this.h[2] = D$3(this.h[3], r10, o9), this.h[3] = D$3(this.h[4], i8, a8), this.h[4] = D$3(this.h[0], s7, u8), this.h[0] = f9; + }, G$2.prototype._digest = function(t9) { + return "hex" === t9 ? B$7.toHex32(this.h, "little") : B$7.split32(this.h, "little"); + }; + var M$5; + var N$3 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]; + var O$4 = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]; + var P$3 = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]; + var Q$1 = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]; + var R$2 = r$b; + var T$4 = o$7; + function U$5(t9, h9, i8) { + if (!(this instanceof U$5)) + return new U$5(t9, h9, i8); + this.Hash = t9, this.blockSize = t9.blockSize / 8, this.outSize = t9.outSize / 8, this.inner = null, this.outer = null, this._init(R$2.toArray(h9, i8)); + } + M$5 = U$5, U$5.prototype._init = function(t9) { + t9.length > this.blockSize && (t9 = new this.Hash().update(t9).digest()), T$4(t9.length <= this.blockSize); + for (var h9 = t9.length; h9 < this.blockSize; h9++) + t9.push(0); + for (h9 = 0; h9 < t9.length; h9++) + t9[h9] ^= 54; + for (this.inner = new this.Hash().update(t9), h9 = 0; h9 < t9.length; h9++) + t9[h9] ^= 106; + this.outer = new this.Hash().update(t9); + }, U$5.prototype.update = function(t9, h9) { + return this.inner.update(t9, h9), this; + }, U$5.prototype.digest = function(t9) { + return this.outer.update(this.inner.digest()), this.outer.digest(t9); + }; + var V$2 = M$5; + var X$2 = {}; + var Y$1 = X$2; + Y$1.utils = r$b, Y$1.common = a$h, Y$1.sha = j$4, Y$1.ripemd = A$7, Y$1.hmac = V$2, Y$1.sha1 = Y$1.sha.sha1, Y$1.sha256 = Y$1.sha.sha256, Y$1.sha224 = Y$1.sha.sha224, Y$1.sha384 = Y$1.sha.sha384, Y$1.sha512 = Y$1.sha.sha512, Y$1.ripemd160 = Y$1.ripemd.ripemd160; + var s$h; + var h$e = X$2; + var r$f = r$a; + var n$l = o$7; + function o$l(t9) { + if (!(this instanceof o$l)) + return new o$l(t9); + this.hash = t9.hash, this.predResist = !!t9.predResist, this.outLen = this.hash.outSize, this.minEntropy = t9.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var e12 = r$f.toArray(t9.entropy, t9.entropyEnc || "hex"), i8 = r$f.toArray(t9.nonce, t9.nonceEnc || "hex"), s7 = r$f.toArray(t9.pers, t9.persEnc || "hex"); + n$l(e12.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._init(e12, i8, s7); + } + s$h = o$l, o$l.prototype._init = function(t9, e12, i8) { + var s7 = t9.concat(e12).concat(i8); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var h9 = 0; h9 < this.V.length; h9++) + this.K[h9] = 0, this.V[h9] = 1; + this._update(s7), this._reseed = 1, this.reseedInterval = 281474976710656; + }, o$l.prototype._hmac = function() { + return new h$e.hmac(this.hash, this.K); + }, o$l.prototype._update = function(t9) { + var e12 = this._hmac().update(this.V).update([0]); + t9 && (e12 = e12.update(t9)), this.K = e12.digest(), this.V = this._hmac().update(this.V).digest(), t9 && (this.K = this._hmac().update(this.V).update([1]).update(t9).digest(), this.V = this._hmac().update(this.V).digest()); + }, o$l.prototype.reseed = function(t9, e12, i8, s7) { + "string" != typeof e12 && (s7 = i8, i8 = e12, e12 = null), t9 = r$f.toArray(t9, e12), i8 = r$f.toArray(i8, s7), n$l(t9.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"), this._update(t9.concat(i8 || [])), this._reseed = 1; + }, o$l.prototype.generate = function(t9, e12, i8, s7) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + "string" != typeof e12 && (s7 = i8, i8 = e12, e12 = null), i8 && (i8 = r$f.toArray(i8, s7 || "hex"), this._update(i8)); + for (var h9 = []; h9.length < t9; ) + this.V = this._hmac().update(this.V).digest(), h9 = h9.concat(this.V); + var n9 = h9.slice(0, t9); + return this._update(i8), this._reseed++, r$f.encode(n9, e12); + }; + var a$l = s$h; + var b$b; + var i$9 = n$c; + var n$m = n$i; + var s$i = n$m.getNAF; + var o$m = n$m.getJSF; + var u$i = n$m.assert; + function h$f(e12, f9) { + this.type = e12, this.p = new i$9(f9.p, 16), this.red = f9.prime ? i$9.red(f9.prime) : i$9.mont(this.p), this.zero = new i$9(0).toRed(this.red), this.one = new i$9(1).toRed(this.red), this.two = new i$9(2).toRed(this.red), this.n = f9.n && new i$9(f9.n, 16), this.g = f9.g && this.pointFromJSON(f9.g, f9.gRed), this._wnafT1 = new Array(4), this._wnafT2 = new Array(4), this._wnafT3 = new Array(4), this._wnafT4 = new Array(4), this._bitLength = this.n ? this.n.bitLength() : 0; + var d7 = this.n && this.p.div(this.n); + !d7 || d7.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = true, this.redN = this.n.toRed(this.red)); + } + function p$j(e12, f9) { + this.curve = e12, this.type = f9, this.precomputed = null; + } + b$b = h$f, h$f.prototype.point = function() { + throw new Error("Not implemented"); + }, h$f.prototype.validate = function() { + throw new Error("Not implemented"); + }, h$f.prototype._fixedNafMul = function(e12, f9) { + u$i(e12.precomputed); + var d7 = e12._getDoubles(), c8 = s$i(f9, 1, this._bitLength), t9 = (1 << d7.step + 1) - (d7.step % 2 == 0 ? 2 : 1); + t9 /= 3; + for (var a8 = [], r10 = 0; r10 < c8.length; r10 += d7.step) { + var b6 = 0; + for (f9 = r10 + d7.step - 1; f9 >= r10; f9--) + b6 = (b6 << 1) + c8[f9]; + a8.push(b6); + } + for (var i8 = this.jpoint(null, null, null), n9 = this.jpoint(null, null, null), o9 = t9; o9 > 0; o9--) { + for (r10 = 0; r10 < a8.length; r10++) { + (b6 = a8[r10]) === o9 ? n9 = n9.mixedAdd(d7.points[r10]) : b6 === -o9 && (n9 = n9.mixedAdd(d7.points[r10].neg())); + } + i8 = i8.add(n9); + } + return i8.toP(); + }, h$f.prototype._wnafMul = function(e12, f9) { + var d7 = 4, c8 = e12._getNAFPoints(d7); + d7 = c8.wnd; + for (var t9 = c8.points, a8 = s$i(f9, d7, this._bitLength), r10 = this.jpoint(null, null, null), b6 = a8.length - 1; b6 >= 0; b6--) { + for (f9 = 0; b6 >= 0 && 0 === a8[b6]; b6--) + f9++; + if (b6 >= 0 && f9++, r10 = r10.dblp(f9), b6 < 0) + break; + var i8 = a8[b6]; + u$i(0 !== i8), r10 = "affine" === e12.type ? i8 > 0 ? r10.mixedAdd(t9[i8 - 1 >> 1]) : r10.mixedAdd(t9[-i8 - 1 >> 1].neg()) : i8 > 0 ? r10.add(t9[i8 - 1 >> 1]) : r10.add(t9[-i8 - 1 >> 1].neg()); + } + return "affine" === e12.type ? r10.toP() : r10; + }, h$f.prototype._wnafMulAdd = function(e12, f9, d7, c8, t9) { + for (var a8 = this._wnafT1, r10 = this._wnafT2, b6 = this._wnafT3, i8 = 0, n9 = 0; n9 < c8; n9++) { + var u8 = (x5 = f9[n9])._getNAFPoints(e12); + a8[n9] = u8.wnd, r10[n9] = u8.points; + } + for (n9 = c8 - 1; n9 >= 1; n9 -= 2) { + var h9 = n9 - 1, p8 = n9; + if (1 === a8[h9] && 1 === a8[p8]) { + var l8 = [f9[h9], null, null, f9[p8]]; + 0 === f9[h9].y.cmp(f9[p8].y) ? (l8[1] = f9[h9].add(f9[p8]), l8[2] = f9[h9].toJ().mixedAdd(f9[p8].neg())) : 0 === f9[h9].y.cmp(f9[p8].y.redNeg()) ? (l8[1] = f9[h9].toJ().mixedAdd(f9[p8]), l8[2] = f9[h9].add(f9[p8].neg())) : (l8[1] = f9[h9].toJ().mixedAdd(f9[p8]), l8[2] = f9[h9].toJ().mixedAdd(f9[p8].neg())); + var v7 = [-3, -1, -5, -7, 0, 7, 5, 1, 3], y7 = o$m(d7[h9], d7[p8]); + i8 = Math.max(y7[0].length, i8), b6[h9] = new Array(i8), b6[p8] = new Array(i8); + for (var m7 = 0; m7 < i8; m7++) { + var S5 = 0 | y7[0][m7], g6 = 0 | y7[1][m7]; + b6[h9][m7] = v7[3 * (S5 + 1) + (g6 + 1)], b6[p8][m7] = 0, r10[h9] = l8; + } + } else + b6[h9] = s$i(d7[h9], a8[h9], this._bitLength), b6[p8] = s$i(d7[p8], a8[p8], this._bitLength), i8 = Math.max(b6[h9].length, i8), i8 = Math.max(b6[p8].length, i8); + } + var A5 = this.jpoint(null, null, null), I5 = this._wnafT4; + for (n9 = i8; n9 >= 0; n9--) { + for (var w5 = 0; n9 >= 0; ) { + var M5 = true; + for (m7 = 0; m7 < c8; m7++) + I5[m7] = 0 | b6[m7][n9], 0 !== I5[m7] && (M5 = false); + if (!M5) + break; + w5++, n9--; + } + if (n9 >= 0 && w5++, A5 = A5.dblp(w5), n9 < 0) + break; + for (m7 = 0; m7 < c8; m7++) { + var x5, _5 = I5[m7]; + 0 !== _5 && (_5 > 0 ? x5 = r10[m7][_5 - 1 >> 1] : _5 < 0 && (x5 = r10[m7][-_5 - 1 >> 1].neg()), A5 = "affine" === x5.type ? A5.mixedAdd(x5) : A5.add(x5)); + } + } + for (n9 = 0; n9 < c8; n9++) + r10[n9] = null; + return t9 ? A5 : A5.toP(); + }, h$f.BasePoint = p$j, p$j.prototype.eq = function() { + throw new Error("Not implemented"); + }, p$j.prototype.validate = function() { + return this.curve.validate(this); + }, h$f.prototype.decodePoint = function(e12, f9) { + e12 = n$m.toArray(e12, f9); + var d7 = this.p.byteLength(); + if ((4 === e12[0] || 6 === e12[0] || 7 === e12[0]) && e12.length - 1 == 2 * d7) + return 6 === e12[0] ? u$i(e12[e12.length - 1] % 2 == 0) : 7 === e12[0] && u$i(e12[e12.length - 1] % 2 == 1), this.point(e12.slice(1, 1 + d7), e12.slice(1 + d7, 1 + 2 * d7)); + if ((2 === e12[0] || 3 === e12[0]) && e12.length - 1 === d7) + return this.pointFromX(e12.slice(1, 1 + d7), 3 === e12[0]); + throw new Error("Unknown point format"); + }, p$j.prototype.encodeCompressed = function(e12) { + return this.encode(e12, true); + }, p$j.prototype._encode = function(e12) { + var f9 = this.curve.p.byteLength(), d7 = this.getX().toArray("be", f9); + return e12 ? [this.getY().isEven() ? 2 : 3].concat(d7) : [4].concat(d7, this.getY().toArray("be", f9)); + }, p$j.prototype.encode = function(e12, f9) { + return n$m.encode(this._encode(f9), e12); + }, p$j.prototype.precompute = function(e12) { + if (this.precomputed) + return this; + var f9 = { doubles: null, naf: null, beta: null }; + return f9.naf = this._getNAFPoints(8), f9.doubles = this._getDoubles(4, e12), f9.beta = this._getBeta(), this.precomputed = f9, this; + }, p$j.prototype._hasDoubles = function(e12) { + if (!this.precomputed) + return false; + var f9 = this.precomputed.doubles; + return !!f9 && f9.points.length >= Math.ceil((e12.bitLength() + 1) / f9.step); + }, p$j.prototype._getDoubles = function(e12, f9) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var d7 = [this], c8 = this, t9 = 0; t9 < f9; t9 += e12) { + for (var a8 = 0; a8 < e12; a8++) + c8 = c8.dbl(); + d7.push(c8); + } + return { step: e12, points: d7 }; + }, p$j.prototype._getNAFPoints = function(e12) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var f9 = [this], d7 = (1 << e12) - 1, c8 = 1 === d7 ? null : this.dbl(), t9 = 1; t9 < d7; t9++) + f9[t9] = f9[t9 - 1].add(c8); + return { wnd: e12, points: f9 }; + }, p$j.prototype._getBeta = function() { + return null; + }, p$j.prototype.dblp = function(e12) { + for (var f9 = this, d7 = 0; d7 < e12; d7++) + f9 = f9.dbl(); + return f9; + }; + var l$j; + var v$e = b$b; + var y$e = n$c; + var m$f = t$2; + var S$9 = v$e; + var g$d = n$i.assert; + function A$8(e12) { + S$9.call(this, "short", e12), this.a = new y$e(e12.a, 16).toRed(this.red), this.b = new y$e(e12.b, 16).toRed(this.red), this.tinv = this.two.redInvm(), this.zeroA = 0 === this.a.fromRed().cmpn(0), this.threeA = 0 === this.a.fromRed().sub(this.p).cmpn(-3), this.endo = this._getEndomorphism(e12), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); + } + function I$8(e12, f9, d7, c8) { + S$9.BasePoint.call(this, e12, "affine"), null === f9 && null === d7 ? (this.x = null, this.y = null, this.inf = true) : (this.x = new y$e(f9, 16), this.y = new y$e(d7, 16), c8 && (this.x.forceRed(this.curve.red), this.y.forceRed(this.curve.red)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.inf = false); + } + function w$e(e12, f9, d7, c8) { + S$9.BasePoint.call(this, e12, "jacobian"), null === f9 && null === d7 && null === c8 ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new y$e(0)) : (this.x = new y$e(f9, 16), this.y = new y$e(d7, 16), this.z = new y$e(c8, 16)), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.z.red || (this.z = this.z.toRed(this.curve.red)), this.zOne = this.z === this.curve.one; + } + m$f(A$8, S$9), l$j = A$8, A$8.prototype._getEndomorphism = function(e12) { + if (this.zeroA && this.g && this.n && 1 === this.p.modn(3)) { + var f9, d7; + if (e12.beta) + f9 = new y$e(e12.beta, 16).toRed(this.red); + else { + var c8 = this._getEndoRoots(this.p); + f9 = (f9 = c8[0].cmp(c8[1]) < 0 ? c8[0] : c8[1]).toRed(this.red); + } + if (e12.lambda) + d7 = new y$e(e12.lambda, 16); + else { + var t9 = this._getEndoRoots(this.n); + 0 === this.g.mul(t9[0]).x.cmp(this.g.x.redMul(f9)) ? d7 = t9[0] : (d7 = t9[1], g$d(0 === this.g.mul(d7).x.cmp(this.g.x.redMul(f9)))); + } + return { beta: f9, lambda: d7, basis: e12.basis ? e12.basis.map(function(e13) { + return { a: new y$e(e13.a, 16), b: new y$e(e13.b, 16) }; + }) : this._getEndoBasis(d7) }; + } + }, A$8.prototype._getEndoRoots = function(e12) { + var f9 = e12 === this.p ? this.red : y$e.mont(e12), d7 = new y$e(2).toRed(f9).redInvm(), c8 = d7.redNeg(), t9 = new y$e(3).toRed(f9).redNeg().redSqrt().redMul(d7); + return [c8.redAdd(t9).fromRed(), c8.redSub(t9).fromRed()]; + }, A$8.prototype._getEndoBasis = function(e12) { + for (var f9, d7, c8, t9, a8, r10, b6, i8, n9, s7 = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), o9 = e12, u8 = this.n.clone(), h9 = new y$e(1), p8 = new y$e(0), l8 = new y$e(0), v7 = new y$e(1), m7 = 0; 0 !== o9.cmpn(0); ) { + var S5 = u8.div(o9); + i8 = u8.sub(S5.mul(o9)), n9 = l8.sub(S5.mul(h9)); + var g6 = v7.sub(S5.mul(p8)); + if (!c8 && i8.cmp(s7) < 0) + f9 = b6.neg(), d7 = h9, c8 = i8.neg(), t9 = n9; + else if (c8 && 2 == ++m7) + break; + b6 = i8, u8 = o9, o9 = i8, l8 = h9, h9 = n9, v7 = p8, p8 = g6; + } + a8 = i8.neg(), r10 = n9; + var A5 = c8.sqr().add(t9.sqr()); + return a8.sqr().add(r10.sqr()).cmp(A5) >= 0 && (a8 = f9, r10 = d7), c8.negative && (c8 = c8.neg(), t9 = t9.neg()), a8.negative && (a8 = a8.neg(), r10 = r10.neg()), [{ a: c8, b: t9 }, { a: a8, b: r10 }]; + }, A$8.prototype._endoSplit = function(e12) { + var f9 = this.endo.basis, d7 = f9[0], c8 = f9[1], t9 = c8.b.mul(e12).divRound(this.n), a8 = d7.b.neg().mul(e12).divRound(this.n), r10 = t9.mul(d7.a), b6 = a8.mul(c8.a), i8 = t9.mul(d7.b), n9 = a8.mul(c8.b); + return { k1: e12.sub(r10).sub(b6), k2: i8.add(n9).neg() }; + }, A$8.prototype.pointFromX = function(e12, f9) { + (e12 = new y$e(e12, 16)).red || (e12 = e12.toRed(this.red)); + var d7 = e12.redSqr().redMul(e12).redIAdd(e12.redMul(this.a)).redIAdd(this.b), c8 = d7.redSqrt(); + if (0 !== c8.redSqr().redSub(d7).cmp(this.zero)) + throw new Error("invalid point"); + var t9 = c8.fromRed().isOdd(); + return (f9 && !t9 || !f9 && t9) && (c8 = c8.redNeg()), this.point(e12, c8); + }, A$8.prototype.validate = function(e12) { + if (e12.inf) + return true; + var f9 = e12.x, d7 = e12.y, c8 = this.a.redMul(f9), t9 = f9.redSqr().redMul(f9).redIAdd(c8).redIAdd(this.b); + return 0 === d7.redSqr().redISub(t9).cmpn(0); + }, A$8.prototype._endoWnafMulAdd = function(e12, f9, d7) { + for (var c8 = this._endoWnafT1, t9 = this._endoWnafT2, a8 = 0; a8 < e12.length; a8++) { + var r10 = this._endoSplit(f9[a8]), b6 = e12[a8], i8 = b6._getBeta(); + r10.k1.negative && (r10.k1.ineg(), b6 = b6.neg(true)), r10.k2.negative && (r10.k2.ineg(), i8 = i8.neg(true)), c8[2 * a8] = b6, c8[2 * a8 + 1] = i8, t9[2 * a8] = r10.k1, t9[2 * a8 + 1] = r10.k2; + } + for (var n9 = this._wnafMulAdd(1, c8, t9, 2 * a8, d7), s7 = 0; s7 < 2 * a8; s7++) + c8[s7] = null, t9[s7] = null; + return n9; + }, m$f(I$8, S$9.BasePoint), A$8.prototype.point = function(e12, f9, d7) { + return new I$8(this, e12, f9, d7); + }, A$8.prototype.pointFromJSON = function(e12, f9) { + return I$8.fromJSON(this, e12, f9); + }, I$8.prototype._getBeta = function() { + if (this.curve.endo) { + var e12 = this.precomputed; + if (e12 && e12.beta) + return e12.beta; + var f9 = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (e12) { + var d7 = this.curve, c8 = function(e13) { + return d7.point(e13.x.redMul(d7.endo.beta), e13.y); + }; + e12.beta = f9, f9.precomputed = { beta: null, naf: e12.naf && { wnd: e12.naf.wnd, points: e12.naf.points.map(c8) }, doubles: e12.doubles && { step: e12.doubles.step, points: e12.doubles.points.map(c8) } }; + } + return f9; + } + }, I$8.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { doubles: this.precomputed.doubles && { step: this.precomputed.doubles.step, points: this.precomputed.doubles.points.slice(1) }, naf: this.precomputed.naf && { wnd: this.precomputed.naf.wnd, points: this.precomputed.naf.points.slice(1) } }] : [this.x, this.y]; + }, I$8.fromJSON = function(e12, f9, d7) { + "string" == typeof f9 && (f9 = JSON.parse(f9)); + var c8 = e12.point(f9[0], f9[1], d7); + if (!f9[2]) + return c8; + function t9(f10) { + return e12.point(f10[0], f10[1], d7); + } + var a8 = f9[2]; + return c8.precomputed = { beta: null, doubles: a8.doubles && { step: a8.doubles.step, points: [c8].concat(a8.doubles.points.map(t9)) }, naf: a8.naf && { wnd: a8.naf.wnd, points: [c8].concat(a8.naf.points.map(t9)) } }, c8; + }, I$8.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, I$8.prototype.isInfinity = function() { + return this.inf; + }, I$8.prototype.add = function(e12) { + if (this.inf) + return e12; + if (e12.inf) + return this; + if (this.eq(e12)) + return this.dbl(); + if (this.neg().eq(e12)) + return this.curve.point(null, null); + if (0 === this.x.cmp(e12.x)) + return this.curve.point(null, null); + var f9 = this.y.redSub(e12.y); + 0 !== f9.cmpn(0) && (f9 = f9.redMul(this.x.redSub(e12.x).redInvm())); + var d7 = f9.redSqr().redISub(this.x).redISub(e12.x), c8 = f9.redMul(this.x.redSub(d7)).redISub(this.y); + return this.curve.point(d7, c8); + }, I$8.prototype.dbl = function() { + if (this.inf) + return this; + var e12 = this.y.redAdd(this.y); + if (0 === e12.cmpn(0)) + return this.curve.point(null, null); + var f9 = this.curve.a, d7 = this.x.redSqr(), c8 = e12.redInvm(), t9 = d7.redAdd(d7).redIAdd(d7).redIAdd(f9).redMul(c8), a8 = t9.redSqr().redISub(this.x.redAdd(this.x)), r10 = t9.redMul(this.x.redSub(a8)).redISub(this.y); + return this.curve.point(a8, r10); + }, I$8.prototype.getX = function() { + return this.x.fromRed(); + }, I$8.prototype.getY = function() { + return this.y.fromRed(); + }, I$8.prototype.mul = function(e12) { + return e12 = new y$e(e12, 16), this.isInfinity() ? this : this._hasDoubles(e12) ? this.curve._fixedNafMul(this, e12) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [e12]) : this.curve._wnafMul(this, e12); + }, I$8.prototype.mulAdd = function(e12, f9, d7) { + var c8 = [this, f9], t9 = [e12, d7]; + return this.curve.endo ? this.curve._endoWnafMulAdd(c8, t9) : this.curve._wnafMulAdd(1, c8, t9, 2); + }, I$8.prototype.jmulAdd = function(e12, f9, d7) { + var c8 = [this, f9], t9 = [e12, d7]; + return this.curve.endo ? this.curve._endoWnafMulAdd(c8, t9, true) : this.curve._wnafMulAdd(1, c8, t9, 2, true); + }, I$8.prototype.eq = function(e12) { + return this === e12 || this.inf === e12.inf && (this.inf || 0 === this.x.cmp(e12.x) && 0 === this.y.cmp(e12.y)); + }, I$8.prototype.neg = function(e12) { + if (this.inf) + return this; + var f9 = this.curve.point(this.x, this.y.redNeg()); + if (e12 && this.precomputed) { + var d7 = this.precomputed, c8 = function(e13) { + return e13.neg(); + }; + f9.precomputed = { naf: d7.naf && { wnd: d7.naf.wnd, points: d7.naf.points.map(c8) }, doubles: d7.doubles && { step: d7.doubles.step, points: d7.doubles.points.map(c8) } }; + } + return f9; + }, I$8.prototype.toJ = function() { + return this.inf ? this.curve.jpoint(null, null, null) : this.curve.jpoint(this.x, this.y, this.curve.one); + }, m$f(w$e, S$9.BasePoint), A$8.prototype.jpoint = function(e12, f9, d7) { + return new w$e(this, e12, f9, d7); + }, w$e.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var e12 = this.z.redInvm(), f9 = e12.redSqr(), d7 = this.x.redMul(f9), c8 = this.y.redMul(f9).redMul(e12); + return this.curve.point(d7, c8); + }, w$e.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); + }, w$e.prototype.add = function(e12) { + if (this.isInfinity()) + return e12; + if (e12.isInfinity()) + return this; + var f9 = e12.z.redSqr(), d7 = this.z.redSqr(), c8 = this.x.redMul(f9), t9 = e12.x.redMul(d7), a8 = this.y.redMul(f9.redMul(e12.z)), r10 = e12.y.redMul(d7.redMul(this.z)), b6 = c8.redSub(t9), i8 = a8.redSub(r10); + if (0 === b6.cmpn(0)) + return 0 !== i8.cmpn(0) ? this.curve.jpoint(null, null, null) : this.dbl(); + var n9 = b6.redSqr(), s7 = n9.redMul(b6), o9 = c8.redMul(n9), u8 = i8.redSqr().redIAdd(s7).redISub(o9).redISub(o9), h9 = i8.redMul(o9.redISub(u8)).redISub(a8.redMul(s7)), p8 = this.z.redMul(e12.z).redMul(b6); + return this.curve.jpoint(u8, h9, p8); + }, w$e.prototype.mixedAdd = function(e12) { + if (this.isInfinity()) + return e12.toJ(); + if (e12.isInfinity()) + return this; + var f9 = this.z.redSqr(), d7 = this.x, c8 = e12.x.redMul(f9), t9 = this.y, a8 = e12.y.redMul(f9).redMul(this.z), r10 = d7.redSub(c8), b6 = t9.redSub(a8); + if (0 === r10.cmpn(0)) + return 0 !== b6.cmpn(0) ? this.curve.jpoint(null, null, null) : this.dbl(); + var i8 = r10.redSqr(), n9 = i8.redMul(r10), s7 = d7.redMul(i8), o9 = b6.redSqr().redIAdd(n9).redISub(s7).redISub(s7), u8 = b6.redMul(s7.redISub(o9)).redISub(t9.redMul(n9)), h9 = this.z.redMul(r10); + return this.curve.jpoint(o9, u8, h9); + }, w$e.prototype.dblp = function(e12) { + if (0 === e12) + return this; + if (this.isInfinity()) + return this; + if (!e12) + return this.dbl(); + if (this.curve.zeroA || this.curve.threeA) { + for (var f9 = this, d7 = 0; d7 < e12; d7++) + f9 = f9.dbl(); + return f9; + } + var c8 = this.curve.a, t9 = this.curve.tinv, a8 = this.x, r10 = this.y, b6 = this.z, i8 = b6.redSqr().redSqr(), n9 = r10.redAdd(r10); + for (d7 = 0; d7 < e12; d7++) { + var s7 = a8.redSqr(), o9 = n9.redSqr(), u8 = o9.redSqr(), h9 = s7.redAdd(s7).redIAdd(s7).redIAdd(c8.redMul(i8)), p8 = a8.redMul(o9), l8 = h9.redSqr().redISub(p8.redAdd(p8)), v7 = p8.redISub(l8), y7 = h9.redMul(v7); + y7 = y7.redIAdd(y7).redISub(u8); + var m7 = n9.redMul(b6); + d7 + 1 < e12 && (i8 = i8.redMul(u8)), a8 = l8, b6 = m7, n9 = y7; + } + return this.curve.jpoint(a8, n9.redMul(t9), b6); + }, w$e.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); + }, w$e.prototype._zeroDbl = function() { + var e12, f9, d7; + if (this.zOne) { + var c8 = this.x.redSqr(), t9 = this.y.redSqr(), a8 = t9.redSqr(), r10 = this.x.redAdd(t9).redSqr().redISub(c8).redISub(a8); + r10 = r10.redIAdd(r10); + var b6 = c8.redAdd(c8).redIAdd(c8), i8 = b6.redSqr().redISub(r10).redISub(r10), n9 = a8.redIAdd(a8); + n9 = (n9 = n9.redIAdd(n9)).redIAdd(n9), e12 = i8, f9 = b6.redMul(r10.redISub(i8)).redISub(n9), d7 = this.y.redAdd(this.y); + } else { + var s7 = this.x.redSqr(), o9 = this.y.redSqr(), u8 = o9.redSqr(), h9 = this.x.redAdd(o9).redSqr().redISub(s7).redISub(u8); + h9 = h9.redIAdd(h9); + var p8 = s7.redAdd(s7).redIAdd(s7), l8 = p8.redSqr(), v7 = u8.redIAdd(u8); + v7 = (v7 = v7.redIAdd(v7)).redIAdd(v7), e12 = l8.redISub(h9).redISub(h9), f9 = p8.redMul(h9.redISub(e12)).redISub(v7), d7 = (d7 = this.y.redMul(this.z)).redIAdd(d7); + } + return this.curve.jpoint(e12, f9, d7); + }, w$e.prototype._threeDbl = function() { + var e12, f9, d7; + if (this.zOne) { + var c8 = this.x.redSqr(), t9 = this.y.redSqr(), a8 = t9.redSqr(), r10 = this.x.redAdd(t9).redSqr().redISub(c8).redISub(a8); + r10 = r10.redIAdd(r10); + var b6 = c8.redAdd(c8).redIAdd(c8).redIAdd(this.curve.a), i8 = b6.redSqr().redISub(r10).redISub(r10); + e12 = i8; + var n9 = a8.redIAdd(a8); + n9 = (n9 = n9.redIAdd(n9)).redIAdd(n9), f9 = b6.redMul(r10.redISub(i8)).redISub(n9), d7 = this.y.redAdd(this.y); + } else { + var s7 = this.z.redSqr(), o9 = this.y.redSqr(), u8 = this.x.redMul(o9), h9 = this.x.redSub(s7).redMul(this.x.redAdd(s7)); + h9 = h9.redAdd(h9).redIAdd(h9); + var p8 = u8.redIAdd(u8), l8 = (p8 = p8.redIAdd(p8)).redAdd(p8); + e12 = h9.redSqr().redISub(l8), d7 = this.y.redAdd(this.z).redSqr().redISub(o9).redISub(s7); + var v7 = o9.redSqr(); + v7 = (v7 = (v7 = v7.redIAdd(v7)).redIAdd(v7)).redIAdd(v7), f9 = h9.redMul(p8.redISub(e12)).redISub(v7); + } + return this.curve.jpoint(e12, f9, d7); + }, w$e.prototype._dbl = function() { + var e12 = this.curve.a, f9 = this.x, d7 = this.y, c8 = this.z, t9 = c8.redSqr().redSqr(), a8 = f9.redSqr(), r10 = d7.redSqr(), b6 = a8.redAdd(a8).redIAdd(a8).redIAdd(e12.redMul(t9)), i8 = f9.redAdd(f9), n9 = (i8 = i8.redIAdd(i8)).redMul(r10), s7 = b6.redSqr().redISub(n9.redAdd(n9)), o9 = n9.redISub(s7), u8 = r10.redSqr(); + u8 = (u8 = (u8 = u8.redIAdd(u8)).redIAdd(u8)).redIAdd(u8); + var h9 = b6.redMul(o9).redISub(u8), p8 = d7.redAdd(d7).redMul(c8); + return this.curve.jpoint(s7, h9, p8); + }, w$e.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var e12 = this.x.redSqr(), f9 = this.y.redSqr(), d7 = this.z.redSqr(), c8 = f9.redSqr(), t9 = e12.redAdd(e12).redIAdd(e12), a8 = t9.redSqr(), r10 = this.x.redAdd(f9).redSqr().redISub(e12).redISub(c8), b6 = (r10 = (r10 = (r10 = r10.redIAdd(r10)).redAdd(r10).redIAdd(r10)).redISub(a8)).redSqr(), i8 = c8.redIAdd(c8); + i8 = (i8 = (i8 = i8.redIAdd(i8)).redIAdd(i8)).redIAdd(i8); + var n9 = t9.redIAdd(r10).redSqr().redISub(a8).redISub(b6).redISub(i8), s7 = f9.redMul(n9); + s7 = (s7 = s7.redIAdd(s7)).redIAdd(s7); + var o9 = this.x.redMul(b6).redISub(s7); + o9 = (o9 = o9.redIAdd(o9)).redIAdd(o9); + var u8 = this.y.redMul(n9.redMul(i8.redISub(n9)).redISub(r10.redMul(b6))); + u8 = (u8 = (u8 = u8.redIAdd(u8)).redIAdd(u8)).redIAdd(u8); + var h9 = this.z.redAdd(r10).redSqr().redISub(d7).redISub(b6); + return this.curve.jpoint(o9, u8, h9); + }, w$e.prototype.mul = function(e12, f9) { + return e12 = new y$e(e12, f9), this.curve._wnafMul(this, e12); + }, w$e.prototype.eq = function(e12) { + if ("affine" === e12.type) + return this.eq(e12.toJ()); + if (this === e12) + return true; + var f9 = this.z.redSqr(), d7 = e12.z.redSqr(); + if (0 !== this.x.redMul(d7).redISub(e12.x.redMul(f9)).cmpn(0)) + return false; + var c8 = f9.redMul(this.z), t9 = d7.redMul(e12.z); + return 0 === this.y.redMul(t9).redISub(e12.y.redMul(c8)).cmpn(0); + }, w$e.prototype.eqXToP = function(e12) { + var f9 = this.z.redSqr(), d7 = e12.toRed(this.curve.red).redMul(f9); + if (0 === this.x.cmp(d7)) + return true; + for (var c8 = e12.clone(), t9 = this.curve.redN.redMul(f9); ; ) { + if (c8.iadd(this.curve.n), c8.cmp(this.curve.p) >= 0) + return false; + if (d7.redIAdd(t9), 0 === this.x.cmp(d7)) + return true; + } + }, w$e.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, w$e.prototype.isInfinity = function() { + return 0 === this.z.cmpn(0); + }; + var M$6; + var x$6 = l$j; + var _$d = n$c; + var z$6 = t$2; + var q$4 = v$e; + var R$3 = n$i; + function P$4(e12) { + q$4.call(this, "mont", e12), this.a = new _$d(e12.a, 16).toRed(this.red), this.b = new _$d(e12.b, 16).toRed(this.red), this.i4 = new _$d(4).toRed(this.red).redInvm(), this.two = new _$d(2).toRed(this.red), this.a24 = this.i4.redMul(this.a.redAdd(this.two)); + } + function j$5(e12, f9, d7) { + q$4.BasePoint.call(this, e12, "projective"), null === f9 && null === d7 ? (this.x = this.curve.one, this.z = this.curve.zero) : (this.x = new _$d(f9, 16), this.z = new _$d(d7, 16), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.z.red || (this.z = this.z.toRed(this.curve.red))); + } + z$6(P$4, q$4), M$6 = P$4, P$4.prototype.validate = function(e12) { + var f9 = e12.normalize().x, d7 = f9.redSqr(), c8 = d7.redMul(f9).redAdd(d7.redMul(this.a)).redAdd(f9); + return 0 === c8.redSqrt().redSqr().cmp(c8); + }, z$6(j$5, q$4.BasePoint), P$4.prototype.decodePoint = function(e12, f9) { + return this.point(R$3.toArray(e12, f9), 1); + }, P$4.prototype.point = function(e12, f9) { + return new j$5(this, e12, f9); + }, P$4.prototype.pointFromJSON = function(e12) { + return j$5.fromJSON(this, e12); + }, j$5.prototype.precompute = function() { + }, j$5.prototype._encode = function() { + return this.getX().toArray("be", this.curve.p.byteLength()); + }, j$5.fromJSON = function(e12, f9) { + return new j$5(e12, f9[0], f9[1] || e12.one); + }, j$5.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, j$5.prototype.isInfinity = function() { + return 0 === this.z.cmpn(0); + }, j$5.prototype.dbl = function() { + var e12 = this.x.redAdd(this.z).redSqr(), f9 = this.x.redSub(this.z).redSqr(), d7 = e12.redSub(f9), c8 = e12.redMul(f9), t9 = d7.redMul(f9.redAdd(this.curve.a24.redMul(d7))); + return this.curve.point(c8, t9); + }, j$5.prototype.add = function() { + throw new Error("Not supported on Montgomery curve"); + }, j$5.prototype.diffAdd = function(e12, f9) { + var d7 = this.x.redAdd(this.z), c8 = this.x.redSub(this.z), t9 = e12.x.redAdd(e12.z), a8 = e12.x.redSub(e12.z).redMul(d7), r10 = t9.redMul(c8), b6 = f9.z.redMul(a8.redAdd(r10).redSqr()), i8 = f9.x.redMul(a8.redISub(r10).redSqr()); + return this.curve.point(b6, i8); + }, j$5.prototype.mul = function(e12) { + for (var f9 = e12.clone(), d7 = this, c8 = this.curve.point(null, null), t9 = []; 0 !== f9.cmpn(0); f9.iushrn(1)) + t9.push(f9.andln(1)); + for (var a8 = t9.length - 1; a8 >= 0; a8--) + 0 === t9[a8] ? (d7 = d7.diffAdd(c8, this), c8 = c8.dbl()) : (c8 = d7.diffAdd(c8, this), d7 = d7.dbl()); + return c8; + }, j$5.prototype.mulAdd = function() { + throw new Error("Not supported on Montgomery curve"); + }, j$5.prototype.jumlAdd = function() { + throw new Error("Not supported on Montgomery curve"); + }, j$5.prototype.eq = function(e12) { + return 0 === this.getX().cmp(e12.getX()); + }, j$5.prototype.normalize = function() { + return this.x = this.x.redMul(this.z.redInvm()), this.z = this.curve.one, this; + }, j$5.prototype.getX = function() { + return this.normalize(), this.x.fromRed(); + }; + var N$4; + var E$8 = M$6; + var k$b = n$c; + var O$5 = t$2; + var L$4 = v$e; + var B$8 = n$i.assert; + function F$5(e12) { + this.twisted = 1 != (0 | e12.a), this.mOneA = this.twisted && -1 == (0 | e12.a), this.extended = this.mOneA, L$4.call(this, "edwards", e12), this.a = new k$b(e12.a, 16).umod(this.red.m), this.a = this.a.toRed(this.red), this.c = new k$b(e12.c, 16).toRed(this.red), this.c2 = this.c.redSqr(), this.d = new k$b(e12.d, 16).toRed(this.red), this.dd = this.d.redAdd(this.d), B$8(!this.twisted || 0 === this.c.fromRed().cmpn(1)), this.oneC = 1 == (0 | e12.c); + } + function C$5(e12, f9, d7, c8, t9) { + L$4.BasePoint.call(this, e12, "projective"), null === f9 && null === d7 && null === c8 ? (this.x = this.curve.zero, this.y = this.curve.one, this.z = this.curve.one, this.t = this.curve.zero, this.zOne = true) : (this.x = new k$b(f9, 16), this.y = new k$b(d7, 16), this.z = c8 ? new k$b(c8, 16) : this.curve.one, this.t = t9 && new k$b(t9, 16), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.y.red || (this.y = this.y.toRed(this.curve.red)), this.z.red || (this.z = this.z.toRed(this.curve.red)), this.t && !this.t.red && (this.t = this.t.toRed(this.curve.red)), this.zOne = this.z === this.curve.one, this.curve.extended && !this.t && (this.t = this.x.redMul(this.y), this.zOne || (this.t = this.t.redMul(this.z.redInvm())))); + } + O$5(F$5, L$4), N$4 = F$5, F$5.prototype._mulA = function(e12) { + return this.mOneA ? e12.redNeg() : this.a.redMul(e12); + }, F$5.prototype._mulC = function(e12) { + return this.oneC ? e12 : this.c.redMul(e12); + }, F$5.prototype.jpoint = function(e12, f9, d7, c8) { + return this.point(e12, f9, d7, c8); + }, F$5.prototype.pointFromX = function(e12, f9) { + (e12 = new k$b(e12, 16)).red || (e12 = e12.toRed(this.red)); + var d7 = e12.redSqr(), c8 = this.c2.redSub(this.a.redMul(d7)), t9 = this.one.redSub(this.c2.redMul(this.d).redMul(d7)), a8 = c8.redMul(t9.redInvm()), r10 = a8.redSqrt(); + if (0 !== r10.redSqr().redSub(a8).cmp(this.zero)) + throw new Error("invalid point"); + var b6 = r10.fromRed().isOdd(); + return (f9 && !b6 || !f9 && b6) && (r10 = r10.redNeg()), this.point(e12, r10); + }, F$5.prototype.pointFromY = function(e12, f9) { + (e12 = new k$b(e12, 16)).red || (e12 = e12.toRed(this.red)); + var d7 = e12.redSqr(), c8 = d7.redSub(this.c2), t9 = d7.redMul(this.d).redMul(this.c2).redSub(this.a), a8 = c8.redMul(t9.redInvm()); + if (0 === a8.cmp(this.zero)) { + if (f9) + throw new Error("invalid point"); + return this.point(this.zero, e12); + } + var r10 = a8.redSqrt(); + if (0 !== r10.redSqr().redSub(a8).cmp(this.zero)) + throw new Error("invalid point"); + return r10.fromRed().isOdd() !== f9 && (r10 = r10.redNeg()), this.point(r10, e12); + }, F$5.prototype.validate = function(e12) { + if (e12.isInfinity()) + return true; + e12.normalize(); + var f9 = e12.x.redSqr(), d7 = e12.y.redSqr(), c8 = f9.redMul(this.a).redAdd(d7), t9 = this.c2.redMul(this.one.redAdd(this.d.redMul(f9).redMul(d7))); + return 0 === c8.cmp(t9); + }, O$5(C$5, L$4.BasePoint), F$5.prototype.pointFromJSON = function(e12) { + return C$5.fromJSON(this, e12); + }, F$5.prototype.point = function(e12, f9, d7, c8) { + return new C$5(this, e12, f9, d7, c8); + }, C$5.fromJSON = function(e12, f9) { + return new C$5(e12, f9[0], f9[1], f9[2]); + }, C$5.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, C$5.prototype.isInfinity = function() { + return 0 === this.x.cmpn(0) && (0 === this.y.cmp(this.z) || this.zOne && 0 === this.y.cmp(this.curve.c)); + }, C$5.prototype._extDbl = function() { + var e12 = this.x.redSqr(), f9 = this.y.redSqr(), d7 = this.z.redSqr(); + d7 = d7.redIAdd(d7); + var c8 = this.curve._mulA(e12), t9 = this.x.redAdd(this.y).redSqr().redISub(e12).redISub(f9), a8 = c8.redAdd(f9), r10 = a8.redSub(d7), b6 = c8.redSub(f9), i8 = t9.redMul(r10), n9 = a8.redMul(b6), s7 = t9.redMul(b6), o9 = r10.redMul(a8); + return this.curve.point(i8, n9, o9, s7); + }, C$5.prototype._projDbl = function() { + var e12, f9, d7, c8 = this.x.redAdd(this.y).redSqr(), t9 = this.x.redSqr(), a8 = this.y.redSqr(); + if (this.curve.twisted) { + var r10 = (n9 = this.curve._mulA(t9)).redAdd(a8); + if (this.zOne) + e12 = c8.redSub(t9).redSub(a8).redMul(r10.redSub(this.curve.two)), f9 = r10.redMul(n9.redSub(a8)), d7 = r10.redSqr().redSub(r10).redSub(r10); + else { + var b6 = this.z.redSqr(), i8 = r10.redSub(b6).redISub(b6); + e12 = c8.redSub(t9).redISub(a8).redMul(i8), f9 = r10.redMul(n9.redSub(a8)), d7 = r10.redMul(i8); + } + } else { + var n9 = t9.redAdd(a8); + b6 = this.curve._mulC(this.z).redSqr(), i8 = n9.redSub(b6).redSub(b6); + e12 = this.curve._mulC(c8.redISub(n9)).redMul(i8), f9 = this.curve._mulC(n9).redMul(t9.redISub(a8)), d7 = n9.redMul(i8); + } + return this.curve.point(e12, f9, d7); + }, C$5.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.extended ? this._extDbl() : this._projDbl(); + }, C$5.prototype._extAdd = function(e12) { + var f9 = this.y.redSub(this.x).redMul(e12.y.redSub(e12.x)), d7 = this.y.redAdd(this.x).redMul(e12.y.redAdd(e12.x)), c8 = this.t.redMul(this.curve.dd).redMul(e12.t), t9 = this.z.redMul(e12.z.redAdd(e12.z)), a8 = d7.redSub(f9), r10 = t9.redSub(c8), b6 = t9.redAdd(c8), i8 = d7.redAdd(f9), n9 = a8.redMul(r10), s7 = b6.redMul(i8), o9 = a8.redMul(i8), u8 = r10.redMul(b6); + return this.curve.point(n9, s7, u8, o9); + }, C$5.prototype._projAdd = function(e12) { + var f9, d7, c8 = this.z.redMul(e12.z), t9 = c8.redSqr(), a8 = this.x.redMul(e12.x), r10 = this.y.redMul(e12.y), b6 = this.curve.d.redMul(a8).redMul(r10), i8 = t9.redSub(b6), n9 = t9.redAdd(b6), s7 = this.x.redAdd(this.y).redMul(e12.x.redAdd(e12.y)).redISub(a8).redISub(r10), o9 = c8.redMul(i8).redMul(s7); + return this.curve.twisted ? (f9 = c8.redMul(n9).redMul(r10.redSub(this.curve._mulA(a8))), d7 = i8.redMul(n9)) : (f9 = c8.redMul(n9).redMul(r10.redSub(a8)), d7 = this.curve._mulC(i8).redMul(n9)), this.curve.point(o9, f9, d7); + }, C$5.prototype.add = function(e12) { + return this.isInfinity() ? e12 : e12.isInfinity() ? this : this.curve.extended ? this._extAdd(e12) : this._projAdd(e12); + }, C$5.prototype.mul = function(e12) { + return this._hasDoubles(e12) ? this.curve._fixedNafMul(this, e12) : this.curve._wnafMul(this, e12); + }, C$5.prototype.mulAdd = function(e12, f9, d7) { + return this.curve._wnafMulAdd(1, [this, f9], [e12, d7], 2, false); + }, C$5.prototype.jmulAdd = function(e12, f9, d7) { + return this.curve._wnafMulAdd(1, [this, f9], [e12, d7], 2, true); + }, C$5.prototype.normalize = function() { + if (this.zOne) + return this; + var e12 = this.z.redInvm(); + return this.x = this.x.redMul(e12), this.y = this.y.redMul(e12), this.t && (this.t = this.t.redMul(e12)), this.z = this.curve.one, this.zOne = true, this; + }, C$5.prototype.neg = function() { + return this.curve.point(this.x.redNeg(), this.y, this.z, this.t && this.t.redNeg()); + }, C$5.prototype.getX = function() { + return this.normalize(), this.x.fromRed(); + }, C$5.prototype.getY = function() { + return this.normalize(), this.y.fromRed(); + }, C$5.prototype.eq = function(e12) { + return this === e12 || 0 === this.getX().cmp(e12.getX()) && 0 === this.getY().cmp(e12.getY()); + }, C$5.prototype.eqXToP = function(e12) { + var f9 = e12.toRed(this.curve.red).redMul(this.z); + if (0 === this.x.cmp(f9)) + return true; + for (var d7 = e12.clone(), c8 = this.curve.redN.redMul(this.z); ; ) { + if (d7.iadd(this.curve.n), d7.cmp(this.curve.p) >= 0) + return false; + if (f9.redIAdd(c8), 0 === this.x.cmp(f9)) + return true; + } + }, C$5.prototype.toP = C$5.prototype.normalize, C$5.prototype.mixedAdd = C$5.prototype.add; + var T$5 = N$4; + var J$3 = {}; + var X$3 = J$3; + X$3.base = v$e, X$3.short = x$6, X$3.mont = E$8, X$3.edwards = T$5; + var D$4; + var Y$2 = { doubles: { step: 4, points: [["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a", "f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"], ["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508", "11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"], ["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739", "d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"], ["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640", "4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"], ["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c", "4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"], ["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda", "96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"], ["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa", "5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"], ["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0", "cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"], ["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d", "9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"], ["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d", "e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"], ["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1", "9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"], ["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0", "5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"], ["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047", "10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"], ["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862", "283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"], ["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7", "7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"], ["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd", "56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"], ["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83", "7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"], ["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a", "53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"], ["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8", "bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"], ["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d", "4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"], ["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725", "7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"], ["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754", "4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"], ["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c", "17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"], ["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6", "6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"], ["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39", "c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"], ["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891", "893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"], ["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b", "febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"], ["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03", "2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"], ["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d", "eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"], ["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070", "7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"], ["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4", "e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"], ["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da", "662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"], ["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11", "1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"], ["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e", "efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"], ["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41", "2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"], ["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef", "67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"], ["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8", "db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"], ["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d", "648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"], ["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96", "35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"], ["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd", "ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"], ["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5", "9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"], ["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266", "40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"], ["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71", "34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"], ["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac", "c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"], ["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751", "1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"], ["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e", "493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"], ["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241", "c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"], ["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3", "be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"], ["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f", "4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"], ["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19", "aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"], ["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be", "b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"], ["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9", "6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"], ["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2", "8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"], ["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13", "7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"], ["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c", "ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"], ["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba", "2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"], ["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151", "e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"], ["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073", "d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"], ["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458", "38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"], ["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b", "69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"], ["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366", "d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"], ["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa", "40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"], ["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0", "620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"], ["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787", "7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"], ["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e", "ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]] }, naf: { wnd: 7, points: [["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9", "388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"], ["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4", "d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"], ["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc", "6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"], ["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe", "cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"], ["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb", "d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"], ["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8", "ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"], ["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e", "581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"], ["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34", "4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"], ["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c", "85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"], ["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5", "321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"], ["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f", "2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"], ["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714", "73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"], ["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729", "a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"], ["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db", "2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"], ["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4", "e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"], ["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5", "b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"], ["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479", "2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"], ["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d", "80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"], ["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f", "1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"], ["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb", "d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"], ["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9", "eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"], ["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963", "758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"], ["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74", "958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"], ["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530", "e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"], ["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b", "5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"], ["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247", "cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"], ["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1", "cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"], ["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120", "4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"], ["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435", "91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"], ["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18", "673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"], ["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8", "59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"], ["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb", "3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"], ["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f", "55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"], ["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143", "efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"], ["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba", "e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"], ["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45", "f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"], ["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a", "744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"], ["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e", "c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"], ["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8", "e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"], ["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c", "30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"], ["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519", "e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"], ["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab", "100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"], ["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca", "ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"], ["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf", "8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"], ["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610", "68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"], ["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4", "f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"], ["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c", "d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"], ["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940", "edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"], ["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980", "a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"], ["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3", "66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"], ["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf", "9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"], ["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63", "4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"], ["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448", "fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"], ["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf", "5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"], ["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5", "8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"], ["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6", "8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"], ["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5", "5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"], ["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99", "f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"], ["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51", "f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"], ["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5", "42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"], ["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5", "204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"], ["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997", "4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"], ["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881", "73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"], ["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5", "39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"], ["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66", "d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"], ["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726", "ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"], ["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede", "6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"], ["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94", "60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"], ["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31", "3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"], ["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51", "b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"], ["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252", "ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"], ["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5", "cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"], ["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b", "6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"], ["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4", "322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"], ["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f", "6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"], ["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889", "2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"], ["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246", "b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"], ["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984", "998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"], ["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a", "b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"], ["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030", "bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"], ["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197", "6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"], ["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593", "c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"], ["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef", "21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"], ["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38", "60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"], ["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a", "49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"], ["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111", "5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"], ["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502", "7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"], ["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea", "be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"], ["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26", "8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"], ["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986", "39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"], ["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e", "62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"], ["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4", "25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"], ["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda", "ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"], ["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859", "cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"], ["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f", "f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"], ["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c", "6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"], ["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942", "fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"], ["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a", "1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"], ["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80", "5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"], ["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d", "438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"], ["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1", "cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"], ["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63", "c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"], ["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352", "6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"], ["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193", "ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"], ["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00", "9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"], ["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58", "ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"], ["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7", "d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"], ["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8", "c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"], ["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e", "67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"], ["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d", "cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"], ["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b", "299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"], ["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f", "f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"], ["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6", "462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"], ["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297", "62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"], ["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a", "7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"], ["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c", "ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"], ["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52", "4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"], ["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb", "bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"], ["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065", "bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"], ["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917", "603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"], ["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9", "cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"], ["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3", "553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"], ["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57", "712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"], ["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66", "ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"], ["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8", "9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"], ["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721", "9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"], ["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180", "4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]] } }; + var W$3 = {}; + var K$4 = W$3; + var U$6 = X$2; + var G$3 = J$3; + var H$5 = n$i.assert; + function Q$2(e12) { + "short" === e12.type ? this.curve = new G$3.short(e12) : "edwards" === e12.type ? this.curve = new G$3.edwards(e12) : this.curve = new G$3.mont(e12), this.g = this.curve.g, this.n = this.curve.n, this.hash = e12.hash, H$5(this.g.validate(), "Invalid curve"), H$5(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + function V$3(e12, f9) { + Object.defineProperty(K$4, e12, { configurable: true, enumerable: true, get: function() { + var d7 = new Q$2(f9); + return Object.defineProperty(K$4, e12, { configurable: true, enumerable: true, value: d7 }), d7; + } }); + } + K$4.PresetCurve = Q$2, V$3("p192", { type: "short", prime: "p192", p: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff", a: "ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc", b: "64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1", n: "ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831", hash: U$6.sha256, gRed: false, g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] }), V$3("p224", { type: "short", prime: "p224", p: "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001", a: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe", b: "b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4", n: "ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d", hash: U$6.sha256, gRed: false, g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] }), V$3("p256", { type: "short", prime: null, p: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff", a: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc", b: "5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b", n: "ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551", hash: U$6.sha256, gRed: false, g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] }), V$3("p384", { type: "short", prime: null, p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff", a: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc", b: "b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef", n: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973", hash: U$6.sha384, gRed: false, g: ["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7", "3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"] }), V$3("p521", { type: "short", prime: null, p: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff", a: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc", b: "00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00", n: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409", hash: U$6.sha512, gRed: false, g: ["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66", "00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"] }), V$3("curve25519", { type: "mont", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "76d06", b: "1", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: U$6.sha256, gRed: false, g: ["9"] }), V$3("ed25519", { type: "edwards", prime: "p25519", p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "-1", c: "1", d: "52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: U$6.sha256, gRed: false, g: ["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", "6666666666666666666666666666666666666666666666666666666666666658"] }); + try { + D$4 = Y$2; + } catch (e12) { + D$4 = void 0; + } + V$3("secp256k1", { type: "short", prime: "k256", p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f", a: "0", b: "7", n: "ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141", h: "1", hash: U$6.sha256, beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [{ a: "3086d221a7d46bcde86c90e49284eb15", b: "-e4437ed6010e88286f547fa90abfe4c3" }, { a: "114ca50f7a8e2f3f657c1108d9d44cfd8", b: "3086d221a7d46bcde86c90e49284eb15" }], gRed: false, g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", D$4] }); + var Z$1; + var $$1 = n$c; + var ee2 = n$i.assert; + function fe2(e12, f9) { + this.ec = e12, this.priv = null, this.pub = null, f9.priv && this._importPrivate(f9.priv, f9.privEnc), f9.pub && this._importPublic(f9.pub, f9.pubEnc); + } + Z$1 = fe2, fe2.fromPublic = function(e12, f9, d7) { + return f9 instanceof fe2 ? f9 : new fe2(e12, { pub: f9, pubEnc: d7 }); + }, fe2.fromPrivate = function(e12, f9, d7) { + return f9 instanceof fe2 ? f9 : new fe2(e12, { priv: f9, privEnc: d7 }); + }, fe2.prototype.validate = function() { + var e12 = this.getPublic(); + return e12.isInfinity() ? { result: false, reason: "Invalid public key" } : e12.validate() ? e12.mul(this.ec.curve.n).isInfinity() ? { result: true, reason: null } : { result: false, reason: "Public key * N != O" } : { result: false, reason: "Public key is not a point" }; + }, fe2.prototype.getPublic = function(e12, f9) { + return "string" == typeof e12 && (f9 = e12, e12 = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), f9 ? this.pub.encode(f9, e12) : this.pub; + }, fe2.prototype.getPrivate = function(e12) { + return "hex" === e12 ? this.priv.toString(16, 2) : this.priv; + }, fe2.prototype._importPrivate = function(e12, f9) { + this.priv = new $$1(e12, f9 || 16), this.priv = this.priv.umod(this.ec.curve.n); + }, fe2.prototype._importPublic = function(e12, f9) { + if (e12.x || e12.y) + return "mont" === this.ec.curve.type ? ee2(e12.x, "Need x coordinate") : "short" !== this.ec.curve.type && "edwards" !== this.ec.curve.type || ee2(e12.x && e12.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(e12.x, e12.y), void 0; + this.pub = this.ec.curve.decodePoint(e12, f9); + }, fe2.prototype.derive = function(e12) { + return e12.mul(this.priv).getX(); + }, fe2.prototype.sign = function(e12, f9, d7) { + return this.ec.sign(e12, this, f9, d7); + }, fe2.prototype.verify = function(e12, f9) { + return this.ec.verify(e12, f9, this); + }, fe2.prototype.inspect = function() { + return ""; + }; + var de2; + var ce2 = Z$1; + var te2 = n$c; + var ae2 = a$l; + var re2 = W$3; + var be2 = f$i; + var ie = n$i.assert; + var ne2 = ce2; + var se2 = d$e; + function oe2(e12) { + if (!(this instanceof oe2)) + return new oe2(e12); + "string" == typeof e12 && (ie(re2.hasOwnProperty(e12), "Unknown curve " + e12), e12 = re2[e12]), e12 instanceof re2.PresetCurve && (e12 = { curve: e12 }), this.curve = e12.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = e12.curve.g, this.g.precompute(e12.curve.n.bitLength() + 1), this.hash = e12.hash || e12.curve.hash; + } + de2 = oe2, oe2.prototype.keyPair = function(e12) { + return new ne2(this, e12); + }, oe2.prototype.keyFromPrivate = function(e12, f9) { + return ne2.fromPrivate(this, e12, f9); + }, oe2.prototype.keyFromPublic = function(e12, f9) { + return ne2.fromPublic(this, e12, f9); + }, oe2.prototype.genKeyPair = function(e12) { + e12 || (e12 = {}); + for (var f9 = new ae2({ hash: this.hash, pers: e12.pers, persEnc: e12.persEnc || "utf8", entropy: e12.entropy || be2(this.hash.hmacStrength), entropyEnc: e12.entropy && e12.entropyEnc || "utf8", nonce: this.n.toArray() }), d7 = this.n.byteLength(), c8 = this.n.sub(new te2(2)); ; ) { + var t9 = new te2(f9.generate(d7)); + if (!(t9.cmp(c8) > 0)) + return t9.iaddn(1), this.keyFromPrivate(t9); + } + }, oe2.prototype._truncateToN = function(e12, f9) { + var d7 = 8 * e12.byteLength() - this.n.bitLength(); + return d7 > 0 && (e12 = e12.ushrn(d7)), !f9 && e12.cmp(this.n) >= 0 ? e12.sub(this.n) : e12; + }, oe2.prototype.sign = function(e12, f9, d7, c8) { + "object" == typeof d7 && (c8 = d7, d7 = null), c8 || (c8 = {}), f9 = this.keyFromPrivate(f9, d7), e12 = this._truncateToN(new te2(e12, 16)); + for (var t9 = this.n.byteLength(), a8 = f9.getPrivate().toArray("be", t9), r10 = e12.toArray("be", t9), b6 = new ae2({ hash: this.hash, entropy: a8, nonce: r10, pers: c8.pers, persEnc: c8.persEnc || "utf8" }), i8 = this.n.sub(new te2(1)), n9 = 0; ; n9++) { + var s7 = c8.k ? c8.k(n9) : new te2(b6.generate(this.n.byteLength())); + if (!((s7 = this._truncateToN(s7, true)).cmpn(1) <= 0 || s7.cmp(i8) >= 0)) { + var o9 = this.g.mul(s7); + if (!o9.isInfinity()) { + var u8 = o9.getX(), h9 = u8.umod(this.n); + if (0 !== h9.cmpn(0)) { + var p8 = s7.invm(this.n).mul(h9.mul(f9.getPrivate()).iadd(e12)); + if (0 !== (p8 = p8.umod(this.n)).cmpn(0)) { + var l8 = (o9.getY().isOdd() ? 1 : 0) | (0 !== u8.cmp(h9) ? 2 : 0); + return c8.canonical && p8.cmp(this.nh) > 0 && (p8 = this.n.sub(p8), l8 ^= 1), new se2({ r: h9, s: p8, recoveryParam: l8 }); + } + } + } + } + } + }, oe2.prototype.verify = function(e12, f9, d7, c8) { + e12 = this._truncateToN(new te2(e12, 16)), d7 = this.keyFromPublic(d7, c8); + var t9 = (f9 = new se2(f9, "hex")).r, a8 = f9.s; + if (t9.cmpn(1) < 0 || t9.cmp(this.n) >= 0) + return false; + if (a8.cmpn(1) < 0 || a8.cmp(this.n) >= 0) + return false; + var r10, b6 = a8.invm(this.n), i8 = b6.mul(e12).umod(this.n), n9 = b6.mul(t9).umod(this.n); + return this.curve._maxwellTrick ? !(r10 = this.g.jmulAdd(i8, d7.getPublic(), n9)).isInfinity() && r10.eqXToP(t9) : !(r10 = this.g.mulAdd(i8, d7.getPublic(), n9)).isInfinity() && 0 === r10.getX().umod(this.n).cmp(t9); + }, oe2.prototype.recoverPubKey = function(e12, f9, d7, c8) { + ie((3 & d7) === d7, "The recovery param is more than two bits"), f9 = new se2(f9, c8); + var t9 = this.n, a8 = new te2(e12), r10 = f9.r, b6 = f9.s, i8 = 1 & d7, n9 = d7 >> 1; + if (r10.cmp(this.curve.p.umod(this.curve.n)) >= 0 && n9) + throw new Error("Unable to find sencond key candinate"); + r10 = n9 ? this.curve.pointFromX(r10.add(this.curve.n), i8) : this.curve.pointFromX(r10, i8); + var s7 = f9.r.invm(t9), o9 = t9.sub(a8).mul(s7).umod(t9), u8 = b6.mul(s7).umod(t9); + return this.g.mulAdd(o9, r10, u8); + }, oe2.prototype.getKeyRecoveryParam = function(e12, f9, d7, c8) { + if (null !== (f9 = new se2(f9, c8)).recoveryParam) + return f9.recoveryParam; + for (var t9 = 0; t9 < 4; t9++) { + var a8; + try { + a8 = this.recoverPubKey(e12, f9, t9); + } catch (e13) { + continue; + } + if (a8.eq(d7)) + return t9; + } + throw new Error("Unable to find valid recovery factor"); + }; + var ue2 = de2; + var he2 = n$i; + var pe2 = he2.assert; + var le2 = he2.parseBytes; + var ve2 = he2.cachedProperty; + function ye2(e12, f9) { + this.eddsa = e12, this._secret = le2(f9.secret), e12.isPoint(f9.pub) ? this._pub = f9.pub : this._pubBytes = le2(f9.pub); + } + ye2.fromPublic = function(e12, f9) { + return f9 instanceof ye2 ? f9 : new ye2(e12, { pub: f9 }); + }, ye2.fromSecret = function(e12, f9) { + return f9 instanceof ye2 ? f9 : new ye2(e12, { secret: f9 }); + }, ye2.prototype.secret = function() { + return this._secret; + }, ve2(ye2, "pubBytes", function() { + return this.eddsa.encodePoint(this.pub()); + }), ve2(ye2, "pub", function() { + return this._pubBytes ? this.eddsa.decodePoint(this._pubBytes) : this.eddsa.g.mul(this.priv()); + }), ve2(ye2, "privBytes", function() { + var e12 = this.eddsa, f9 = this.hash(), d7 = e12.encodingLength - 1, c8 = f9.slice(0, e12.encodingLength); + return c8[0] &= 248, c8[d7] &= 127, c8[d7] |= 64, c8; + }), ve2(ye2, "priv", function() { + return this.eddsa.decodeInt(this.privBytes()); + }), ve2(ye2, "hash", function() { + return this.eddsa.hash().update(this.secret()).digest(); + }), ve2(ye2, "messagePrefix", function() { + return this.hash().slice(this.eddsa.encodingLength); + }), ye2.prototype.sign = function(e12) { + return pe2(this._secret, "KeyPair can only verify"), this.eddsa.sign(e12, this); + }, ye2.prototype.verify = function(e12, f9) { + return this.eddsa.verify(e12, f9, this); + }, ye2.prototype.getSecret = function(e12) { + return pe2(this._secret, "KeyPair is public only"), he2.encode(this.secret(), e12); + }, ye2.prototype.getPublic = function(e12) { + return he2.encode(this.pubBytes(), e12); + }; + var me2 = ye2; + var Se2 = n$c; + var ge2 = n$i; + var Ae2 = ge2.assert; + var Ie = ge2.cachedProperty; + var we2 = ge2.parseBytes; + function Me(e12, f9) { + this.eddsa = e12, "object" != typeof f9 && (f9 = we2(f9)), Array.isArray(f9) && (f9 = { R: f9.slice(0, e12.encodingLength), S: f9.slice(e12.encodingLength) }), Ae2(f9.R && f9.S, "Signature without R or S"), e12.isPoint(f9.R) && (this._R = f9.R), f9.S instanceof Se2 && (this._S = f9.S), this._Rencoded = Array.isArray(f9.R) ? f9.R : f9.Rencoded, this._Sencoded = Array.isArray(f9.S) ? f9.S : f9.Sencoded; + } + Ie(Me, "S", function() { + return this.eddsa.decodeInt(this.Sencoded()); + }), Ie(Me, "R", function() { + return this.eddsa.decodePoint(this.Rencoded()); + }), Ie(Me, "Rencoded", function() { + return this.eddsa.encodePoint(this.R()); + }), Ie(Me, "Sencoded", function() { + return this.eddsa.encodeInt(this.S()); + }), Me.prototype.toBytes = function() { + return this.Rencoded().concat(this.Sencoded()); + }, Me.prototype.toHex = function() { + return ge2.encode(this.toBytes(), "hex").toUpperCase(); + }; + var xe; + var _e = Me; + var ze = X$2; + var qe = W$3; + var Re = n$i; + var Pe = Re.assert; + var je2 = Re.parseBytes; + var Ne = me2; + var Ee2 = _e; + function ke2(e12) { + if (Pe("ed25519" === e12, "only tested with ed25519 so far"), !(this instanceof ke2)) + return new ke2(e12); + e12 = qe[e12].curve; + this.curve = e12, this.g = e12.g, this.g.precompute(e12.n.bitLength() + 1), this.pointClass = e12.point().constructor, this.encodingLength = Math.ceil(e12.n.bitLength() / 8), this.hash = ze.sha512; + } + xe = ke2, ke2.prototype.sign = function(e12, f9) { + e12 = je2(e12); + var d7 = this.keyFromSecret(f9), c8 = this.hashInt(d7.messagePrefix(), e12), t9 = this.g.mul(c8), a8 = this.encodePoint(t9), r10 = this.hashInt(a8, d7.pubBytes(), e12).mul(d7.priv()), b6 = c8.add(r10).umod(this.curve.n); + return this.makeSignature({ R: t9, S: b6, Rencoded: a8 }); + }, ke2.prototype.verify = function(e12, f9, d7) { + e12 = je2(e12), f9 = this.makeSignature(f9); + var c8 = this.keyFromPublic(d7), t9 = this.hashInt(f9.Rencoded(), c8.pubBytes(), e12), a8 = this.g.mul(f9.S()); + return f9.R().add(c8.pub().mul(t9)).eq(a8); + }, ke2.prototype.hashInt = function() { + for (var e12 = this.hash(), f9 = 0; f9 < arguments.length; f9++) + e12.update(arguments[f9]); + return Re.intFromLE(e12.digest()).umod(this.curve.n); + }, ke2.prototype.keyFromPublic = function(e12) { + return Ne.fromPublic(this, e12); + }, ke2.prototype.keyFromSecret = function(e12) { + return Ne.fromSecret(this, e12); + }, ke2.prototype.makeSignature = function(e12) { + return e12 instanceof Ee2 ? e12 : new Ee2(this, e12); + }, ke2.prototype.encodePoint = function(e12) { + var f9 = e12.getY().toArray("le", this.encodingLength); + return f9[this.encodingLength - 1] |= e12.getX().isOdd() ? 128 : 0, f9; + }, ke2.prototype.decodePoint = function(e12) { + var f9 = (e12 = Re.parseBytes(e12)).length - 1, d7 = e12.slice(0, f9).concat(-129 & e12[f9]), c8 = 0 != (128 & e12[f9]), t9 = Re.intFromLE(d7); + return this.curve.pointFromY(t9, c8); + }, ke2.prototype.encodeInt = function(e12) { + return e12.toArray("le", this.encodingLength); + }, ke2.prototype.decodeInt = function(e12) { + return Re.intFromLE(e12); + }, ke2.prototype.isPoint = function(e12) { + return e12 instanceof this.pointClass; + }; + var Oe2 = xe; + var Le = {}; + var Be2 = Le; + Be2.version = ["elliptic", "6.5.2", "EC cryptography", "lib/elliptic.js", ["lib"], { jscs: "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", jshint: "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", lint: "npm run jscs && npm run jshint", unit: "istanbul test _mocha --reporter=spec test/index.js", test: "npm run lint && npm run unit", version: "grunt dist && git add dist/" }, { type: "git", url: "git@github.com:indutny/elliptic" }, ["EC", "Elliptic", "curve", "Cryptography"], "Fedor Indutny ", "MIT", { url: "https://github.com/indutny/elliptic/issues" }, "https://github.com/indutny/elliptic", { brfs: "^1.4.3", coveralls: "^3.0.8", grunt: "^1.0.4", "grunt-browserify": "^5.0.0", "grunt-cli": "^1.2.0", "grunt-contrib-connect": "^1.0.0", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-uglify": "^1.0.1", "grunt-mocha-istanbul": "^3.0.1", "grunt-saucelabs": "^9.0.1", istanbul: "^0.4.2", jscs: "^3.0.7", jshint: "^2.10.3", mocha: "^6.2.2" }, { "bn.js": "^4.4.0", brorand: "^1.0.1", "hash.js": "^1.0.0", "hmac-drbg": "^1.0.0", inherits: "^2.0.1", "minimalistic-assert": "^1.0.0", "minimalistic-crypto-utils": "^1.0.0" }][1], Be2.utils = n$i, Be2.rand = f$i, Be2.curve = J$3, Be2.curves = W$3, Be2.ec = ue2, Be2.eddsa = Oe2; + var o$n = {}; + var s$j = false; + var a$m = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var u$j = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var c$i = {}; + var f$n = t$2; + function l$k(e12) { + (this || u$j)._reporterState = { obj: null, path: [], options: e12 || {}, errors: [] }; + } + function h$g(e12, t9) { + (this || u$j).path = e12, this.rethrow(t9); + } + c$i.Reporter = l$k, l$k.prototype.isError = function(e12) { + return e12 instanceof h$g; + }, l$k.prototype.save = function() { + var e12 = (this || u$j)._reporterState; + return { obj: e12.obj, pathLen: e12.path.length }; + }, l$k.prototype.restore = function(e12) { + var t9 = (this || u$j)._reporterState; + t9.obj = e12.obj, t9.path = t9.path.slice(0, e12.pathLen); + }, l$k.prototype.enterKey = function(e12) { + return (this || u$j)._reporterState.path.push(e12); + }, l$k.prototype.exitKey = function(e12) { + var t9 = (this || u$j)._reporterState; + t9.path = t9.path.slice(0, e12 - 1); + }, l$k.prototype.leaveKey = function(e12, t9, r10) { + var n9 = (this || u$j)._reporterState; + this.exitKey(e12), null !== n9.obj && (n9.obj[t9] = r10); + }, l$k.prototype.path = function() { + return (this || u$j)._reporterState.path.join("/"); + }, l$k.prototype.enterObject = function() { + var e12 = (this || u$j)._reporterState, t9 = e12.obj; + return e12.obj = {}, t9; + }, l$k.prototype.leaveObject = function(e12) { + var t9 = (this || u$j)._reporterState, r10 = t9.obj; + return t9.obj = e12, r10; + }, l$k.prototype.error = function(e12) { + var t9, r10 = (this || u$j)._reporterState, n9 = e12 instanceof h$g; + if (t9 = n9 ? e12 : new h$g(r10.path.map(function(e13) { + return "[" + JSON.stringify(e13) + "]"; + }).join(""), e12.message || e12, e12.stack), !r10.options.partial) + throw t9; + return n9 || r10.errors.push(t9), t9; + }, l$k.prototype.wrapResult = function(e12) { + var t9 = (this || u$j)._reporterState; + return t9.options.partial ? { result: this.isError(e12) ? null : e12, errors: t9.errors } : e12; + }, f$n(h$g, Error), h$g.prototype.rethrow = function(e12) { + if ((this || u$j).message = e12 + " at: " + ((this || u$j).path || "(shallow)"), Error.captureStackTrace && Error.captureStackTrace(this || u$j, h$g), !(this || u$j).stack) + try { + throw new Error((this || u$j).message); + } catch (e13) { + (this || u$j).stack = e13.stack; + } + return this || u$j; + }; + var p$k = {}; + var d$i = false; + var g$e = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + function y$f() { + if (d$i) + return p$k; + d$i = true; + var e12 = t$2, r10 = E$9().Reporter, i8 = e$1$1.Buffer; + function o9(e13, t9) { + if (r10.call(this || g$e, t9), !i8.isBuffer(e13)) + return this.error("Input not Buffer"), void 0; + (this || g$e).base = e13, (this || g$e).offset = 0, (this || g$e).length = e13.length; + } + function s7(e13, t9) { + if (Array.isArray(e13)) + (this || g$e).length = 0, (this || g$e).value = e13.map(function(e14) { + return e14 instanceof s7 || (e14 = new s7(e14, t9)), (this || g$e).length += e14.length, e14; + }, this || g$e); + else if ("number" == typeof e13) { + if (!(0 <= e13 && e13 <= 255)) + return t9.error("non-byte EncoderBuffer value"); + (this || g$e).value = e13, (this || g$e).length = 1; + } else if ("string" == typeof e13) + (this || g$e).value = e13, (this || g$e).length = i8.byteLength(e13); + else { + if (!i8.isBuffer(e13)) + return t9.error("Unsupported type: " + typeof e13); + (this || g$e).value = e13, (this || g$e).length = e13.length; + } + } + return e12(o9, r10), p$k.DecoderBuffer = o9, o9.prototype.save = function() { + return { offset: (this || g$e).offset, reporter: r10.prototype.save.call(this || g$e) }; + }, o9.prototype.restore = function(e13) { + var t9 = new o9((this || g$e).base); + return t9.offset = e13.offset, t9.length = (this || g$e).offset, (this || g$e).offset = e13.offset, r10.prototype.restore.call(this || g$e, e13.reporter), t9; + }, o9.prototype.isEmpty = function() { + return (this || g$e).offset === (this || g$e).length; + }, o9.prototype.readUInt8 = function(e13) { + return (this || g$e).offset + 1 <= (this || g$e).length ? (this || g$e).base.readUInt8((this || g$e).offset++, true) : this.error(e13 || "DecoderBuffer overrun"); + }, o9.prototype.skip = function(e13, t9) { + if (!((this || g$e).offset + e13 <= (this || g$e).length)) + return this.error(t9 || "DecoderBuffer overrun"); + var r11 = new o9((this || g$e).base); + return r11._reporterState = (this || g$e)._reporterState, r11.offset = (this || g$e).offset, r11.length = (this || g$e).offset + e13, (this || g$e).offset += e13, r11; + }, o9.prototype.raw = function(e13) { + return (this || g$e).base.slice(e13 ? e13.offset : (this || g$e).offset, (this || g$e).length); + }, p$k.EncoderBuffer = s7, s7.prototype.join = function(e13, t9) { + return e13 || (e13 = new i8((this || g$e).length)), t9 || (t9 = 0), 0 === (this || g$e).length || (Array.isArray((this || g$e).value) ? (this || g$e).value.forEach(function(r11) { + r11.join(e13, t9), t9 += r11.length; + }) : ("number" == typeof (this || g$e).value ? e13[t9] = (this || g$e).value : "string" == typeof (this || g$e).value ? e13.write((this || g$e).value, t9) : i8.isBuffer((this || g$e).value) && (this || g$e).value.copy(e13, t9), t9 += (this || g$e).length)), e13; + }, p$k; + } + var _$e = {}; + var v$f = false; + var b$c = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var m$g = {}; + var S$a = false; + function E$9() { + if (S$a) + return m$g; + S$a = true; + var e12 = m$g; + return e12.Reporter = c$i.Reporter, e12.DecoderBuffer = y$f().DecoderBuffer, e12.EncoderBuffer = y$f().EncoderBuffer, e12.Node = function() { + if (v$f) + return _$e; + v$f = true; + var e13 = E$9().Reporter, t9 = E$9().EncoderBuffer, r10 = E$9().DecoderBuffer, n9 = o$7, o9 = ["seq", "seqof", "set", "setof", "objid", "bool", "gentime", "utctime", "null_", "enum", "int", "objDesc", "bitstr", "bmpstr", "charstr", "genstr", "graphstr", "ia5str", "iso646str", "numstr", "octstr", "printstr", "t61str", "unistr", "utf8str", "videostr"], s7 = ["key", "obj", "use", "optional", "explicit", "implicit", "def", "choice", "any", "contains"].concat(o9); + function a8(e14, t10) { + var r11 = {}; + (this || b$c)._baseState = r11, r11.enc = e14, r11.parent = t10 || null, r11.children = null, r11.tag = null, r11.args = null, r11.reverseArgs = null, r11.choice = null, r11.optional = false, r11.any = false, r11.obj = false, r11.use = null, r11.useDecoder = null, r11.key = null, r11.default = null, r11.explicit = null, r11.implicit = null, r11.contains = null, r11.parent || (r11.children = [], this._wrap()); + } + _$e = a8; + var u8 = ["enc", "parent", "children", "tag", "args", "reverseArgs", "choice", "optional", "any", "obj", "use", "alteredUse", "key", "default", "explicit", "implicit", "contains"]; + return a8.prototype.clone = function() { + var e14 = (this || b$c)._baseState, t10 = {}; + u8.forEach(function(r12) { + t10[r12] = e14[r12]; + }); + var r11 = new (this || b$c).constructor(t10.parent); + return r11._baseState = t10, r11; + }, a8.prototype._wrap = function() { + var e14 = (this || b$c)._baseState; + s7.forEach(function(t10) { + (this || b$c)[t10] = function() { + var r11 = new (this || b$c).constructor(this || b$c); + return e14.children.push(r11), r11[t10].apply(r11, arguments); + }; + }, this || b$c); + }, a8.prototype._init = function(e14) { + var t10 = (this || b$c)._baseState; + n9(null === t10.parent), e14.call(this || b$c), t10.children = t10.children.filter(function(e15) { + return e15._baseState.parent === (this || b$c); + }, this || b$c), n9.equal(t10.children.length, 1, "Root node can have only one child"); + }, a8.prototype._useArgs = function(e14) { + var t10 = (this || b$c)._baseState, r11 = e14.filter(function(e15) { + return e15 instanceof (this || b$c).constructor; + }, this || b$c); + e14 = e14.filter(function(e15) { + return !(e15 instanceof (this || b$c).constructor); + }, this || b$c), 0 !== r11.length && (n9(null === t10.children), t10.children = r11, r11.forEach(function(e15) { + e15._baseState.parent = this || b$c; + }, this || b$c)), 0 !== e14.length && (n9(null === t10.args), t10.args = e14, t10.reverseArgs = e14.map(function(e15) { + if ("object" != typeof e15 || e15.constructor !== Object) + return e15; + var t11 = {}; + return Object.keys(e15).forEach(function(r12) { + r12 == (0 | r12) && (r12 |= 0); + var n10 = e15[r12]; + t11[n10] = r12; + }), t11; + })); + }, ["_peekTag", "_decodeTag", "_use", "_decodeStr", "_decodeObjid", "_decodeTime", "_decodeNull", "_decodeInt", "_decodeBool", "_decodeList", "_encodeComposite", "_encodeStr", "_encodeObjid", "_encodeTime", "_encodeNull", "_encodeInt", "_encodeBool"].forEach(function(e14) { + a8.prototype[e14] = function() { + var t10 = (this || b$c)._baseState; + throw new Error(e14 + " not implemented for encoding: " + t10.enc); + }; + }), o9.forEach(function(e14) { + a8.prototype[e14] = function() { + var t10 = (this || b$c)._baseState, r11 = Array.prototype.slice.call(arguments); + return n9(null === t10.tag), t10.tag = e14, this._useArgs(r11), this || b$c; + }; + }), a8.prototype.use = function(e14) { + n9(e14); + var t10 = (this || b$c)._baseState; + return n9(null === t10.use), t10.use = e14, this || b$c; + }, a8.prototype.optional = function() { + return (this || b$c)._baseState.optional = true, this || b$c; + }, a8.prototype.def = function(e14) { + var t10 = (this || b$c)._baseState; + return n9(null === t10.default), t10.default = e14, t10.optional = true, this || b$c; + }, a8.prototype.explicit = function(e14) { + var t10 = (this || b$c)._baseState; + return n9(null === t10.explicit && null === t10.implicit), t10.explicit = e14, this || b$c; + }, a8.prototype.implicit = function(e14) { + var t10 = (this || b$c)._baseState; + return n9(null === t10.explicit && null === t10.implicit), t10.implicit = e14, this || b$c; + }, a8.prototype.obj = function() { + var e14 = (this || b$c)._baseState, t10 = Array.prototype.slice.call(arguments); + return e14.obj = true, 0 !== t10.length && this._useArgs(t10), this || b$c; + }, a8.prototype.key = function(e14) { + var t10 = (this || b$c)._baseState; + return n9(null === t10.key), t10.key = e14, this || b$c; + }, a8.prototype.any = function() { + return (this || b$c)._baseState.any = true, this || b$c; + }, a8.prototype.choice = function(e14) { + var t10 = (this || b$c)._baseState; + return n9(null === t10.choice), t10.choice = e14, this._useArgs(Object.keys(e14).map(function(t11) { + return e14[t11]; + })), this || b$c; + }, a8.prototype.contains = function(e14) { + var t10 = (this || b$c)._baseState; + return n9(null === t10.use), t10.contains = e14, this || b$c; + }, a8.prototype._decode = function(e14, t10) { + var n10 = (this || b$c)._baseState; + if (null === n10.parent) + return e14.wrapResult(n10.children[0]._decode(e14, t10)); + var i8, o10 = n10.default, s8 = true, a9 = null; + if (null !== n10.key && (a9 = e14.enterKey(n10.key)), n10.optional) { + var u9 = null; + if (null !== n10.explicit ? u9 = n10.explicit : null !== n10.implicit ? u9 = n10.implicit : null !== n10.tag && (u9 = n10.tag), null !== u9 || n10.any) { + if (s8 = this._peekTag(e14, u9, n10.any), e14.isError(s8)) + return s8; + } else { + var c8 = e14.save(); + try { + null === n10.choice ? this._decodeGeneric(n10.tag, e14, t10) : this._decodeChoice(e14, t10), s8 = true; + } catch (e15) { + s8 = false; + } + e14.restore(c8); + } + } + if (n10.obj && s8 && (i8 = e14.enterObject()), s8) { + if (null !== n10.explicit) { + var f9 = this._decodeTag(e14, n10.explicit); + if (e14.isError(f9)) + return f9; + e14 = f9; + } + var l8 = e14.offset; + if (null === n10.use && null === n10.choice) { + if (n10.any) + c8 = e14.save(); + var h9 = this._decodeTag(e14, null !== n10.implicit ? n10.implicit : n10.tag, n10.any); + if (e14.isError(h9)) + return h9; + n10.any ? o10 = e14.raw(c8) : e14 = h9; + } + if (t10 && t10.track && null !== n10.tag && t10.track(e14.path(), l8, e14.length, "tagged"), t10 && t10.track && null !== n10.tag && t10.track(e14.path(), e14.offset, e14.length, "content"), o10 = n10.any ? o10 : null === n10.choice ? this._decodeGeneric(n10.tag, e14, t10) : this._decodeChoice(e14, t10), e14.isError(o10)) + return o10; + if (n10.any || null !== n10.choice || null === n10.children || n10.children.forEach(function(r11) { + r11._decode(e14, t10); + }), n10.contains && ("octstr" === n10.tag || "bitstr" === n10.tag)) { + var p8 = new r10(o10); + o10 = this._getUse(n10.contains, e14._reporterState.obj)._decode(p8, t10); + } + } + return n10.obj && s8 && (o10 = e14.leaveObject(i8)), null === n10.key || null === o10 && true !== s8 ? null !== a9 && e14.exitKey(a9) : e14.leaveKey(a9, n10.key, o10), o10; + }, a8.prototype._decodeGeneric = function(e14, t10, r11) { + var n10 = (this || b$c)._baseState; + return "seq" === e14 || "set" === e14 ? null : "seqof" === e14 || "setof" === e14 ? this._decodeList(t10, e14, n10.args[0], r11) : /str$/.test(e14) ? this._decodeStr(t10, e14, r11) : "objid" === e14 && n10.args ? this._decodeObjid(t10, n10.args[0], n10.args[1], r11) : "objid" === e14 ? this._decodeObjid(t10, null, null, r11) : "gentime" === e14 || "utctime" === e14 ? this._decodeTime(t10, e14, r11) : "null_" === e14 ? this._decodeNull(t10, r11) : "bool" === e14 ? this._decodeBool(t10, r11) : "objDesc" === e14 ? this._decodeStr(t10, e14, r11) : "int" === e14 || "enum" === e14 ? this._decodeInt(t10, n10.args && n10.args[0], r11) : null !== n10.use ? this._getUse(n10.use, t10._reporterState.obj)._decode(t10, r11) : t10.error("unknown tag: " + e14); + }, a8.prototype._getUse = function(e14, t10) { + var r11 = (this || b$c)._baseState; + return r11.useDecoder = this._use(e14, t10), n9(null === r11.useDecoder._baseState.parent), r11.useDecoder = r11.useDecoder._baseState.children[0], r11.implicit !== r11.useDecoder._baseState.implicit && (r11.useDecoder = r11.useDecoder.clone(), r11.useDecoder._baseState.implicit = r11.implicit), r11.useDecoder; + }, a8.prototype._decodeChoice = function(e14, t10) { + var r11 = (this || b$c)._baseState, n10 = null, i8 = false; + return Object.keys(r11.choice).some(function(o10) { + var s8 = e14.save(), a9 = r11.choice[o10]; + try { + var u9 = a9._decode(e14, t10); + if (e14.isError(u9)) + return false; + n10 = { type: o10, value: u9 }, i8 = true; + } catch (t11) { + return e14.restore(s8), false; + } + return true; + }, this || b$c), i8 ? n10 : e14.error("Choice not matched"); + }, a8.prototype._createEncoderBuffer = function(e14) { + return new t9(e14, (this || b$c).reporter); + }, a8.prototype._encode = function(e14, t10, r11) { + var n10 = (this || b$c)._baseState; + if (null === n10.default || n10.default !== e14) { + var i8 = this._encodeValue(e14, t10, r11); + if (void 0 !== i8 && !this._skipDefault(i8, t10, r11)) + return i8; + } + }, a8.prototype._encodeValue = function(t10, r11, n10) { + var i8 = (this || b$c)._baseState; + if (null === i8.parent) + return i8.children[0]._encode(t10, r11 || new e13()); + var o10 = null; + if ((this || b$c).reporter = r11, i8.optional && void 0 === t10) { + if (null === i8.default) + return; + t10 = i8.default; + } + var s8 = null, a9 = false; + if (i8.any) + o10 = this._createEncoderBuffer(t10); + else if (i8.choice) + o10 = this._encodeChoice(t10, r11); + else if (i8.contains) + s8 = this._getUse(i8.contains, n10)._encode(t10, r11), a9 = true; + else if (i8.children) + s8 = i8.children.map(function(e14) { + if ("null_" === e14._baseState.tag) + return e14._encode(null, r11, t10); + if (null === e14._baseState.key) + return r11.error("Child should have a key"); + var n11 = r11.enterKey(e14._baseState.key); + if ("object" != typeof t10) + return r11.error("Child expected, but input is not object"); + var i9 = e14._encode(t10[e14._baseState.key], r11, t10); + return r11.leaveKey(n11), i9; + }, this || b$c).filter(function(e14) { + return e14; + }), s8 = this._createEncoderBuffer(s8); + else if ("seqof" === i8.tag || "setof" === i8.tag) { + if (!i8.args || 1 !== i8.args.length) + return r11.error("Too many args for : " + i8.tag); + if (!Array.isArray(t10)) + return r11.error("seqof/setof, but data is not Array"); + var u9 = this.clone(); + u9._baseState.implicit = null, s8 = this._createEncoderBuffer(t10.map(function(e14) { + var n11 = (this || b$c)._baseState; + return this._getUse(n11.args[0], t10)._encode(e14, r11); + }, u9)); + } else + null !== i8.use ? o10 = this._getUse(i8.use, n10)._encode(t10, r11) : (s8 = this._encodePrimitive(i8.tag, t10), a9 = true); + if (!i8.any && null === i8.choice) { + var c8 = null !== i8.implicit ? i8.implicit : i8.tag, f9 = null === i8.implicit ? "universal" : "context"; + null === c8 ? null === i8.use && r11.error("Tag could be omitted only for .use()") : null === i8.use && (o10 = this._encodeComposite(c8, a9, f9, s8)); + } + return null !== i8.explicit && (o10 = this._encodeComposite(i8.explicit, false, "context", o10)), o10; + }, a8.prototype._encodeChoice = function(e14, t10) { + var r11 = (this || b$c)._baseState, i8 = r11.choice[e14.type]; + return i8 || n9(false, e14.type + " not found in " + JSON.stringify(Object.keys(r11.choice))), i8._encode(e14.value, t10); + }, a8.prototype._encodePrimitive = function(e14, t10) { + var r11 = (this || b$c)._baseState; + if (/str$/.test(e14)) + return this._encodeStr(t10, e14); + if ("objid" === e14 && r11.args) + return this._encodeObjid(t10, r11.reverseArgs[0], r11.args[1]); + if ("objid" === e14) + return this._encodeObjid(t10, null, null); + if ("gentime" === e14 || "utctime" === e14) + return this._encodeTime(t10, e14); + if ("null_" === e14) + return this._encodeNull(); + if ("int" === e14 || "enum" === e14) + return this._encodeInt(t10, r11.args && r11.reverseArgs[0]); + if ("bool" === e14) + return this._encodeBool(t10); + if ("objDesc" === e14) + return this._encodeStr(t10, e14); + throw new Error("Unsupported tag: " + e14); + }, a8.prototype._isNumstr = function(e14) { + return /^[0-9 ]*$/.test(e14); + }, a8.prototype._isPrintstr = function(e14) { + return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e14); + }, _$e; + }(), m$g; + } + var j$6 = {}; + var w$f = false; + var B$9 = {}; + var k$c = false; + function T$6() { + if (k$c) + return B$9; + k$c = true; + var e12 = B$9; + return e12._reverse = function(e13) { + var t9 = {}; + return Object.keys(e13).forEach(function(r10) { + (0 | r10) == r10 && (r10 |= 0); + var n9 = e13[r10]; + t9[n9] = r10; + }), t9; + }, e12.der = function() { + if (w$f) + return j$6; + w$f = true; + var e13 = T$6(); + return j$6.tagClass = { 0: "universal", 1: "application", 2: "context", 3: "private" }, j$6.tagClassByName = e13._reverse(j$6.tagClass), j$6.tag = { 0: "end", 1: "bool", 2: "int", 3: "bitstr", 4: "octstr", 5: "null_", 6: "objid", 7: "objDesc", 8: "external", 9: "real", 10: "enum", 11: "embed", 12: "utf8str", 13: "relativeOid", 16: "seq", 17: "set", 18: "numstr", 19: "printstr", 20: "t61str", 21: "videostr", 22: "ia5str", 23: "utctime", 24: "gentime", 25: "graphstr", 26: "iso646str", 27: "genstr", 28: "unistr", 29: "charstr", 30: "bmpstr" }, j$6.tagByName = e13._reverse(j$6.tag), j$6; + }(), B$9; + } + var D$5 = {}; + var U$7 = false; + var N$5 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + function C$6() { + if (U$7) + return D$5; + U$7 = true; + var e12 = t$2, r10 = Y$3(), n9 = r10.base, i8 = r10.bignum, o9 = r10.constants.der; + function s7(e13) { + (this || N$5).enc = "der", (this || N$5).name = e13.name, (this || N$5).entity = e13, (this || N$5).tree = new a8(), (this || N$5).tree._init(e13.body); + } + function a8(e13) { + n9.Node.call(this || N$5, "der", e13); + } + function u8(e13, t9) { + var r11 = e13.readUInt8(t9); + if (e13.isError(r11)) + return r11; + var n10 = o9.tagClass[r11 >> 6], i9 = 0 == (32 & r11); + if (31 == (31 & r11)) { + var s8 = r11; + for (r11 = 0; 128 == (128 & s8); ) { + if (s8 = e13.readUInt8(t9), e13.isError(s8)) + return s8; + r11 <<= 7, r11 |= 127 & s8; + } + } else + r11 &= 31; + return { cls: n10, primitive: i9, tag: r11, tagStr: o9.tag[r11] }; + } + function c8(e13, t9, r11) { + var n10 = e13.readUInt8(r11); + if (e13.isError(n10)) + return n10; + if (!t9 && 128 === n10) + return null; + if (0 == (128 & n10)) + return n10; + var i9 = 127 & n10; + if (i9 > 4) + return e13.error("length octect is too long"); + n10 = 0; + for (var o10 = 0; o10 < i9; o10++) { + n10 <<= 8; + var s8 = e13.readUInt8(r11); + if (e13.isError(s8)) + return s8; + n10 |= s8; + } + return n10; + } + return D$5 = s7, s7.prototype.decode = function(e13, t9) { + return e13 instanceof n9.DecoderBuffer || (e13 = new n9.DecoderBuffer(e13, t9)), (this || N$5).tree._decode(e13, t9); + }, e12(a8, n9.Node), a8.prototype._peekTag = function(e13, t9, r11) { + if (e13.isEmpty()) + return false; + var n10 = e13.save(), i9 = u8(e13, 'Failed to peek tag: "' + t9 + '"'); + return e13.isError(i9) ? i9 : (e13.restore(n10), i9.tag === t9 || i9.tagStr === t9 || i9.tagStr + "of" === t9 || r11); + }, a8.prototype._decodeTag = function(e13, t9, r11) { + var n10 = u8(e13, 'Failed to decode tag of "' + t9 + '"'); + if (e13.isError(n10)) + return n10; + var i9 = c8(e13, n10.primitive, 'Failed to get length of "' + t9 + '"'); + if (e13.isError(i9)) + return i9; + if (!r11 && n10.tag !== t9 && n10.tagStr !== t9 && n10.tagStr + "of" !== t9) + return e13.error('Failed to match tag: "' + t9 + '"'); + if (n10.primitive || null !== i9) + return e13.skip(i9, 'Failed to match body of: "' + t9 + '"'); + var o10 = e13.save(), s8 = this._skipUntilEnd(e13, 'Failed to skip indefinite length body: "' + (this || N$5).tag + '"'); + return e13.isError(s8) ? s8 : (i9 = e13.offset - o10.offset, e13.restore(o10), e13.skip(i9, 'Failed to match body of: "' + t9 + '"')); + }, a8.prototype._skipUntilEnd = function(e13, t9) { + for (; ; ) { + var r11 = u8(e13, t9); + if (e13.isError(r11)) + return r11; + var n10, i9 = c8(e13, r11.primitive, t9); + if (e13.isError(i9)) + return i9; + if (n10 = r11.primitive || null !== i9 ? e13.skip(i9) : this._skipUntilEnd(e13, t9), e13.isError(n10)) + return n10; + if ("end" === r11.tagStr) + break; + } + }, a8.prototype._decodeList = function(e13, t9, r11, n10) { + for (var i9 = []; !e13.isEmpty(); ) { + var o10 = this._peekTag(e13, "end"); + if (e13.isError(o10)) + return o10; + var s8 = r11.decode(e13, "der", n10); + if (e13.isError(s8) && o10) + break; + i9.push(s8); + } + return i9; + }, a8.prototype._decodeStr = function(e13, t9) { + if ("bitstr" === t9) { + var r11 = e13.readUInt8(); + return e13.isError(r11) ? r11 : { unused: r11, data: e13.raw() }; + } + if ("bmpstr" === t9) { + var n10 = e13.raw(); + if (n10.length % 2 == 1) + return e13.error("Decoding of string type: bmpstr length mismatch"); + for (var i9 = "", o10 = 0; o10 < n10.length / 2; o10++) + i9 += String.fromCharCode(n10.readUInt16BE(2 * o10)); + return i9; + } + if ("numstr" === t9) { + var s8 = e13.raw().toString("ascii"); + return this._isNumstr(s8) ? s8 : e13.error("Decoding of string type: numstr unsupported characters"); + } + if ("octstr" === t9) + return e13.raw(); + if ("objDesc" === t9) + return e13.raw(); + if ("printstr" === t9) { + var a9 = e13.raw().toString("ascii"); + return this._isPrintstr(a9) ? a9 : e13.error("Decoding of string type: printstr unsupported characters"); + } + return /str$/.test(t9) ? e13.raw().toString() : e13.error("Decoding of string type: " + t9 + " unsupported"); + }, a8.prototype._decodeObjid = function(e13, t9, r11) { + for (var n10, i9 = [], o10 = 0; !e13.isEmpty(); ) { + var s8 = e13.readUInt8(); + o10 <<= 7, o10 |= 127 & s8, 0 == (128 & s8) && (i9.push(o10), o10 = 0); + } + 128 & s8 && i9.push(o10); + var a9 = i9[0] / 40 | 0, u9 = i9[0] % 40; + if (n10 = r11 ? i9 : [a9, u9].concat(i9.slice(1)), t9) { + var c9 = t9[n10.join(" ")]; + void 0 === c9 && (c9 = t9[n10.join(".")]), void 0 !== c9 && (n10 = c9); + } + return n10; + }, a8.prototype._decodeTime = function(e13, t9) { + var r11 = e13.raw().toString(); + if ("gentime" === t9) + var n10 = 0 | r11.slice(0, 4), i9 = 0 | r11.slice(4, 6), o10 = 0 | r11.slice(6, 8), s8 = 0 | r11.slice(8, 10), a9 = 0 | r11.slice(10, 12), u9 = 0 | r11.slice(12, 14); + else { + if ("utctime" !== t9) + return e13.error("Decoding " + t9 + " time is not supported yet"); + n10 = 0 | r11.slice(0, 2), i9 = 0 | r11.slice(2, 4), o10 = 0 | r11.slice(4, 6), s8 = 0 | r11.slice(6, 8), a9 = 0 | r11.slice(8, 10), u9 = 0 | r11.slice(10, 12); + n10 = n10 < 70 ? 2e3 + n10 : 1900 + n10; + } + return Date.UTC(n10, i9 - 1, o10, s8, a9, u9, 0); + }, a8.prototype._decodeNull = function(e13) { + return null; + }, a8.prototype._decodeBool = function(e13) { + var t9 = e13.readUInt8(); + return e13.isError(t9) ? t9 : 0 !== t9; + }, a8.prototype._decodeInt = function(e13, t9) { + var r11 = e13.raw(), n10 = new i8(r11); + return t9 && (n10 = t9[n10.toString(10)] || n10), n10; + }, a8.prototype._use = function(e13, t9) { + return "function" == typeof e13 && (e13 = e13(t9)), e13._getDecoder("der").tree; + }, D$5; + } + var O$6 = {}; + var A$9 = false; + var x$7 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var I$9 = {}; + var q$5 = false; + function P$5() { + if (q$5) + return I$9; + q$5 = true; + var e12 = I$9; + return e12.der = C$6(), e12.pem = function() { + if (A$9) + return O$6; + A$9 = true; + var e13 = t$2, r10 = e$1$1.Buffer, i8 = C$6(); + function o9(e14) { + i8.call(this || x$7, e14), (this || x$7).enc = "pem"; + } + return e13(o9, i8), O$6 = o9, o9.prototype.decode = function(e14, t9) { + for (var n9 = e14.toString().split(/[\r\n]+/g), o10 = t9.label.toUpperCase(), s7 = /^-----(BEGIN|END) ([^-]+)-----$/, a8 = -1, u8 = -1, c8 = 0; c8 < n9.length; c8++) { + var f9 = n9[c8].match(s7); + if (null !== f9 && f9[2] === o10) { + if (-1 !== a8) { + if ("END" !== f9[1]) + break; + u8 = c8; + break; + } + if ("BEGIN" !== f9[1]) + break; + a8 = c8; + } + } + if (-1 === a8 || -1 === u8) + throw new Error("PEM section not found for: " + o10); + var l8 = n9.slice(a8 + 1, u8).join(""); + l8.replace(/[^a-z0-9\+\/=]+/gi, ""); + var h9 = new r10(l8, "base64"); + return i8.prototype.decode.call(this || x$7, h9, t9); + }, O$6; + }(), I$9; + } + var F$6 = {}; + var K$5 = false; + var R$4 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + function $$2() { + if (K$5) + return F$6; + K$5 = true; + var e12 = t$2, r10 = e$1$1.Buffer, i8 = Y$3(), o9 = i8.base, s7 = i8.constants.der; + function a8(e13) { + (this || R$4).enc = "der", (this || R$4).name = e13.name, (this || R$4).entity = e13, (this || R$4).tree = new u8(), (this || R$4).tree._init(e13.body); + } + function u8(e13) { + o9.Node.call(this || R$4, "der", e13); + } + function c8(e13) { + return e13 < 10 ? "0" + e13 : e13; + } + return F$6 = a8, a8.prototype.encode = function(e13, t9) { + return (this || R$4).tree._encode(e13, t9).join(); + }, e12(u8, o9.Node), u8.prototype._encodeComposite = function(e13, t9, n9, i9) { + var o10, a9 = function(e14, t10, r11, n10) { + var i10; + "seqof" === e14 ? e14 = "seq" : "setof" === e14 && (e14 = "set"); + if (s7.tagByName.hasOwnProperty(e14)) + i10 = s7.tagByName[e14]; + else { + if ("number" != typeof e14 || (0 | e14) !== e14) + return n10.error("Unknown tag: " + e14); + i10 = e14; + } + if (i10 >= 31) + return n10.error("Multi-octet tag encoding unsupported"); + t10 || (i10 |= 32); + return i10 |= s7.tagClassByName[r11 || "universal"] << 6; + }(e13, t9, n9, (this || R$4).reporter); + if (i9.length < 128) + return (o10 = new r10(2))[0] = a9, o10[1] = i9.length, this._createEncoderBuffer([o10, i9]); + for (var u9 = 1, c9 = i9.length; c9 >= 256; c9 >>= 8) + u9++; + (o10 = new r10(2 + u9))[0] = a9, o10[1] = 128 | u9; + c9 = 1 + u9; + for (var f9 = i9.length; f9 > 0; c9--, f9 >>= 8) + o10[c9] = 255 & f9; + return this._createEncoderBuffer([o10, i9]); + }, u8.prototype._encodeStr = function(e13, t9) { + if ("bitstr" === t9) + return this._createEncoderBuffer([0 | e13.unused, e13.data]); + if ("bmpstr" === t9) { + for (var n9 = new r10(2 * e13.length), i9 = 0; i9 < e13.length; i9++) + n9.writeUInt16BE(e13.charCodeAt(i9), 2 * i9); + return this._createEncoderBuffer(n9); + } + return "numstr" === t9 ? this._isNumstr(e13) ? this._createEncoderBuffer(e13) : (this || R$4).reporter.error("Encoding of string type: numstr supports only digits and space") : "printstr" === t9 ? this._isPrintstr(e13) ? this._createEncoderBuffer(e13) : (this || R$4).reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark") : /str$/.test(t9) || "objDesc" === t9 ? this._createEncoderBuffer(e13) : (this || R$4).reporter.error("Encoding of string type: " + t9 + " unsupported"); + }, u8.prototype._encodeObjid = function(e13, t9, n9) { + if ("string" == typeof e13) { + if (!t9) + return (this || R$4).reporter.error("string objid given, but no values map found"); + if (!t9.hasOwnProperty(e13)) + return (this || R$4).reporter.error("objid not found in values map"); + e13 = t9[e13].split(/[\s\.]+/g); + for (var i9 = 0; i9 < e13.length; i9++) + e13[i9] |= 0; + } else if (Array.isArray(e13)) { + e13 = e13.slice(); + for (i9 = 0; i9 < e13.length; i9++) + e13[i9] |= 0; + } + if (!Array.isArray(e13)) + return (this || R$4).reporter.error("objid() should be either array or string, got: " + JSON.stringify(e13)); + if (!n9) { + if (e13[1] >= 40) + return (this || R$4).reporter.error("Second objid identifier OOB"); + e13.splice(0, 2, 40 * e13[0] + e13[1]); + } + var o10 = 0; + for (i9 = 0; i9 < e13.length; i9++) { + var s8 = e13[i9]; + for (o10++; s8 >= 128; s8 >>= 7) + o10++; + } + var a9 = new r10(o10), u9 = a9.length - 1; + for (i9 = e13.length - 1; i9 >= 0; i9--) { + s8 = e13[i9]; + for (a9[u9--] = 127 & s8; (s8 >>= 7) > 0; ) + a9[u9--] = 128 | 127 & s8; + } + return this._createEncoderBuffer(a9); + }, u8.prototype._encodeTime = function(e13, t9) { + var r11, n9 = new Date(e13); + return "gentime" === t9 ? r11 = [c8(n9.getFullYear()), c8(n9.getUTCMonth() + 1), c8(n9.getUTCDate()), c8(n9.getUTCHours()), c8(n9.getUTCMinutes()), c8(n9.getUTCSeconds()), "Z"].join("") : "utctime" === t9 ? r11 = [c8(n9.getFullYear() % 100), c8(n9.getUTCMonth() + 1), c8(n9.getUTCDate()), c8(n9.getUTCHours()), c8(n9.getUTCMinutes()), c8(n9.getUTCSeconds()), "Z"].join("") : (this || R$4).reporter.error("Encoding " + t9 + " time is not supported yet"), this._encodeStr(r11, "octstr"); + }, u8.prototype._encodeNull = function() { + return this._createEncoderBuffer(""); + }, u8.prototype._encodeInt = function(e13, t9) { + if ("string" == typeof e13) { + if (!t9) + return (this || R$4).reporter.error("String int or enum given, but no values map"); + if (!t9.hasOwnProperty(e13)) + return (this || R$4).reporter.error("Values map doesn't contain: " + JSON.stringify(e13)); + e13 = t9[e13]; + } + if ("number" != typeof e13 && !r10.isBuffer(e13)) { + var n9 = e13.toArray(); + !e13.sign && 128 & n9[0] && n9.unshift(0), e13 = new r10(n9); + } + if (r10.isBuffer(e13)) { + var i9 = e13.length; + 0 === e13.length && i9++; + var o10 = new r10(i9); + return e13.copy(o10), 0 === e13.length && (o10[0] = 0), this._createEncoderBuffer(o10); + } + if (e13 < 128) + return this._createEncoderBuffer(e13); + if (e13 < 256) + return this._createEncoderBuffer([0, e13]); + i9 = 1; + for (var s8 = e13; s8 >= 256; s8 >>= 8) + i9++; + for (s8 = (o10 = new Array(i9)).length - 1; s8 >= 0; s8--) + o10[s8] = 255 & e13, e13 >>= 8; + return 128 & o10[0] && o10.unshift(0), this._createEncoderBuffer(new r10(o10)); + }, u8.prototype._encodeBool = function(e13) { + return this._createEncoderBuffer(e13 ? 255 : 0); + }, u8.prototype._use = function(e13, t9) { + return "function" == typeof e13 && (e13 = e13(t9)), e13._getEncoder("der").tree; + }, u8.prototype._skipDefault = function(e13, t9, r11) { + var n9, i9 = (this || R$4)._baseState; + if (null === i9.default) + return false; + var o10 = e13.join(); + if (void 0 === i9.defaultBuffer && (i9.defaultBuffer = this._encodeValue(i9.default, t9, r11).join()), o10.length !== i9.defaultBuffer.length) + return false; + for (n9 = 0; n9 < o10.length; n9++) + if (o10[n9] !== i9.defaultBuffer[n9]) + return false; + return true; + }, F$6; + } + var G$4 = {}; + var L$5 = false; + var M$7 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var J$4 = {}; + var V$4 = false; + function Z$2() { + if (V$4) + return J$4; + V$4 = true; + var e12 = J$4; + return e12.der = $$2(), e12.pem = function() { + if (L$5) + return G$4; + L$5 = true; + var e13 = t$2, r10 = $$2(); + function n9(e14) { + r10.call(this || M$7, e14), (this || M$7).enc = "pem"; + } + return e13(n9, r10), G$4 = n9, n9.prototype.encode = function(e14, t9) { + for (var n10 = r10.prototype.encode.call(this || M$7, e14).toString("base64"), i8 = ["-----BEGIN " + t9.label + "-----"], o9 = 0; o9 < n10.length; o9 += 64) + i8.push(n10.slice(o9, o9 + 64)); + return i8.push("-----END " + t9.label + "-----"), i8.join("\n"); + }, G$4; + }(), J$4; + } + var z$7 = {}; + var H$6 = false; + function Y$3() { + if (H$6) + return z$7; + H$6 = true; + var n9 = z$7; + return n9.bignum = n$c, n9.define = function() { + if (s$j) + return o$n; + s$j = true; + var e12 = Y$3(), n10 = t$2; + function i8(e13, t9) { + (this || a$m).name = e13, (this || a$m).body = t9, (this || a$m).decoders = {}, (this || a$m).encoders = {}; + } + return o$n.define = function(e13, t9) { + return new i8(e13, t9); + }, i8.prototype._createNamed = function(e13) { + var t9; + try { + t9 = exports$11$1.runInThisContext("(function " + (this || a$m).name + "(entity) {\n this._initNamed(entity);\n})"); + } catch (e14) { + t9 = function(e15) { + this._initNamed(e15); + }; + } + return n10(t9, e13), t9.prototype._initNamed = function(t10) { + e13.call(this || a$m, t10); + }, new t9(this || a$m); + }, i8.prototype._getDecoder = function(t9) { + return t9 = t9 || "der", (this || a$m).decoders.hasOwnProperty(t9) || ((this || a$m).decoders[t9] = this._createNamed(e12.decoders[t9])), (this || a$m).decoders[t9]; + }, i8.prototype.decode = function(e13, t9, r10) { + return this._getDecoder(t9).decode(e13, r10); + }, i8.prototype._getEncoder = function(t9) { + return t9 = t9 || "der", (this || a$m).encoders.hasOwnProperty(t9) || ((this || a$m).encoders[t9] = this._createNamed(e12.encoders[t9])), (this || a$m).encoders[t9]; + }, i8.prototype.encode = function(e13, t9, r10) { + return this._getEncoder(t9).encode(e13, r10); + }, o$n; + }().define, n9.base = E$9(), n9.constants = T$6(), n9.decoders = P$5(), n9.encoders = Z$2(), z$7; + } + var Q$3 = Y$3(); + var e$f = Q$3; + var t$a = e$f.define("Time", function() { + this.choice({ utcTime: this.utctime(), generalTime: this.gentime() }); + }); + var s$k = e$f.define("AttributeTypeValue", function() { + this.seq().obj(this.key("type").objid(), this.key("value").any()); + }); + var n$n = e$f.define("AlgorithmIdentifier", function() { + this.seq().obj(this.key("algorithm").objid(), this.key("parameters").optional(), this.key("curve").objid().optional()); + }); + var o$o = e$f.define("SubjectPublicKeyInfo", function() { + this.seq().obj(this.key("algorithm").use(n$n), this.key("subjectPublicKey").bitstr()); + }); + var h$h = e$f.define("RelativeDistinguishedName", function() { + this.setof(s$k); + }); + var y$g = e$f.define("RDNSequence", function() { + this.seqof(h$h); + }); + var r$g = e$f.define("Name", function() { + this.choice({ rdnSequence: this.use(y$g) }); + }); + var u$k = e$f.define("Validity", function() { + this.seq().obj(this.key("notBefore").use(t$a), this.key("notAfter").use(t$a)); + }); + var a$n = e$f.define("Extension", function() { + this.seq().obj(this.key("extnID").objid(), this.key("critical").bool().def(false), this.key("extnValue").octstr()); + }); + var c$j = e$f.define("TBSCertificate", function() { + this.seq().obj(this.key("version").explicit(0).int().optional(), this.key("serialNumber").int(), this.key("signature").use(n$n), this.key("issuer").use(r$g), this.key("validity").use(u$k), this.key("subject").use(r$g), this.key("subjectPublicKeyInfo").use(o$o), this.key("issuerUniqueID").implicit(1).bitstr().optional(), this.key("subjectUniqueID").implicit(2).bitstr().optional(), this.key("extensions").explicit(3).seqof(a$n).optional()); + }); + var k$d = e$f.define("X509Certificate", function() { + this.seq().obj(this.key("tbsCertificate").use(c$j), this.key("signatureAlgorithm").use(n$n), this.key("signatureValue").bitstr()); + }); + var f$o = {}; + var b$d = Q$3; + f$o.certificate = k$d; + var l$l = b$d.define("RSAPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("modulus").int(), this.key("publicExponent").int(), this.key("privateExponent").int(), this.key("prime1").int(), this.key("prime2").int(), this.key("exponent1").int(), this.key("exponent2").int(), this.key("coefficient").int()); + }); + f$o.RSAPrivateKey = l$l; + var d$j = b$d.define("RSAPublicKey", function() { + this.seq().obj(this.key("modulus").int(), this.key("publicExponent").int()); + }); + f$o.RSAPublicKey = d$j; + var p$l = b$d.define("SubjectPublicKeyInfo", function() { + this.seq().obj(this.key("algorithm").use(j$7), this.key("subjectPublicKey").bitstr()); + }); + f$o.PublicKey = p$l; + var j$7 = b$d.define("AlgorithmIdentifier", function() { + this.seq().obj(this.key("algorithm").objid(), this.key("none").null_().optional(), this.key("curve").objid().optional(), this.key("params").seq().obj(this.key("p").int(), this.key("q").int(), this.key("g").int()).optional()); + }); + var v$g = b$d.define("PrivateKeyInfo", function() { + this.seq().obj(this.key("version").int(), this.key("algorithm").use(j$7), this.key("subjectPrivateKey").octstr()); + }); + f$o.PrivateKey = v$g; + var m$h = b$d.define("EncryptedPrivateKeyInfo", function() { + this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(), this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(), this.key("kdeparams").seq().obj(this.key("salt").octstr(), this.key("iters").int())), this.key("cipher").seq().obj(this.key("algo").objid(), this.key("iv").octstr()))), this.key("subjectPrivateKey").octstr()); + }); + f$o.EncryptedPrivateKey = m$h; + var q$6 = b$d.define("DSAPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("p").int(), this.key("q").int(), this.key("g").int(), this.key("pub_key").int(), this.key("priv_key").int()); + }); + f$o.DSAPrivateKey = q$6, f$o.DSAparam = b$d.define("DSAparam", function() { + this.int(); + }); + var K$6 = b$d.define("ECPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("privateKey").octstr(), this.key("parameters").optional().explicit(0).use(P$6), this.key("publicKey").optional().explicit(1).bitstr()); + }); + f$o.ECPrivateKey = K$6; + var P$6 = b$d.define("ECParameters", function() { + this.choice({ namedCurve: this.objid() }); + }); + f$o.signature = b$d.define("signature", function() { + this.seq().obj(this.key("r").int(), this.key("s").int()); + }); + var s$l; + var i$a = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r\+\/\=]+)[\n\r]+/m; + var o$p = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m; + var d$k = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r\+\/\=]+)-----END \1-----$/m; + var n$o = a$c; + var p$m = t$3; + var u$l = u4.Buffer; + var y$h = f$o; + var m$i = { "2.16.840.1.101.3.4.1.1": "aes-128-ecb", "2.16.840.1.101.3.4.1.2": "aes-128-cbc", "2.16.840.1.101.3.4.1.3": "aes-128-ofb", "2.16.840.1.101.3.4.1.4": "aes-128-cfb", "2.16.840.1.101.3.4.1.21": "aes-192-ecb", "2.16.840.1.101.3.4.1.22": "aes-192-cbc", "2.16.840.1.101.3.4.1.23": "aes-192-ofb", "2.16.840.1.101.3.4.1.24": "aes-192-cfb", "2.16.840.1.101.3.4.1.41": "aes-256-ecb", "2.16.840.1.101.3.4.1.42": "aes-256-cbc", "2.16.840.1.101.3.4.1.43": "aes-256-ofb", "2.16.840.1.101.3.4.1.44": "aes-256-cfb" }; + var f$p = function(e12, r10) { + var a8, t9 = e12.toString(), c8 = t9.match(i$a); + if (c8) { + var s7 = "aes" + c8[1], y7 = u$l.from(c8[2], "hex"), m7 = u$l.from(c8[3].replace(/[\r\n]/g, ""), "base64"), f9 = n$o(r10, y7.slice(0, 8), parseInt(c8[1], 10)).key, b6 = [], E5 = p$m.createDecipheriv(s7, f9, y7); + b6.push(E5.update(m7)), b6.push(E5.final()), a8 = u$l.concat(b6); + } else { + var h9 = t9.match(d$k); + a8 = new u$l(h9[2].replace(/[\r\n]/g, ""), "base64"); + } + return { tag: t9.match(o$p)[1], data: a8 }; + }; + var b$e = t$3; + var E$a = M$1; + var h$i = u4.Buffer; + function l$m(e12) { + var r10; + "object" != typeof e12 || h$i.isBuffer(e12) || (r10 = e12.passphrase, e12 = e12.key), "string" == typeof e12 && (e12 = h$i.from(e12)); + var a8, t9, c8 = f$p(e12, r10), s7 = c8.tag, i8 = c8.data; + switch (s7) { + case "CERTIFICATE": + t9 = y$h.certificate.decode(i8, "der").tbsCertificate.subjectPublicKeyInfo; + case "PUBLIC KEY": + switch (t9 || (t9 = y$h.PublicKey.decode(i8, "der")), a8 = t9.algorithm.algorithm.join(".")) { + case "1.2.840.113549.1.1.1": + return y$h.RSAPublicKey.decode(t9.subjectPublicKey.data, "der"); + case "1.2.840.10045.2.1": + return t9.subjectPrivateKey = t9.subjectPublicKey, { type: "ec", data: t9 }; + case "1.2.840.10040.4.1": + return t9.algorithm.params.pub_key = y$h.DSAparam.decode(t9.subjectPublicKey.data, "der"), { type: "dsa", data: t9.algorithm.params }; + default: + throw new Error("unknown key id " + a8); + } + case "ENCRYPTED PRIVATE KEY": + i8 = function(e13, r11) { + var a9 = e13.algorithm.decrypt.kde.kdeparams.salt, t10 = parseInt(e13.algorithm.decrypt.kde.kdeparams.iters.toString(), 10), c9 = m$i[e13.algorithm.decrypt.cipher.algo.join(".")], s8 = e13.algorithm.decrypt.cipher.iv, i9 = e13.subjectPrivateKey, o9 = parseInt(c9.split("-")[1], 10) / 8, d7 = E$a.pbkdf2Sync(r11, a9, t10, o9, "sha1"), n9 = b$e.createDecipheriv(c9, d7, s8), p8 = []; + return p8.push(n9.update(i9)), p8.push(n9.final()), h$i.concat(p8); + }(i8 = y$h.EncryptedPrivateKey.decode(i8, "der"), r10); + case "PRIVATE KEY": + switch (a8 = (t9 = y$h.PrivateKey.decode(i8, "der")).algorithm.algorithm.join(".")) { + case "1.2.840.113549.1.1.1": + return y$h.RSAPrivateKey.decode(t9.subjectPrivateKey, "der"); + case "1.2.840.10045.2.1": + return { curve: t9.algorithm.curve, privateKey: y$h.ECPrivateKey.decode(t9.subjectPrivateKey, "der").privateKey }; + case "1.2.840.10040.4.1": + return t9.algorithm.params.priv_key = y$h.DSAparam.decode(t9.subjectPrivateKey, "der"), { type: "dsa", params: t9.algorithm.params }; + default: + throw new Error("unknown key id " + a8); + } + case "RSA PUBLIC KEY": + return y$h.RSAPublicKey.decode(i8, "der"); + case "RSA PRIVATE KEY": + return y$h.RSAPrivateKey.decode(i8, "der"); + case "DSA PRIVATE KEY": + return { type: "dsa", params: y$h.DSAPrivateKey.decode(i8, "der") }; + case "EC PRIVATE KEY": + return { curve: (i8 = y$h.ECPrivateKey.decode(i8, "der")).parameters.value, privateKey: i8.privateKey }; + default: + throw new Error("unknown key type " + s7); + } + } + s$l = l$m, l$m.signature = y$h.signature; + var v$h = s$l; + var p$n = { "1.3.132.0.10": "secp256k1", "1.3.132.0.33": "p224", "1.2.840.10045.3.1.1": "p192", "1.2.840.10045.3.1.7": "p256", "1.3.132.0.34": "p384", "1.3.132.0.35": "p521" }; + var d$l = {}; + var f$q = e$1$1.Buffer; + var c$k = w$3; + var g$f = l$d; + var w$g = Le.ec; + var l$n = n$c; + var m$j = v$h; + var v$i = p$n; + function y$i(e12, t9, r10, n9) { + if ((e12 = new f$q(e12.toArray())).length < t9.byteLength()) { + var a8 = new f$q(t9.byteLength() - e12.length); + a8.fill(0), e12 = f$q.concat([a8, e12]); + } + var o9 = r10.length, i8 = function(e13, t10) { + e13 = (e13 = b$f(e13, t10)).mod(t10); + var r11 = new f$q(e13.toArray()); + if (r11.length < t10.byteLength()) { + var n10 = new f$q(t10.byteLength() - r11.length); + n10.fill(0), r11 = f$q.concat([n10, r11]); + } + return r11; + }(r10, t9), s7 = new f$q(o9); + s7.fill(1); + var h9 = new f$q(o9); + return h9.fill(0), h9 = c$k(n9, h9).update(s7).update(new f$q([0])).update(e12).update(i8).digest(), s7 = c$k(n9, h9).update(s7).digest(), { k: h9 = c$k(n9, h9).update(s7).update(new f$q([1])).update(e12).update(i8).digest(), v: s7 = c$k(n9, h9).update(s7).digest() }; + } + function b$f(e12, t9) { + var r10 = new l$n(e12), n9 = (e12.length << 3) - t9.bitLength(); + return n9 > 0 && r10.ishrn(n9), r10; + } + function _$f(e12, t9, r10) { + var n9, a8; + do { + for (n9 = new f$q(0); 8 * n9.length < e12.bitLength(); ) + t9.v = c$k(r10, t9.k).update(t9.v).digest(), n9 = f$q.concat([n9, t9.v]); + a8 = b$f(n9, e12), t9.k = c$k(r10, t9.k).update(t9.v).update(new f$q([0])).digest(), t9.v = c$k(r10, t9.k).update(t9.v).digest(); + } while (-1 !== a8.cmp(e12)); + return a8; + } + function k$e(e12, t9, r10, n9) { + return e12.toRed(l$n.mont(r10)).redPow(t9).fromRed().mod(n9); + } + (d$l = function(e12, t9, r10, n9, a8) { + var o9 = m$j(t9); + if (o9.curve) { + if ("ecdsa" !== n9 && "ecdsa/rsa" !== n9) + throw new Error("wrong private key type"); + return function(e13, t10) { + var r11 = v$i[t10.curve.join(".")]; + if (!r11) + throw new Error("unknown curve " + t10.curve.join(".")); + var n10 = new w$g(r11).keyFromPrivate(t10.privateKey).sign(e13); + return new f$q(n10.toDER()); + }(e12, o9); + } + if ("dsa" === o9.type) { + if ("dsa" !== n9) + throw new Error("wrong private key type"); + return function(e13, t10, r11) { + var n10, a9 = t10.params.priv_key, o10 = t10.params.p, i9 = t10.params.q, s8 = t10.params.g, h10 = new l$n(0), u8 = b$f(e13, i9).mod(i9), p8 = false, d7 = y$i(a9, i9, e13, r11); + for (; false === p8; ) + n10 = _$f(i9, d7, r11), h10 = k$e(s8, n10, o10, i9), 0 === (p8 = n10.invm(i9).imul(u8.add(a9.mul(h10))).mod(i9)).cmpn(0) && (p8 = false, h10 = new l$n(0)); + return function(e14, t11) { + e14 = e14.toArray(), t11 = t11.toArray(), 128 & e14[0] && (e14 = [0].concat(e14)); + 128 & t11[0] && (t11 = [0].concat(t11)); + var r12 = [48, e14.length + t11.length + 4, 2, e14.length]; + return r12 = r12.concat(e14, [2, t11.length], t11), new f$q(r12); + }(h10, p8); + }(e12, o9, r10); + } + if ("rsa" !== n9 && "ecdsa/rsa" !== n9) + throw new Error("wrong private key type"); + e12 = f$q.concat([a8, e12]); + for (var i8 = o9.modulus.byteLength(), s7 = [0, 1]; e12.length + s7.length + 1 < i8; ) + s7.push(255); + s7.push(0); + for (var h9 = -1; ++h9 < e12.length; ) + s7.push(e12[h9]); + return g$f(s7, o9); + }).getKey = y$i, d$l.makeKey = _$f; + var E$b = d$l; + var L$6 = e$1$1.Buffer; + var R$5 = n$c; + var j$8 = Le.ec; + var T$7 = v$h; + var P$7 = p$n; + function A$a(e12, t9) { + if (e12.cmpn(0) <= 0) + throw new Error("invalid sig"); + if (e12.cmp(t9) >= t9) + throw new Error("invalid sig"); + } + var K$7 = function(e12, t9, r10, n9, a8) { + var o9 = T$7(r10); + if ("ec" === o9.type) { + if ("ecdsa" !== n9 && "ecdsa/rsa" !== n9) + throw new Error("wrong public key type"); + return function(e13, t10, r11) { + var n10 = P$7[r11.data.algorithm.curve.join(".")]; + if (!n10) + throw new Error("unknown curve " + r11.data.algorithm.curve.join(".")); + var a9 = new j$8(n10), o10 = r11.data.subjectPrivateKey.data; + return a9.verify(t10, e13, o10); + }(e12, t9, o9); + } + if ("dsa" === o9.type) { + if ("dsa" !== n9) + throw new Error("wrong public key type"); + return function(e13, t10, r11) { + var n10 = r11.data.p, a9 = r11.data.q, o10 = r11.data.g, i9 = r11.data.pub_key, s8 = T$7.signature.decode(e13, "der"), h10 = s8.s, u9 = s8.r; + A$a(h10, a9), A$a(u9, a9); + var p9 = R$5.mont(n10), d8 = h10.invm(a9); + return 0 === o10.toRed(p9).redPow(new R$5(t10).mul(d8).mod(a9)).fromRed().mul(i9.toRed(p9).redPow(u9.mul(d8).mod(a9)).fromRed()).mod(n10).mod(a9).cmp(u9); + }(e12, t9, o9); + } + if ("rsa" !== n9 && "ecdsa/rsa" !== n9) + throw new Error("wrong public key type"); + t9 = L$6.concat([a8, t9]); + for (var i8 = o9.modulus.byteLength(), s7 = [1], h9 = 0; t9.length + s7.length + 2 < i8; ) + s7.push(255), h9++; + s7.push(0); + for (var u8 = -1; ++u8 < t9.length; ) + s7.push(t9[u8]); + s7 = new L$6(s7); + var p8 = R$5.mont(o9.modulus); + e12 = (e12 = new R$5(e12).toRed(p8)).redPow(new R$5(o9.publicExponent)), e12 = new L$6(e12.fromRed().toArray()); + var d7 = h9 < 8 ? 1 : 0; + for (i8 = Math.min(e12.length, s7.length), e12.length !== s7.length && (d7 = 1), u8 = -1; ++u8 < i8; ) + d7 |= e12[u8] ^ s7[u8]; + return 0 === d7; + }; + var W$4 = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var x$8 = e$1$1.Buffer; + var B$a = h$4; + var S$b = b$i; + var q$7 = t$2; + var U$8 = E$b; + var V$5 = K$7; + var C$7 = s$4; + function D$6(e12) { + S$b.Writable.call(this || W$4); + var t9 = C$7[e12]; + if (!t9) + throw new Error("Unknown message digest"); + (this || W$4)._hashType = t9.hash, (this || W$4)._hash = B$a(t9.hash), (this || W$4)._tag = t9.id, (this || W$4)._signType = t9.sign; + } + function F$7(e12) { + S$b.Writable.call(this || W$4); + var t9 = C$7[e12]; + if (!t9) + throw new Error("Unknown message digest"); + (this || W$4)._hash = B$a(t9.hash), (this || W$4)._tag = t9.id, (this || W$4)._signType = t9.sign; + } + function M$8(e12) { + return new D$6(e12); + } + function O$7(e12) { + return new F$7(e12); + } + Object.keys(C$7).forEach(function(e12) { + C$7[e12].id = new x$8(C$7[e12].id, "hex"), C$7[e12.toLowerCase()] = C$7[e12]; + }), q$7(D$6, S$b.Writable), D$6.prototype._write = function(e12, t9, r10) { + (this || W$4)._hash.update(e12), r10(); + }, D$6.prototype.update = function(e12, t9) { + return "string" == typeof e12 && (e12 = new x$8(e12, t9)), (this || W$4)._hash.update(e12), this || W$4; + }, D$6.prototype.sign = function(e12, t9) { + this.end(); + var r10 = (this || W$4)._hash.digest(), n9 = U$8(r10, e12, (this || W$4)._hashType, (this || W$4)._signType, (this || W$4)._tag); + return t9 ? n9.toString(t9) : n9; + }, q$7(F$7, S$b.Writable), F$7.prototype._write = function(e12, t9, r10) { + (this || W$4)._hash.update(e12), r10(); + }, F$7.prototype.update = function(e12, t9) { + return "string" == typeof e12 && (e12 = new x$8(e12, t9)), (this || W$4)._hash.update(e12), this || W$4; + }, F$7.prototype.verify = function(e12, t9, r10) { + "string" == typeof t9 && (t9 = new x$8(t9, r10)), this.end(); + var n9 = (this || W$4)._hash.digest(); + return V$5(t9, n9, e12, (this || W$4)._signType, (this || W$4)._tag); + }; + var z$8 = { Sign: M$8, Verify: O$7, createSign: M$8, createVerify: O$7 }; + var i$b; + var n$p = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var p$o = e$1$1.Buffer; + var s$m = Le; + var u$m = n$c; + i$b = function(e12) { + return new c$l(e12); + }; + var o$q = { secp256k1: { name: "secp256k1", byteLength: 32 }, secp224r1: { name: "p224", byteLength: 28 }, prime256v1: { name: "p256", byteLength: 32 }, prime192v1: { name: "p192", byteLength: 24 }, ed25519: { name: "ed25519", byteLength: 32 }, secp384r1: { name: "p384", byteLength: 48 }, secp521r1: { name: "p521", byteLength: 66 } }; + function c$l(e12) { + (this || n$p).curveType = o$q[e12], (this || n$p).curveType || ((this || n$p).curveType = { name: e12 }), (this || n$p).curve = new s$m.ec((this || n$p).curveType.name), (this || n$p).keys = void 0; + } + function y$j(e12, t9, r10) { + Array.isArray(e12) || (e12 = e12.toArray()); + var i8 = new p$o(e12); + if (r10 && i8.length < r10) { + var n9 = new p$o(r10 - i8.length); + n9.fill(0), i8 = p$o.concat([n9, i8]); + } + return t9 ? i8.toString(t9) : i8; + } + o$q.p224 = o$q.secp224r1, o$q.p256 = o$q.secp256r1 = o$q.prime256v1, o$q.p192 = o$q.secp192r1 = o$q.prime192v1, o$q.p384 = o$q.secp384r1, o$q.p521 = o$q.secp521r1, c$l.prototype.generateKeys = function(e12, t9) { + return (this || n$p).keys = (this || n$p).curve.genKeyPair(), this.getPublicKey(e12, t9); + }, c$l.prototype.computeSecret = function(e12, t9, r10) { + return t9 = t9 || "utf8", p$o.isBuffer(e12) || (e12 = new p$o(e12, t9)), y$j((this || n$p).curve.keyFromPublic(e12).getPublic().mul((this || n$p).keys.getPrivate()).getX(), r10, (this || n$p).curveType.byteLength); + }, c$l.prototype.getPublicKey = function(e12, t9) { + var r10 = (this || n$p).keys.getPublic("compressed" === t9, true); + return "hybrid" === t9 && (r10[r10.length - 1] % 2 ? r10[0] = 7 : r10[0] = 6), y$j(r10, e12); + }, c$l.prototype.getPrivateKey = function(e12) { + return y$j((this || n$p).keys.getPrivate(), e12); + }, c$l.prototype.setPublicKey = function(e12, t9) { + return t9 = t9 || "utf8", p$o.isBuffer(e12) || (e12 = new p$o(e12, t9)), (this || n$p).keys._importPublic(e12), this || n$p; + }, c$l.prototype.setPrivateKey = function(e12, t9) { + t9 = t9 || "utf8", p$o.isBuffer(e12) || (e12 = new p$o(e12, t9)); + var r10 = new u$m(e12); + return r10 = r10.toString(16), (this || n$p).keys = (this || n$p).curve.genKeyPair(), (this || n$p).keys._importPrivate(r10), this || n$p; + }; + var f$r = i$b; + var i$c = h$4; + var l$o = u4.Buffer; + function f$s(r10) { + var n9 = l$o.allocUnsafe(4); + return n9.writeUInt32BE(r10, 0), n9; + } + var u$n = function(r10, n9) { + for (var e12, t9 = l$o.alloc(0), o9 = 0; t9.length < n9; ) + e12 = f$s(o9++), t9 = l$o.concat([t9, i$c("sha1").update(r10).update(e12).digest()]); + return t9.slice(0, n9); + }; + var c$m = function(r10, n9) { + for (var e12 = r10.length, t9 = -1; ++t9 < e12; ) + r10[t9] ^= n9[t9]; + return r10; + }; + var p$p = n$c; + var d$m = u4.Buffer; + var h$j = function(r10, n9) { + return d$m.from(r10.toRed(p$p.mont(n9.modulus)).redPow(new p$p(n9.publicExponent)).fromRed().toArray()); + }; + var s$n = v$h; + var g$g = a5; + var m$k = h$4; + var w$h = u$n; + var v$j = c$m; + var y$k = n$c; + var E$c = h$j; + var b$g = l$d; + var B$b = u4.Buffer; + var x$9 = function(r10, n9, e12) { + var t9; + t9 = r10.padding ? r10.padding : e12 ? 1 : 4; + var o9, a8 = s$n(r10); + if (4 === t9) + o9 = function(r11, n10) { + var e13 = r11.modulus.byteLength(), t10 = n10.length, o10 = m$k("sha1").update(B$b.alloc(0)).digest(), a9 = o10.length, i8 = 2 * a9; + if (t10 > e13 - i8 - 2) + throw new Error("message too long"); + var l8 = B$b.alloc(e13 - t10 - i8 - 2), f9 = e13 - a9 - 1, u8 = g$g(a9), c8 = v$j(B$b.concat([o10, l8, B$b.alloc(1, 1), n10], f9), w$h(u8, f9)), p8 = v$j(u8, w$h(c8, a9)); + return new y$k(B$b.concat([B$b.alloc(1), p8, c8], e13)); + }(a8, n9); + else if (1 === t9) + o9 = function(r11, n10, e13) { + var t10, o10 = n10.length, a9 = r11.modulus.byteLength(); + if (o10 > a9 - 11) + throw new Error("message too long"); + t10 = e13 ? B$b.alloc(a9 - o10 - 3, 255) : function(r12) { + var n11, e14 = B$b.allocUnsafe(r12), t11 = 0, o11 = g$g(2 * r12), a10 = 0; + for (; t11 < r12; ) + a10 === o11.length && (o11 = g$g(2 * r12), a10 = 0), (n11 = o11[a10++]) && (e14[t11++] = n11); + return e14; + }(a9 - o10 - 3); + return new y$k(B$b.concat([B$b.from([0, e13 ? 1 : 2]), t10, B$b.alloc(1), n10], a9)); + }(a8, n9, e12); + else { + if (3 !== t9) + throw new Error("unknown padding"); + if ((o9 = new y$k(n9)).cmp(a8.modulus) >= 0) + throw new Error("data too long for modulus"); + } + return e12 ? b$g(o9, a8) : E$c(o9, a8); + }; + var L$7 = v$h; + var k$f = u$n; + var D$7 = c$m; + var U$9 = n$c; + var R$6 = l$d; + var S$c = h$4; + var j$9 = h$j; + var A$b = u4.Buffer; + var I$a = function(r10, n9, e12) { + var t9; + t9 = r10.padding ? r10.padding : e12 ? 1 : 4; + var o9, a8 = L$7(r10), i8 = a8.modulus.byteLength(); + if (n9.length > i8 || new U$9(n9).cmp(a8.modulus) >= 0) + throw new Error("decryption error"); + o9 = e12 ? j$9(new U$9(n9), a8) : R$6(n9, a8); + var l8 = A$b.alloc(i8 - o9.length); + if (o9 = A$b.concat([l8, o9], i8), 4 === t9) + return function(r11, n10) { + var e13 = r11.modulus.byteLength(), t10 = S$c("sha1").update(A$b.alloc(0)).digest(), o10 = t10.length; + if (0 !== n10[0]) + throw new Error("decryption error"); + var a9 = n10.slice(1, o10 + 1), i9 = n10.slice(o10 + 1), l9 = D$7(a9, k$f(i9, o10)), f9 = D$7(i9, k$f(l9, e13 - o10 - 1)); + if (function(r12, n11) { + r12 = A$b.from(r12), n11 = A$b.from(n11); + var e14 = 0, t11 = r12.length; + r12.length !== n11.length && (e14++, t11 = Math.min(r12.length, n11.length)); + var o11 = -1; + for (; ++o11 < t11; ) + e14 += r12[o11] ^ n11[o11]; + return e14; + }(t10, f9.slice(0, o10))) + throw new Error("decryption error"); + var u8 = o10; + for (; 0 === f9[u8]; ) + u8++; + if (1 !== f9[u8++]) + throw new Error("decryption error"); + return f9.slice(u8); + }(a8, o9); + if (1 === t9) + return function(r11, n10, e13) { + var t10 = n10.slice(0, 2), o10 = 2, a9 = 0; + for (; 0 !== n10[o10++]; ) + if (o10 >= n10.length) { + a9++; + break; + } + var i9 = n10.slice(2, o10 - 1); + ("0002" !== t10.toString("hex") && !e13 || "0001" !== t10.toString("hex") && e13) && a9++; + i9.length < 8 && a9++; + if (a9) + throw new Error("decryption error"); + return n10.slice(o10); + }(0, o9, e12); + if (3 === t9) + return o9; + throw new Error("unknown padding"); + }; + var M$9 = {}; + M$9.publicEncrypt = x$9, M$9.privateDecrypt = I$a, M$9.privateEncrypt = function(r10, n9) { + return M$9.publicEncrypt(r10, n9, true); + }, M$9.publicDecrypt = function(r10, n9) { + return M$9.privateDecrypt(r10, n9, true); + }; + var o$r = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : global; + var t$b = {}; + var f$t = T; + function i$d() { + throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11"); + } + var u$o = u4; + var a$o = a5; + var s$o = u$o.Buffer; + var l$p = u$o.kMaxLength; + var m$l = o$r.crypto || o$r.msCrypto; + var p$q = Math.pow(2, 32) - 1; + function y$l(r10, e12) { + if ("number" != typeof r10 || r10 != r10) + throw new TypeError("offset must be a number"); + if (r10 > p$q || r10 < 0) + throw new TypeError("offset must be a uint32"); + if (r10 > l$p || r10 > e12) + throw new RangeError("offset out of range"); + } + function b$h(r10, e12, n9) { + if ("number" != typeof r10 || r10 != r10) + throw new TypeError("size must be a number"); + if (r10 > p$q || r10 < 0) + throw new TypeError("size must be a uint32"); + if (r10 + e12 > n9 || r10 > l$p) + throw new RangeError("buffer too small"); + } + function w$i(r10, e12, n9, o9) { + if (f$t.browser) { + var t9 = r10.buffer, i8 = new Uint8Array(t9, e12, n9); + return m$l.getRandomValues(i8), o9 ? (f$t.nextTick(function() { + o9(null, r10); + }), void 0) : r10; + } + return o9 ? (a$o(n9, function(n10, t10) { + if (n10) + return o9(n10); + t10.copy(r10, e12), o9(null, r10); + }), void 0) : (a$o(n9).copy(r10, e12), r10); + } + m$l && m$l.getRandomValues || !f$t.browser ? (t$b.randomFill = function(r10, e12, n9, t9) { + if (!(s$o.isBuffer(r10) || r10 instanceof o$r.Uint8Array)) + throw new TypeError('"buf" argument must be a Buffer or Uint8Array'); + if ("function" == typeof e12) + t9 = e12, e12 = 0, n9 = r10.length; + else if ("function" == typeof n9) + t9 = n9, n9 = r10.length - e12; + else if ("function" != typeof t9) + throw new TypeError('"cb" argument must be a function'); + return y$l(e12, r10.length), b$h(n9, e12, r10.length), w$i(r10, e12, n9, t9); + }, t$b.randomFillSync = function(r10, e12, n9) { + void 0 === e12 && (e12 = 0); + if (!(s$o.isBuffer(r10) || r10 instanceof o$r.Uint8Array)) + throw new TypeError('"buf" argument must be a Buffer or Uint8Array'); + y$l(e12, r10.length), void 0 === n9 && (n9 = r10.length - e12); + return b$h(n9, e12, r10.length), w$i(r10, e12, n9); + }) : (t$b.randomFill = i$d, t$b.randomFillSync = i$d); + var l$q = {}; + l$q.randomBytes = l$q.rng = l$q.pseudoRandomBytes = l$q.prng = a5, l$q.createHash = l$q.Hash = h$4, l$q.createHmac = l$q.Hmac = w$3; + var D$8 = s$4; + var s$p = Object.keys(D$8); + var _$g = ["sha1", "sha224", "sha256", "sha384", "sha512", "md5", "rmd160"].concat(s$p); + l$q.getHashes = function() { + return _$g; + }; + var h$k = M$1; + l$q.pbkdf2 = h$k.pbkdf2, l$q.pbkdf2Sync = h$k.pbkdf2Sync; + var y$m = p$d; + l$q.Cipher = y$m.Cipher, l$q.createCipher = y$m.createCipher, l$q.Cipheriv = y$m.Cipheriv, l$q.createCipheriv = y$m.createCipheriv, l$q.Decipher = y$m.Decipher, l$q.createDecipher = y$m.createDecipher, l$q.Decipheriv = y$m.Decipheriv, l$q.createDecipheriv = y$m.createDecipheriv, l$q.getCiphers = y$m.getCiphers, l$q.listCiphers = y$m.listCiphers; + var E$d = O$3; + l$q.DiffieHellmanGroup = E$d.DiffieHellmanGroup, l$q.createDiffieHellmanGroup = E$d.createDiffieHellmanGroup, l$q.getDiffieHellman = E$d.getDiffieHellman, l$q.createDiffieHellman = E$d.createDiffieHellman, l$q.DiffieHellman = E$d.DiffieHellman; + var S$d = z$8; + l$q.createSign = S$d.createSign, l$q.Sign = S$d.Sign, l$q.createVerify = S$d.createVerify, l$q.Verify = S$d.Verify, l$q.createECDH = f$r; + var C$8 = M$9; + l$q.publicEncrypt = C$8.publicEncrypt, l$q.privateEncrypt = C$8.privateEncrypt, l$q.publicDecrypt = C$8.publicDecrypt, l$q.privateDecrypt = C$8.privateDecrypt; + var N$6 = t$b; + l$q.randomFill = N$6.randomFill, l$q.randomFillSync = N$6.randomFillSync, l$q.createCredentials = function() { + throw new Error(["sorry, createCredentials is not implemented yet", "we accept pull requests", "https://github.com/crypto-browserify/crypto-browserify"].join("\n")); + }, l$q.constants = { DH_CHECK_P_NOT_SAFE_PRIME: 2, DH_CHECK_P_NOT_PRIME: 1, DH_UNABLE_TO_CHECK_GENERATOR: 4, DH_NOT_SUITABLE_GENERATOR: 8, NPN_ENABLED: 1, ALPN_ENABLED: 1, RSA_PKCS1_PADDING: 1, RSA_SSLV23_PADDING: 2, RSA_NO_PADDING: 3, RSA_PKCS1_OAEP_PADDING: 4, RSA_X931_PADDING: 5, RSA_PKCS1_PSS_PADDING: 6, POINT_CONVERSION_COMPRESSED: 2, POINT_CONVERSION_UNCOMPRESSED: 4, POINT_CONVERSION_HYBRID: 6 }; + var exports$10$1 = {}; + var _dewExec$10$1 = false; + var _global$a$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$10$1() { + if (_dewExec$10$1) + return exports$10$1; + _dewExec$10$1 = true; + var r10; + exports$10$1 = function rand(len) { + if (!r10) + r10 = new Rand(null); + return r10.generate(len); + }; + function Rand(rand) { + (this || _global$a$1).rand = rand; + } + exports$10$1.Rand = Rand; + Rand.prototype.generate = function generate3(len) { + return this._rand(len); + }; + Rand.prototype._rand = function _rand(n9) { + if ((this || _global$a$1).rand.getBytes) + return (this || _global$a$1).rand.getBytes(n9); + var res = new Uint8Array(n9); + for (var i8 = 0; i8 < res.length; i8++) + res[i8] = (this || _global$a$1).rand.getByte(); + return res; + }; + if (typeof self === "object") { + if (self.crypto && self.crypto.getRandomValues) { + Rand.prototype._rand = function _rand(n9) { + var arr = new Uint8Array(n9); + self.crypto.getRandomValues(arr); + return arr; + }; + } else if (self.msCrypto && self.msCrypto.getRandomValues) { + Rand.prototype._rand = function _rand(n9) { + var arr = new Uint8Array(n9); + self.msCrypto.getRandomValues(arr); + return arr; + }; + } else if (typeof window === "object") { + Rand.prototype._rand = function() { + throw new Error("Not implemented yet"); + }; + } + } else { + try { + var crypto5 = l$q; + if (typeof crypto5.randomBytes !== "function") + throw new Error("Not supported"); + Rand.prototype._rand = function _rand(n9) { + return crypto5.randomBytes(n9); + }; + } catch (e12) { + } + } + return exports$10$1; + } + var exports$$$1 = {}; + var _dewExec$$$1 = false; + var _global$9$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$$$1() { + if (_dewExec$$$1) + return exports$$$1; + _dewExec$$$1 = true; + var bn = dew$11$1(); + var brorand = dew$10$1(); + function MillerRabin(rand) { + (this || _global$9$1).rand = rand || new brorand.Rand(); + } + exports$$$1 = MillerRabin; + MillerRabin.create = function create21(rand) { + return new MillerRabin(rand); + }; + MillerRabin.prototype._randbelow = function _randbelow(n9) { + var len = n9.bitLength(); + var min_bytes = Math.ceil(len / 8); + do + var a8 = new bn((this || _global$9$1).rand.generate(min_bytes)); + while (a8.cmp(n9) >= 0); + return a8; + }; + MillerRabin.prototype._randrange = function _randrange(start, stop) { + var size4 = stop.sub(start); + return start.add(this._randbelow(size4)); + }; + MillerRabin.prototype.test = function test(n9, k5, cb) { + var len = n9.bitLength(); + var red = bn.mont(n9); + var rone = new bn(1).toRed(red); + if (!k5) + k5 = Math.max(1, len / 48 | 0); + var n1 = n9.subn(1); + for (var s7 = 0; !n1.testn(s7); s7++) { + } + var d7 = n9.shrn(s7); + var rn1 = n1.toRed(red); + var prime = true; + for (; k5 > 0; k5--) { + var a8 = this._randrange(new bn(2), n1); + if (cb) + cb(a8); + var x5 = a8.toRed(red).redPow(d7); + if (x5.cmp(rone) === 0 || x5.cmp(rn1) === 0) + continue; + for (var i8 = 1; i8 < s7; i8++) { + x5 = x5.redSqr(); + if (x5.cmp(rone) === 0) + return false; + if (x5.cmp(rn1) === 0) + break; + } + if (i8 === s7) + return false; + } + return prime; + }; + MillerRabin.prototype.getDivisor = function getDivisor(n9, k5) { + var len = n9.bitLength(); + var red = bn.mont(n9); + var rone = new bn(1).toRed(red); + if (!k5) + k5 = Math.max(1, len / 48 | 0); + var n1 = n9.subn(1); + for (var s7 = 0; !n1.testn(s7); s7++) { + } + var d7 = n9.shrn(s7); + var rn1 = n1.toRed(red); + for (; k5 > 0; k5--) { + var a8 = this._randrange(new bn(2), n1); + var g6 = n9.gcd(a8); + if (g6.cmpn(1) !== 0) + return g6; + var x5 = a8.toRed(red).redPow(d7); + if (x5.cmp(rone) === 0 || x5.cmp(rn1) === 0) + continue; + for (var i8 = 1; i8 < s7; i8++) { + x5 = x5.redSqr(); + if (x5.cmp(rone) === 0) + return x5.fromRed().subn(1).gcd(n9); + if (x5.cmp(rn1) === 0) + break; + } + if (i8 === s7) { + x5 = x5.redSqr(); + return x5.fromRed().subn(1).gcd(n9); + } + } + return false; + }; + return exports$$$1; + } + var exports$_$1 = {}; + var _dewExec$_$1 = false; + function dew$_$1() { + if (_dewExec$_$1) + return exports$_$1; + _dewExec$_$1 = true; + var randomBytes3 = dew$1S(); + exports$_$1 = findPrime; + findPrime.simpleSieve = simpleSieve; + findPrime.fermatTest = fermatTest; + var BN = dew$122(); + var TWENTYFOUR = new BN(24); + var MillerRabin = dew$$$1(); + var millerRabin = new MillerRabin(); + var ONE = new BN(1); + var TWO = new BN(2); + var FIVE = new BN(5); + new BN(16); + new BN(8); + var TEN = new BN(10); + var THREE = new BN(3); + new BN(7); + var ELEVEN = new BN(11); + var FOUR = new BN(4); + new BN(12); + var primes = null; + function _getPrimes() { + if (primes !== null) + return primes; + var limit = 1048576; + var res = []; + res[0] = 2; + for (var i8 = 1, k5 = 3; k5 < limit; k5 += 2) { + var sqrt = Math.ceil(Math.sqrt(k5)); + for (var j5 = 0; j5 < i8 && res[j5] <= sqrt; j5++) + if (k5 % res[j5] === 0) + break; + if (i8 !== j5 && res[j5] <= sqrt) + continue; + res[i8++] = k5; + } + primes = res; + return res; + } + function simpleSieve(p8) { + var primes2 = _getPrimes(); + for (var i8 = 0; i8 < primes2.length; i8++) + if (p8.modn(primes2[i8]) === 0) { + if (p8.cmpn(primes2[i8]) === 0) { + return true; + } else { + return false; + } + } + return true; + } + function fermatTest(p8) { + var red = BN.mont(p8); + return TWO.toRed(red).redPow(p8.subn(1)).fromRed().cmpn(1) === 0; + } + function findPrime(bits, gen) { + if (bits < 16) { + if (gen === 2 || gen === 5) { + return new BN([140, 123]); + } else { + return new BN([140, 39]); + } + } + gen = new BN(gen); + var num, n22; + while (true) { + num = new BN(randomBytes3(Math.ceil(bits / 8))); + while (num.bitLength() > bits) { + num.ishrn(1); + } + if (num.isEven()) { + num.iadd(ONE); + } + if (!num.testn(1)) { + num.iadd(TWO); + } + if (!gen.cmp(TWO)) { + while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { + num.iadd(FOUR); + } + } else if (!gen.cmp(FIVE)) { + while (num.mod(TEN).cmp(THREE)) { + num.iadd(FOUR); + } + } + n22 = num.shrn(1); + if (simpleSieve(n22) && simpleSieve(num) && fermatTest(n22) && fermatTest(num) && millerRabin.test(n22) && millerRabin.test(num)) { + return num; + } + } + } + return exports$_$1; + } + var _primes$1 = { + "modp1": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" + }, + "modp2": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" + }, + "modp5": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" + }, + "modp14": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" + }, + "modp15": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" + }, + "modp16": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" + }, + "modp17": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" + }, + "modp18": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" + } + }; + var exports$Z$1 = {}; + var _dewExec$Z$1 = false; + var _global$8$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$Z$1() { + if (_dewExec$Z$1) + return exports$Z$1; + _dewExec$Z$1 = true; + var Buffer2 = e$1$1.Buffer; + var BN = dew$122(); + var MillerRabin = dew$$$1(); + var millerRabin = new MillerRabin(); + var TWENTYFOUR = new BN(24); + var ELEVEN = new BN(11); + var TEN = new BN(10); + var THREE = new BN(3); + var SEVEN = new BN(7); + var primes = dew$_$1(); + var randomBytes3 = dew$1S(); + exports$Z$1 = DH; + function setPublicKey(pub, enc) { + enc = enc || "utf8"; + if (!Buffer2.isBuffer(pub)) { + pub = new Buffer2(pub, enc); + } + (this || _global$8$1)._pub = new BN(pub); + return this || _global$8$1; + } + function setPrivateKey(priv, enc) { + enc = enc || "utf8"; + if (!Buffer2.isBuffer(priv)) { + priv = new Buffer2(priv, enc); + } + (this || _global$8$1)._priv = new BN(priv); + return this || _global$8$1; + } + var primeCache = {}; + function checkPrime(prime, generator) { + var gen = generator.toString("hex"); + var hex = [gen, prime.toString(16)].join("_"); + if (hex in primeCache) { + return primeCache[hex]; + } + var error7 = 0; + if (prime.isEven() || !primes.simpleSieve || !primes.fermatTest(prime) || !millerRabin.test(prime)) { + error7 += 1; + if (gen === "02" || gen === "05") { + error7 += 8; + } else { + error7 += 4; + } + primeCache[hex] = error7; + return error7; + } + if (!millerRabin.test(prime.shrn(1))) { + error7 += 2; + } + var rem; + switch (gen) { + case "02": + if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { + error7 += 8; + } + break; + case "05": + rem = prime.mod(TEN); + if (rem.cmp(THREE) && rem.cmp(SEVEN)) { + error7 += 8; + } + break; + default: + error7 += 4; + } + primeCache[hex] = error7; + return error7; + } + function DH(prime, generator, malleable) { + this.setGenerator(generator); + (this || _global$8$1).__prime = new BN(prime); + (this || _global$8$1)._prime = BN.mont((this || _global$8$1).__prime); + (this || _global$8$1)._primeLen = prime.length; + (this || _global$8$1)._pub = void 0; + (this || _global$8$1)._priv = void 0; + (this || _global$8$1)._primeCode = void 0; + if (malleable) { + (this || _global$8$1).setPublicKey = setPublicKey; + (this || _global$8$1).setPrivateKey = setPrivateKey; + } else { + (this || _global$8$1)._primeCode = 8; + } + } + Object.defineProperty(DH.prototype, "verifyError", { + enumerable: true, + get: function() { + if (typeof (this || _global$8$1)._primeCode !== "number") { + (this || _global$8$1)._primeCode = checkPrime((this || _global$8$1).__prime, (this || _global$8$1).__gen); + } + return (this || _global$8$1)._primeCode; + } + }); + DH.prototype.generateKeys = function() { + if (!(this || _global$8$1)._priv) { + (this || _global$8$1)._priv = new BN(randomBytes3((this || _global$8$1)._primeLen)); + } + (this || _global$8$1)._pub = (this || _global$8$1)._gen.toRed((this || _global$8$1)._prime).redPow((this || _global$8$1)._priv).fromRed(); + return this.getPublicKey(); + }; + DH.prototype.computeSecret = function(other) { + other = new BN(other); + other = other.toRed((this || _global$8$1)._prime); + var secret = other.redPow((this || _global$8$1)._priv).fromRed(); + var out = new Buffer2(secret.toArray()); + var prime = this.getPrime(); + if (out.length < prime.length) { + var front = new Buffer2(prime.length - out.length); + front.fill(0); + out = Buffer2.concat([front, out]); + } + return out; + }; + DH.prototype.getPublicKey = function getPublicKey2(enc) { + return formatReturnValue((this || _global$8$1)._pub, enc); + }; + DH.prototype.getPrivateKey = function getPrivateKey(enc) { + return formatReturnValue((this || _global$8$1)._priv, enc); + }; + DH.prototype.getPrime = function(enc) { + return formatReturnValue((this || _global$8$1).__prime, enc); + }; + DH.prototype.getGenerator = function(enc) { + return formatReturnValue((this || _global$8$1)._gen, enc); + }; + DH.prototype.setGenerator = function(gen, enc) { + enc = enc || "utf8"; + if (!Buffer2.isBuffer(gen)) { + gen = new Buffer2(gen, enc); + } + (this || _global$8$1).__gen = gen; + (this || _global$8$1)._gen = new BN(gen); + return this || _global$8$1; + }; + function formatReturnValue(bn, enc) { + var buf3 = new Buffer2(bn.toArray()); + if (!enc) { + return buf3; + } else { + return buf3.toString(enc); + } + } + return exports$Z$1; + } + var exports$Y$1 = {}; + var _dewExec$Y$1 = false; + function dew$Y$1() { + if (_dewExec$Y$1) + return exports$Y$1; + _dewExec$Y$1 = true; + var Buffer2 = e$1$1.Buffer; + var generatePrime = dew$_$1(); + var primes = _primes$1; + var DH = dew$Z$1(); + function getDiffieHellman2(mod3) { + var prime = new Buffer2(primes[mod3].prime, "hex"); + var gen = new Buffer2(primes[mod3].gen, "hex"); + return new DH(prime, gen); + } + var ENCODINGS = { + "binary": true, + "hex": true, + "base64": true + }; + function createDiffieHellman2(prime, enc, generator, genc) { + if (Buffer2.isBuffer(enc) || ENCODINGS[enc] === void 0) { + return createDiffieHellman2(prime, "binary", enc, generator); + } + enc = enc || "binary"; + genc = genc || "binary"; + generator = generator || new Buffer2([2]); + if (!Buffer2.isBuffer(generator)) { + generator = new Buffer2(generator, genc); + } + if (typeof prime === "number") { + return new DH(generatePrime(prime, generator), generator, true); + } + if (!Buffer2.isBuffer(prime)) { + prime = new Buffer2(prime, enc); + } + return new DH(prime, generator, true); + } + exports$Y$1.DiffieHellmanGroup = exports$Y$1.createDiffieHellmanGroup = exports$Y$1.getDiffieHellman = getDiffieHellman2; + exports$Y$1.createDiffieHellman = exports$Y$1.DiffieHellman = createDiffieHellman2; + return exports$Y$1; + } + var exports$X$1 = {}; + var _dewExec$X$1 = false; + var module$4$1 = { + exports: exports$X$1 + }; + var _global$7$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$X$1() { + if (_dewExec$X$1) + return module$4$1.exports; + _dewExec$X$1 = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$7$1).negative = 0; + (this || _global$7$1).words = null; + (this || _global$7$1).length = 0; + (this || _global$7$1).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = e$1$1.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$7$1).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$7$1).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$7$1).words = [number3 & 67108863]; + (this || _global$7$1).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$7$1).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$7$1).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$7$1).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$7$1).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$7$1).words = [0]; + (this || _global$7$1).length = 1; + return this || _global$7$1; + } + (this || _global$7$1).length = Math.ceil(number3.length / 3); + (this || _global$7$1).words = new Array((this || _global$7$1).length); + for (var i8 = 0; i8 < (this || _global$7$1).length; i8++) { + (this || _global$7$1).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$7$1).words[j5] |= w5 << off & 67108863; + (this || _global$7$1).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$7$1).words[j5] |= w5 << off & 67108863; + (this || _global$7$1).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this._strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 48 && c8 <= 57) { + return c8 - 48; + } else if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + assert(false, "Invalid character in " + string4); + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$7$1).length = Math.ceil((number3.length - start) / 6); + (this || _global$7$1).words = new Array((this || _global$7$1).length); + for (var i8 = 0; i8 < (this || _global$7$1).length; i8++) { + (this || _global$7$1).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$7$1).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$7$1).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$7$1).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$7$1).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this._strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var b6 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + b6 = c8 - 49 + 10; + } else if (c8 >= 17) { + b6 = c8 - 17 + 10; + } else { + b6 = c8; + } + assert(c8 >= 0 && b6 < mul, "Invalid character"); + r10 += b6; + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$7$1).words = [0]; + (this || _global$7$1).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$7$1).words[0] + word < 67108864) { + (this || _global$7$1).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$7$1).words[0] + word < 67108864) { + (this || _global$7$1).words[0] += word; + } else { + this._iaddn(word); + } + } + this._strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$7$1).length); + for (var i8 = 0; i8 < (this || _global$7$1).length; i8++) { + dest.words[i8] = (this || _global$7$1).words[i8]; + } + dest.length = (this || _global$7$1).length; + dest.negative = (this || _global$7$1).negative; + dest.red = (this || _global$7$1).red; + }; + function move2(dest, src3) { + dest.words = src3.words; + dest.length = src3.length; + dest.negative = src3.negative; + dest.red = src3.red; + } + BN.prototype._move = function _move(dest) { + move2(dest, this || _global$7$1); + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$7$1).length < size4) { + (this || _global$7$1).words[(this || _global$7$1).length++] = 0; + } + return this || _global$7$1; + }; + BN.prototype._strip = function strip() { + while ((this || _global$7$1).length > 1 && (this || _global$7$1).words[(this || _global$7$1).length - 1] === 0) { + (this || _global$7$1).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$7$1).length === 1 && (this || _global$7$1).words[0] === 0) { + (this || _global$7$1).negative = 0; + } + return this || _global$7$1; + }; + if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") { + try { + BN.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect3; + } catch (e12) { + BN.prototype.inspect = inspect3; + } + } else { + BN.prototype.inspect = inspect3; + } + function inspect3() { + return ((this || _global$7$1).red ? ""; + } + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$7$1).length; i8++) { + var w5 = (this || _global$7$1).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$7$1).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$7$1).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modrn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$7$1).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$7$1).words[0]; + if ((this || _global$7$1).length === 2) { + ret += (this || _global$7$1).words[1] * 67108864; + } else if ((this || _global$7$1).length === 3 && (this || _global$7$1).words[2] === 1) { + ret += 4503599627370496 + (this || _global$7$1).words[1] * 67108864; + } else if ((this || _global$7$1).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$7$1).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16, 2); + }; + if (Buffer2) { + BN.prototype.toBuffer = function toBuffer(endian, length3) { + return this.toArrayLike(Buffer2, endian, length3); + }; + } + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + var allocate3 = function allocate4(ArrayType, size4) { + if (ArrayType.allocUnsafe) { + return ArrayType.allocUnsafe(size4); + } + return new ArrayType(size4); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + this._strip(); + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + var res = allocate3(ArrayType, reqLength); + var postfix = endian === "le" ? "LE" : "BE"; + this["_toArrayLike" + postfix](res, byteLength); + return res; + }; + BN.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) { + var position = 0; + var carry = 0; + for (var i8 = 0, shift = 0; i8 < (this || _global$7$1).length; i8++) { + var word = (this || _global$7$1).words[i8] << shift | carry; + res[position++] = word & 255; + if (position < res.length) { + res[position++] = word >> 8 & 255; + } + if (position < res.length) { + res[position++] = word >> 16 & 255; + } + if (shift === 6) { + if (position < res.length) { + res[position++] = word >> 24 & 255; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } + if (position < res.length) { + res[position++] = carry; + while (position < res.length) { + res[position++] = 0; + } + } + }; + BN.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) { + var position = res.length - 1; + var carry = 0; + for (var i8 = 0, shift = 0; i8 < (this || _global$7$1).length; i8++) { + var word = (this || _global$7$1).words[i8] << shift | carry; + res[position--] = word & 255; + if (position >= 0) { + res[position--] = word >> 8 & 255; + } + if (position >= 0) { + res[position--] = word >> 16 & 255; + } + if (shift === 6) { + if (position >= 0) { + res[position--] = word >> 24 & 255; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } + if (position >= 0) { + res[position--] = carry; + while (position >= 0) { + res[position--] = 0; + } + } + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$7$1).words[(this || _global$7$1).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$7$1).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = num.words[off] >>> wbit & 1; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$7$1).length; i8++) { + var b6 = this._zeroBits((this || _global$7$1).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$7$1).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$7$1).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$7$1).negative ^= 1; + } + return this || _global$7$1; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$7$1).length < num.length) { + (this || _global$7$1).words[(this || _global$7$1).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$7$1).words[i8] = (this || _global$7$1).words[i8] | num.words[i8]; + } + return this._strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$7$1).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$7$1).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$7$1); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$7$1).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$7$1); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$7$1).length > num.length) { + b6 = num; + } else { + b6 = this || _global$7$1; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$7$1).words[i8] = (this || _global$7$1).words[i8] & num.words[i8]; + } + (this || _global$7$1).length = b6.length; + return this._strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$7$1).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$7$1).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$7$1); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$7$1).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$7$1); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$7$1).length > num.length) { + a8 = this || _global$7$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$7$1; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$7$1).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$7$1) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$7$1).words[i8] = a8.words[i8]; + } + } + (this || _global$7$1).length = a8.length; + return this._strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$7$1).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$7$1).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$7$1); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$7$1).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$7$1); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$7$1).words[i8] = ~(this || _global$7$1).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$7$1).words[i8] = ~(this || _global$7$1).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this._strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$7$1).words[off] = (this || _global$7$1).words[off] | 1 << wbit; + } else { + (this || _global$7$1).words[off] = (this || _global$7$1).words[off] & ~(1 << wbit); + } + return this._strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$7$1).negative !== 0 && num.negative === 0) { + (this || _global$7$1).negative = 0; + r10 = this.isub(num); + (this || _global$7$1).negative ^= 1; + return this._normSign(); + } else if ((this || _global$7$1).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$7$1).length > num.length) { + a8 = this || _global$7$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$7$1; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$7$1).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$7$1).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$7$1).length = a8.length; + if (carry !== 0) { + (this || _global$7$1).words[(this || _global$7$1).length] = carry; + (this || _global$7$1).length++; + } else if (a8 !== (this || _global$7$1)) { + for (; i8 < a8.length; i8++) { + (this || _global$7$1).words[i8] = a8.words[i8]; + } + } + return this || _global$7$1; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$7$1).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$7$1).negative !== 0) { + (this || _global$7$1).negative = 0; + res = num.sub(this || _global$7$1); + (this || _global$7$1).negative = 1; + return res; + } + if ((this || _global$7$1).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$7$1); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$7$1).negative !== 0) { + (this || _global$7$1).negative = 0; + this.iadd(num); + (this || _global$7$1).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$7$1).negative = 0; + (this || _global$7$1).length = 1; + (this || _global$7$1).words[0] = 0; + return this || _global$7$1; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$7$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$7$1; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$7$1).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$7$1).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$7$1)) { + for (; i8 < a8.length; i8++) { + (this || _global$7$1).words[i8] = a8.words[i8]; + } + } + (this || _global$7$1).length = Math.max((this || _global$7$1).length, i8); + if (a8 !== (this || _global$7$1)) { + (this || _global$7$1).negative = 1; + } + return this._strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out._strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out._strip(); + } + function jumboMulTo(self2, num, out) { + return bigMulTo(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$7$1).length + num.length; + if ((this || _global$7$1).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$7$1, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$7$1, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$7$1, num, out); + } else { + res = jumboMulTo(this || _global$7$1, num, out); + } + return res; + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$7$1).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$7$1).length + num.length); + return jumboMulTo(this || _global$7$1, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$7$1); + }; + BN.prototype.imuln = function imuln(num) { + var isNegNum = num < 0; + if (isNegNum) + num = -num; + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$7$1).length; i8++) { + var w5 = ((this || _global$7$1).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$7$1).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$7$1).words[i8] = carry; + (this || _global$7$1).length++; + } + return isNegNum ? this.ineg() : this || _global$7$1; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$7$1); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$7$1; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$7$1).length; i8++) { + var newCarry = (this || _global$7$1).words[i8] & carryMask; + var c8 = ((this || _global$7$1).words[i8] | 0) - newCarry << r10; + (this || _global$7$1).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$7$1).words[i8] = carry; + (this || _global$7$1).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$7$1).length - 1; i8 >= 0; i8--) { + (this || _global$7$1).words[i8 + s7] = (this || _global$7$1).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$7$1).words[i8] = 0; + } + (this || _global$7$1).length += s7; + } + return this._strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$7$1).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$7$1).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$7$1).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$7$1).length > s7) { + (this || _global$7$1).length -= s7; + for (i8 = 0; i8 < (this || _global$7$1).length; i8++) { + (this || _global$7$1).words[i8] = (this || _global$7$1).words[i8 + s7]; + } + } else { + (this || _global$7$1).words[0] = 0; + (this || _global$7$1).length = 1; + } + var carry = 0; + for (i8 = (this || _global$7$1).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$7$1).words[i8] | 0; + (this || _global$7$1).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$7$1).length === 0) { + (this || _global$7$1).words[0] = 0; + (this || _global$7$1).length = 1; + } + return this._strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$7$1).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$7$1).length <= s7) + return false; + var w5 = (this || _global$7$1).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$7$1).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$7$1).length <= s7) { + return this || _global$7$1; + } + if (r10 !== 0) { + s7++; + } + (this || _global$7$1).length = Math.min(s7, (this || _global$7$1).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$7$1).words[(this || _global$7$1).length - 1] &= mask2; + } + return this._strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$7$1).negative !== 0) { + if ((this || _global$7$1).length === 1 && ((this || _global$7$1).words[0] | 0) <= num) { + (this || _global$7$1).words[0] = num - ((this || _global$7$1).words[0] | 0); + (this || _global$7$1).negative = 0; + return this || _global$7$1; + } + (this || _global$7$1).negative = 0; + this.isubn(num); + (this || _global$7$1).negative = 1; + return this || _global$7$1; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$7$1).words[0] += num; + for (var i8 = 0; i8 < (this || _global$7$1).length && (this || _global$7$1).words[i8] >= 67108864; i8++) { + (this || _global$7$1).words[i8] -= 67108864; + if (i8 === (this || _global$7$1).length - 1) { + (this || _global$7$1).words[i8 + 1] = 1; + } else { + (this || _global$7$1).words[i8 + 1]++; + } + } + (this || _global$7$1).length = Math.max((this || _global$7$1).length, i8 + 1); + return this || _global$7$1; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$7$1).negative !== 0) { + (this || _global$7$1).negative = 0; + this.iaddn(num); + (this || _global$7$1).negative = 1; + return this || _global$7$1; + } + (this || _global$7$1).words[0] -= num; + if ((this || _global$7$1).length === 1 && (this || _global$7$1).words[0] < 0) { + (this || _global$7$1).words[0] = -(this || _global$7$1).words[0]; + (this || _global$7$1).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$7$1).length && (this || _global$7$1).words[i8] < 0; i8++) { + (this || _global$7$1).words[i8] += 67108864; + (this || _global$7$1).words[i8 + 1] -= 1; + } + } + return this._strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$7$1).negative = 0; + return this || _global$7$1; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$7$1).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$7$1).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$7$1).length - shift; i8++) { + w5 = ((this || _global$7$1).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$7$1).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this._strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$7$1).length; i8++) { + w5 = -((this || _global$7$1).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$7$1).words[i8] = w5 & 67108863; + } + (this || _global$7$1).negative = 1; + return this._strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$7$1).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4._strip(); + } + a8._strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$7$1).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$7$1).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$7$1).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$7$1).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$7$1 + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modrn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modrn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modrn = function modrn(num) { + var isNegNum = num < 0; + if (isNegNum) + num = -num; + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$7$1).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$7$1).words[i8] | 0)) % num; + } + return isNegNum ? -acc : acc; + }; + BN.prototype.modn = function modn(num) { + return this.modrn(num); + }; + BN.prototype.idivn = function idivn(num) { + var isNegNum = num < 0; + if (isNegNum) + num = -num; + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$7$1).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$7$1).words[i8] | 0) + carry * 67108864; + (this || _global$7$1).words[i8] = w5 / num | 0; + carry = w5 % num; + } + this._strip(); + return isNegNum ? this.ineg() : this || _global$7$1; + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$7$1; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$7$1; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$7$1).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$7$1).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$7$1).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$7$1).length <= s7) { + this._expand(s7 + 1); + (this || _global$7$1).words[s7] |= q4; + return this || _global$7$1; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$7$1).length; i8++) { + var w5 = (this || _global$7$1).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$7$1).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$7$1).words[i8] = carry; + (this || _global$7$1).length++; + } + return this || _global$7$1; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$7$1).length === 1 && (this || _global$7$1).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$7$1).negative !== 0 && !negative) + return -1; + if ((this || _global$7$1).negative === 0 && negative) + return 1; + this._strip(); + var res; + if ((this || _global$7$1).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$7$1).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$7$1).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$7$1).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$7$1).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$7$1).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$7$1).length > num.length) + return 1; + if ((this || _global$7$1).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$7$1).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$7$1).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$7$1).red, "Already a number in reduction context"); + assert((this || _global$7$1).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$7$1)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$7$1).red, "fromRed works only with numbers in reduction context"); + return (this || _global$7$1).red.convertFrom(this || _global$7$1); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$7$1).red = ctx; + return this || _global$7$1; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$7$1).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$7$1).red, "redAdd works only with red numbers"); + return (this || _global$7$1).red.add(this || _global$7$1, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$7$1).red, "redIAdd works only with red numbers"); + return (this || _global$7$1).red.iadd(this || _global$7$1, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$7$1).red, "redSub works only with red numbers"); + return (this || _global$7$1).red.sub(this || _global$7$1, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$7$1).red, "redISub works only with red numbers"); + return (this || _global$7$1).red.isub(this || _global$7$1, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$7$1).red, "redShl works only with red numbers"); + return (this || _global$7$1).red.shl(this || _global$7$1, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$7$1).red, "redMul works only with red numbers"); + (this || _global$7$1).red._verify2(this || _global$7$1, num); + return (this || _global$7$1).red.mul(this || _global$7$1, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$7$1).red, "redMul works only with red numbers"); + (this || _global$7$1).red._verify2(this || _global$7$1, num); + return (this || _global$7$1).red.imul(this || _global$7$1, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$7$1).red, "redSqr works only with red numbers"); + (this || _global$7$1).red._verify1(this || _global$7$1); + return (this || _global$7$1).red.sqr(this || _global$7$1); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$7$1).red, "redISqr works only with red numbers"); + (this || _global$7$1).red._verify1(this || _global$7$1); + return (this || _global$7$1).red.isqr(this || _global$7$1); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$7$1).red, "redSqrt works only with red numbers"); + (this || _global$7$1).red._verify1(this || _global$7$1); + return (this || _global$7$1).red.sqrt(this || _global$7$1); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$7$1).red, "redInvm works only with red numbers"); + (this || _global$7$1).red._verify1(this || _global$7$1); + return (this || _global$7$1).red.invm(this || _global$7$1); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$7$1).red, "redNeg works only with red numbers"); + (this || _global$7$1).red._verify1(this || _global$7$1); + return (this || _global$7$1).red.neg(this || _global$7$1); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$7$1).red && !num.red, "redPow(normalNum)"); + (this || _global$7$1).red._verify1(this || _global$7$1); + return (this || _global$7$1).red.pow(this || _global$7$1, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$7$1).name = name15; + (this || _global$7$1).p = new BN(p8, 16); + (this || _global$7$1).n = (this || _global$7$1).p.bitLength(); + (this || _global$7$1).k = new BN(1).iushln((this || _global$7$1).n).isub((this || _global$7$1).p); + (this || _global$7$1).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$7$1).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$7$1).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$7$1).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$7$1).n); + var cmp = rlen < (this || _global$7$1).n ? -1 : r10.ucmp((this || _global$7$1).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$7$1).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$7$1).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$7$1).k); + }; + function K256() { + MPrime.call(this || _global$7$1, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$7$1, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$7$1, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$7$1, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$7$1).m = prime.p; + (this || _global$7$1).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$7$1).m = m7; + (this || _global$7$1).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$7$1).prime) + return (this || _global$7$1).prime.ireduce(a8)._forceRed(this || _global$7$1); + move2(a8, a8.umod((this || _global$7$1).m)._forceRed(this || _global$7$1)); + return a8; + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$7$1).m.sub(a8)._forceRed(this || _global$7$1); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$7$1).m) >= 0) { + res.isub((this || _global$7$1).m); + } + return res._forceRed(this || _global$7$1); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$7$1).m) >= 0) { + res.isub((this || _global$7$1).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$7$1).m); + } + return res._forceRed(this || _global$7$1); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$7$1).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$7$1).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$7$1).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$7$1).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$7$1); + var nOne = one.redNeg(); + var lpow = (this || _global$7$1).m.subn(1).iushrn(1); + var z6 = (this || _global$7$1).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$7$1); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$7$1).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$7$1); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$7$1); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$7$1).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$7$1, m7); + (this || _global$7$1).shift = (this || _global$7$1).m.bitLength(); + if ((this || _global$7$1).shift % 26 !== 0) { + (this || _global$7$1).shift += 26 - (this || _global$7$1).shift % 26; + } + (this || _global$7$1).r = new BN(1).iushln((this || _global$7$1).shift); + (this || _global$7$1).r2 = this.imod((this || _global$7$1).r.sqr()); + (this || _global$7$1).rinv = (this || _global$7$1).r._invmp((this || _global$7$1).m); + (this || _global$7$1).minv = (this || _global$7$1).rinv.mul((this || _global$7$1).r).isubn(1).div((this || _global$7$1).m); + (this || _global$7$1).minv = (this || _global$7$1).minv.umod((this || _global$7$1).r); + (this || _global$7$1).minv = (this || _global$7$1).r.sub((this || _global$7$1).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$7$1).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$7$1).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$7$1).shift).mul((this || _global$7$1).minv).imaskn((this || _global$7$1).shift).mul((this || _global$7$1).m); + var u8 = t9.isub(c8).iushrn((this || _global$7$1).shift); + var res = u8; + if (u8.cmp((this || _global$7$1).m) >= 0) { + res = u8.isub((this || _global$7$1).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$7$1).m); + } + return res._forceRed(this || _global$7$1); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$7$1); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$7$1).shift).mul((this || _global$7$1).minv).imaskn((this || _global$7$1).shift).mul((this || _global$7$1).m); + var u8 = t9.isub(c8).iushrn((this || _global$7$1).shift); + var res = u8; + if (u8.cmp((this || _global$7$1).m) >= 0) { + res = u8.isub((this || _global$7$1).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$7$1).m); + } + return res._forceRed(this || _global$7$1); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$7$1).m).mul((this || _global$7$1).r2)); + return res._forceRed(this || _global$7$1); + }; + })(module$4$1, exports$X$1); + return module$4$1.exports; + } + var exports$W$1 = {}; + var _dewExec$W$1 = false; + function dew$W$1() { + if (_dewExec$W$1) + return exports$W$1; + _dewExec$W$1 = true; + var Buffer2 = e$1$1.Buffer; + var BN = dew$X$1(); + var randomBytes3 = dew$1S(); + function blind(priv) { + var r10 = getr(priv); + var blinder = r10.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed(); + return { + blinder, + unblinder: r10.invm(priv.modulus) + }; + } + function getr(priv) { + var len = priv.modulus.byteLength(); + var r10; + do { + r10 = new BN(randomBytes3(len)); + } while (r10.cmp(priv.modulus) >= 0 || !r10.umod(priv.prime1) || !r10.umod(priv.prime2)); + return r10; + } + function crt(msg, priv) { + var blinds = blind(priv); + var len = priv.modulus.byteLength(); + var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus); + var c1 = blinded.toRed(BN.mont(priv.prime1)); + var c22 = blinded.toRed(BN.mont(priv.prime2)); + var qinv = priv.coefficient; + var p8 = priv.prime1; + var q4 = priv.prime2; + var m1 = c1.redPow(priv.exponent1).fromRed(); + var m22 = c22.redPow(priv.exponent2).fromRed(); + var h9 = m1.isub(m22).imul(qinv).umod(p8).imul(q4); + return m22.iadd(h9).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer2, "be", len); + } + crt.getr = getr; + exports$W$1 = crt; + return exports$W$1; + } + var _package$1 = { + "_args": [ + [ + "elliptic@6.5.4", + "C:\\Users\\guybe\\Projects\\rollup-plugin-jspm" + ] + ], + "_from": "elliptic@6.5.4", + "_id": "elliptic@6.5.4", + "_inBundle": false, + "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "_location": "/@jspm/core/elliptic", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "elliptic@6.5.4", + "name": "elliptic", + "escapedName": "elliptic", + "rawSpec": "6.5.4", + "saveSpec": null, + "fetchSpec": "6.5.4" + }, + "_requiredBy": [ + "/@jspm/core/browserify-sign", + "/@jspm/core/create-ecdh" + ], + "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "_spec": "6.5.4", + "_where": "C:\\Users\\guybe\\Projects\\rollup-plugin-jspm", + "author": { + "name": "Fedor Indutny", + "email": "fedor@indutny.com" + }, + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + }, + "description": "EC cryptography", + "devDependencies": { + "brfs": "^2.0.2", + "coveralls": "^3.1.0", + "eslint": "^7.6.0", + "grunt": "^1.2.1", + "grunt-browserify": "^5.3.0", + "grunt-cli": "^1.3.2", + "grunt-contrib-connect": "^3.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^5.0.0", + "grunt-mocha-istanbul": "^5.0.2", + "grunt-saucelabs": "^9.0.1", + "istanbul": "^0.4.5", + "mocha": "^8.0.1" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/indutny/elliptic", + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "license": "MIT", + "main": "lib/elliptic.js", + "name": "elliptic", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/indutny/elliptic.git" + }, + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "test": "npm run lint && npm run unit", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "version": "grunt dist && git add dist/" + }, + "version": "6.5.4" + }; + var exports$V$1 = {}; + var _dewExec$V$1 = false; + var module$3$1 = { + exports: exports$V$1 + }; + var _global$6$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$V$1() { + if (_dewExec$V$1) + return module$3$1.exports; + _dewExec$V$1 = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$6$1).negative = 0; + (this || _global$6$1).words = null; + (this || _global$6$1).length = 0; + (this || _global$6$1).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = e$1$1.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$6$1).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$6$1).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$6$1).words = [number3 & 67108863]; + (this || _global$6$1).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$6$1).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$6$1).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$6$1).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$6$1).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$6$1).words = [0]; + (this || _global$6$1).length = 1; + return this || _global$6$1; + } + (this || _global$6$1).length = Math.ceil(number3.length / 3); + (this || _global$6$1).words = new Array((this || _global$6$1).length); + for (var i8 = 0; i8 < (this || _global$6$1).length; i8++) { + (this || _global$6$1).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$6$1).words[j5] |= w5 << off & 67108863; + (this || _global$6$1).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$6$1).words[j5] |= w5 << off & 67108863; + (this || _global$6$1).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$6$1).length = Math.ceil((number3.length - start) / 6); + (this || _global$6$1).words = new Array((this || _global$6$1).length); + for (var i8 = 0; i8 < (this || _global$6$1).length; i8++) { + (this || _global$6$1).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$6$1).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$6$1).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$6$1).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$6$1).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$6$1).words = [0]; + (this || _global$6$1).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$6$1).words[0] + word < 67108864) { + (this || _global$6$1).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$6$1).words[0] + word < 67108864) { + (this || _global$6$1).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$6$1).length); + for (var i8 = 0; i8 < (this || _global$6$1).length; i8++) { + dest.words[i8] = (this || _global$6$1).words[i8]; + } + dest.length = (this || _global$6$1).length; + dest.negative = (this || _global$6$1).negative; + dest.red = (this || _global$6$1).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$6$1).length < size4) { + (this || _global$6$1).words[(this || _global$6$1).length++] = 0; + } + return this || _global$6$1; + }; + BN.prototype.strip = function strip() { + while ((this || _global$6$1).length > 1 && (this || _global$6$1).words[(this || _global$6$1).length - 1] === 0) { + (this || _global$6$1).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$6$1).length === 1 && (this || _global$6$1).words[0] === 0) { + (this || _global$6$1).negative = 0; + } + return this || _global$6$1; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$6$1).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$6$1).length; i8++) { + var w5 = (this || _global$6$1).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$6$1).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$6$1).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$6$1).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$6$1).words[0]; + if ((this || _global$6$1).length === 2) { + ret += (this || _global$6$1).words[1] * 67108864; + } else if ((this || _global$6$1).length === 3 && (this || _global$6$1).words[2] === 1) { + ret += 4503599627370496 + (this || _global$6$1).words[1] * 67108864; + } else if ((this || _global$6$1).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$6$1).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$6$1).words[(this || _global$6$1).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$6$1).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$6$1).length; i8++) { + var b6 = this._zeroBits((this || _global$6$1).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$6$1).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$6$1).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$6$1).negative ^= 1; + } + return this || _global$6$1; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$6$1).length < num.length) { + (this || _global$6$1).words[(this || _global$6$1).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$6$1).words[i8] = (this || _global$6$1).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$6$1).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$6$1).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$6$1); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$6$1).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$6$1); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$6$1).length > num.length) { + b6 = num; + } else { + b6 = this || _global$6$1; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$6$1).words[i8] = (this || _global$6$1).words[i8] & num.words[i8]; + } + (this || _global$6$1).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$6$1).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$6$1).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$6$1); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$6$1).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$6$1); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$6$1).length > num.length) { + a8 = this || _global$6$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$6$1; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$6$1).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$6$1) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$6$1).words[i8] = a8.words[i8]; + } + } + (this || _global$6$1).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$6$1).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$6$1).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$6$1); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$6$1).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$6$1); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$6$1).words[i8] = ~(this || _global$6$1).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$6$1).words[i8] = ~(this || _global$6$1).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$6$1).words[off] = (this || _global$6$1).words[off] | 1 << wbit; + } else { + (this || _global$6$1).words[off] = (this || _global$6$1).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$6$1).negative !== 0 && num.negative === 0) { + (this || _global$6$1).negative = 0; + r10 = this.isub(num); + (this || _global$6$1).negative ^= 1; + return this._normSign(); + } else if ((this || _global$6$1).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$6$1).length > num.length) { + a8 = this || _global$6$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$6$1; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$6$1).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$6$1).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$6$1).length = a8.length; + if (carry !== 0) { + (this || _global$6$1).words[(this || _global$6$1).length] = carry; + (this || _global$6$1).length++; + } else if (a8 !== (this || _global$6$1)) { + for (; i8 < a8.length; i8++) { + (this || _global$6$1).words[i8] = a8.words[i8]; + } + } + return this || _global$6$1; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$6$1).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$6$1).negative !== 0) { + (this || _global$6$1).negative = 0; + res = num.sub(this || _global$6$1); + (this || _global$6$1).negative = 1; + return res; + } + if ((this || _global$6$1).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$6$1); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$6$1).negative !== 0) { + (this || _global$6$1).negative = 0; + this.iadd(num); + (this || _global$6$1).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$6$1).negative = 0; + (this || _global$6$1).length = 1; + (this || _global$6$1).words[0] = 0; + return this || _global$6$1; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$6$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$6$1; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$6$1).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$6$1).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$6$1)) { + for (; i8 < a8.length; i8++) { + (this || _global$6$1).words[i8] = a8.words[i8]; + } + } + (this || _global$6$1).length = Math.max((this || _global$6$1).length, i8); + if (a8 !== (this || _global$6$1)) { + (this || _global$6$1).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$6$1).length + num.length; + if ((this || _global$6$1).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$6$1, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$6$1, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$6$1, num, out); + } else { + res = jumboMulTo(this || _global$6$1, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$6$1).x = x5; + (this || _global$6$1).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$6$1).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$6$1).length + num.length); + return jumboMulTo(this || _global$6$1, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$6$1); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$6$1).length; i8++) { + var w5 = ((this || _global$6$1).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$6$1).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$6$1).words[i8] = carry; + (this || _global$6$1).length++; + } + return this || _global$6$1; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$6$1); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$6$1; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$6$1).length; i8++) { + var newCarry = (this || _global$6$1).words[i8] & carryMask; + var c8 = ((this || _global$6$1).words[i8] | 0) - newCarry << r10; + (this || _global$6$1).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$6$1).words[i8] = carry; + (this || _global$6$1).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$6$1).length - 1; i8 >= 0; i8--) { + (this || _global$6$1).words[i8 + s7] = (this || _global$6$1).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$6$1).words[i8] = 0; + } + (this || _global$6$1).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$6$1).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$6$1).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$6$1).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$6$1).length > s7) { + (this || _global$6$1).length -= s7; + for (i8 = 0; i8 < (this || _global$6$1).length; i8++) { + (this || _global$6$1).words[i8] = (this || _global$6$1).words[i8 + s7]; + } + } else { + (this || _global$6$1).words[0] = 0; + (this || _global$6$1).length = 1; + } + var carry = 0; + for (i8 = (this || _global$6$1).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$6$1).words[i8] | 0; + (this || _global$6$1).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$6$1).length === 0) { + (this || _global$6$1).words[0] = 0; + (this || _global$6$1).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$6$1).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$6$1).length <= s7) + return false; + var w5 = (this || _global$6$1).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$6$1).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$6$1).length <= s7) { + return this || _global$6$1; + } + if (r10 !== 0) { + s7++; + } + (this || _global$6$1).length = Math.min(s7, (this || _global$6$1).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$6$1).words[(this || _global$6$1).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$6$1).negative !== 0) { + if ((this || _global$6$1).length === 1 && ((this || _global$6$1).words[0] | 0) < num) { + (this || _global$6$1).words[0] = num - ((this || _global$6$1).words[0] | 0); + (this || _global$6$1).negative = 0; + return this || _global$6$1; + } + (this || _global$6$1).negative = 0; + this.isubn(num); + (this || _global$6$1).negative = 1; + return this || _global$6$1; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$6$1).words[0] += num; + for (var i8 = 0; i8 < (this || _global$6$1).length && (this || _global$6$1).words[i8] >= 67108864; i8++) { + (this || _global$6$1).words[i8] -= 67108864; + if (i8 === (this || _global$6$1).length - 1) { + (this || _global$6$1).words[i8 + 1] = 1; + } else { + (this || _global$6$1).words[i8 + 1]++; + } + } + (this || _global$6$1).length = Math.max((this || _global$6$1).length, i8 + 1); + return this || _global$6$1; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$6$1).negative !== 0) { + (this || _global$6$1).negative = 0; + this.iaddn(num); + (this || _global$6$1).negative = 1; + return this || _global$6$1; + } + (this || _global$6$1).words[0] -= num; + if ((this || _global$6$1).length === 1 && (this || _global$6$1).words[0] < 0) { + (this || _global$6$1).words[0] = -(this || _global$6$1).words[0]; + (this || _global$6$1).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$6$1).length && (this || _global$6$1).words[i8] < 0; i8++) { + (this || _global$6$1).words[i8] += 67108864; + (this || _global$6$1).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$6$1).negative = 0; + return this || _global$6$1; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$6$1).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$6$1).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$6$1).length - shift; i8++) { + w5 = ((this || _global$6$1).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$6$1).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$6$1).length; i8++) { + w5 = -((this || _global$6$1).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$6$1).words[i8] = w5 & 67108863; + } + (this || _global$6$1).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$6$1).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$6$1).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$6$1).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$6$1).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$6$1).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$6$1 + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$6$1).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$6$1).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$6$1).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$6$1).words[i8] | 0) + carry * 67108864; + (this || _global$6$1).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$6$1; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$6$1; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$6$1).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$6$1).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$6$1).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$6$1).length <= s7) { + this._expand(s7 + 1); + (this || _global$6$1).words[s7] |= q4; + return this || _global$6$1; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$6$1).length; i8++) { + var w5 = (this || _global$6$1).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$6$1).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$6$1).words[i8] = carry; + (this || _global$6$1).length++; + } + return this || _global$6$1; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$6$1).length === 1 && (this || _global$6$1).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$6$1).negative !== 0 && !negative) + return -1; + if ((this || _global$6$1).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$6$1).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$6$1).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$6$1).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$6$1).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$6$1).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$6$1).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$6$1).length > num.length) + return 1; + if ((this || _global$6$1).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$6$1).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$6$1).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$6$1).red, "Already a number in reduction context"); + assert((this || _global$6$1).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$6$1)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$6$1).red, "fromRed works only with numbers in reduction context"); + return (this || _global$6$1).red.convertFrom(this || _global$6$1); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$6$1).red = ctx; + return this || _global$6$1; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$6$1).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$6$1).red, "redAdd works only with red numbers"); + return (this || _global$6$1).red.add(this || _global$6$1, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$6$1).red, "redIAdd works only with red numbers"); + return (this || _global$6$1).red.iadd(this || _global$6$1, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$6$1).red, "redSub works only with red numbers"); + return (this || _global$6$1).red.sub(this || _global$6$1, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$6$1).red, "redISub works only with red numbers"); + return (this || _global$6$1).red.isub(this || _global$6$1, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$6$1).red, "redShl works only with red numbers"); + return (this || _global$6$1).red.shl(this || _global$6$1, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$6$1).red, "redMul works only with red numbers"); + (this || _global$6$1).red._verify2(this || _global$6$1, num); + return (this || _global$6$1).red.mul(this || _global$6$1, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$6$1).red, "redMul works only with red numbers"); + (this || _global$6$1).red._verify2(this || _global$6$1, num); + return (this || _global$6$1).red.imul(this || _global$6$1, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$6$1).red, "redSqr works only with red numbers"); + (this || _global$6$1).red._verify1(this || _global$6$1); + return (this || _global$6$1).red.sqr(this || _global$6$1); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$6$1).red, "redISqr works only with red numbers"); + (this || _global$6$1).red._verify1(this || _global$6$1); + return (this || _global$6$1).red.isqr(this || _global$6$1); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$6$1).red, "redSqrt works only with red numbers"); + (this || _global$6$1).red._verify1(this || _global$6$1); + return (this || _global$6$1).red.sqrt(this || _global$6$1); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$6$1).red, "redInvm works only with red numbers"); + (this || _global$6$1).red._verify1(this || _global$6$1); + return (this || _global$6$1).red.invm(this || _global$6$1); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$6$1).red, "redNeg works only with red numbers"); + (this || _global$6$1).red._verify1(this || _global$6$1); + return (this || _global$6$1).red.neg(this || _global$6$1); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$6$1).red && !num.red, "redPow(normalNum)"); + (this || _global$6$1).red._verify1(this || _global$6$1); + return (this || _global$6$1).red.pow(this || _global$6$1, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$6$1).name = name15; + (this || _global$6$1).p = new BN(p8, 16); + (this || _global$6$1).n = (this || _global$6$1).p.bitLength(); + (this || _global$6$1).k = new BN(1).iushln((this || _global$6$1).n).isub((this || _global$6$1).p); + (this || _global$6$1).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$6$1).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$6$1).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$6$1).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$6$1).n); + var cmp = rlen < (this || _global$6$1).n ? -1 : r10.ucmp((this || _global$6$1).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$6$1).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$6$1).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$6$1).k); + }; + function K256() { + MPrime.call(this || _global$6$1, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$6$1, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$6$1, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$6$1, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$6$1).m = prime.p; + (this || _global$6$1).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$6$1).m = m7; + (this || _global$6$1).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$6$1).prime) + return (this || _global$6$1).prime.ireduce(a8)._forceRed(this || _global$6$1); + return a8.umod((this || _global$6$1).m)._forceRed(this || _global$6$1); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$6$1).m.sub(a8)._forceRed(this || _global$6$1); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$6$1).m) >= 0) { + res.isub((this || _global$6$1).m); + } + return res._forceRed(this || _global$6$1); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$6$1).m) >= 0) { + res.isub((this || _global$6$1).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$6$1).m); + } + return res._forceRed(this || _global$6$1); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$6$1).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$6$1).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$6$1).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$6$1).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$6$1); + var nOne = one.redNeg(); + var lpow = (this || _global$6$1).m.subn(1).iushrn(1); + var z6 = (this || _global$6$1).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$6$1); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$6$1).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$6$1); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$6$1); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$6$1).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$6$1, m7); + (this || _global$6$1).shift = (this || _global$6$1).m.bitLength(); + if ((this || _global$6$1).shift % 26 !== 0) { + (this || _global$6$1).shift += 26 - (this || _global$6$1).shift % 26; + } + (this || _global$6$1).r = new BN(1).iushln((this || _global$6$1).shift); + (this || _global$6$1).r2 = this.imod((this || _global$6$1).r.sqr()); + (this || _global$6$1).rinv = (this || _global$6$1).r._invmp((this || _global$6$1).m); + (this || _global$6$1).minv = (this || _global$6$1).rinv.mul((this || _global$6$1).r).isubn(1).div((this || _global$6$1).m); + (this || _global$6$1).minv = (this || _global$6$1).minv.umod((this || _global$6$1).r); + (this || _global$6$1).minv = (this || _global$6$1).r.sub((this || _global$6$1).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$6$1).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$6$1).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$6$1).shift).mul((this || _global$6$1).minv).imaskn((this || _global$6$1).shift).mul((this || _global$6$1).m); + var u8 = t9.isub(c8).iushrn((this || _global$6$1).shift); + var res = u8; + if (u8.cmp((this || _global$6$1).m) >= 0) { + res = u8.isub((this || _global$6$1).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$6$1).m); + } + return res._forceRed(this || _global$6$1); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$6$1); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$6$1).shift).mul((this || _global$6$1).minv).imaskn((this || _global$6$1).shift).mul((this || _global$6$1).m); + var u8 = t9.isub(c8).iushrn((this || _global$6$1).shift); + var res = u8; + if (u8.cmp((this || _global$6$1).m) >= 0) { + res = u8.isub((this || _global$6$1).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$6$1).m); + } + return res._forceRed(this || _global$6$1); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$6$1).m).mul((this || _global$6$1).r2)); + return res._forceRed(this || _global$6$1); + }; + })(module$3$1, exports$V$1); + return module$3$1.exports; + } + var exports$U$1 = {}; + var _dewExec$U$1 = false; + function dew$U$1() { + if (_dewExec$U$1) + return exports$U$1; + _dewExec$U$1 = true; + var utils2 = exports$U$1; + function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg !== "string") { + for (var i8 = 0; i8 < msg.length; i8++) + res[i8] = msg[i8] | 0; + return res; + } + if (enc === "hex") { + msg = msg.replace(/[^a-z0-9]+/ig, ""); + if (msg.length % 2 !== 0) + msg = "0" + msg; + for (var i8 = 0; i8 < msg.length; i8 += 2) + res.push(parseInt(msg[i8] + msg[i8 + 1], 16)); + } else { + for (var i8 = 0; i8 < msg.length; i8++) { + var c8 = msg.charCodeAt(i8); + var hi = c8 >> 8; + var lo = c8 & 255; + if (hi) + res.push(hi, lo); + else + res.push(lo); + } + } + return res; + } + utils2.toArray = toArray; + function zero2(word) { + if (word.length === 1) + return "0" + word; + else + return word; + } + utils2.zero2 = zero2; + function toHex2(msg) { + var res = ""; + for (var i8 = 0; i8 < msg.length; i8++) + res += zero2(msg[i8].toString(16)); + return res; + } + utils2.toHex = toHex2; + utils2.encode = function encode41(arr, enc) { + if (enc === "hex") + return toHex2(arr); + else + return arr; + }; + return exports$U$1; + } + var exports$T$1 = {}; + var _dewExec$T$1 = false; + function dew$T$1() { + if (_dewExec$T$1) + return exports$T$1; + _dewExec$T$1 = true; + var utils2 = exports$T$1; + var BN = dew$V$1(); + var minAssert = dew$1t(); + var minUtils = dew$U$1(); + utils2.assert = minAssert; + utils2.toArray = minUtils.toArray; + utils2.zero2 = minUtils.zero2; + utils2.toHex = minUtils.toHex; + utils2.encode = minUtils.encode; + function getNAF(num, w5, bits) { + var naf = new Array(Math.max(num.bitLength(), bits) + 1); + naf.fill(0); + var ws2 = 1 << w5 + 1; + var k5 = num.clone(); + for (var i8 = 0; i8 < naf.length; i8++) { + var z6; + var mod3 = k5.andln(ws2 - 1); + if (k5.isOdd()) { + if (mod3 > (ws2 >> 1) - 1) + z6 = (ws2 >> 1) - mod3; + else + z6 = mod3; + k5.isubn(z6); + } else { + z6 = 0; + } + naf[i8] = z6; + k5.iushrn(1); + } + return naf; + } + utils2.getNAF = getNAF; + function getJSF(k1, k22) { + var jsf = [[], []]; + k1 = k1.clone(); + k22 = k22.clone(); + var d1 = 0; + var d22 = 0; + var m8; + while (k1.cmpn(-d1) > 0 || k22.cmpn(-d22) > 0) { + var m14 = k1.andln(3) + d1 & 3; + var m24 = k22.andln(3) + d22 & 3; + if (m14 === 3) + m14 = -1; + if (m24 === 3) + m24 = -1; + var u1; + if ((m14 & 1) === 0) { + u1 = 0; + } else { + m8 = k1.andln(7) + d1 & 7; + if ((m8 === 3 || m8 === 5) && m24 === 2) + u1 = -m14; + else + u1 = m14; + } + jsf[0].push(u1); + var u22; + if ((m24 & 1) === 0) { + u22 = 0; + } else { + m8 = k22.andln(7) + d22 & 7; + if ((m8 === 3 || m8 === 5) && m14 === 2) + u22 = -m24; + else + u22 = m24; + } + jsf[1].push(u22); + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d22 === u22 + 1) + d22 = 1 - d22; + k1.iushrn(1); + k22.iushrn(1); + } + return jsf; + } + utils2.getJSF = getJSF; + function cachedProperty(obj, name15, computer) { + var key = "_" + name15; + obj.prototype[name15] = function cachedProperty2() { + return this[key] !== void 0 ? this[key] : this[key] = computer.call(this); + }; + } + utils2.cachedProperty = cachedProperty; + function parseBytes(bytes2) { + return typeof bytes2 === "string" ? utils2.toArray(bytes2, "hex") : bytes2; + } + utils2.parseBytes = parseBytes; + function intFromLE(bytes2) { + return new BN(bytes2, "hex", "le"); + } + utils2.intFromLE = intFromLE; + return exports$T$1; + } + var exports$S$1 = {}; + var _dewExec$S$1 = false; + function dew$S$1() { + if (_dewExec$S$1) + return exports$S$1; + _dewExec$S$1 = true; + var BN = dew$V$1(); + var utils2 = dew$T$1(); + var getNAF = utils2.getNAF; + var getJSF = utils2.getJSF; + var assert = utils2.assert; + function BaseCurve(type3, conf) { + this.type = type3; + this.p = new BN(conf.p, 16); + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + this.zero = new BN(0).toRed(this.red); + this.one = new BN(1).toRed(this.red); + this.two = new BN(2).toRed(this.red); + this.n = conf.n && new BN(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + this._wnafT1 = new Array(4); + this._wnafT2 = new Array(4); + this._wnafT3 = new Array(4); + this._wnafT4 = new Array(4); + this._bitLength = this.n ? this.n.bitLength() : 0; + var adjustCount = this.n && this.p.div(this.n); + if (!adjustCount || adjustCount.cmpn(100) > 0) { + this.redN = null; + } else { + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); + } + } + exports$S$1 = BaseCurve; + BaseCurve.prototype.point = function point() { + throw new Error("Not implemented"); + }; + BaseCurve.prototype.validate = function validate3() { + throw new Error("Not implemented"); + }; + BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p8, k5) { + assert(p8.precomputed); + var doubles = p8._getDoubles(); + var naf = getNAF(k5, 1, this._bitLength); + var I5 = (1 << doubles.step + 1) - (doubles.step % 2 === 0 ? 2 : 1); + I5 /= 3; + var repr = []; + var j5; + var nafW; + for (j5 = 0; j5 < naf.length; j5 += doubles.step) { + nafW = 0; + for (var l8 = j5 + doubles.step - 1; l8 >= j5; l8--) + nafW = (nafW << 1) + naf[l8]; + repr.push(nafW); + } + var a8 = this.jpoint(null, null, null); + var b6 = this.jpoint(null, null, null); + for (var i8 = I5; i8 > 0; i8--) { + for (j5 = 0; j5 < repr.length; j5++) { + nafW = repr[j5]; + if (nafW === i8) + b6 = b6.mixedAdd(doubles.points[j5]); + else if (nafW === -i8) + b6 = b6.mixedAdd(doubles.points[j5].neg()); + } + a8 = a8.add(b6); + } + return a8.toP(); + }; + BaseCurve.prototype._wnafMul = function _wnafMul(p8, k5) { + var w5 = 4; + var nafPoints = p8._getNAFPoints(w5); + w5 = nafPoints.wnd; + var wnd = nafPoints.points; + var naf = getNAF(k5, w5, this._bitLength); + var acc = this.jpoint(null, null, null); + for (var i8 = naf.length - 1; i8 >= 0; i8--) { + for (var l8 = 0; i8 >= 0 && naf[i8] === 0; i8--) + l8++; + if (i8 >= 0) + l8++; + acc = acc.dblp(l8); + if (i8 < 0) + break; + var z6 = naf[i8]; + assert(z6 !== 0); + if (p8.type === "affine") { + if (z6 > 0) + acc = acc.mixedAdd(wnd[z6 - 1 >> 1]); + else + acc = acc.mixedAdd(wnd[-z6 - 1 >> 1].neg()); + } else { + if (z6 > 0) + acc = acc.add(wnd[z6 - 1 >> 1]); + else + acc = acc.add(wnd[-z6 - 1 >> 1].neg()); + } + } + return p8.type === "affine" ? acc.toP() : acc; + }; + BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, points, coeffs, len, jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; + var max = 0; + var i8; + var j5; + var p8; + for (i8 = 0; i8 < len; i8++) { + p8 = points[i8]; + var nafPoints = p8._getNAFPoints(defW); + wndWidth[i8] = nafPoints.wnd; + wnd[i8] = nafPoints.points; + } + for (i8 = len - 1; i8 >= 1; i8 -= 2) { + var a8 = i8 - 1; + var b6 = i8; + if (wndWidth[a8] !== 1 || wndWidth[b6] !== 1) { + naf[a8] = getNAF(coeffs[a8], wndWidth[a8], this._bitLength); + naf[b6] = getNAF(coeffs[b6], wndWidth[b6], this._bitLength); + max = Math.max(naf[a8].length, max); + max = Math.max(naf[b6].length, max); + continue; + } + var comb = [ + points[a8], + /* 1 */ + null, + /* 3 */ + null, + /* 5 */ + points[b6] + /* 7 */ + ]; + if (points[a8].y.cmp(points[b6].y) === 0) { + comb[1] = points[a8].add(points[b6]); + comb[2] = points[a8].toJ().mixedAdd(points[b6].neg()); + } else if (points[a8].y.cmp(points[b6].y.redNeg()) === 0) { + comb[1] = points[a8].toJ().mixedAdd(points[b6]); + comb[2] = points[a8].add(points[b6].neg()); + } else { + comb[1] = points[a8].toJ().mixedAdd(points[b6]); + comb[2] = points[a8].toJ().mixedAdd(points[b6].neg()); + } + var index2 = [ + -3, + /* -1 -1 */ + -1, + /* -1 0 */ + -5, + /* -1 1 */ + -7, + /* 0 -1 */ + 0, + /* 0 0 */ + 7, + /* 0 1 */ + 5, + /* 1 -1 */ + 1, + /* 1 0 */ + 3 + /* 1 1 */ + ]; + var jsf = getJSF(coeffs[a8], coeffs[b6]); + max = Math.max(jsf[0].length, max); + naf[a8] = new Array(max); + naf[b6] = new Array(max); + for (j5 = 0; j5 < max; j5++) { + var ja = jsf[0][j5] | 0; + var jb = jsf[1][j5] | 0; + naf[a8][j5] = index2[(ja + 1) * 3 + (jb + 1)]; + naf[b6][j5] = 0; + wnd[a8] = comb; + } + } + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (i8 = max; i8 >= 0; i8--) { + var k5 = 0; + while (i8 >= 0) { + var zero2 = true; + for (j5 = 0; j5 < len; j5++) { + tmp[j5] = naf[j5][i8] | 0; + if (tmp[j5] !== 0) + zero2 = false; + } + if (!zero2) + break; + k5++; + i8--; + } + if (i8 >= 0) + k5++; + acc = acc.dblp(k5); + if (i8 < 0) + break; + for (j5 = 0; j5 < len; j5++) { + var z6 = tmp[j5]; + if (z6 === 0) + continue; + else if (z6 > 0) + p8 = wnd[j5][z6 - 1 >> 1]; + else if (z6 < 0) + p8 = wnd[j5][-z6 - 1 >> 1].neg(); + if (p8.type === "affine") + acc = acc.mixedAdd(p8); + else + acc = acc.add(p8); + } + } + for (i8 = 0; i8 < len; i8++) + wnd[i8] = null; + if (jacobianResult) + return acc; + else + return acc.toP(); + }; + function BasePoint(curve, type3) { + this.curve = curve; + this.type = type3; + this.precomputed = null; + } + BaseCurve.BasePoint = BasePoint; + BasePoint.prototype.eq = function eq() { + throw new Error("Not implemented"); + }; + BasePoint.prototype.validate = function validate3() { + return this.curve.validate(this); + }; + BaseCurve.prototype.decodePoint = function decodePoint(bytes2, enc) { + bytes2 = utils2.toArray(bytes2, enc); + var len = this.p.byteLength(); + if ((bytes2[0] === 4 || bytes2[0] === 6 || bytes2[0] === 7) && bytes2.length - 1 === 2 * len) { + if (bytes2[0] === 6) + assert(bytes2[bytes2.length - 1] % 2 === 0); + else if (bytes2[0] === 7) + assert(bytes2[bytes2.length - 1] % 2 === 1); + var res = this.point(bytes2.slice(1, 1 + len), bytes2.slice(1 + len, 1 + 2 * len)); + return res; + } else if ((bytes2[0] === 2 || bytes2[0] === 3) && bytes2.length - 1 === len) { + return this.pointFromX(bytes2.slice(1, 1 + len), bytes2[0] === 3); + } + throw new Error("Unknown point format"); + }; + BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); + }; + BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x5 = this.getX().toArray("be", len); + if (compact) + return [this.getY().isEven() ? 2 : 3].concat(x5); + return [4].concat(x5, this.getY().toArray("be", len)); + }; + BasePoint.prototype.encode = function encode41(enc, compact) { + return utils2.encode(this._encode(compact), enc); + }; + BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; + var precomputed = { + doubles: null, + naf: null, + beta: null + }; + precomputed.naf = this._getNAFPoints(8); + precomputed.doubles = this._getDoubles(4, power); + precomputed.beta = this._getBeta(); + this.precomputed = precomputed; + return this; + }; + BasePoint.prototype._hasDoubles = function _hasDoubles(k5) { + if (!this.precomputed) + return false; + var doubles = this.precomputed.doubles; + if (!doubles) + return false; + return doubles.points.length >= Math.ceil((k5.bitLength() + 1) / doubles.step); + }; + BasePoint.prototype._getDoubles = function _getDoubles(step2, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + var doubles = [this]; + var acc = this; + for (var i8 = 0; i8 < power; i8 += step2) { + for (var j5 = 0; j5 < step2; j5++) + acc = acc.dbl(); + doubles.push(acc); + } + return { + step: step2, + points: doubles + }; + }; + BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + var res = [this]; + var max = (1 << wnd) - 1; + var dbl = max === 1 ? null : this.dbl(); + for (var i8 = 1; i8 < max; i8++) + res[i8] = res[i8 - 1].add(dbl); + return { + wnd, + points: res + }; + }; + BasePoint.prototype._getBeta = function _getBeta() { + return null; + }; + BasePoint.prototype.dblp = function dblp(k5) { + var r10 = this; + for (var i8 = 0; i8 < k5; i8++) + r10 = r10.dbl(); + return r10; + }; + return exports$S$1; + } + var exports$R$1 = {}; + var _dewExec$R$1 = false; + function dew$R$1() { + if (_dewExec$R$1) + return exports$R$1; + _dewExec$R$1 = true; + var utils2 = dew$T$1(); + var BN = dew$V$1(); + var inherits3 = dew$f$2(); + var Base2 = dew$S$1(); + var assert = utils2.assert; + function ShortCurve(conf) { + Base2.call(this, "short", conf); + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.tinv = this.two.redInvm(); + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + this.endo = this._getEndomorphism(conf); + this._endoWnafT1 = new Array(4); + this._endoWnafT2 = new Array(4); + } + inherits3(ShortCurve, Base2); + exports$R$1 = ShortCurve; + ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; + var beta; + var lambda; + if (conf.beta) { + beta = new BN(conf.beta, 16).toRed(this.red); + } else { + var betas = this._getEndoRoots(this.p); + beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; + beta = beta.toRed(this.red); + } + if (conf.lambda) { + lambda = new BN(conf.lambda, 16); + } else { + var lambdas = this._getEndoRoots(this.n); + if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { + lambda = lambdas[0]; + } else { + lambda = lambdas[1]; + assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); + } + } + var basis; + if (conf.basis) { + basis = conf.basis.map(function(vec) { + return { + a: new BN(vec.a, 16), + b: new BN(vec.b, 16) + }; + }); + } else { + basis = this._getEndoBasis(lambda); + } + return { + beta, + lambda, + basis + }; + }; + ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { + var red = num === this.p ? this.red : BN.mont(num); + var tinv = new BN(2).toRed(red).redInvm(); + var ntinv = tinv.redNeg(); + var s7 = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); + var l1 = ntinv.redAdd(s7).fromRed(); + var l22 = ntinv.redSub(s7).fromRed(); + return [l1, l22]; + }; + ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); + var u8 = lambda; + var v7 = this.n.clone(); + var x1 = new BN(1); + var y1 = new BN(0); + var x22 = new BN(0); + var y22 = new BN(1); + var a0; + var b0; + var a1; + var b1; + var a22; + var b22; + var prevR; + var i8 = 0; + var r10; + var x5; + while (u8.cmpn(0) !== 0) { + var q4 = v7.div(u8); + r10 = v7.sub(q4.mul(u8)); + x5 = x22.sub(q4.mul(x1)); + var y7 = y22.sub(q4.mul(y1)); + if (!a1 && r10.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r10.neg(); + b1 = x5; + } else if (a1 && ++i8 === 2) { + break; + } + prevR = r10; + v7 = u8; + u8 = r10; + x22 = x1; + x1 = x5; + y22 = y1; + y1 = y7; + } + a22 = r10.neg(); + b22 = x5; + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a22.sqr().add(b22.sqr()); + if (len2.cmp(len1) >= 0) { + a22 = a0; + b22 = b0; + } + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a22.negative) { + a22 = a22.neg(); + b22 = b22.neg(); + } + return [{ + a: a1, + b: b1 + }, { + a: a22, + b: b22 + }]; + }; + ShortCurve.prototype._endoSplit = function _endoSplit(k5) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v22 = basis[1]; + var c1 = v22.b.mul(k5).divRound(this.n); + var c22 = v1.b.neg().mul(k5).divRound(this.n); + var p1 = c1.mul(v1.a); + var p22 = c22.mul(v22.a); + var q1 = c1.mul(v1.b); + var q22 = c22.mul(v22.b); + var k1 = k5.sub(p1).sub(p22); + var k22 = q1.add(q22).neg(); + return { + k1, + k2: k22 + }; + }; + ShortCurve.prototype.pointFromX = function pointFromX(x5, odd) { + x5 = new BN(x5, 16); + if (!x5.red) + x5 = x5.toRed(this.red); + var y22 = x5.redSqr().redMul(x5).redIAdd(x5.redMul(this.a)).redIAdd(this.b); + var y7 = y22.redSqrt(); + if (y7.redSqr().redSub(y22).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var isOdd = y7.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y7 = y7.redNeg(); + return this.point(x5, y7); + }; + ShortCurve.prototype.validate = function validate3(point) { + if (point.inf) + return true; + var x5 = point.x; + var y7 = point.y; + var ax = this.a.redMul(x5); + var rhs = x5.redSqr().redMul(x5).redIAdd(ax).redIAdd(this.b); + return y7.redSqr().redISub(rhs).cmpn(0) === 0; + }; + ShortCurve.prototype._endoWnafMulAdd = function _endoWnafMulAdd(points, coeffs, jacobianResult) { + var npoints = this._endoWnafT1; + var ncoeffs = this._endoWnafT2; + for (var i8 = 0; i8 < points.length; i8++) { + var split2 = this._endoSplit(coeffs[i8]); + var p8 = points[i8]; + var beta = p8._getBeta(); + if (split2.k1.negative) { + split2.k1.ineg(); + p8 = p8.neg(true); + } + if (split2.k2.negative) { + split2.k2.ineg(); + beta = beta.neg(true); + } + npoints[i8 * 2] = p8; + npoints[i8 * 2 + 1] = beta; + ncoeffs[i8 * 2] = split2.k1; + ncoeffs[i8 * 2 + 1] = split2.k2; + } + var res = this._wnafMulAdd(1, npoints, ncoeffs, i8 * 2, jacobianResult); + for (var j5 = 0; j5 < i8 * 2; j5++) { + npoints[j5] = null; + ncoeffs[j5] = null; + } + return res; + }; + function Point2(curve, x5, y7, isRed) { + Base2.BasePoint.call(this, curve, "affine"); + if (x5 === null && y7 === null) { + this.x = null; + this.y = null; + this.inf = true; + } else { + this.x = new BN(x5, 16); + this.y = new BN(y7, 16); + if (isRed) { + this.x.forceRed(this.curve.red); + this.y.forceRed(this.curve.red); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + this.inf = false; + } + } + inherits3(Point2, Base2.BasePoint); + ShortCurve.prototype.point = function point(x5, y7, isRed) { + return new Point2(this, x5, y7, isRed); + }; + ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point2.fromJSON(this, obj, red); + }; + Point2.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; + var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (pre) { + var curve = this.curve; + var endoMul = function(p8) { + return curve.point(p8.x.redMul(curve.endo.beta), p8.y); + }; + pre.beta = beta; + beta.precomputed = { + beta: null, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(endoMul) + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(endoMul) + } + }; + } + return beta; + }; + Point2.prototype.toJSON = function toJSON4() { + if (!this.precomputed) + return [this.x, this.y]; + return [this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1) + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1) + } + }]; + }; + Point2.fromJSON = function fromJSON3(curve, obj, red) { + if (typeof obj === "string") + obj = JSON.parse(obj); + var res = curve.point(obj[0], obj[1], red); + if (!obj[2]) + return res; + function obj2point(obj2) { + return curve.point(obj2[0], obj2[1], red); + } + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [res].concat(pre.doubles.points.map(obj2point)) + }, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [res].concat(pre.naf.points.map(obj2point)) + } + }; + return res; + }; + Point2.prototype.inspect = function inspect3() { + if (this.isInfinity()) + return ""; + return ""; + }; + Point2.prototype.isInfinity = function isInfinity() { + return this.inf; + }; + Point2.prototype.add = function add12(p8) { + if (this.inf) + return p8; + if (p8.inf) + return this; + if (this.eq(p8)) + return this.dbl(); + if (this.neg().eq(p8)) + return this.curve.point(null, null); + if (this.x.cmp(p8.x) === 0) + return this.curve.point(null, null); + var c8 = this.y.redSub(p8.y); + if (c8.cmpn(0) !== 0) + c8 = c8.redMul(this.x.redSub(p8.x).redInvm()); + var nx = c8.redSqr().redISub(this.x).redISub(p8.x); + var ny = c8.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); + }; + Point2.prototype.dbl = function dbl() { + if (this.inf) + return this; + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); + var a8 = this.curve.a; + var x22 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c8 = x22.redAdd(x22).redIAdd(x22).redIAdd(a8).redMul(dyinv); + var nx = c8.redSqr().redISub(this.x.redAdd(this.x)); + var ny = c8.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); + }; + Point2.prototype.getX = function getX() { + return this.x.fromRed(); + }; + Point2.prototype.getY = function getY() { + return this.y.fromRed(); + }; + Point2.prototype.mul = function mul(k5) { + k5 = new BN(k5, 16); + if (this.isInfinity()) + return this; + else if (this._hasDoubles(k5)) + return this.curve._fixedNafMul(this, k5); + else if (this.curve.endo) + return this.curve._endoWnafMulAdd([this], [k5]); + else + return this.curve._wnafMul(this, k5); + }; + Point2.prototype.mulAdd = function mulAdd(k1, p22, k22) { + var points = [this, p22]; + var coeffs = [k1, k22]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2); + }; + Point2.prototype.jmulAdd = function jmulAdd(k1, p22, k22) { + var points = [this, p22]; + var coeffs = [k1, k22]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs, true); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); + }; + Point2.prototype.eq = function eq(p8) { + return this === p8 || this.inf === p8.inf && (this.inf || this.x.cmp(p8.x) === 0 && this.y.cmp(p8.y) === 0); + }; + Point2.prototype.neg = function neg(_precompute) { + if (this.inf) + return this; + var res = this.curve.point(this.x, this.y.redNeg()); + if (_precompute && this.precomputed) { + var pre = this.precomputed; + var negate = function(p8) { + return p8.neg(); + }; + res.precomputed = { + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(negate) + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(negate) + } + }; + } + return res; + }; + Point2.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; + }; + function JPoint(curve, x5, y7, z6) { + Base2.BasePoint.call(this, curve, "jacobian"); + if (x5 === null && y7 === null && z6 === null) { + this.x = this.curve.one; + this.y = this.curve.one; + this.z = new BN(0); + } else { + this.x = new BN(x5, 16); + this.y = new BN(y7, 16); + this.z = new BN(z6, 16); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + this.zOne = this.z === this.curve.one; + } + inherits3(JPoint, Base2.BasePoint); + ShortCurve.prototype.jpoint = function jpoint(x5, y7, z6) { + return new JPoint(this, x5, y7, z6); + }; + JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); + return this.curve.point(ax, ay); + }; + JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); + }; + JPoint.prototype.add = function add12(p8) { + if (this.isInfinity()) + return p8; + if (p8.isInfinity()) + return this; + var pz2 = p8.z.redSqr(); + var z22 = this.z.redSqr(); + var u1 = this.x.redMul(pz2); + var u22 = p8.x.redMul(z22); + var s1 = this.y.redMul(pz2.redMul(p8.z)); + var s22 = p8.y.redMul(z22.redMul(this.z)); + var h9 = u1.redSub(u22); + var r10 = s1.redSub(s22); + if (h9.cmpn(0) === 0) { + if (r10.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + var h22 = h9.redSqr(); + var h32 = h22.redMul(h9); + var v7 = u1.redMul(h22); + var nx = r10.redSqr().redIAdd(h32).redISub(v7).redISub(v7); + var ny = r10.redMul(v7.redISub(nx)).redISub(s1.redMul(h32)); + var nz = this.z.redMul(p8.z).redMul(h9); + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype.mixedAdd = function mixedAdd(p8) { + if (this.isInfinity()) + return p8.toJ(); + if (p8.isInfinity()) + return this; + var z22 = this.z.redSqr(); + var u1 = this.x; + var u22 = p8.x.redMul(z22); + var s1 = this.y; + var s22 = p8.y.redMul(z22).redMul(this.z); + var h9 = u1.redSub(u22); + var r10 = s1.redSub(s22); + if (h9.cmpn(0) === 0) { + if (r10.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + var h22 = h9.redSqr(); + var h32 = h22.redMul(h9); + var v7 = u1.redMul(h22); + var nx = r10.redSqr().redIAdd(h32).redISub(v7).redISub(v7); + var ny = r10.redMul(v7.redISub(nx)).redISub(s1.redMul(h32)); + var nz = this.z.redMul(h9); + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); + var i8; + if (this.curve.zeroA || this.curve.threeA) { + var r10 = this; + for (i8 = 0; i8 < pow; i8++) + r10 = r10.dbl(); + return r10; + } + var a8 = this.curve.a; + var tinv = this.curve.tinv; + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + var jyd = jy.redAdd(jy); + for (i8 = 0; i8 < pow; i8++) { + var jx2 = jx.redSqr(); + var jyd2 = jyd.redSqr(); + var jyd4 = jyd2.redSqr(); + var c8 = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a8.redMul(jz4)); + var t1 = jx.redMul(jyd2); + var nx = c8.redSqr().redISub(t1.redAdd(t1)); + var t22 = t1.redISub(nx); + var dny = c8.redMul(t22); + dny = dny.redIAdd(dny).redISub(jyd4); + var nz = jyd.redMul(jz); + if (i8 + 1 < pow) + jz4 = jz4.redMul(jyd4); + jx = nx; + jz = nz; + jyd = dny; + } + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); + }; + JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); + else + return this._dbl(); + }; + JPoint.prototype._zeroDbl = function _zeroDbl() { + var nx; + var ny; + var nz; + if (this.zOne) { + var xx = this.x.redSqr(); + var yy = this.y.redSqr(); + var yyyy = yy.redSqr(); + var s7 = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s7 = s7.redIAdd(s7); + var m7 = xx.redAdd(xx).redIAdd(xx); + var t9 = m7.redSqr().redISub(s7).redISub(s7); + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + nx = t9; + ny = m7.redMul(s7.redISub(t9)).redISub(yyyy8); + nz = this.y.redAdd(this.y); + } else { + var a8 = this.x.redSqr(); + var b6 = this.y.redSqr(); + var c8 = b6.redSqr(); + var d7 = this.x.redAdd(b6).redSqr().redISub(a8).redISub(c8); + d7 = d7.redIAdd(d7); + var e12 = a8.redAdd(a8).redIAdd(a8); + var f9 = e12.redSqr(); + var c82 = c8.redIAdd(c8); + c82 = c82.redIAdd(c82); + c82 = c82.redIAdd(c82); + nx = f9.redISub(d7).redISub(d7); + ny = e12.redMul(d7.redISub(nx)).redISub(c82); + nz = this.y.redMul(this.z); + nz = nz.redIAdd(nz); + } + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype._threeDbl = function _threeDbl() { + var nx; + var ny; + var nz; + if (this.zOne) { + var xx = this.x.redSqr(); + var yy = this.y.redSqr(); + var yyyy = yy.redSqr(); + var s7 = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s7 = s7.redIAdd(s7); + var m7 = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); + var t9 = m7.redSqr().redISub(s7).redISub(s7); + nx = t9; + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + ny = m7.redMul(s7.redISub(t9)).redISub(yyyy8); + nz = this.y.redAdd(this.y); + } else { + var delta = this.z.redSqr(); + var gamma = this.y.redSqr(); + var beta = this.x.redMul(gamma); + var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); + alpha = alpha.redAdd(alpha).redIAdd(alpha); + var beta4 = beta.redIAdd(beta); + beta4 = beta4.redIAdd(beta4); + var beta8 = beta4.redAdd(beta4); + nx = alpha.redSqr().redISub(beta8); + nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); + var ggamma8 = gamma.redSqr(); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); + } + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype._dbl = function _dbl() { + var a8 = this.curve.a; + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); + var c8 = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a8.redMul(jz4)); + var jxd4 = jx.redAdd(jx); + jxd4 = jxd4.redIAdd(jxd4); + var t1 = jxd4.redMul(jy2); + var nx = c8.redSqr().redISub(t1.redAdd(t1)); + var t22 = t1.redISub(nx); + var jyd8 = jy2.redSqr(); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + var ny = c8.redMul(t22).redISub(jyd8); + var nz = jy.redAdd(jy).redMul(jz); + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var xx = this.x.redSqr(); + var yy = this.y.redSqr(); + var zz = this.z.redSqr(); + var yyyy = yy.redSqr(); + var m7 = xx.redAdd(xx).redIAdd(xx); + var mm = m7.redSqr(); + var e12 = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + e12 = e12.redIAdd(e12); + e12 = e12.redAdd(e12).redIAdd(e12); + e12 = e12.redISub(mm); + var ee3 = e12.redSqr(); + var t9 = yyyy.redIAdd(yyyy); + t9 = t9.redIAdd(t9); + t9 = t9.redIAdd(t9); + t9 = t9.redIAdd(t9); + var u8 = m7.redIAdd(e12).redSqr().redISub(mm).redISub(ee3).redISub(t9); + var yyu4 = yy.redMul(u8); + yyu4 = yyu4.redIAdd(yyu4); + yyu4 = yyu4.redIAdd(yyu4); + var nx = this.x.redMul(ee3).redISub(yyu4); + nx = nx.redIAdd(nx); + nx = nx.redIAdd(nx); + var ny = this.y.redMul(u8.redMul(t9.redISub(u8)).redISub(e12.redMul(ee3))); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + var nz = this.z.redAdd(e12).redSqr().redISub(zz).redISub(ee3); + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype.mul = function mul(k5, kbase) { + k5 = new BN(k5, kbase); + return this.curve._wnafMul(this, k5); + }; + JPoint.prototype.eq = function eq(p8) { + if (p8.type === "affine") + return this.eq(p8.toJ()); + if (this === p8) + return true; + var z22 = this.z.redSqr(); + var pz2 = p8.z.redSqr(); + if (this.x.redMul(pz2).redISub(p8.x.redMul(z22)).cmpn(0) !== 0) + return false; + var z32 = z22.redMul(this.z); + var pz3 = pz2.redMul(p8.z); + return this.y.redMul(pz3).redISub(p8.y.redMul(z32)).cmpn(0) === 0; + }; + JPoint.prototype.eqXToP = function eqXToP(x5) { + var zs = this.z.redSqr(); + var rx = x5.toRed(this.curve.red).redMul(zs); + if (this.x.cmp(rx) === 0) + return true; + var xc = x5.clone(); + var t9 = this.curve.redN.redMul(zs); + for (; ; ) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + rx.redIAdd(t9); + if (this.x.cmp(rx) === 0) + return true; + } + }; + JPoint.prototype.inspect = function inspect3() { + if (this.isInfinity()) + return ""; + return ""; + }; + JPoint.prototype.isInfinity = function isInfinity() { + return this.z.cmpn(0) === 0; + }; + return exports$R$1; + } + var exports$Q$1 = {}; + var _dewExec$Q$1 = false; + function dew$Q$1() { + if (_dewExec$Q$1) + return exports$Q$1; + _dewExec$Q$1 = true; + var BN = dew$V$1(); + var inherits3 = dew$f$2(); + var Base2 = dew$S$1(); + var utils2 = dew$T$1(); + function MontCurve(conf) { + Base2.call(this, "mont", conf); + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.i4 = new BN(4).toRed(this.red).redInvm(); + this.two = new BN(2).toRed(this.red); + this.a24 = this.i4.redMul(this.a.redAdd(this.two)); + } + inherits3(MontCurve, Base2); + exports$Q$1 = MontCurve; + MontCurve.prototype.validate = function validate3(point) { + var x5 = point.normalize().x; + var x22 = x5.redSqr(); + var rhs = x22.redMul(x5).redAdd(x22.redMul(this.a)).redAdd(x5); + var y7 = rhs.redSqrt(); + return y7.redSqr().cmp(rhs) === 0; + }; + function Point2(curve, x5, z6) { + Base2.BasePoint.call(this, curve, "projective"); + if (x5 === null && z6 === null) { + this.x = this.curve.one; + this.z = this.curve.zero; + } else { + this.x = new BN(x5, 16); + this.z = new BN(z6, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + } + } + inherits3(Point2, Base2.BasePoint); + MontCurve.prototype.decodePoint = function decodePoint(bytes2, enc) { + return this.point(utils2.toArray(bytes2, enc), 1); + }; + MontCurve.prototype.point = function point(x5, z6) { + return new Point2(this, x5, z6); + }; + MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point2.fromJSON(this, obj); + }; + Point2.prototype.precompute = function precompute() { + }; + Point2.prototype._encode = function _encode() { + return this.getX().toArray("be", this.curve.p.byteLength()); + }; + Point2.fromJSON = function fromJSON3(curve, obj) { + return new Point2(curve, obj[0], obj[1] || curve.one); + }; + Point2.prototype.inspect = function inspect3() { + if (this.isInfinity()) + return ""; + return ""; + }; + Point2.prototype.isInfinity = function isInfinity() { + return this.z.cmpn(0) === 0; + }; + Point2.prototype.dbl = function dbl() { + var a8 = this.x.redAdd(this.z); + var aa = a8.redSqr(); + var b6 = this.x.redSub(this.z); + var bb = b6.redSqr(); + var c8 = aa.redSub(bb); + var nx = aa.redMul(bb); + var nz = c8.redMul(bb.redAdd(this.curve.a24.redMul(c8))); + return this.curve.point(nx, nz); + }; + Point2.prototype.add = function add12() { + throw new Error("Not supported on Montgomery curve"); + }; + Point2.prototype.diffAdd = function diffAdd(p8, diff) { + var a8 = this.x.redAdd(this.z); + var b6 = this.x.redSub(this.z); + var c8 = p8.x.redAdd(p8.z); + var d7 = p8.x.redSub(p8.z); + var da = d7.redMul(a8); + var cb = c8.redMul(b6); + var nx = diff.z.redMul(da.redAdd(cb).redSqr()); + var nz = diff.x.redMul(da.redISub(cb).redSqr()); + return this.curve.point(nx, nz); + }; + Point2.prototype.mul = function mul(k5) { + var t9 = k5.clone(); + var a8 = this; + var b6 = this.curve.point(null, null); + var c8 = this; + for (var bits = []; t9.cmpn(0) !== 0; t9.iushrn(1)) + bits.push(t9.andln(1)); + for (var i8 = bits.length - 1; i8 >= 0; i8--) { + if (bits[i8] === 0) { + a8 = a8.diffAdd(b6, c8); + b6 = b6.dbl(); + } else { + b6 = a8.diffAdd(b6, c8); + a8 = a8.dbl(); + } + } + return b6; + }; + Point2.prototype.mulAdd = function mulAdd() { + throw new Error("Not supported on Montgomery curve"); + }; + Point2.prototype.jumlAdd = function jumlAdd() { + throw new Error("Not supported on Montgomery curve"); + }; + Point2.prototype.eq = function eq(other) { + return this.getX().cmp(other.getX()) === 0; + }; + Point2.prototype.normalize = function normalize2() { + this.x = this.x.redMul(this.z.redInvm()); + this.z = this.curve.one; + return this; + }; + Point2.prototype.getX = function getX() { + this.normalize(); + return this.x.fromRed(); + }; + return exports$Q$1; + } + var exports$P$1 = {}; + var _dewExec$P$1 = false; + function dew$P$1() { + if (_dewExec$P$1) + return exports$P$1; + _dewExec$P$1 = true; + var utils2 = dew$T$1(); + var BN = dew$V$1(); + var inherits3 = dew$f$2(); + var Base2 = dew$S$1(); + var assert = utils2.assert; + function EdwardsCurve(conf) { + this.twisted = (conf.a | 0) !== 1; + this.mOneA = this.twisted && (conf.a | 0) === -1; + this.extended = this.mOneA; + Base2.call(this, "edwards", conf); + this.a = new BN(conf.a, 16).umod(this.red.m); + this.a = this.a.toRed(this.red); + this.c = new BN(conf.c, 16).toRed(this.red); + this.c2 = this.c.redSqr(); + this.d = new BN(conf.d, 16).toRed(this.red); + this.dd = this.d.redAdd(this.d); + assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); + this.oneC = (conf.c | 0) === 1; + } + inherits3(EdwardsCurve, Base2); + exports$P$1 = EdwardsCurve; + EdwardsCurve.prototype._mulA = function _mulA(num) { + if (this.mOneA) + return num.redNeg(); + else + return this.a.redMul(num); + }; + EdwardsCurve.prototype._mulC = function _mulC(num) { + if (this.oneC) + return num; + else + return this.c.redMul(num); + }; + EdwardsCurve.prototype.jpoint = function jpoint(x5, y7, z6, t9) { + return this.point(x5, y7, z6, t9); + }; + EdwardsCurve.prototype.pointFromX = function pointFromX(x5, odd) { + x5 = new BN(x5, 16); + if (!x5.red) + x5 = x5.toRed(this.red); + var x22 = x5.redSqr(); + var rhs = this.c2.redSub(this.a.redMul(x22)); + var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x22)); + var y22 = rhs.redMul(lhs.redInvm()); + var y7 = y22.redSqrt(); + if (y7.redSqr().redSub(y22).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var isOdd = y7.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y7 = y7.redNeg(); + return this.point(x5, y7); + }; + EdwardsCurve.prototype.pointFromY = function pointFromY(y7, odd) { + y7 = new BN(y7, 16); + if (!y7.red) + y7 = y7.toRed(this.red); + var y22 = y7.redSqr(); + var lhs = y22.redSub(this.c2); + var rhs = y22.redMul(this.d).redMul(this.c2).redSub(this.a); + var x22 = lhs.redMul(rhs.redInvm()); + if (x22.cmp(this.zero) === 0) { + if (odd) + throw new Error("invalid point"); + else + return this.point(this.zero, y7); + } + var x5 = x22.redSqrt(); + if (x5.redSqr().redSub(x22).cmp(this.zero) !== 0) + throw new Error("invalid point"); + if (x5.fromRed().isOdd() !== odd) + x5 = x5.redNeg(); + return this.point(x5, y7); + }; + EdwardsCurve.prototype.validate = function validate3(point) { + if (point.isInfinity()) + return true; + point.normalize(); + var x22 = point.x.redSqr(); + var y22 = point.y.redSqr(); + var lhs = x22.redMul(this.a).redAdd(y22); + var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x22).redMul(y22))); + return lhs.cmp(rhs) === 0; + }; + function Point2(curve, x5, y7, z6, t9) { + Base2.BasePoint.call(this, curve, "projective"); + if (x5 === null && y7 === null && z6 === null) { + this.x = this.curve.zero; + this.y = this.curve.one; + this.z = this.curve.one; + this.t = this.curve.zero; + this.zOne = true; + } else { + this.x = new BN(x5, 16); + this.y = new BN(y7, 16); + this.z = z6 ? new BN(z6, 16) : this.curve.one; + this.t = t9 && new BN(t9, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + if (this.t && !this.t.red) + this.t = this.t.toRed(this.curve.red); + this.zOne = this.z === this.curve.one; + if (this.curve.extended && !this.t) { + this.t = this.x.redMul(this.y); + if (!this.zOne) + this.t = this.t.redMul(this.z.redInvm()); + } + } + } + inherits3(Point2, Base2.BasePoint); + EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point2.fromJSON(this, obj); + }; + EdwardsCurve.prototype.point = function point(x5, y7, z6, t9) { + return new Point2(this, x5, y7, z6, t9); + }; + Point2.fromJSON = function fromJSON3(curve, obj) { + return new Point2(curve, obj[0], obj[1], obj[2]); + }; + Point2.prototype.inspect = function inspect3() { + if (this.isInfinity()) + return ""; + return ""; + }; + Point2.prototype.isInfinity = function isInfinity() { + return this.x.cmpn(0) === 0 && (this.y.cmp(this.z) === 0 || this.zOne && this.y.cmp(this.curve.c) === 0); + }; + Point2.prototype._extDbl = function _extDbl() { + var a8 = this.x.redSqr(); + var b6 = this.y.redSqr(); + var c8 = this.z.redSqr(); + c8 = c8.redIAdd(c8); + var d7 = this.curve._mulA(a8); + var e12 = this.x.redAdd(this.y).redSqr().redISub(a8).redISub(b6); + var g6 = d7.redAdd(b6); + var f9 = g6.redSub(c8); + var h9 = d7.redSub(b6); + var nx = e12.redMul(f9); + var ny = g6.redMul(h9); + var nt2 = e12.redMul(h9); + var nz = f9.redMul(g6); + return this.curve.point(nx, ny, nz, nt2); + }; + Point2.prototype._projDbl = function _projDbl() { + var b6 = this.x.redAdd(this.y).redSqr(); + var c8 = this.x.redSqr(); + var d7 = this.y.redSqr(); + var nx; + var ny; + var nz; + var e12; + var h9; + var j5; + if (this.curve.twisted) { + e12 = this.curve._mulA(c8); + var f9 = e12.redAdd(d7); + if (this.zOne) { + nx = b6.redSub(c8).redSub(d7).redMul(f9.redSub(this.curve.two)); + ny = f9.redMul(e12.redSub(d7)); + nz = f9.redSqr().redSub(f9).redSub(f9); + } else { + h9 = this.z.redSqr(); + j5 = f9.redSub(h9).redISub(h9); + nx = b6.redSub(c8).redISub(d7).redMul(j5); + ny = f9.redMul(e12.redSub(d7)); + nz = f9.redMul(j5); + } + } else { + e12 = c8.redAdd(d7); + h9 = this.curve._mulC(this.z).redSqr(); + j5 = e12.redSub(h9).redSub(h9); + nx = this.curve._mulC(b6.redISub(e12)).redMul(j5); + ny = this.curve._mulC(e12).redMul(c8.redISub(d7)); + nz = e12.redMul(j5); + } + return this.curve.point(nx, ny, nz); + }; + Point2.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + if (this.curve.extended) + return this._extDbl(); + else + return this._projDbl(); + }; + Point2.prototype._extAdd = function _extAdd(p8) { + var a8 = this.y.redSub(this.x).redMul(p8.y.redSub(p8.x)); + var b6 = this.y.redAdd(this.x).redMul(p8.y.redAdd(p8.x)); + var c8 = this.t.redMul(this.curve.dd).redMul(p8.t); + var d7 = this.z.redMul(p8.z.redAdd(p8.z)); + var e12 = b6.redSub(a8); + var f9 = d7.redSub(c8); + var g6 = d7.redAdd(c8); + var h9 = b6.redAdd(a8); + var nx = e12.redMul(f9); + var ny = g6.redMul(h9); + var nt2 = e12.redMul(h9); + var nz = f9.redMul(g6); + return this.curve.point(nx, ny, nz, nt2); + }; + Point2.prototype._projAdd = function _projAdd(p8) { + var a8 = this.z.redMul(p8.z); + var b6 = a8.redSqr(); + var c8 = this.x.redMul(p8.x); + var d7 = this.y.redMul(p8.y); + var e12 = this.curve.d.redMul(c8).redMul(d7); + var f9 = b6.redSub(e12); + var g6 = b6.redAdd(e12); + var tmp = this.x.redAdd(this.y).redMul(p8.x.redAdd(p8.y)).redISub(c8).redISub(d7); + var nx = a8.redMul(f9).redMul(tmp); + var ny; + var nz; + if (this.curve.twisted) { + ny = a8.redMul(g6).redMul(d7.redSub(this.curve._mulA(c8))); + nz = f9.redMul(g6); + } else { + ny = a8.redMul(g6).redMul(d7.redSub(c8)); + nz = this.curve._mulC(f9).redMul(g6); + } + return this.curve.point(nx, ny, nz); + }; + Point2.prototype.add = function add12(p8) { + if (this.isInfinity()) + return p8; + if (p8.isInfinity()) + return this; + if (this.curve.extended) + return this._extAdd(p8); + else + return this._projAdd(p8); + }; + Point2.prototype.mul = function mul(k5) { + if (this._hasDoubles(k5)) + return this.curve._fixedNafMul(this, k5); + else + return this.curve._wnafMul(this, k5); + }; + Point2.prototype.mulAdd = function mulAdd(k1, p8, k22) { + return this.curve._wnafMulAdd(1, [this, p8], [k1, k22], 2, false); + }; + Point2.prototype.jmulAdd = function jmulAdd(k1, p8, k22) { + return this.curve._wnafMulAdd(1, [this, p8], [k1, k22], 2, true); + }; + Point2.prototype.normalize = function normalize2() { + if (this.zOne) + return this; + var zi = this.z.redInvm(); + this.x = this.x.redMul(zi); + this.y = this.y.redMul(zi); + if (this.t) + this.t = this.t.redMul(zi); + this.z = this.curve.one; + this.zOne = true; + return this; + }; + Point2.prototype.neg = function neg() { + return this.curve.point(this.x.redNeg(), this.y, this.z, this.t && this.t.redNeg()); + }; + Point2.prototype.getX = function getX() { + this.normalize(); + return this.x.fromRed(); + }; + Point2.prototype.getY = function getY() { + this.normalize(); + return this.y.fromRed(); + }; + Point2.prototype.eq = function eq(other) { + return this === other || this.getX().cmp(other.getX()) === 0 && this.getY().cmp(other.getY()) === 0; + }; + Point2.prototype.eqXToP = function eqXToP(x5) { + var rx = x5.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(rx) === 0) + return true; + var xc = x5.clone(); + var t9 = this.curve.redN.redMul(this.z); + for (; ; ) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + rx.redIAdd(t9); + if (this.x.cmp(rx) === 0) + return true; + } + }; + Point2.prototype.toP = Point2.prototype.normalize; + Point2.prototype.mixedAdd = Point2.prototype.add; + return exports$P$1; + } + var exports$O$1 = {}; + var _dewExec$O$1 = false; + function dew$O$1() { + if (_dewExec$O$1) + return exports$O$1; + _dewExec$O$1 = true; + var curve = exports$O$1; + curve.base = dew$S$1(); + curve.short = dew$R$1(); + curve.mont = dew$Q$1(); + curve.edwards = dew$P$1(); + return exports$O$1; + } + var exports$N$1 = {}; + var _dewExec$N$1 = false; + function dew$N$1() { + if (_dewExec$N$1) + return exports$N$1; + _dewExec$N$1 = true; + var assert = dew$1t(); + var inherits3 = dew$f$2(); + exports$N$1.inherits = inherits3; + function isSurrogatePair(msg, i8) { + if ((msg.charCodeAt(i8) & 64512) !== 55296) { + return false; + } + if (i8 < 0 || i8 + 1 >= msg.length) { + return false; + } + return (msg.charCodeAt(i8 + 1) & 64512) === 56320; + } + function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg === "string") { + if (!enc) { + var p8 = 0; + for (var i8 = 0; i8 < msg.length; i8++) { + var c8 = msg.charCodeAt(i8); + if (c8 < 128) { + res[p8++] = c8; + } else if (c8 < 2048) { + res[p8++] = c8 >> 6 | 192; + res[p8++] = c8 & 63 | 128; + } else if (isSurrogatePair(msg, i8)) { + c8 = 65536 + ((c8 & 1023) << 10) + (msg.charCodeAt(++i8) & 1023); + res[p8++] = c8 >> 18 | 240; + res[p8++] = c8 >> 12 & 63 | 128; + res[p8++] = c8 >> 6 & 63 | 128; + res[p8++] = c8 & 63 | 128; + } else { + res[p8++] = c8 >> 12 | 224; + res[p8++] = c8 >> 6 & 63 | 128; + res[p8++] = c8 & 63 | 128; + } + } + } else if (enc === "hex") { + msg = msg.replace(/[^a-z0-9]+/ig, ""); + if (msg.length % 2 !== 0) + msg = "0" + msg; + for (i8 = 0; i8 < msg.length; i8 += 2) + res.push(parseInt(msg[i8] + msg[i8 + 1], 16)); + } + } else { + for (i8 = 0; i8 < msg.length; i8++) + res[i8] = msg[i8] | 0; + } + return res; + } + exports$N$1.toArray = toArray; + function toHex2(msg) { + var res = ""; + for (var i8 = 0; i8 < msg.length; i8++) + res += zero2(msg[i8].toString(16)); + return res; + } + exports$N$1.toHex = toHex2; + function htonl(w5) { + var res = w5 >>> 24 | w5 >>> 8 & 65280 | w5 << 8 & 16711680 | (w5 & 255) << 24; + return res >>> 0; + } + exports$N$1.htonl = htonl; + function toHex32(msg, endian) { + var res = ""; + for (var i8 = 0; i8 < msg.length; i8++) { + var w5 = msg[i8]; + if (endian === "little") + w5 = htonl(w5); + res += zero8(w5.toString(16)); + } + return res; + } + exports$N$1.toHex32 = toHex32; + function zero2(word) { + if (word.length === 1) + return "0" + word; + else + return word; + } + exports$N$1.zero2 = zero2; + function zero8(word) { + if (word.length === 7) + return "0" + word; + else if (word.length === 6) + return "00" + word; + else if (word.length === 5) + return "000" + word; + else if (word.length === 4) + return "0000" + word; + else if (word.length === 3) + return "00000" + word; + else if (word.length === 2) + return "000000" + word; + else if (word.length === 1) + return "0000000" + word; + else + return word; + } + exports$N$1.zero8 = zero8; + function join32(msg, start, end, endian) { + var len = end - start; + assert(len % 4 === 0); + var res = new Array(len / 4); + for (var i8 = 0, k5 = start; i8 < res.length; i8++, k5 += 4) { + var w5; + if (endian === "big") + w5 = msg[k5] << 24 | msg[k5 + 1] << 16 | msg[k5 + 2] << 8 | msg[k5 + 3]; + else + w5 = msg[k5 + 3] << 24 | msg[k5 + 2] << 16 | msg[k5 + 1] << 8 | msg[k5]; + res[i8] = w5 >>> 0; + } + return res; + } + exports$N$1.join32 = join32; + function split32(msg, endian) { + var res = new Array(msg.length * 4); + for (var i8 = 0, k5 = 0; i8 < msg.length; i8++, k5 += 4) { + var m7 = msg[i8]; + if (endian === "big") { + res[k5] = m7 >>> 24; + res[k5 + 1] = m7 >>> 16 & 255; + res[k5 + 2] = m7 >>> 8 & 255; + res[k5 + 3] = m7 & 255; + } else { + res[k5 + 3] = m7 >>> 24; + res[k5 + 2] = m7 >>> 16 & 255; + res[k5 + 1] = m7 >>> 8 & 255; + res[k5] = m7 & 255; + } + } + return res; + } + exports$N$1.split32 = split32; + function rotr32(w5, b6) { + return w5 >>> b6 | w5 << 32 - b6; + } + exports$N$1.rotr32 = rotr32; + function rotl32(w5, b6) { + return w5 << b6 | w5 >>> 32 - b6; + } + exports$N$1.rotl32 = rotl32; + function sum32(a8, b6) { + return a8 + b6 >>> 0; + } + exports$N$1.sum32 = sum32; + function sum32_3(a8, b6, c8) { + return a8 + b6 + c8 >>> 0; + } + exports$N$1.sum32_3 = sum32_3; + function sum32_4(a8, b6, c8, d7) { + return a8 + b6 + c8 + d7 >>> 0; + } + exports$N$1.sum32_4 = sum32_4; + function sum32_5(a8, b6, c8, d7, e12) { + return a8 + b6 + c8 + d7 + e12 >>> 0; + } + exports$N$1.sum32_5 = sum32_5; + function sum64(buf3, pos, ah, al) { + var bh = buf3[pos]; + var bl = buf3[pos + 1]; + var lo = al + bl >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + buf3[pos] = hi >>> 0; + buf3[pos + 1] = lo; + } + exports$N$1.sum64 = sum64; + function sum64_hi(ah, al, bh, bl) { + var lo = al + bl >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + return hi >>> 0; + } + exports$N$1.sum64_hi = sum64_hi; + function sum64_lo(ah, al, bh, bl) { + var lo = al + bl; + return lo >>> 0; + } + exports$N$1.sum64_lo = sum64_lo; + function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { + var carry = 0; + var lo = al; + lo = lo + bl >>> 0; + carry += lo < al ? 1 : 0; + lo = lo + cl >>> 0; + carry += lo < cl ? 1 : 0; + lo = lo + dl >>> 0; + carry += lo < dl ? 1 : 0; + var hi = ah + bh + ch + dh + carry; + return hi >>> 0; + } + exports$N$1.sum64_4_hi = sum64_4_hi; + function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { + var lo = al + bl + cl + dl; + return lo >>> 0; + } + exports$N$1.sum64_4_lo = sum64_4_lo; + function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var carry = 0; + var lo = al; + lo = lo + bl >>> 0; + carry += lo < al ? 1 : 0; + lo = lo + cl >>> 0; + carry += lo < cl ? 1 : 0; + lo = lo + dl >>> 0; + carry += lo < dl ? 1 : 0; + lo = lo + el >>> 0; + carry += lo < el ? 1 : 0; + var hi = ah + bh + ch + dh + eh + carry; + return hi >>> 0; + } + exports$N$1.sum64_5_hi = sum64_5_hi; + function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var lo = al + bl + cl + dl + el; + return lo >>> 0; + } + exports$N$1.sum64_5_lo = sum64_5_lo; + function rotr64_hi(ah, al, num) { + var r10 = al << 32 - num | ah >>> num; + return r10 >>> 0; + } + exports$N$1.rotr64_hi = rotr64_hi; + function rotr64_lo(ah, al, num) { + var r10 = ah << 32 - num | al >>> num; + return r10 >>> 0; + } + exports$N$1.rotr64_lo = rotr64_lo; + function shr64_hi(ah, al, num) { + return ah >>> num; + } + exports$N$1.shr64_hi = shr64_hi; + function shr64_lo(ah, al, num) { + var r10 = ah << 32 - num | al >>> num; + return r10 >>> 0; + } + exports$N$1.shr64_lo = shr64_lo; + return exports$N$1; + } + var exports$M$1 = {}; + var _dewExec$M$1 = false; + function dew$M$1() { + if (_dewExec$M$1) + return exports$M$1; + _dewExec$M$1 = true; + var utils2 = dew$N$1(); + var assert = dew$1t(); + function BlockHash() { + this.pending = null; + this.pendingTotal = 0; + this.blockSize = this.constructor.blockSize; + this.outSize = this.constructor.outSize; + this.hmacStrength = this.constructor.hmacStrength; + this.padLength = this.constructor.padLength / 8; + this.endian = "big"; + this._delta8 = this.blockSize / 8; + this._delta32 = this.blockSize / 32; + } + exports$M$1.BlockHash = BlockHash; + BlockHash.prototype.update = function update2(msg, enc) { + msg = utils2.toArray(msg, enc); + if (!this.pending) + this.pending = msg; + else + this.pending = this.pending.concat(msg); + this.pendingTotal += msg.length; + if (this.pending.length >= this._delta8) { + msg = this.pending; + var r10 = msg.length % this._delta8; + this.pending = msg.slice(msg.length - r10, msg.length); + if (this.pending.length === 0) + this.pending = null; + msg = utils2.join32(msg, 0, msg.length - r10, this.endian); + for (var i8 = 0; i8 < msg.length; i8 += this._delta32) + this._update(msg, i8, i8 + this._delta32); + } + return this; + }; + BlockHash.prototype.digest = function digest3(enc) { + this.update(this._pad()); + assert(this.pending === null); + return this._digest(enc); + }; + BlockHash.prototype._pad = function pad() { + var len = this.pendingTotal; + var bytes2 = this._delta8; + var k5 = bytes2 - (len + this.padLength) % bytes2; + var res = new Array(k5 + this.padLength); + res[0] = 128; + for (var i8 = 1; i8 < k5; i8++) + res[i8] = 0; + len <<= 3; + if (this.endian === "big") { + for (var t9 = 8; t9 < this.padLength; t9++) + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = len >>> 24 & 255; + res[i8++] = len >>> 16 & 255; + res[i8++] = len >>> 8 & 255; + res[i8++] = len & 255; + } else { + res[i8++] = len & 255; + res[i8++] = len >>> 8 & 255; + res[i8++] = len >>> 16 & 255; + res[i8++] = len >>> 24 & 255; + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = 0; + for (t9 = 8; t9 < this.padLength; t9++) + res[i8++] = 0; + } + return res; + }; + return exports$M$1; + } + var exports$L$1 = {}; + var _dewExec$L$1 = false; + function dew$L$1() { + if (_dewExec$L$1) + return exports$L$1; + _dewExec$L$1 = true; + return exports$L$1; + } + var exports$K$1 = {}; + var _dewExec$K$1 = false; + function dew$K$1() { + if (_dewExec$K$1) + return exports$K$1; + _dewExec$K$1 = true; + var utils2 = dew$N$1(); + var common = dew$M$1(); + var rotl32 = utils2.rotl32; + var sum32 = utils2.sum32; + var sum32_3 = utils2.sum32_3; + var sum32_4 = utils2.sum32_4; + var BlockHash = common.BlockHash; + function RIPEMD160() { + if (!(this instanceof RIPEMD160)) + return new RIPEMD160(); + BlockHash.call(this); + this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520]; + this.endian = "little"; + } + utils2.inherits(RIPEMD160, BlockHash); + exports$K$1.ripemd160 = RIPEMD160; + RIPEMD160.blockSize = 512; + RIPEMD160.outSize = 160; + RIPEMD160.hmacStrength = 192; + RIPEMD160.padLength = 64; + RIPEMD160.prototype._update = function update2(msg, start) { + var A5 = this.h[0]; + var B5 = this.h[1]; + var C5 = this.h[2]; + var D5 = this.h[3]; + var E5 = this.h[4]; + var Ah = A5; + var Bh = B5; + var Ch = C5; + var Dh = D5; + var Eh = E5; + for (var j5 = 0; j5 < 80; j5++) { + var T6 = sum32(rotl32(sum32_4(A5, f9(j5, B5, C5, D5), msg[r10[j5] + start], K4(j5)), s7[j5]), E5); + A5 = E5; + E5 = D5; + D5 = rotl32(C5, 10); + C5 = B5; + B5 = T6; + T6 = sum32(rotl32(sum32_4(Ah, f9(79 - j5, Bh, Ch, Dh), msg[rh[j5] + start], Kh(j5)), sh[j5]), Eh); + Ah = Eh; + Eh = Dh; + Dh = rotl32(Ch, 10); + Ch = Bh; + Bh = T6; + } + T6 = sum32_3(this.h[1], C5, Dh); + this.h[1] = sum32_3(this.h[2], D5, Eh); + this.h[2] = sum32_3(this.h[3], E5, Ah); + this.h[3] = sum32_3(this.h[4], A5, Bh); + this.h[4] = sum32_3(this.h[0], B5, Ch); + this.h[0] = T6; + }; + RIPEMD160.prototype._digest = function digest3(enc) { + if (enc === "hex") + return utils2.toHex32(this.h, "little"); + else + return utils2.split32(this.h, "little"); + }; + function f9(j5, x5, y7, z6) { + if (j5 <= 15) + return x5 ^ y7 ^ z6; + else if (j5 <= 31) + return x5 & y7 | ~x5 & z6; + else if (j5 <= 47) + return (x5 | ~y7) ^ z6; + else if (j5 <= 63) + return x5 & z6 | y7 & ~z6; + else + return x5 ^ (y7 | ~z6); + } + function K4(j5) { + if (j5 <= 15) + return 0; + else if (j5 <= 31) + return 1518500249; + else if (j5 <= 47) + return 1859775393; + else if (j5 <= 63) + return 2400959708; + else + return 2840853838; + } + function Kh(j5) { + if (j5 <= 15) + return 1352829926; + else if (j5 <= 31) + return 1548603684; + else if (j5 <= 47) + return 1836072691; + else if (j5 <= 63) + return 2053994217; + else + return 0; + } + var r10 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]; + var rh = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]; + var s7 = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]; + var sh = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]; + return exports$K$1; + } + var exports$J$1 = {}; + var _dewExec$J$1 = false; + function dew$J$1() { + if (_dewExec$J$1) + return exports$J$1; + _dewExec$J$1 = true; + var utils2 = dew$N$1(); + var assert = dew$1t(); + function Hmac2(hash, key, enc) { + if (!(this instanceof Hmac2)) + return new Hmac2(hash, key, enc); + this.Hash = hash; + this.blockSize = hash.blockSize / 8; + this.outSize = hash.outSize / 8; + this.inner = null; + this.outer = null; + this._init(utils2.toArray(key, enc)); + } + exports$J$1 = Hmac2; + Hmac2.prototype._init = function init3(key) { + if (key.length > this.blockSize) + key = new this.Hash().update(key).digest(); + assert(key.length <= this.blockSize); + for (var i8 = key.length; i8 < this.blockSize; i8++) + key.push(0); + for (i8 = 0; i8 < key.length; i8++) + key[i8] ^= 54; + this.inner = new this.Hash().update(key); + for (i8 = 0; i8 < key.length; i8++) + key[i8] ^= 106; + this.outer = new this.Hash().update(key); + }; + Hmac2.prototype.update = function update2(msg, enc) { + this.inner.update(msg, enc); + return this; + }; + Hmac2.prototype.digest = function digest3(enc) { + this.outer.update(this.inner.digest()); + return this.outer.digest(enc); + }; + return exports$J$1; + } + var exports$I$1 = {}; + var _dewExec$I$1 = false; + function dew$I$1() { + if (_dewExec$I$1) + return exports$I$1; + _dewExec$I$1 = true; + var hash = exports$I$1; + hash.utils = dew$N$1(); + hash.common = dew$M$1(); + hash.sha = dew$L$1(); + hash.ripemd = dew$K$1(); + hash.hmac = dew$J$1(); + hash.sha1 = hash.sha.sha1; + hash.sha256 = hash.sha.sha256; + hash.sha224 = hash.sha.sha224; + hash.sha384 = hash.sha.sha384; + hash.sha512 = hash.sha.sha512; + hash.ripemd160 = hash.ripemd.ripemd160; + return exports$I$1; + } + var exports$H$1 = {}; + var _dewExec$H$1 = false; + function dew$H$1() { + if (_dewExec$H$1) + return exports$H$1; + _dewExec$H$1 = true; + exports$H$1 = { + doubles: { + step: 4, + points: [["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a", "f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"], ["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508", "11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"], ["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739", "d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"], ["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640", "4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"], ["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c", "4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"], ["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda", "96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"], ["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa", "5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"], ["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0", "cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"], ["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d", "9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"], ["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d", "e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"], ["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1", "9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"], ["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0", "5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"], ["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047", "10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"], ["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862", "283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"], ["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7", "7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"], ["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd", "56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"], ["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83", "7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"], ["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a", "53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"], ["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8", "bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"], ["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d", "4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"], ["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725", "7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"], ["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754", "4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"], ["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c", "17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"], ["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6", "6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"], ["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39", "c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"], ["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891", "893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"], ["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b", "febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"], ["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03", "2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"], ["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d", "eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"], ["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070", "7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"], ["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4", "e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"], ["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da", "662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"], ["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11", "1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"], ["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e", "efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"], ["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41", "2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"], ["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef", "67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"], ["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8", "db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"], ["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d", "648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"], ["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96", "35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"], ["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd", "ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"], ["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5", "9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"], ["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266", "40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"], ["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71", "34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"], ["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac", "c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"], ["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751", "1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"], ["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e", "493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"], ["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241", "c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"], ["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3", "be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"], ["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f", "4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"], ["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19", "aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"], ["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be", "b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"], ["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9", "6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"], ["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2", "8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"], ["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13", "7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"], ["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c", "ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"], ["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba", "2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"], ["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151", "e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"], ["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073", "d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"], ["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458", "38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"], ["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b", "69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"], ["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366", "d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"], ["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa", "40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"], ["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0", "620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"], ["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787", "7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"], ["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e", "ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]] + }, + naf: { + wnd: 7, + points: [["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9", "388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"], ["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4", "d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"], ["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc", "6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"], ["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe", "cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"], ["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb", "d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"], ["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8", "ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"], ["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e", "581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"], ["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34", "4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"], ["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c", "85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"], ["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5", "321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"], ["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f", "2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"], ["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714", "73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"], ["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729", "a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"], ["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db", "2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"], ["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4", "e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"], ["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5", "b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"], ["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479", "2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"], ["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d", "80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"], ["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f", "1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"], ["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb", "d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"], ["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9", "eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"], ["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963", "758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"], ["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74", "958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"], ["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530", "e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"], ["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b", "5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"], ["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247", "cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"], ["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1", "cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"], ["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120", "4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"], ["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435", "91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"], ["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18", "673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"], ["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8", "59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"], ["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb", "3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"], ["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f", "55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"], ["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143", "efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"], ["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba", "e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"], ["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45", "f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"], ["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a", "744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"], ["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e", "c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"], ["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8", "e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"], ["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c", "30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"], ["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519", "e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"], ["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab", "100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"], ["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca", "ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"], ["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf", "8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"], ["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610", "68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"], ["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4", "f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"], ["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c", "d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"], ["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940", "edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"], ["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980", "a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"], ["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3", "66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"], ["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf", "9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"], ["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63", "4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"], ["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448", "fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"], ["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf", "5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"], ["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5", "8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"], ["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6", "8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"], ["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5", "5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"], ["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99", "f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"], ["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51", "f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"], ["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5", "42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"], ["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5", "204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"], ["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997", "4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"], ["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881", "73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"], ["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5", "39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"], ["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66", "d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"], ["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726", "ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"], ["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede", "6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"], ["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94", "60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"], ["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31", "3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"], ["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51", "b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"], ["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252", "ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"], ["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5", "cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"], ["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b", "6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"], ["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4", "322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"], ["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f", "6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"], ["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889", "2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"], ["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246", "b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"], ["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984", "998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"], ["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a", "b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"], ["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030", "bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"], ["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197", "6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"], ["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593", "c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"], ["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef", "21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"], ["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38", "60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"], ["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a", "49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"], ["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111", "5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"], ["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502", "7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"], ["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea", "be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"], ["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26", "8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"], ["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986", "39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"], ["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e", "62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"], ["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4", "25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"], ["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda", "ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"], ["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859", "cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"], ["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f", "f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"], ["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c", "6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"], ["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942", "fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"], ["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a", "1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"], ["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80", "5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"], ["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d", "438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"], ["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1", "cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"], ["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63", "c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"], ["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352", "6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"], ["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193", "ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"], ["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00", "9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"], ["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58", "ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"], ["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7", "d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"], ["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8", "c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"], ["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e", "67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"], ["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d", "cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"], ["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b", "299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"], ["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f", "f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"], ["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6", "462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"], ["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297", "62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"], ["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a", "7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"], ["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c", "ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"], ["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52", "4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"], ["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb", "bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"], ["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065", "bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"], ["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917", "603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"], ["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9", "cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"], ["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3", "553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"], ["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57", "712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"], ["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66", "ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"], ["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8", "9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"], ["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721", "9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"], ["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180", "4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]] + } + }; + return exports$H$1; + } + var exports$G$1 = {}; + var _dewExec$G$1 = false; + function dew$G$1() { + if (_dewExec$G$1) + return exports$G$1; + _dewExec$G$1 = true; + var curves = exports$G$1; + var hash = dew$I$1(); + var curve = dew$O$1(); + var utils2 = dew$T$1(); + var assert = utils2.assert; + function PresetCurve(options) { + if (options.type === "short") + this.curve = new curve.short(options); + else if (options.type === "edwards") + this.curve = new curve.edwards(options); + else + this.curve = new curve.mont(options); + this.g = this.curve.g; + this.n = this.curve.n; + this.hash = options.hash; + assert(this.g.validate(), "Invalid curve"); + assert(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + curves.PresetCurve = PresetCurve; + function defineCurve(name15, options) { + Object.defineProperty(curves, name15, { + configurable: true, + enumerable: true, + get: function() { + var curve2 = new PresetCurve(options); + Object.defineProperty(curves, name15, { + configurable: true, + enumerable: true, + value: curve2 + }); + return curve2; + } + }); + } + defineCurve("p192", { + type: "short", + prime: "p192", + p: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff", + a: "ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc", + b: "64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1", + n: "ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831", + hash: hash.sha256, + gRed: false, + g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] + }); + defineCurve("p224", { + type: "short", + prime: "p224", + p: "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001", + a: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe", + b: "b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4", + n: "ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d", + hash: hash.sha256, + gRed: false, + g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] + }); + defineCurve("p256", { + type: "short", + prime: null, + p: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff", + a: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc", + b: "5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b", + n: "ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551", + hash: hash.sha256, + gRed: false, + g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] + }); + defineCurve("p384", { + type: "short", + prime: null, + p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff", + a: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc", + b: "b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef", + n: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973", + hash: hash.sha384, + gRed: false, + g: ["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7", "3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"] + }); + defineCurve("p521", { + type: "short", + prime: null, + p: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff", + a: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc", + b: "00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00", + n: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409", + hash: hash.sha512, + gRed: false, + g: ["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66", "00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"] + }); + defineCurve("curve25519", { + type: "mont", + prime: "p25519", + p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", + a: "76d06", + b: "1", + n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", + hash: hash.sha256, + gRed: false, + g: ["9"] + }); + defineCurve("ed25519", { + type: "edwards", + prime: "p25519", + p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", + a: "-1", + c: "1", + // -121665 * (121666^(-1)) (mod P) + d: "52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3", + n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", + hash: hash.sha256, + gRed: false, + g: [ + "216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", + // 4/5 + "6666666666666666666666666666666666666666666666666666666666666658" + ] + }); + var pre; + try { + pre = dew$H$1(); + } catch (e12) { + pre = void 0; + } + defineCurve("secp256k1", { + type: "short", + prime: "k256", + p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f", + a: "0", + b: "7", + n: "ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141", + h: "1", + hash: hash.sha256, + // Precomputed endomorphism + beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", + lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", + basis: [{ + a: "3086d221a7d46bcde86c90e49284eb15", + b: "-e4437ed6010e88286f547fa90abfe4c3" + }, { + a: "114ca50f7a8e2f3f657c1108d9d44cfd8", + b: "3086d221a7d46bcde86c90e49284eb15" + }], + gRed: false, + g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", pre] + }); + return exports$G$1; + } + var exports$F$1 = {}; + var _dewExec$F$1 = false; + function dew$F$1() { + if (_dewExec$F$1) + return exports$F$1; + _dewExec$F$1 = true; + var hash = dew$I$1(); + var utils2 = dew$U$1(); + var assert = dew$1t(); + function HmacDRBG(options) { + if (!(this instanceof HmacDRBG)) + return new HmacDRBG(options); + this.hash = options.hash; + this.predResist = !!options.predResist; + this.outLen = this.hash.outSize; + this.minEntropy = options.minEntropy || this.hash.hmacStrength; + this._reseed = null; + this.reseedInterval = null; + this.K = null; + this.V = null; + var entropy = utils2.toArray(options.entropy, options.entropyEnc || "hex"); + var nonce = utils2.toArray(options.nonce, options.nonceEnc || "hex"); + var pers = utils2.toArray(options.pers, options.persEnc || "hex"); + assert(entropy.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"); + this._init(entropy, nonce, pers); + } + exports$F$1 = HmacDRBG; + HmacDRBG.prototype._init = function init3(entropy, nonce, pers) { + var seed = entropy.concat(nonce).concat(pers); + this.K = new Array(this.outLen / 8); + this.V = new Array(this.outLen / 8); + for (var i8 = 0; i8 < this.V.length; i8++) { + this.K[i8] = 0; + this.V[i8] = 1; + } + this._update(seed); + this._reseed = 1; + this.reseedInterval = 281474976710656; + }; + HmacDRBG.prototype._hmac = function hmac() { + return new hash.hmac(this.hash, this.K); + }; + HmacDRBG.prototype._update = function update2(seed) { + var kmac = this._hmac().update(this.V).update([0]); + if (seed) + kmac = kmac.update(seed); + this.K = kmac.digest(); + this.V = this._hmac().update(this.V).digest(); + if (!seed) + return; + this.K = this._hmac().update(this.V).update([1]).update(seed).digest(); + this.V = this._hmac().update(this.V).digest(); + }; + HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add12, addEnc) { + if (typeof entropyEnc !== "string") { + addEnc = add12; + add12 = entropyEnc; + entropyEnc = null; + } + entropy = utils2.toArray(entropy, entropyEnc); + add12 = utils2.toArray(add12, addEnc); + assert(entropy.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"); + this._update(entropy.concat(add12 || [])); + this._reseed = 1; + }; + HmacDRBG.prototype.generate = function generate3(len, enc, add12, addEnc) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + if (typeof enc !== "string") { + addEnc = add12; + add12 = enc; + enc = null; + } + if (add12) { + add12 = utils2.toArray(add12, addEnc || "hex"); + this._update(add12); + } + var temp = []; + while (temp.length < len) { + this.V = this._hmac().update(this.V).digest(); + temp = temp.concat(this.V); + } + var res = temp.slice(0, len); + this._update(add12); + this._reseed++; + return utils2.encode(res, enc); + }; + return exports$F$1; + } + var exports$E$1 = {}; + var _dewExec$E$1 = false; + function dew$E$1() { + if (_dewExec$E$1) + return exports$E$1; + _dewExec$E$1 = true; + var BN = dew$V$1(); + var utils2 = dew$T$1(); + var assert = utils2.assert; + function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; + if (options.priv) + this._importPrivate(options.priv, options.privEnc); + if (options.pub) + this._importPublic(options.pub, options.pubEnc); + } + exports$E$1 = KeyPair; + KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(ec, { + pub, + pubEnc: enc + }); + }; + KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; + return new KeyPair(ec, { + priv, + privEnc: enc + }); + }; + KeyPair.prototype.validate = function validate3() { + var pub = this.getPublic(); + if (pub.isInfinity()) + return { + result: false, + reason: "Invalid public key" + }; + if (!pub.validate()) + return { + result: false, + reason: "Public key is not a point" + }; + if (!pub.mul(this.ec.curve.n).isInfinity()) + return { + result: false, + reason: "Public key * N != O" + }; + return { + result: true, + reason: null + }; + }; + KeyPair.prototype.getPublic = function getPublic(compact, enc) { + if (typeof compact === "string") { + enc = compact; + compact = null; + } + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); + if (!enc) + return this.pub; + return this.pub.encode(enc, compact); + }; + KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === "hex") + return this.priv.toString(16, 2); + else + return this.priv; + }; + KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); + this.priv = this.priv.umod(this.ec.curve.n); + }; + KeyPair.prototype._importPublic = function _importPublic(key, enc) { + if (key.x || key.y) { + if (this.ec.curve.type === "mont") { + assert(key.x, "Need x coordinate"); + } else if (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") { + assert(key.x && key.y, "Need both x and y coordinate"); + } + this.pub = this.ec.curve.point(key.x, key.y); + return; + } + this.pub = this.ec.curve.decodePoint(key, enc); + }; + KeyPair.prototype.derive = function derive4(pub) { + if (!pub.validate()) { + assert(pub.validate(), "public point not validated"); + } + return pub.mul(this.priv).getX(); + }; + KeyPair.prototype.sign = function sign2(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); + }; + KeyPair.prototype.verify = function verify2(msg, signature) { + return this.ec.verify(msg, signature, this); + }; + KeyPair.prototype.inspect = function inspect3() { + return ""; + }; + return exports$E$1; + } + var exports$D$1 = {}; + var _dewExec$D$1 = false; + function dew$D$1() { + if (_dewExec$D$1) + return exports$D$1; + _dewExec$D$1 = true; + var BN = dew$V$1(); + var utils2 = dew$T$1(); + var assert = utils2.assert; + function Signature3(options, enc) { + if (options instanceof Signature3) + return options; + if (this._importDER(options, enc)) + return; + assert(options.r && options.s, "Signature without r or s"); + this.r = new BN(options.r, 16); + this.s = new BN(options.s, 16); + if (options.recoveryParam === void 0) + this.recoveryParam = null; + else + this.recoveryParam = options.recoveryParam; + } + exports$D$1 = Signature3; + function Position() { + this.place = 0; + } + function getLength(buf3, p8) { + var initial = buf3[p8.place++]; + if (!(initial & 128)) { + return initial; + } + var octetLen = initial & 15; + if (octetLen === 0 || octetLen > 4) { + return false; + } + var val = 0; + for (var i8 = 0, off = p8.place; i8 < octetLen; i8++, off++) { + val <<= 8; + val |= buf3[off]; + val >>>= 0; + } + if (val <= 127) { + return false; + } + p8.place = off; + return val; + } + function rmPadding(buf3) { + var i8 = 0; + var len = buf3.length - 1; + while (!buf3[i8] && !(buf3[i8 + 1] & 128) && i8 < len) { + i8++; + } + if (i8 === 0) { + return buf3; + } + return buf3.slice(i8); + } + Signature3.prototype._importDER = function _importDER(data, enc) { + data = utils2.toArray(data, enc); + var p8 = new Position(); + if (data[p8.place++] !== 48) { + return false; + } + var len = getLength(data, p8); + if (len === false) { + return false; + } + if (len + p8.place !== data.length) { + return false; + } + if (data[p8.place++] !== 2) { + return false; + } + var rlen = getLength(data, p8); + if (rlen === false) { + return false; + } + var r10 = data.slice(p8.place, rlen + p8.place); + p8.place += rlen; + if (data[p8.place++] !== 2) { + return false; + } + var slen = getLength(data, p8); + if (slen === false) { + return false; + } + if (data.length !== slen + p8.place) { + return false; + } + var s7 = data.slice(p8.place, slen + p8.place); + if (r10[0] === 0) { + if (r10[1] & 128) { + r10 = r10.slice(1); + } else { + return false; + } + } + if (s7[0] === 0) { + if (s7[1] & 128) { + s7 = s7.slice(1); + } else { + return false; + } + } + this.r = new BN(r10); + this.s = new BN(s7); + this.recoveryParam = null; + return true; + }; + function constructLength(arr, len) { + if (len < 128) { + arr.push(len); + return; + } + var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); + arr.push(octets | 128); + while (--octets) { + arr.push(len >>> (octets << 3) & 255); + } + arr.push(len); + } + Signature3.prototype.toDER = function toDER(enc) { + var r10 = this.r.toArray(); + var s7 = this.s.toArray(); + if (r10[0] & 128) + r10 = [0].concat(r10); + if (s7[0] & 128) + s7 = [0].concat(s7); + r10 = rmPadding(r10); + s7 = rmPadding(s7); + while (!s7[0] && !(s7[1] & 128)) { + s7 = s7.slice(1); + } + var arr = [2]; + constructLength(arr, r10.length); + arr = arr.concat(r10); + arr.push(2); + constructLength(arr, s7.length); + var backHalf = arr.concat(s7); + var res = [48]; + constructLength(res, backHalf.length); + res = res.concat(backHalf); + return utils2.encode(res, enc); + }; + return exports$D$1; + } + var exports$C$1 = {}; + var _dewExec$C$1 = false; + function dew$C$1() { + if (_dewExec$C$1) + return exports$C$1; + _dewExec$C$1 = true; + var BN = dew$V$1(); + var HmacDRBG = dew$F$1(); + var utils2 = dew$T$1(); + var curves = dew$G$1(); + var rand = dew$10$1(); + var assert = utils2.assert; + var KeyPair = dew$E$1(); + var Signature3 = dew$D$1(); + function EC(options) { + if (!(this instanceof EC)) + return new EC(options); + if (typeof options === "string") { + assert(Object.prototype.hasOwnProperty.call(curves, options), "Unknown curve " + options); + options = curves[options]; + } + if (options instanceof curves.PresetCurve) + options = { + curve: options + }; + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); + this.hash = options.hash || options.curve.hash; + } + exports$C$1 = EC; + EC.prototype.keyPair = function keyPair(options) { + return new KeyPair(this, options); + }; + EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); + }; + EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); + }; + EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; + var drbg = new HmacDRBG({ + hash: this.hash, + pers: options.pers, + persEnc: options.persEnc || "utf8", + entropy: options.entropy || rand(this.hash.hmacStrength), + entropyEnc: options.entropy && options.entropyEnc || "utf8", + nonce: this.n.toArray() + }); + var bytes2 = this.n.byteLength(); + var ns2 = this.n.sub(new BN(2)); + for (; ; ) { + var priv = new BN(drbg.generate(bytes2)); + if (priv.cmp(ns2) > 0) + continue; + priv.iaddn(1); + return this.keyFromPrivate(priv); + } + }; + EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) { + var delta = msg.byteLength() * 8 - this.n.bitLength(); + if (delta > 0) + msg = msg.ushrn(delta); + if (!truncOnly && msg.cmp(this.n) >= 0) + return msg.sub(this.n); + else + return msg; + }; + EC.prototype.sign = function sign2(msg, key, enc, options) { + if (typeof enc === "object") { + options = enc; + enc = null; + } + if (!options) + options = {}; + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); + var bytes2 = this.n.byteLength(); + var bkey = key.getPrivate().toArray("be", bytes2); + var nonce = msg.toArray("be", bytes2); + var drbg = new HmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce, + pers: options.pers, + persEnc: options.persEnc || "utf8" + }); + var ns1 = this.n.sub(new BN(1)); + for (var iter = 0; ; iter++) { + var k5 = options.k ? options.k(iter) : new BN(drbg.generate(this.n.byteLength())); + k5 = this._truncateToN(k5, true); + if (k5.cmpn(1) <= 0 || k5.cmp(ns1) >= 0) + continue; + var kp = this.g.mul(k5); + if (kp.isInfinity()) + continue; + var kpX = kp.getX(); + var r10 = kpX.umod(this.n); + if (r10.cmpn(0) === 0) + continue; + var s7 = k5.invm(this.n).mul(r10.mul(key.getPrivate()).iadd(msg)); + s7 = s7.umod(this.n); + if (s7.cmpn(0) === 0) + continue; + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | (kpX.cmp(r10) !== 0 ? 2 : 0); + if (options.canonical && s7.cmp(this.nh) > 0) { + s7 = this.n.sub(s7); + recoveryParam ^= 1; + } + return new Signature3({ + r: r10, + s: s7, + recoveryParam + }); + } + }; + EC.prototype.verify = function verify2(msg, signature, key, enc) { + msg = this._truncateToN(new BN(msg, 16)); + key = this.keyFromPublic(key, enc); + signature = new Signature3(signature, "hex"); + var r10 = signature.r; + var s7 = signature.s; + if (r10.cmpn(1) < 0 || r10.cmp(this.n) >= 0) + return false; + if (s7.cmpn(1) < 0 || s7.cmp(this.n) >= 0) + return false; + var sinv = s7.invm(this.n); + var u1 = sinv.mul(msg).umod(this.n); + var u22 = sinv.mul(r10).umod(this.n); + var p8; + if (!this.curve._maxwellTrick) { + p8 = this.g.mulAdd(u1, key.getPublic(), u22); + if (p8.isInfinity()) + return false; + return p8.getX().umod(this.n).cmp(r10) === 0; + } + p8 = this.g.jmulAdd(u1, key.getPublic(), u22); + if (p8.isInfinity()) + return false; + return p8.eqXToP(r10); + }; + EC.prototype.recoverPubKey = function(msg, signature, j5, enc) { + assert((3 & j5) === j5, "The recovery param is more than two bits"); + signature = new Signature3(signature, enc); + var n9 = this.n; + var e12 = new BN(msg); + var r10 = signature.r; + var s7 = signature.s; + var isYOdd = j5 & 1; + var isSecondKey = j5 >> 1; + if (r10.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) + throw new Error("Unable to find sencond key candinate"); + if (isSecondKey) + r10 = this.curve.pointFromX(r10.add(this.curve.n), isYOdd); + else + r10 = this.curve.pointFromX(r10, isYOdd); + var rInv = signature.r.invm(n9); + var s1 = n9.sub(e12).mul(rInv).umod(n9); + var s22 = s7.mul(rInv).umod(n9); + return this.g.mulAdd(s1, r10, s22); + }; + EC.prototype.getKeyRecoveryParam = function(e12, signature, Q4, enc) { + signature = new Signature3(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; + for (var i8 = 0; i8 < 4; i8++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e12, signature, i8); + } catch (e13) { + continue; + } + if (Qprime.eq(Q4)) + return i8; + } + throw new Error("Unable to find valid recovery factor"); + }; + return exports$C$1; + } + var exports$B$1 = {}; + var _dewExec$B$1 = false; + function dew$B$1() { + if (_dewExec$B$1) + return exports$B$1; + _dewExec$B$1 = true; + var utils2 = dew$T$1(); + var assert = utils2.assert; + var parseBytes = utils2.parseBytes; + var cachedProperty = utils2.cachedProperty; + function KeyPair(eddsa, params) { + this.eddsa = eddsa; + this._secret = parseBytes(params.secret); + if (eddsa.isPoint(params.pub)) + this._pub = params.pub; + else + this._pubBytes = parseBytes(params.pub); + } + KeyPair.fromPublic = function fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(eddsa, { + pub + }); + }; + KeyPair.fromSecret = function fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) + return secret; + return new KeyPair(eddsa, { + secret + }); + }; + KeyPair.prototype.secret = function secret() { + return this._secret; + }; + cachedProperty(KeyPair, "pubBytes", function pubBytes() { + return this.eddsa.encodePoint(this.pub()); + }); + cachedProperty(KeyPair, "pub", function pub() { + if (this._pubBytes) + return this.eddsa.decodePoint(this._pubBytes); + return this.eddsa.g.mul(this.priv()); + }); + cachedProperty(KeyPair, "privBytes", function privBytes() { + var eddsa = this.eddsa; + var hash = this.hash(); + var lastIx = eddsa.encodingLength - 1; + var a8 = hash.slice(0, eddsa.encodingLength); + a8[0] &= 248; + a8[lastIx] &= 127; + a8[lastIx] |= 64; + return a8; + }); + cachedProperty(KeyPair, "priv", function priv() { + return this.eddsa.decodeInt(this.privBytes()); + }); + cachedProperty(KeyPair, "hash", function hash() { + return this.eddsa.hash().update(this.secret()).digest(); + }); + cachedProperty(KeyPair, "messagePrefix", function messagePrefix() { + return this.hash().slice(this.eddsa.encodingLength); + }); + KeyPair.prototype.sign = function sign2(message2) { + assert(this._secret, "KeyPair can only verify"); + return this.eddsa.sign(message2, this); + }; + KeyPair.prototype.verify = function verify2(message2, sig) { + return this.eddsa.verify(message2, sig, this); + }; + KeyPair.prototype.getSecret = function getSecret(enc) { + assert(this._secret, "KeyPair is public only"); + return utils2.encode(this.secret(), enc); + }; + KeyPair.prototype.getPublic = function getPublic(enc) { + return utils2.encode(this.pubBytes(), enc); + }; + exports$B$1 = KeyPair; + return exports$B$1; + } + var exports$A$1 = {}; + var _dewExec$A$1 = false; + function dew$A$1() { + if (_dewExec$A$1) + return exports$A$1; + _dewExec$A$1 = true; + var BN = dew$V$1(); + var utils2 = dew$T$1(); + var assert = utils2.assert; + var cachedProperty = utils2.cachedProperty; + var parseBytes = utils2.parseBytes; + function Signature3(eddsa, sig) { + this.eddsa = eddsa; + if (typeof sig !== "object") + sig = parseBytes(sig); + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength) + }; + } + assert(sig.R && sig.S, "Signature without R or S"); + if (eddsa.isPoint(sig.R)) + this._R = sig.R; + if (sig.S instanceof BN) + this._S = sig.S; + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; + } + cachedProperty(Signature3, "S", function S5() { + return this.eddsa.decodeInt(this.Sencoded()); + }); + cachedProperty(Signature3, "R", function R5() { + return this.eddsa.decodePoint(this.Rencoded()); + }); + cachedProperty(Signature3, "Rencoded", function Rencoded() { + return this.eddsa.encodePoint(this.R()); + }); + cachedProperty(Signature3, "Sencoded", function Sencoded() { + return this.eddsa.encodeInt(this.S()); + }); + Signature3.prototype.toBytes = function toBytes3() { + return this.Rencoded().concat(this.Sencoded()); + }; + Signature3.prototype.toHex = function toHex2() { + return utils2.encode(this.toBytes(), "hex").toUpperCase(); + }; + exports$A$1 = Signature3; + return exports$A$1; + } + var exports$z$1 = {}; + var _dewExec$z$1 = false; + function dew$z$1() { + if (_dewExec$z$1) + return exports$z$1; + _dewExec$z$1 = true; + var hash = dew$I$1(); + var curves = dew$G$1(); + var utils2 = dew$T$1(); + var assert = utils2.assert; + var parseBytes = utils2.parseBytes; + var KeyPair = dew$B$1(); + var Signature3 = dew$A$1(); + function EDDSA(curve) { + assert(curve === "ed25519", "only tested with ed25519 so far"); + if (!(this instanceof EDDSA)) + return new EDDSA(curve); + curve = curves[curve].curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 1); + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = hash.sha512; + } + exports$z$1 = EDDSA; + EDDSA.prototype.sign = function sign2(message2, secret) { + message2 = parseBytes(message2); + var key = this.keyFromSecret(secret); + var r10 = this.hashInt(key.messagePrefix(), message2); + var R5 = this.g.mul(r10); + var Rencoded = this.encodePoint(R5); + var s_ = this.hashInt(Rencoded, key.pubBytes(), message2).mul(key.priv()); + var S5 = r10.add(s_).umod(this.curve.n); + return this.makeSignature({ + R: R5, + S: S5, + Rencoded + }); + }; + EDDSA.prototype.verify = function verify2(message2, sig, pub) { + message2 = parseBytes(message2); + sig = this.makeSignature(sig); + var key = this.keyFromPublic(pub); + var h9 = this.hashInt(sig.Rencoded(), key.pubBytes(), message2); + var SG = this.g.mul(sig.S()); + var RplusAh = sig.R().add(key.pub().mul(h9)); + return RplusAh.eq(SG); + }; + EDDSA.prototype.hashInt = function hashInt() { + var hash2 = this.hash(); + for (var i8 = 0; i8 < arguments.length; i8++) + hash2.update(arguments[i8]); + return utils2.intFromLE(hash2.digest()).umod(this.curve.n); + }; + EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { + return KeyPair.fromPublic(this, pub); + }; + EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { + return KeyPair.fromSecret(this, secret); + }; + EDDSA.prototype.makeSignature = function makeSignature(sig) { + if (sig instanceof Signature3) + return sig; + return new Signature3(this, sig); + }; + EDDSA.prototype.encodePoint = function encodePoint(point) { + var enc = point.getY().toArray("le", this.encodingLength); + enc[this.encodingLength - 1] |= point.getX().isOdd() ? 128 : 0; + return enc; + }; + EDDSA.prototype.decodePoint = function decodePoint(bytes2) { + bytes2 = utils2.parseBytes(bytes2); + var lastIx = bytes2.length - 1; + var normed = bytes2.slice(0, lastIx).concat(bytes2[lastIx] & ~128); + var xIsOdd = (bytes2[lastIx] & 128) !== 0; + var y7 = utils2.intFromLE(normed); + return this.curve.pointFromY(y7, xIsOdd); + }; + EDDSA.prototype.encodeInt = function encodeInt2(num) { + return num.toArray("le", this.encodingLength); + }; + EDDSA.prototype.decodeInt = function decodeInt(bytes2) { + return utils2.intFromLE(bytes2); + }; + EDDSA.prototype.isPoint = function isPoint(val) { + return val instanceof this.pointClass; + }; + return exports$z$1; + } + var exports$y$1 = {}; + var _dewExec$y$1 = false; + function dew$y$1() { + if (_dewExec$y$1) + return exports$y$1; + _dewExec$y$1 = true; + var elliptic = exports$y$1; + elliptic.version = _package$1.version; + elliptic.utils = dew$T$1(); + elliptic.rand = dew$10$1(); + elliptic.curve = dew$O$1(); + elliptic.curves = dew$G$1(); + elliptic.ec = dew$C$1(); + elliptic.eddsa = dew$z$1(); + return exports$y$1; + } + var exports$x$1 = {}; + var _dewExec$x$1 = false; + var module$2$1 = { + exports: exports$x$1 + }; + var _global$5$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$x$1() { + if (_dewExec$x$1) + return module$2$1.exports; + _dewExec$x$1 = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$5$1).negative = 0; + (this || _global$5$1).words = null; + (this || _global$5$1).length = 0; + (this || _global$5$1).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = e$1$1.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$5$1).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$5$1).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$5$1).words = [number3 & 67108863]; + (this || _global$5$1).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$5$1).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$5$1).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$5$1).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$5$1).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$5$1).words = [0]; + (this || _global$5$1).length = 1; + return this || _global$5$1; + } + (this || _global$5$1).length = Math.ceil(number3.length / 3); + (this || _global$5$1).words = new Array((this || _global$5$1).length); + for (var i8 = 0; i8 < (this || _global$5$1).length; i8++) { + (this || _global$5$1).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$5$1).words[j5] |= w5 << off & 67108863; + (this || _global$5$1).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$5$1).words[j5] |= w5 << off & 67108863; + (this || _global$5$1).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$5$1).length = Math.ceil((number3.length - start) / 6); + (this || _global$5$1).words = new Array((this || _global$5$1).length); + for (var i8 = 0; i8 < (this || _global$5$1).length; i8++) { + (this || _global$5$1).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$5$1).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$5$1).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$5$1).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$5$1).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$5$1).words = [0]; + (this || _global$5$1).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$5$1).words[0] + word < 67108864) { + (this || _global$5$1).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$5$1).words[0] + word < 67108864) { + (this || _global$5$1).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$5$1).length); + for (var i8 = 0; i8 < (this || _global$5$1).length; i8++) { + dest.words[i8] = (this || _global$5$1).words[i8]; + } + dest.length = (this || _global$5$1).length; + dest.negative = (this || _global$5$1).negative; + dest.red = (this || _global$5$1).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$5$1).length < size4) { + (this || _global$5$1).words[(this || _global$5$1).length++] = 0; + } + return this || _global$5$1; + }; + BN.prototype.strip = function strip() { + while ((this || _global$5$1).length > 1 && (this || _global$5$1).words[(this || _global$5$1).length - 1] === 0) { + (this || _global$5$1).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$5$1).length === 1 && (this || _global$5$1).words[0] === 0) { + (this || _global$5$1).negative = 0; + } + return this || _global$5$1; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$5$1).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$5$1).length; i8++) { + var w5 = (this || _global$5$1).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$5$1).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$5$1).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$5$1).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$5$1).words[0]; + if ((this || _global$5$1).length === 2) { + ret += (this || _global$5$1).words[1] * 67108864; + } else if ((this || _global$5$1).length === 3 && (this || _global$5$1).words[2] === 1) { + ret += 4503599627370496 + (this || _global$5$1).words[1] * 67108864; + } else if ((this || _global$5$1).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$5$1).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$5$1).words[(this || _global$5$1).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$5$1).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$5$1).length; i8++) { + var b6 = this._zeroBits((this || _global$5$1).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$5$1).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$5$1).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$5$1).negative ^= 1; + } + return this || _global$5$1; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$5$1).length < num.length) { + (this || _global$5$1).words[(this || _global$5$1).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$5$1).words[i8] = (this || _global$5$1).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$5$1).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$5$1).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$5$1); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$5$1).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$5$1); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$5$1).length > num.length) { + b6 = num; + } else { + b6 = this || _global$5$1; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$5$1).words[i8] = (this || _global$5$1).words[i8] & num.words[i8]; + } + (this || _global$5$1).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$5$1).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$5$1).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$5$1); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$5$1).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$5$1); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$5$1).length > num.length) { + a8 = this || _global$5$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$5$1; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$5$1).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$5$1) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$5$1).words[i8] = a8.words[i8]; + } + } + (this || _global$5$1).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$5$1).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$5$1).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$5$1); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$5$1).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$5$1); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$5$1).words[i8] = ~(this || _global$5$1).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$5$1).words[i8] = ~(this || _global$5$1).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$5$1).words[off] = (this || _global$5$1).words[off] | 1 << wbit; + } else { + (this || _global$5$1).words[off] = (this || _global$5$1).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$5$1).negative !== 0 && num.negative === 0) { + (this || _global$5$1).negative = 0; + r10 = this.isub(num); + (this || _global$5$1).negative ^= 1; + return this._normSign(); + } else if ((this || _global$5$1).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$5$1).length > num.length) { + a8 = this || _global$5$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$5$1; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$5$1).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$5$1).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$5$1).length = a8.length; + if (carry !== 0) { + (this || _global$5$1).words[(this || _global$5$1).length] = carry; + (this || _global$5$1).length++; + } else if (a8 !== (this || _global$5$1)) { + for (; i8 < a8.length; i8++) { + (this || _global$5$1).words[i8] = a8.words[i8]; + } + } + return this || _global$5$1; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$5$1).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$5$1).negative !== 0) { + (this || _global$5$1).negative = 0; + res = num.sub(this || _global$5$1); + (this || _global$5$1).negative = 1; + return res; + } + if ((this || _global$5$1).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$5$1); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$5$1).negative !== 0) { + (this || _global$5$1).negative = 0; + this.iadd(num); + (this || _global$5$1).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$5$1).negative = 0; + (this || _global$5$1).length = 1; + (this || _global$5$1).words[0] = 0; + return this || _global$5$1; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$5$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$5$1; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$5$1).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$5$1).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$5$1)) { + for (; i8 < a8.length; i8++) { + (this || _global$5$1).words[i8] = a8.words[i8]; + } + } + (this || _global$5$1).length = Math.max((this || _global$5$1).length, i8); + if (a8 !== (this || _global$5$1)) { + (this || _global$5$1).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$5$1).length + num.length; + if ((this || _global$5$1).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$5$1, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$5$1, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$5$1, num, out); + } else { + res = jumboMulTo(this || _global$5$1, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$5$1).x = x5; + (this || _global$5$1).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$5$1).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$5$1).length + num.length); + return jumboMulTo(this || _global$5$1, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$5$1); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$5$1).length; i8++) { + var w5 = ((this || _global$5$1).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$5$1).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$5$1).words[i8] = carry; + (this || _global$5$1).length++; + } + return this || _global$5$1; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$5$1); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$5$1; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$5$1).length; i8++) { + var newCarry = (this || _global$5$1).words[i8] & carryMask; + var c8 = ((this || _global$5$1).words[i8] | 0) - newCarry << r10; + (this || _global$5$1).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$5$1).words[i8] = carry; + (this || _global$5$1).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$5$1).length - 1; i8 >= 0; i8--) { + (this || _global$5$1).words[i8 + s7] = (this || _global$5$1).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$5$1).words[i8] = 0; + } + (this || _global$5$1).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$5$1).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$5$1).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$5$1).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$5$1).length > s7) { + (this || _global$5$1).length -= s7; + for (i8 = 0; i8 < (this || _global$5$1).length; i8++) { + (this || _global$5$1).words[i8] = (this || _global$5$1).words[i8 + s7]; + } + } else { + (this || _global$5$1).words[0] = 0; + (this || _global$5$1).length = 1; + } + var carry = 0; + for (i8 = (this || _global$5$1).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$5$1).words[i8] | 0; + (this || _global$5$1).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$5$1).length === 0) { + (this || _global$5$1).words[0] = 0; + (this || _global$5$1).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$5$1).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$5$1).length <= s7) + return false; + var w5 = (this || _global$5$1).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$5$1).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$5$1).length <= s7) { + return this || _global$5$1; + } + if (r10 !== 0) { + s7++; + } + (this || _global$5$1).length = Math.min(s7, (this || _global$5$1).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$5$1).words[(this || _global$5$1).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$5$1).negative !== 0) { + if ((this || _global$5$1).length === 1 && ((this || _global$5$1).words[0] | 0) < num) { + (this || _global$5$1).words[0] = num - ((this || _global$5$1).words[0] | 0); + (this || _global$5$1).negative = 0; + return this || _global$5$1; + } + (this || _global$5$1).negative = 0; + this.isubn(num); + (this || _global$5$1).negative = 1; + return this || _global$5$1; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$5$1).words[0] += num; + for (var i8 = 0; i8 < (this || _global$5$1).length && (this || _global$5$1).words[i8] >= 67108864; i8++) { + (this || _global$5$1).words[i8] -= 67108864; + if (i8 === (this || _global$5$1).length - 1) { + (this || _global$5$1).words[i8 + 1] = 1; + } else { + (this || _global$5$1).words[i8 + 1]++; + } + } + (this || _global$5$1).length = Math.max((this || _global$5$1).length, i8 + 1); + return this || _global$5$1; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$5$1).negative !== 0) { + (this || _global$5$1).negative = 0; + this.iaddn(num); + (this || _global$5$1).negative = 1; + return this || _global$5$1; + } + (this || _global$5$1).words[0] -= num; + if ((this || _global$5$1).length === 1 && (this || _global$5$1).words[0] < 0) { + (this || _global$5$1).words[0] = -(this || _global$5$1).words[0]; + (this || _global$5$1).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$5$1).length && (this || _global$5$1).words[i8] < 0; i8++) { + (this || _global$5$1).words[i8] += 67108864; + (this || _global$5$1).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$5$1).negative = 0; + return this || _global$5$1; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$5$1).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$5$1).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$5$1).length - shift; i8++) { + w5 = ((this || _global$5$1).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$5$1).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$5$1).length; i8++) { + w5 = -((this || _global$5$1).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$5$1).words[i8] = w5 & 67108863; + } + (this || _global$5$1).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$5$1).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$5$1).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$5$1).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$5$1).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$5$1).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$5$1 + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$5$1).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$5$1).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$5$1).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$5$1).words[i8] | 0) + carry * 67108864; + (this || _global$5$1).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$5$1; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$5$1; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$5$1).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$5$1).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$5$1).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$5$1).length <= s7) { + this._expand(s7 + 1); + (this || _global$5$1).words[s7] |= q4; + return this || _global$5$1; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$5$1).length; i8++) { + var w5 = (this || _global$5$1).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$5$1).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$5$1).words[i8] = carry; + (this || _global$5$1).length++; + } + return this || _global$5$1; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$5$1).length === 1 && (this || _global$5$1).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$5$1).negative !== 0 && !negative) + return -1; + if ((this || _global$5$1).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$5$1).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$5$1).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$5$1).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$5$1).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$5$1).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$5$1).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$5$1).length > num.length) + return 1; + if ((this || _global$5$1).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$5$1).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$5$1).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$5$1).red, "Already a number in reduction context"); + assert((this || _global$5$1).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$5$1)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$5$1).red, "fromRed works only with numbers in reduction context"); + return (this || _global$5$1).red.convertFrom(this || _global$5$1); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$5$1).red = ctx; + return this || _global$5$1; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$5$1).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$5$1).red, "redAdd works only with red numbers"); + return (this || _global$5$1).red.add(this || _global$5$1, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$5$1).red, "redIAdd works only with red numbers"); + return (this || _global$5$1).red.iadd(this || _global$5$1, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$5$1).red, "redSub works only with red numbers"); + return (this || _global$5$1).red.sub(this || _global$5$1, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$5$1).red, "redISub works only with red numbers"); + return (this || _global$5$1).red.isub(this || _global$5$1, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$5$1).red, "redShl works only with red numbers"); + return (this || _global$5$1).red.shl(this || _global$5$1, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$5$1).red, "redMul works only with red numbers"); + (this || _global$5$1).red._verify2(this || _global$5$1, num); + return (this || _global$5$1).red.mul(this || _global$5$1, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$5$1).red, "redMul works only with red numbers"); + (this || _global$5$1).red._verify2(this || _global$5$1, num); + return (this || _global$5$1).red.imul(this || _global$5$1, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$5$1).red, "redSqr works only with red numbers"); + (this || _global$5$1).red._verify1(this || _global$5$1); + return (this || _global$5$1).red.sqr(this || _global$5$1); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$5$1).red, "redISqr works only with red numbers"); + (this || _global$5$1).red._verify1(this || _global$5$1); + return (this || _global$5$1).red.isqr(this || _global$5$1); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$5$1).red, "redSqrt works only with red numbers"); + (this || _global$5$1).red._verify1(this || _global$5$1); + return (this || _global$5$1).red.sqrt(this || _global$5$1); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$5$1).red, "redInvm works only with red numbers"); + (this || _global$5$1).red._verify1(this || _global$5$1); + return (this || _global$5$1).red.invm(this || _global$5$1); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$5$1).red, "redNeg works only with red numbers"); + (this || _global$5$1).red._verify1(this || _global$5$1); + return (this || _global$5$1).red.neg(this || _global$5$1); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$5$1).red && !num.red, "redPow(normalNum)"); + (this || _global$5$1).red._verify1(this || _global$5$1); + return (this || _global$5$1).red.pow(this || _global$5$1, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$5$1).name = name15; + (this || _global$5$1).p = new BN(p8, 16); + (this || _global$5$1).n = (this || _global$5$1).p.bitLength(); + (this || _global$5$1).k = new BN(1).iushln((this || _global$5$1).n).isub((this || _global$5$1).p); + (this || _global$5$1).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$5$1).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$5$1).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$5$1).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$5$1).n); + var cmp = rlen < (this || _global$5$1).n ? -1 : r10.ucmp((this || _global$5$1).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$5$1).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$5$1).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$5$1).k); + }; + function K256() { + MPrime.call(this || _global$5$1, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$5$1, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$5$1, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$5$1, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$5$1).m = prime.p; + (this || _global$5$1).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$5$1).m = m7; + (this || _global$5$1).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$5$1).prime) + return (this || _global$5$1).prime.ireduce(a8)._forceRed(this || _global$5$1); + return a8.umod((this || _global$5$1).m)._forceRed(this || _global$5$1); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$5$1).m.sub(a8)._forceRed(this || _global$5$1); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$5$1).m) >= 0) { + res.isub((this || _global$5$1).m); + } + return res._forceRed(this || _global$5$1); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$5$1).m) >= 0) { + res.isub((this || _global$5$1).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$5$1).m); + } + return res._forceRed(this || _global$5$1); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$5$1).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$5$1).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$5$1).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$5$1).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$5$1); + var nOne = one.redNeg(); + var lpow = (this || _global$5$1).m.subn(1).iushrn(1); + var z6 = (this || _global$5$1).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$5$1); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$5$1).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$5$1); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$5$1); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$5$1).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$5$1, m7); + (this || _global$5$1).shift = (this || _global$5$1).m.bitLength(); + if ((this || _global$5$1).shift % 26 !== 0) { + (this || _global$5$1).shift += 26 - (this || _global$5$1).shift % 26; + } + (this || _global$5$1).r = new BN(1).iushln((this || _global$5$1).shift); + (this || _global$5$1).r2 = this.imod((this || _global$5$1).r.sqr()); + (this || _global$5$1).rinv = (this || _global$5$1).r._invmp((this || _global$5$1).m); + (this || _global$5$1).minv = (this || _global$5$1).rinv.mul((this || _global$5$1).r).isubn(1).div((this || _global$5$1).m); + (this || _global$5$1).minv = (this || _global$5$1).minv.umod((this || _global$5$1).r); + (this || _global$5$1).minv = (this || _global$5$1).r.sub((this || _global$5$1).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$5$1).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$5$1).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$5$1).shift).mul((this || _global$5$1).minv).imaskn((this || _global$5$1).shift).mul((this || _global$5$1).m); + var u8 = t9.isub(c8).iushrn((this || _global$5$1).shift); + var res = u8; + if (u8.cmp((this || _global$5$1).m) >= 0) { + res = u8.isub((this || _global$5$1).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$5$1).m); + } + return res._forceRed(this || _global$5$1); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$5$1); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$5$1).shift).mul((this || _global$5$1).minv).imaskn((this || _global$5$1).shift).mul((this || _global$5$1).m); + var u8 = t9.isub(c8).iushrn((this || _global$5$1).shift); + var res = u8; + if (u8.cmp((this || _global$5$1).m) >= 0) { + res = u8.isub((this || _global$5$1).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$5$1).m); + } + return res._forceRed(this || _global$5$1); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$5$1).m).mul((this || _global$5$1).r2)); + return res._forceRed(this || _global$5$1); + }; + })(module$2$1, exports$x$1); + return module$2$1.exports; + } + var exports$w$1 = {}; + var _dewExec$w$1 = false; + function dew$w$1() { + if (_dewExec$w$1) + return exports$w$1; + _dewExec$w$1 = true; + var process3 = T; + var buffer4 = e$1$1; + var Buffer2 = buffer4.Buffer; + var safer = {}; + var key; + for (key in buffer4) { + if (!buffer4.hasOwnProperty(key)) + continue; + if (key === "SlowBuffer" || key === "Buffer") + continue; + safer[key] = buffer4[key]; + } + var Safer = safer.Buffer = {}; + for (key in Buffer2) { + if (!Buffer2.hasOwnProperty(key)) + continue; + if (key === "allocUnsafe" || key === "allocUnsafeSlow") + continue; + Safer[key] = Buffer2[key]; + } + safer.Buffer.prototype = Buffer2.prototype; + if (!Safer.from || Safer.from === Uint8Array.from) { + Safer.from = function(value, encodingOrOffset, length3) { + if (typeof value === "number") { + throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value); + } + if (value && typeof value.length === "undefined") { + throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); + } + return Buffer2(value, encodingOrOffset, length3); + }; + } + if (!Safer.alloc) { + Safer.alloc = function(size4, fill, encoding) { + if (typeof size4 !== "number") { + throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size4); + } + if (size4 < 0 || size4 >= 2 * (1 << 30)) { + throw new RangeError('The value "' + size4 + '" is invalid for option "size"'); + } + var buf3 = Buffer2(size4); + if (!fill || fill.length === 0) { + buf3.fill(0); + } else if (typeof encoding === "string") { + buf3.fill(fill, encoding); + } else { + buf3.fill(fill); + } + return buf3; + }; + } + if (!safer.kStringMaxLength) { + try { + safer.kStringMaxLength = process3.binding("buffer").kStringMaxLength; + } catch (e12) { + } + } + if (!safer.constants) { + safer.constants = { + MAX_LENGTH: safer.kMaxLength + }; + if (safer.kStringMaxLength) { + safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength; + } + } + exports$w$1 = safer; + return exports$w$1; + } + var exports$v$1 = {}; + var _dewExec$v$1 = false; + function dew$v$1() { + if (_dewExec$v$1) + return exports$v$1; + _dewExec$v$1 = true; + const inherits3 = dew$f$2(); + function Reporter(options) { + this._reporterState = { + obj: null, + path: [], + options: options || {}, + errors: [] + }; + } + exports$v$1.Reporter = Reporter; + Reporter.prototype.isError = function isError3(obj) { + return obj instanceof ReporterError; + }; + Reporter.prototype.save = function save() { + const state = this._reporterState; + return { + obj: state.obj, + pathLen: state.path.length + }; + }; + Reporter.prototype.restore = function restore(data) { + const state = this._reporterState; + state.obj = data.obj; + state.path = state.path.slice(0, data.pathLen); + }; + Reporter.prototype.enterKey = function enterKey(key) { + return this._reporterState.path.push(key); + }; + Reporter.prototype.exitKey = function exitKey(index2) { + const state = this._reporterState; + state.path = state.path.slice(0, index2 - 1); + }; + Reporter.prototype.leaveKey = function leaveKey(index2, key, value) { + const state = this._reporterState; + this.exitKey(index2); + if (state.obj !== null) + state.obj[key] = value; + }; + Reporter.prototype.path = function path2() { + return this._reporterState.path.join("/"); + }; + Reporter.prototype.enterObject = function enterObject() { + const state = this._reporterState; + const prev = state.obj; + state.obj = {}; + return prev; + }; + Reporter.prototype.leaveObject = function leaveObject(prev) { + const state = this._reporterState; + const now2 = state.obj; + state.obj = prev; + return now2; + }; + Reporter.prototype.error = function error7(msg) { + let err; + const state = this._reporterState; + const inherited = msg instanceof ReporterError; + if (inherited) { + err = msg; + } else { + err = new ReporterError(state.path.map(function(elem) { + return "[" + JSON.stringify(elem) + "]"; + }).join(""), msg.message || msg, msg.stack); + } + if (!state.options.partial) + throw err; + if (!inherited) + state.errors.push(err); + return err; + }; + Reporter.prototype.wrapResult = function wrapResult(result) { + const state = this._reporterState; + if (!state.options.partial) + return result; + return { + result: this.isError(result) ? null : result, + errors: state.errors + }; + }; + function ReporterError(path2, msg) { + this.path = path2; + this.rethrow(msg); + } + inherits3(ReporterError, Error); + ReporterError.prototype.rethrow = function rethrow(msg) { + this.message = msg + " at: " + (this.path || "(shallow)"); + if (Error.captureStackTrace) + Error.captureStackTrace(this, ReporterError); + if (!this.stack) { + try { + throw new Error(this.message); + } catch (e12) { + this.stack = e12.stack; + } + } + return this; + }; + return exports$v$1; + } + var exports$u$1 = {}; + var _dewExec$u$1 = false; + function dew$u$1() { + if (_dewExec$u$1) + return exports$u$1; + _dewExec$u$1 = true; + const inherits3 = dew$f$2(); + const Reporter = dew$v$1().Reporter; + const Buffer2 = dew$w$1().Buffer; + function DecoderBuffer(base3, options) { + Reporter.call(this, options); + if (!Buffer2.isBuffer(base3)) { + this.error("Input not Buffer"); + return; + } + this.base = base3; + this.offset = 0; + this.length = base3.length; + } + inherits3(DecoderBuffer, Reporter); + exports$u$1.DecoderBuffer = DecoderBuffer; + DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) { + if (data instanceof DecoderBuffer) { + return true; + } + const isCompatible = typeof data === "object" && Buffer2.isBuffer(data.base) && data.constructor.name === "DecoderBuffer" && typeof data.offset === "number" && typeof data.length === "number" && typeof data.save === "function" && typeof data.restore === "function" && typeof data.isEmpty === "function" && typeof data.readUInt8 === "function" && typeof data.skip === "function" && typeof data.raw === "function"; + return isCompatible; + }; + DecoderBuffer.prototype.save = function save() { + return { + offset: this.offset, + reporter: Reporter.prototype.save.call(this) + }; + }; + DecoderBuffer.prototype.restore = function restore(save) { + const res = new DecoderBuffer(this.base); + res.offset = save.offset; + res.length = this.offset; + this.offset = save.offset; + Reporter.prototype.restore.call(this, save.reporter); + return res; + }; + DecoderBuffer.prototype.isEmpty = function isEmpty3() { + return this.offset === this.length; + }; + DecoderBuffer.prototype.readUInt8 = function readUInt8(fail5) { + if (this.offset + 1 <= this.length) + return this.base.readUInt8(this.offset++, true); + else + return this.error(fail5 || "DecoderBuffer overrun"); + }; + DecoderBuffer.prototype.skip = function skip2(bytes2, fail5) { + if (!(this.offset + bytes2 <= this.length)) + return this.error(fail5 || "DecoderBuffer overrun"); + const res = new DecoderBuffer(this.base); + res._reporterState = this._reporterState; + res.offset = this.offset; + res.length = this.offset + bytes2; + this.offset += bytes2; + return res; + }; + DecoderBuffer.prototype.raw = function raw(save) { + return this.base.slice(save ? save.offset : this.offset, this.length); + }; + function EncoderBuffer(value, reporter) { + if (Array.isArray(value)) { + this.length = 0; + this.value = value.map(function(item) { + if (!EncoderBuffer.isEncoderBuffer(item)) + item = new EncoderBuffer(item, reporter); + this.length += item.length; + return item; + }, this); + } else if (typeof value === "number") { + if (!(0 <= value && value <= 255)) + return reporter.error("non-byte EncoderBuffer value"); + this.value = value; + this.length = 1; + } else if (typeof value === "string") { + this.value = value; + this.length = Buffer2.byteLength(value); + } else if (Buffer2.isBuffer(value)) { + this.value = value; + this.length = value.length; + } else { + return reporter.error("Unsupported type: " + typeof value); + } + } + exports$u$1.EncoderBuffer = EncoderBuffer; + EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) { + if (data instanceof EncoderBuffer) { + return true; + } + const isCompatible = typeof data === "object" && data.constructor.name === "EncoderBuffer" && typeof data.length === "number" && typeof data.join === "function"; + return isCompatible; + }; + EncoderBuffer.prototype.join = function join3(out, offset2) { + if (!out) + out = Buffer2.alloc(this.length); + if (!offset2) + offset2 = 0; + if (this.length === 0) + return out; + if (Array.isArray(this.value)) { + this.value.forEach(function(item) { + item.join(out, offset2); + offset2 += item.length; + }); + } else { + if (typeof this.value === "number") + out[offset2] = this.value; + else if (typeof this.value === "string") + out.write(this.value, offset2); + else if (Buffer2.isBuffer(this.value)) + this.value.copy(out, offset2); + offset2 += this.length; + } + return out; + }; + return exports$u$1; + } + var exports$t$1 = {}; + var _dewExec$t$1 = false; + function dew$t$1() { + if (_dewExec$t$1) + return exports$t$1; + _dewExec$t$1 = true; + const Reporter = dew$v$1().Reporter; + const EncoderBuffer = dew$u$1().EncoderBuffer; + const DecoderBuffer = dew$u$1().DecoderBuffer; + const assert = dew$1t(); + const tags = ["seq", "seqof", "set", "setof", "objid", "bool", "gentime", "utctime", "null_", "enum", "int", "objDesc", "bitstr", "bmpstr", "charstr", "genstr", "graphstr", "ia5str", "iso646str", "numstr", "octstr", "printstr", "t61str", "unistr", "utf8str", "videostr"]; + const methods2 = ["key", "obj", "use", "optional", "explicit", "implicit", "def", "choice", "any", "contains"].concat(tags); + const overrided = ["_peekTag", "_decodeTag", "_use", "_decodeStr", "_decodeObjid", "_decodeTime", "_decodeNull", "_decodeInt", "_decodeBool", "_decodeList", "_encodeComposite", "_encodeStr", "_encodeObjid", "_encodeTime", "_encodeNull", "_encodeInt", "_encodeBool"]; + function Node3(enc, parent, name15) { + const state = {}; + this._baseState = state; + state.name = name15; + state.enc = enc; + state.parent = parent || null; + state.children = null; + state.tag = null; + state.args = null; + state.reverseArgs = null; + state.choice = null; + state.optional = false; + state.any = false; + state.obj = false; + state.use = null; + state.useDecoder = null; + state.key = null; + state["default"] = null; + state.explicit = null; + state.implicit = null; + state.contains = null; + if (!state.parent) { + state.children = []; + this._wrap(); + } + } + exports$t$1 = Node3; + const stateProps = ["enc", "parent", "children", "tag", "args", "reverseArgs", "choice", "optional", "any", "obj", "use", "alteredUse", "key", "default", "explicit", "implicit", "contains"]; + Node3.prototype.clone = function clone() { + const state = this._baseState; + const cstate = {}; + stateProps.forEach(function(prop) { + cstate[prop] = state[prop]; + }); + const res = new this.constructor(cstate.parent); + res._baseState = cstate; + return res; + }; + Node3.prototype._wrap = function wrap2() { + const state = this._baseState; + methods2.forEach(function(method) { + this[method] = function _wrappedMethod() { + const clone = new this.constructor(this); + state.children.push(clone); + return clone[method].apply(clone, arguments); + }; + }, this); + }; + Node3.prototype._init = function init3(body) { + const state = this._baseState; + assert(state.parent === null); + body.call(this); + state.children = state.children.filter(function(child) { + return child._baseState.parent === this; + }, this); + assert.equal(state.children.length, 1, "Root node can have only one child"); + }; + Node3.prototype._useArgs = function useArgs(args) { + const state = this._baseState; + const children = args.filter(function(arg) { + return arg instanceof this.constructor; + }, this); + args = args.filter(function(arg) { + return !(arg instanceof this.constructor); + }, this); + if (children.length !== 0) { + assert(state.children === null); + state.children = children; + children.forEach(function(child) { + child._baseState.parent = this; + }, this); + } + if (args.length !== 0) { + assert(state.args === null); + state.args = args; + state.reverseArgs = args.map(function(arg) { + if (typeof arg !== "object" || arg.constructor !== Object) + return arg; + const res = {}; + Object.keys(arg).forEach(function(key) { + if (key == (key | 0)) + key |= 0; + const value = arg[key]; + res[value] = key; + }); + return res; + }); + } + }; + overrided.forEach(function(method) { + Node3.prototype[method] = function _overrided() { + const state = this._baseState; + throw new Error(method + " not implemented for encoding: " + state.enc); + }; + }); + tags.forEach(function(tag2) { + Node3.prototype[tag2] = function _tagMethod() { + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); + assert(state.tag === null); + state.tag = tag2; + this._useArgs(args); + return this; + }; + }); + Node3.prototype.use = function use(item) { + assert(item); + const state = this._baseState; + assert(state.use === null); + state.use = item; + return this; + }; + Node3.prototype.optional = function optional5() { + const state = this._baseState; + state.optional = true; + return this; + }; + Node3.prototype.def = function def(val) { + const state = this._baseState; + assert(state["default"] === null); + state["default"] = val; + state.optional = true; + return this; + }; + Node3.prototype.explicit = function explicit(num) { + const state = this._baseState; + assert(state.explicit === null && state.implicit === null); + state.explicit = num; + return this; + }; + Node3.prototype.implicit = function implicit(num) { + const state = this._baseState; + assert(state.explicit === null && state.implicit === null); + state.implicit = num; + return this; + }; + Node3.prototype.obj = function obj() { + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); + state.obj = true; + if (args.length !== 0) + this._useArgs(args); + return this; + }; + Node3.prototype.key = function key(newKey) { + const state = this._baseState; + assert(state.key === null); + state.key = newKey; + return this; + }; + Node3.prototype.any = function any() { + const state = this._baseState; + state.any = true; + return this; + }; + Node3.prototype.choice = function choice(obj) { + const state = this._baseState; + assert(state.choice === null); + state.choice = obj; + this._useArgs(Object.keys(obj).map(function(key) { + return obj[key]; + })); + return this; + }; + Node3.prototype.contains = function contains2(item) { + const state = this._baseState; + assert(state.use === null); + state.contains = item; + return this; + }; + Node3.prototype._decode = function decode46(input, options) { + const state = this._baseState; + if (state.parent === null) + return input.wrapResult(state.children[0]._decode(input, options)); + let result = state["default"]; + let present = true; + let prevKey = null; + if (state.key !== null) + prevKey = input.enterKey(state.key); + if (state.optional) { + let tag2 = null; + if (state.explicit !== null) + tag2 = state.explicit; + else if (state.implicit !== null) + tag2 = state.implicit; + else if (state.tag !== null) + tag2 = state.tag; + if (tag2 === null && !state.any) { + const save = input.save(); + try { + if (state.choice === null) + this._decodeGeneric(state.tag, input, options); + else + this._decodeChoice(input, options); + present = true; + } catch (e12) { + present = false; + } + input.restore(save); + } else { + present = this._peekTag(input, tag2, state.any); + if (input.isError(present)) + return present; + } + } + let prevObj; + if (state.obj && present) + prevObj = input.enterObject(); + if (present) { + if (state.explicit !== null) { + const explicit = this._decodeTag(input, state.explicit); + if (input.isError(explicit)) + return explicit; + input = explicit; + } + const start = input.offset; + if (state.use === null && state.choice === null) { + let save; + if (state.any) + save = input.save(); + const body = this._decodeTag(input, state.implicit !== null ? state.implicit : state.tag, state.any); + if (input.isError(body)) + return body; + if (state.any) + result = input.raw(save); + else + input = body; + } + if (options && options.track && state.tag !== null) + options.track(input.path(), start, input.length, "tagged"); + if (options && options.track && state.tag !== null) + options.track(input.path(), input.offset, input.length, "content"); + if (state.any) + ; + else if (state.choice === null) { + result = this._decodeGeneric(state.tag, input, options); + } else { + result = this._decodeChoice(input, options); + } + if (input.isError(result)) + return result; + if (!state.any && state.choice === null && state.children !== null) { + state.children.forEach(function decodeChildren(child) { + child._decode(input, options); + }); + } + if (state.contains && (state.tag === "octstr" || state.tag === "bitstr")) { + const data = new DecoderBuffer(result); + result = this._getUse(state.contains, input._reporterState.obj)._decode(data, options); + } + } + if (state.obj && present) + result = input.leaveObject(prevObj); + if (state.key !== null && (result !== null || present === true)) + input.leaveKey(prevKey, state.key, result); + else if (prevKey !== null) + input.exitKey(prevKey); + return result; + }; + Node3.prototype._decodeGeneric = function decodeGeneric(tag2, input, options) { + const state = this._baseState; + if (tag2 === "seq" || tag2 === "set") + return null; + if (tag2 === "seqof" || tag2 === "setof") + return this._decodeList(input, tag2, state.args[0], options); + else if (/str$/.test(tag2)) + return this._decodeStr(input, tag2, options); + else if (tag2 === "objid" && state.args) + return this._decodeObjid(input, state.args[0], state.args[1], options); + else if (tag2 === "objid") + return this._decodeObjid(input, null, null, options); + else if (tag2 === "gentime" || tag2 === "utctime") + return this._decodeTime(input, tag2, options); + else if (tag2 === "null_") + return this._decodeNull(input, options); + else if (tag2 === "bool") + return this._decodeBool(input, options); + else if (tag2 === "objDesc") + return this._decodeStr(input, tag2, options); + else if (tag2 === "int" || tag2 === "enum") + return this._decodeInt(input, state.args && state.args[0], options); + if (state.use !== null) { + return this._getUse(state.use, input._reporterState.obj)._decode(input, options); + } else { + return input.error("unknown tag: " + tag2); + } + }; + Node3.prototype._getUse = function _getUse(entity, obj) { + const state = this._baseState; + state.useDecoder = this._use(entity, obj); + assert(state.useDecoder._baseState.parent === null); + state.useDecoder = state.useDecoder._baseState.children[0]; + if (state.implicit !== state.useDecoder._baseState.implicit) { + state.useDecoder = state.useDecoder.clone(); + state.useDecoder._baseState.implicit = state.implicit; + } + return state.useDecoder; + }; + Node3.prototype._decodeChoice = function decodeChoice(input, options) { + const state = this._baseState; + let result = null; + let match10 = false; + Object.keys(state.choice).some(function(key) { + const save = input.save(); + const node = state.choice[key]; + try { + const value = node._decode(input, options); + if (input.isError(value)) + return false; + result = { + type: key, + value + }; + match10 = true; + } catch (e12) { + input.restore(save); + return false; + } + return true; + }, this); + if (!match10) + return input.error("Choice not matched"); + return result; + }; + Node3.prototype._createEncoderBuffer = function createEncoderBuffer(data) { + return new EncoderBuffer(data, this.reporter); + }; + Node3.prototype._encode = function encode41(data, reporter, parent) { + const state = this._baseState; + if (state["default"] !== null && state["default"] === data) + return; + const result = this._encodeValue(data, reporter, parent); + if (result === void 0) + return; + if (this._skipDefault(result, reporter, parent)) + return; + return result; + }; + Node3.prototype._encodeValue = function encode41(data, reporter, parent) { + const state = this._baseState; + if (state.parent === null) + return state.children[0]._encode(data, reporter || new Reporter()); + let result = null; + this.reporter = reporter; + if (state.optional && data === void 0) { + if (state["default"] !== null) + data = state["default"]; + else + return; + } + let content = null; + let primitive = false; + if (state.any) { + result = this._createEncoderBuffer(data); + } else if (state.choice) { + result = this._encodeChoice(data, reporter); + } else if (state.contains) { + content = this._getUse(state.contains, parent)._encode(data, reporter); + primitive = true; + } else if (state.children) { + content = state.children.map(function(child) { + if (child._baseState.tag === "null_") + return child._encode(null, reporter, data); + if (child._baseState.key === null) + return reporter.error("Child should have a key"); + const prevKey = reporter.enterKey(child._baseState.key); + if (typeof data !== "object") + return reporter.error("Child expected, but input is not object"); + const res = child._encode(data[child._baseState.key], reporter, data); + reporter.leaveKey(prevKey); + return res; + }, this).filter(function(child) { + return child; + }); + content = this._createEncoderBuffer(content); + } else { + if (state.tag === "seqof" || state.tag === "setof") { + if (!(state.args && state.args.length === 1)) + return reporter.error("Too many args for : " + state.tag); + if (!Array.isArray(data)) + return reporter.error("seqof/setof, but data is not Array"); + const child = this.clone(); + child._baseState.implicit = null; + content = this._createEncoderBuffer(data.map(function(item) { + const state2 = this._baseState; + return this._getUse(state2.args[0], data)._encode(item, reporter); + }, child)); + } else if (state.use !== null) { + result = this._getUse(state.use, parent)._encode(data, reporter); + } else { + content = this._encodePrimitive(state.tag, data); + primitive = true; + } + } + if (!state.any && state.choice === null) { + const tag2 = state.implicit !== null ? state.implicit : state.tag; + const cls = state.implicit === null ? "universal" : "context"; + if (tag2 === null) { + if (state.use === null) + reporter.error("Tag could be omitted only for .use()"); + } else { + if (state.use === null) + result = this._encodeComposite(tag2, primitive, cls, content); + } + } + if (state.explicit !== null) + result = this._encodeComposite(state.explicit, false, "context", result); + return result; + }; + Node3.prototype._encodeChoice = function encodeChoice(data, reporter) { + const state = this._baseState; + const node = state.choice[data.type]; + if (!node) { + assert(false, data.type + " not found in " + JSON.stringify(Object.keys(state.choice))); + } + return node._encode(data.value, reporter); + }; + Node3.prototype._encodePrimitive = function encodePrimitive(tag2, data) { + const state = this._baseState; + if (/str$/.test(tag2)) + return this._encodeStr(data, tag2); + else if (tag2 === "objid" && state.args) + return this._encodeObjid(data, state.reverseArgs[0], state.args[1]); + else if (tag2 === "objid") + return this._encodeObjid(data, null, null); + else if (tag2 === "gentime" || tag2 === "utctime") + return this._encodeTime(data, tag2); + else if (tag2 === "null_") + return this._encodeNull(); + else if (tag2 === "int" || tag2 === "enum") + return this._encodeInt(data, state.args && state.reverseArgs[0]); + else if (tag2 === "bool") + return this._encodeBool(data); + else if (tag2 === "objDesc") + return this._encodeStr(data, tag2); + else + throw new Error("Unsupported tag: " + tag2); + }; + Node3.prototype._isNumstr = function isNumstr(str) { + return /^[0-9 ]*$/.test(str); + }; + Node3.prototype._isPrintstr = function isPrintstr(str) { + return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str); + }; + return exports$t$1; + } + var exports$s$1 = {}; + var _dewExec$s$1 = false; + function dew$s$1() { + if (_dewExec$s$1) + return exports$s$1; + _dewExec$s$1 = true; + function reverse(map2) { + const res = {}; + Object.keys(map2).forEach(function(key) { + if ((key | 0) == key) + key = key | 0; + const value = map2[key]; + res[value] = key; + }); + return res; + } + exports$s$1.tagClass = { + 0: "universal", + 1: "application", + 2: "context", + 3: "private" + }; + exports$s$1.tagClassByName = reverse(exports$s$1.tagClass); + exports$s$1.tag = { + 0: "end", + 1: "bool", + 2: "int", + 3: "bitstr", + 4: "octstr", + 5: "null_", + 6: "objid", + 7: "objDesc", + 8: "external", + 9: "real", + 10: "enum", + 11: "embed", + 12: "utf8str", + 13: "relativeOid", + 16: "seq", + 17: "set", + 18: "numstr", + 19: "printstr", + 20: "t61str", + 21: "videostr", + 22: "ia5str", + 23: "utctime", + 24: "gentime", + 25: "graphstr", + 26: "iso646str", + 27: "genstr", + 28: "unistr", + 29: "charstr", + 30: "bmpstr" + }; + exports$s$1.tagByName = reverse(exports$s$1.tag); + return exports$s$1; + } + var exports$r$1 = {}; + var _dewExec$r$1 = false; + function dew$r$1() { + if (_dewExec$r$1) + return exports$r$1; + _dewExec$r$1 = true; + const inherits3 = dew$f$2(); + const Buffer2 = dew$w$1().Buffer; + const Node3 = dew$t$1(); + const der = dew$s$1(); + function DEREncoder(entity) { + this.enc = "der"; + this.name = entity.name; + this.entity = entity; + this.tree = new DERNode(); + this.tree._init(entity.body); + } + exports$r$1 = DEREncoder; + DEREncoder.prototype.encode = function encode41(data, reporter) { + return this.tree._encode(data, reporter).join(); + }; + function DERNode(parent) { + Node3.call(this, "der", parent); + } + inherits3(DERNode, Node3); + DERNode.prototype._encodeComposite = function encodeComposite(tag2, primitive, cls, content) { + const encodedTag = encodeTag3(tag2, primitive, cls, this.reporter); + if (content.length < 128) { + const header2 = Buffer2.alloc(2); + header2[0] = encodedTag; + header2[1] = content.length; + return this._createEncoderBuffer([header2, content]); + } + let lenOctets = 1; + for (let i8 = content.length; i8 >= 256; i8 >>= 8) + lenOctets++; + const header = Buffer2.alloc(1 + 1 + lenOctets); + header[0] = encodedTag; + header[1] = 128 | lenOctets; + for (let i8 = 1 + lenOctets, j5 = content.length; j5 > 0; i8--, j5 >>= 8) + header[i8] = j5 & 255; + return this._createEncoderBuffer([header, content]); + }; + DERNode.prototype._encodeStr = function encodeStr(str, tag2) { + if (tag2 === "bitstr") { + return this._createEncoderBuffer([str.unused | 0, str.data]); + } else if (tag2 === "bmpstr") { + const buf3 = Buffer2.alloc(str.length * 2); + for (let i8 = 0; i8 < str.length; i8++) { + buf3.writeUInt16BE(str.charCodeAt(i8), i8 * 2); + } + return this._createEncoderBuffer(buf3); + } else if (tag2 === "numstr") { + if (!this._isNumstr(str)) { + return this.reporter.error("Encoding of string type: numstr supports only digits and space"); + } + return this._createEncoderBuffer(str); + } else if (tag2 === "printstr") { + if (!this._isPrintstr(str)) { + return this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"); + } + return this._createEncoderBuffer(str); + } else if (/str$/.test(tag2)) { + return this._createEncoderBuffer(str); + } else if (tag2 === "objDesc") { + return this._createEncoderBuffer(str); + } else { + return this.reporter.error("Encoding of string type: " + tag2 + " unsupported"); + } + }; + DERNode.prototype._encodeObjid = function encodeObjid(id, values2, relative2) { + if (typeof id === "string") { + if (!values2) + return this.reporter.error("string objid given, but no values map found"); + if (!values2.hasOwnProperty(id)) + return this.reporter.error("objid not found in values map"); + id = values2[id].split(/[\s.]+/g); + for (let i8 = 0; i8 < id.length; i8++) + id[i8] |= 0; + } else if (Array.isArray(id)) { + id = id.slice(); + for (let i8 = 0; i8 < id.length; i8++) + id[i8] |= 0; + } + if (!Array.isArray(id)) { + return this.reporter.error("objid() should be either array or string, got: " + JSON.stringify(id)); + } + if (!relative2) { + if (id[1] >= 40) + return this.reporter.error("Second objid identifier OOB"); + id.splice(0, 2, id[0] * 40 + id[1]); + } + let size4 = 0; + for (let i8 = 0; i8 < id.length; i8++) { + let ident = id[i8]; + for (size4++; ident >= 128; ident >>= 7) + size4++; + } + const objid = Buffer2.alloc(size4); + let offset2 = objid.length - 1; + for (let i8 = id.length - 1; i8 >= 0; i8--) { + let ident = id[i8]; + objid[offset2--] = ident & 127; + while ((ident >>= 7) > 0) + objid[offset2--] = 128 | ident & 127; + } + return this._createEncoderBuffer(objid); + }; + function two(num) { + if (num < 10) + return "0" + num; + else + return num; + } + DERNode.prototype._encodeTime = function encodeTime(time, tag2) { + let str; + const date = new Date(time); + if (tag2 === "gentime") { + str = [two(date.getUTCFullYear()), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), two(date.getUTCMinutes()), two(date.getUTCSeconds()), "Z"].join(""); + } else if (tag2 === "utctime") { + str = [two(date.getUTCFullYear() % 100), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), two(date.getUTCMinutes()), two(date.getUTCSeconds()), "Z"].join(""); + } else { + this.reporter.error("Encoding " + tag2 + " time is not supported yet"); + } + return this._encodeStr(str, "octstr"); + }; + DERNode.prototype._encodeNull = function encodeNull() { + return this._createEncoderBuffer(""); + }; + DERNode.prototype._encodeInt = function encodeInt2(num, values2) { + if (typeof num === "string") { + if (!values2) + return this.reporter.error("String int or enum given, but no values map"); + if (!values2.hasOwnProperty(num)) { + return this.reporter.error("Values map doesn't contain: " + JSON.stringify(num)); + } + num = values2[num]; + } + if (typeof num !== "number" && !Buffer2.isBuffer(num)) { + const numArray = num.toArray(); + if (!num.sign && numArray[0] & 128) { + numArray.unshift(0); + } + num = Buffer2.from(numArray); + } + if (Buffer2.isBuffer(num)) { + let size5 = num.length; + if (num.length === 0) + size5++; + const out2 = Buffer2.alloc(size5); + num.copy(out2); + if (num.length === 0) + out2[0] = 0; + return this._createEncoderBuffer(out2); + } + if (num < 128) + return this._createEncoderBuffer(num); + if (num < 256) + return this._createEncoderBuffer([0, num]); + let size4 = 1; + for (let i8 = num; i8 >= 256; i8 >>= 8) + size4++; + const out = new Array(size4); + for (let i8 = out.length - 1; i8 >= 0; i8--) { + out[i8] = num & 255; + num >>= 8; + } + if (out[0] & 128) { + out.unshift(0); + } + return this._createEncoderBuffer(Buffer2.from(out)); + }; + DERNode.prototype._encodeBool = function encodeBool(value) { + return this._createEncoderBuffer(value ? 255 : 0); + }; + DERNode.prototype._use = function use(entity, obj) { + if (typeof entity === "function") + entity = entity(obj); + return entity._getEncoder("der").tree; + }; + DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) { + const state = this._baseState; + let i8; + if (state["default"] === null) + return false; + const data = dataBuffer.join(); + if (state.defaultBuffer === void 0) + state.defaultBuffer = this._encodeValue(state["default"], reporter, parent).join(); + if (data.length !== state.defaultBuffer.length) + return false; + for (i8 = 0; i8 < data.length; i8++) + if (data[i8] !== state.defaultBuffer[i8]) + return false; + return true; + }; + function encodeTag3(tag2, primitive, cls, reporter) { + let res; + if (tag2 === "seqof") + tag2 = "seq"; + else if (tag2 === "setof") + tag2 = "set"; + if (der.tagByName.hasOwnProperty(tag2)) + res = der.tagByName[tag2]; + else if (typeof tag2 === "number" && (tag2 | 0) === tag2) + res = tag2; + else + return reporter.error("Unknown tag: " + tag2); + if (res >= 31) + return reporter.error("Multi-octet tag encoding unsupported"); + if (!primitive) + res |= 32; + res |= der.tagClassByName[cls || "universal"] << 6; + return res; + } + return exports$r$1; + } + var exports$q$1 = {}; + var _dewExec$q$1 = false; + function dew$q$1() { + if (_dewExec$q$1) + return exports$q$1; + _dewExec$q$1 = true; + const inherits3 = dew$f$2(); + const DEREncoder = dew$r$1(); + function PEMEncoder(entity) { + DEREncoder.call(this, entity); + this.enc = "pem"; + } + inherits3(PEMEncoder, DEREncoder); + exports$q$1 = PEMEncoder; + PEMEncoder.prototype.encode = function encode41(data, options) { + const buf3 = DEREncoder.prototype.encode.call(this, data); + const p8 = buf3.toString("base64"); + const out = ["-----BEGIN " + options.label + "-----"]; + for (let i8 = 0; i8 < p8.length; i8 += 64) + out.push(p8.slice(i8, i8 + 64)); + out.push("-----END " + options.label + "-----"); + return out.join("\n"); + }; + return exports$q$1; + } + var exports$p$1 = {}; + var _dewExec$p$1 = false; + function dew$p$1() { + if (_dewExec$p$1) + return exports$p$1; + _dewExec$p$1 = true; + const encoders = exports$p$1; + encoders.der = dew$r$1(); + encoders.pem = dew$q$1(); + return exports$p$1; + } + var exports$o$1 = {}; + var _dewExec$o$1 = false; + function dew$o$1() { + if (_dewExec$o$1) + return exports$o$1; + _dewExec$o$1 = true; + const inherits3 = dew$f$2(); + const bignum = dew$x$1(); + const DecoderBuffer = dew$u$1().DecoderBuffer; + const Node3 = dew$t$1(); + const der = dew$s$1(); + function DERDecoder(entity) { + this.enc = "der"; + this.name = entity.name; + this.entity = entity; + this.tree = new DERNode(); + this.tree._init(entity.body); + } + exports$o$1 = DERDecoder; + DERDecoder.prototype.decode = function decode46(data, options) { + if (!DecoderBuffer.isDecoderBuffer(data)) { + data = new DecoderBuffer(data, options); + } + return this.tree._decode(data, options); + }; + function DERNode(parent) { + Node3.call(this, "der", parent); + } + inherits3(DERNode, Node3); + DERNode.prototype._peekTag = function peekTag(buffer4, tag2, any) { + if (buffer4.isEmpty()) + return false; + const state = buffer4.save(); + const decodedTag = derDecodeTag(buffer4, 'Failed to peek tag: "' + tag2 + '"'); + if (buffer4.isError(decodedTag)) + return decodedTag; + buffer4.restore(state); + return decodedTag.tag === tag2 || decodedTag.tagStr === tag2 || decodedTag.tagStr + "of" === tag2 || any; + }; + DERNode.prototype._decodeTag = function decodeTag(buffer4, tag2, any) { + const decodedTag = derDecodeTag(buffer4, 'Failed to decode tag of "' + tag2 + '"'); + if (buffer4.isError(decodedTag)) + return decodedTag; + let len = derDecodeLen(buffer4, decodedTag.primitive, 'Failed to get length of "' + tag2 + '"'); + if (buffer4.isError(len)) + return len; + if (!any && decodedTag.tag !== tag2 && decodedTag.tagStr !== tag2 && decodedTag.tagStr + "of" !== tag2) { + return buffer4.error('Failed to match tag: "' + tag2 + '"'); + } + if (decodedTag.primitive || len !== null) + return buffer4.skip(len, 'Failed to match body of: "' + tag2 + '"'); + const state = buffer4.save(); + const res = this._skipUntilEnd(buffer4, 'Failed to skip indefinite length body: "' + this.tag + '"'); + if (buffer4.isError(res)) + return res; + len = buffer4.offset - state.offset; + buffer4.restore(state); + return buffer4.skip(len, 'Failed to match body of: "' + tag2 + '"'); + }; + DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer4, fail5) { + for (; ; ) { + const tag2 = derDecodeTag(buffer4, fail5); + if (buffer4.isError(tag2)) + return tag2; + const len = derDecodeLen(buffer4, tag2.primitive, fail5); + if (buffer4.isError(len)) + return len; + let res; + if (tag2.primitive || len !== null) + res = buffer4.skip(len); + else + res = this._skipUntilEnd(buffer4, fail5); + if (buffer4.isError(res)) + return res; + if (tag2.tagStr === "end") + break; + } + }; + DERNode.prototype._decodeList = function decodeList(buffer4, tag2, decoder4, options) { + const result = []; + while (!buffer4.isEmpty()) { + const possibleEnd = this._peekTag(buffer4, "end"); + if (buffer4.isError(possibleEnd)) + return possibleEnd; + const res = decoder4.decode(buffer4, "der", options); + if (buffer4.isError(res) && possibleEnd) + break; + result.push(res); + } + return result; + }; + DERNode.prototype._decodeStr = function decodeStr(buffer4, tag2) { + if (tag2 === "bitstr") { + const unused = buffer4.readUInt8(); + if (buffer4.isError(unused)) + return unused; + return { + unused, + data: buffer4.raw() + }; + } else if (tag2 === "bmpstr") { + const raw = buffer4.raw(); + if (raw.length % 2 === 1) + return buffer4.error("Decoding of string type: bmpstr length mismatch"); + let str = ""; + for (let i8 = 0; i8 < raw.length / 2; i8++) { + str += String.fromCharCode(raw.readUInt16BE(i8 * 2)); + } + return str; + } else if (tag2 === "numstr") { + const numstr = buffer4.raw().toString("ascii"); + if (!this._isNumstr(numstr)) { + return buffer4.error("Decoding of string type: numstr unsupported characters"); + } + return numstr; + } else if (tag2 === "octstr") { + return buffer4.raw(); + } else if (tag2 === "objDesc") { + return buffer4.raw(); + } else if (tag2 === "printstr") { + const printstr = buffer4.raw().toString("ascii"); + if (!this._isPrintstr(printstr)) { + return buffer4.error("Decoding of string type: printstr unsupported characters"); + } + return printstr; + } else if (/str$/.test(tag2)) { + return buffer4.raw().toString(); + } else { + return buffer4.error("Decoding of string type: " + tag2 + " unsupported"); + } + }; + DERNode.prototype._decodeObjid = function decodeObjid(buffer4, values2, relative2) { + let result; + const identifiers = []; + let ident = 0; + let subident = 0; + while (!buffer4.isEmpty()) { + subident = buffer4.readUInt8(); + ident <<= 7; + ident |= subident & 127; + if ((subident & 128) === 0) { + identifiers.push(ident); + ident = 0; + } + } + if (subident & 128) + identifiers.push(ident); + const first = identifiers[0] / 40 | 0; + const second = identifiers[0] % 40; + if (relative2) + result = identifiers; + else + result = [first, second].concat(identifiers.slice(1)); + if (values2) { + let tmp = values2[result.join(" ")]; + if (tmp === void 0) + tmp = values2[result.join(".")]; + if (tmp !== void 0) + result = tmp; + } + return result; + }; + DERNode.prototype._decodeTime = function decodeTime(buffer4, tag2) { + const str = buffer4.raw().toString(); + let year; + let mon; + let day; + let hour; + let min; + let sec; + if (tag2 === "gentime") { + year = str.slice(0, 4) | 0; + mon = str.slice(4, 6) | 0; + day = str.slice(6, 8) | 0; + hour = str.slice(8, 10) | 0; + min = str.slice(10, 12) | 0; + sec = str.slice(12, 14) | 0; + } else if (tag2 === "utctime") { + year = str.slice(0, 2) | 0; + mon = str.slice(2, 4) | 0; + day = str.slice(4, 6) | 0; + hour = str.slice(6, 8) | 0; + min = str.slice(8, 10) | 0; + sec = str.slice(10, 12) | 0; + if (year < 70) + year = 2e3 + year; + else + year = 1900 + year; + } else { + return buffer4.error("Decoding " + tag2 + " time is not supported yet"); + } + return Date.UTC(year, mon - 1, day, hour, min, sec, 0); + }; + DERNode.prototype._decodeNull = function decodeNull() { + return null; + }; + DERNode.prototype._decodeBool = function decodeBool(buffer4) { + const res = buffer4.readUInt8(); + if (buffer4.isError(res)) + return res; + else + return res !== 0; + }; + DERNode.prototype._decodeInt = function decodeInt(buffer4, values2) { + const raw = buffer4.raw(); + let res = new bignum(raw); + if (values2) + res = values2[res.toString(10)] || res; + return res; + }; + DERNode.prototype._use = function use(entity, obj) { + if (typeof entity === "function") + entity = entity(obj); + return entity._getDecoder("der").tree; + }; + function derDecodeTag(buf3, fail5) { + let tag2 = buf3.readUInt8(fail5); + if (buf3.isError(tag2)) + return tag2; + const cls = der.tagClass[tag2 >> 6]; + const primitive = (tag2 & 32) === 0; + if ((tag2 & 31) === 31) { + let oct = tag2; + tag2 = 0; + while ((oct & 128) === 128) { + oct = buf3.readUInt8(fail5); + if (buf3.isError(oct)) + return oct; + tag2 <<= 7; + tag2 |= oct & 127; + } + } else { + tag2 &= 31; + } + const tagStr = der.tag[tag2]; + return { + cls, + primitive, + tag: tag2, + tagStr + }; + } + function derDecodeLen(buf3, primitive, fail5) { + let len = buf3.readUInt8(fail5); + if (buf3.isError(len)) + return len; + if (!primitive && len === 128) + return null; + if ((len & 128) === 0) { + return len; + } + const num = len & 127; + if (num > 4) + return buf3.error("length octect is too long"); + len = 0; + for (let i8 = 0; i8 < num; i8++) { + len <<= 8; + const j5 = buf3.readUInt8(fail5); + if (buf3.isError(j5)) + return j5; + len |= j5; + } + return len; + } + return exports$o$1; + } + var exports$n$1 = {}; + var _dewExec$n$1 = false; + function dew$n$1() { + if (_dewExec$n$1) + return exports$n$1; + _dewExec$n$1 = true; + const inherits3 = dew$f$2(); + const Buffer2 = dew$w$1().Buffer; + const DERDecoder = dew$o$1(); + function PEMDecoder(entity) { + DERDecoder.call(this, entity); + this.enc = "pem"; + } + inherits3(PEMDecoder, DERDecoder); + exports$n$1 = PEMDecoder; + PEMDecoder.prototype.decode = function decode46(data, options) { + const lines = data.toString().split(/[\r\n]+/g); + const label = options.label.toUpperCase(); + const re3 = /^-----(BEGIN|END) ([^-]+)-----$/; + let start = -1; + let end = -1; + for (let i8 = 0; i8 < lines.length; i8++) { + const match10 = lines[i8].match(re3); + if (match10 === null) + continue; + if (match10[2] !== label) + continue; + if (start === -1) { + if (match10[1] !== "BEGIN") + break; + start = i8; + } else { + if (match10[1] !== "END") + break; + end = i8; + break; + } + } + if (start === -1 || end === -1) + throw new Error("PEM section not found for: " + label); + const base643 = lines.slice(start + 1, end).join(""); + base643.replace(/[^a-z0-9+/=]+/gi, ""); + const input = Buffer2.from(base643, "base64"); + return DERDecoder.prototype.decode.call(this, input, options); + }; + return exports$n$1; + } + var exports$m$1 = {}; + var _dewExec$m$1 = false; + function dew$m$1() { + if (_dewExec$m$1) + return exports$m$1; + _dewExec$m$1 = true; + const decoders = exports$m$1; + decoders.der = dew$o$1(); + decoders.pem = dew$n$1(); + return exports$m$1; + } + var exports$l$1 = {}; + var _dewExec$l$1 = false; + function dew$l$1() { + if (_dewExec$l$1) + return exports$l$1; + _dewExec$l$1 = true; + const encoders = dew$p$1(); + const decoders = dew$m$1(); + const inherits3 = dew$f$2(); + const api = exports$l$1; + api.define = function define2(name15, body) { + return new Entity(name15, body); + }; + function Entity(name15, body) { + this.name = name15; + this.body = body; + this.decoders = {}; + this.encoders = {}; + } + Entity.prototype._createNamed = function createNamed2(Base2) { + const name15 = this.name; + function Generated(entity) { + this._initNamed(entity, name15); + } + inherits3(Generated, Base2); + Generated.prototype._initNamed = function _initNamed(entity, name16) { + Base2.call(this, entity, name16); + }; + return new Generated(this); + }; + Entity.prototype._getDecoder = function _getDecoder(enc) { + enc = enc || "der"; + if (!this.decoders.hasOwnProperty(enc)) + this.decoders[enc] = this._createNamed(decoders[enc]); + return this.decoders[enc]; + }; + Entity.prototype.decode = function decode46(data, enc, options) { + return this._getDecoder(enc).decode(data, options); + }; + Entity.prototype._getEncoder = function _getEncoder(enc) { + enc = enc || "der"; + if (!this.encoders.hasOwnProperty(enc)) + this.encoders[enc] = this._createNamed(encoders[enc]); + return this.encoders[enc]; + }; + Entity.prototype.encode = function encode41(data, enc, reporter) { + return this._getEncoder(enc).encode(data, reporter); + }; + return exports$l$1; + } + var exports$k$1 = {}; + var _dewExec$k$1 = false; + function dew$k$1() { + if (_dewExec$k$1) + return exports$k$1; + _dewExec$k$1 = true; + const base3 = exports$k$1; + base3.Reporter = dew$v$1().Reporter; + base3.DecoderBuffer = dew$u$1().DecoderBuffer; + base3.EncoderBuffer = dew$u$1().EncoderBuffer; + base3.Node = dew$t$1(); + return exports$k$1; + } + var exports$j$1 = {}; + var _dewExec$j$1 = false; + function dew$j$1() { + if (_dewExec$j$1) + return exports$j$1; + _dewExec$j$1 = true; + const constants4 = exports$j$1; + constants4._reverse = function reverse(map2) { + const res = {}; + Object.keys(map2).forEach(function(key) { + if ((key | 0) == key) + key = key | 0; + const value = map2[key]; + res[value] = key; + }); + return res; + }; + constants4.der = dew$s$1(); + return exports$j$1; + } + var exports$i$1 = {}; + var _dewExec$i$1 = false; + function dew$i$1() { + if (_dewExec$i$1) + return exports$i$1; + _dewExec$i$1 = true; + const asn1 = exports$i$1; + asn1.bignum = dew$x$1(); + asn1.define = dew$l$1().define; + asn1.base = dew$k$1(); + asn1.constants = dew$j$1(); + asn1.decoders = dew$m$1(); + asn1.encoders = dew$p$1(); + return exports$i$1; + } + var exports$h$1 = {}; + var _dewExec$h$1 = false; + function dew$h$1() { + if (_dewExec$h$1) + return exports$h$1; + _dewExec$h$1 = true; + var asn = dew$i$1(); + var Time = asn.define("Time", function() { + this.choice({ + utcTime: this.utctime(), + generalTime: this.gentime() + }); + }); + var AttributeTypeValue = asn.define("AttributeTypeValue", function() { + this.seq().obj(this.key("type").objid(), this.key("value").any()); + }); + var AlgorithmIdentifier2 = asn.define("AlgorithmIdentifier", function() { + this.seq().obj(this.key("algorithm").objid(), this.key("parameters").optional(), this.key("curve").objid().optional()); + }); + var SubjectPublicKeyInfo = asn.define("SubjectPublicKeyInfo", function() { + this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier2), this.key("subjectPublicKey").bitstr()); + }); + var RelativeDistinguishedName = asn.define("RelativeDistinguishedName", function() { + this.setof(AttributeTypeValue); + }); + var RDNSequence = asn.define("RDNSequence", function() { + this.seqof(RelativeDistinguishedName); + }); + var Name = asn.define("Name", function() { + this.choice({ + rdnSequence: this.use(RDNSequence) + }); + }); + var Validity = asn.define("Validity", function() { + this.seq().obj(this.key("notBefore").use(Time), this.key("notAfter").use(Time)); + }); + var Extension = asn.define("Extension", function() { + this.seq().obj(this.key("extnID").objid(), this.key("critical").bool().def(false), this.key("extnValue").octstr()); + }); + var TBSCertificate = asn.define("TBSCertificate", function() { + this.seq().obj(this.key("version").explicit(0).int().optional(), this.key("serialNumber").int(), this.key("signature").use(AlgorithmIdentifier2), this.key("issuer").use(Name), this.key("validity").use(Validity), this.key("subject").use(Name), this.key("subjectPublicKeyInfo").use(SubjectPublicKeyInfo), this.key("issuerUniqueID").implicit(1).bitstr().optional(), this.key("subjectUniqueID").implicit(2).bitstr().optional(), this.key("extensions").explicit(3).seqof(Extension).optional()); + }); + var X509Certificate = asn.define("X509Certificate", function() { + this.seq().obj(this.key("tbsCertificate").use(TBSCertificate), this.key("signatureAlgorithm").use(AlgorithmIdentifier2), this.key("signatureValue").bitstr()); + }); + exports$h$1 = X509Certificate; + return exports$h$1; + } + var exports$g$1 = {}; + var _dewExec$g$1 = false; + function dew$g$1() { + if (_dewExec$g$1) + return exports$g$1; + _dewExec$g$1 = true; + var asn1 = dew$i$1(); + exports$g$1.certificate = dew$h$1(); + var RSAPrivateKey = asn1.define("RSAPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("modulus").int(), this.key("publicExponent").int(), this.key("privateExponent").int(), this.key("prime1").int(), this.key("prime2").int(), this.key("exponent1").int(), this.key("exponent2").int(), this.key("coefficient").int()); + }); + exports$g$1.RSAPrivateKey = RSAPrivateKey; + var RSAPublicKey = asn1.define("RSAPublicKey", function() { + this.seq().obj(this.key("modulus").int(), this.key("publicExponent").int()); + }); + exports$g$1.RSAPublicKey = RSAPublicKey; + var PublicKey = asn1.define("SubjectPublicKeyInfo", function() { + this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier2), this.key("subjectPublicKey").bitstr()); + }); + exports$g$1.PublicKey = PublicKey; + var AlgorithmIdentifier2 = asn1.define("AlgorithmIdentifier", function() { + this.seq().obj(this.key("algorithm").objid(), this.key("none").null_().optional(), this.key("curve").objid().optional(), this.key("params").seq().obj(this.key("p").int(), this.key("q").int(), this.key("g").int()).optional()); + }); + var PrivateKeyInfo2 = asn1.define("PrivateKeyInfo", function() { + this.seq().obj(this.key("version").int(), this.key("algorithm").use(AlgorithmIdentifier2), this.key("subjectPrivateKey").octstr()); + }); + exports$g$1.PrivateKey = PrivateKeyInfo2; + var EncryptedPrivateKeyInfo = asn1.define("EncryptedPrivateKeyInfo", function() { + this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(), this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(), this.key("kdeparams").seq().obj(this.key("salt").octstr(), this.key("iters").int())), this.key("cipher").seq().obj(this.key("algo").objid(), this.key("iv").octstr()))), this.key("subjectPrivateKey").octstr()); + }); + exports$g$1.EncryptedPrivateKey = EncryptedPrivateKeyInfo; + var DSAPrivateKey = asn1.define("DSAPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("p").int(), this.key("q").int(), this.key("g").int(), this.key("pub_key").int(), this.key("priv_key").int()); + }); + exports$g$1.DSAPrivateKey = DSAPrivateKey; + exports$g$1.DSAparam = asn1.define("DSAparam", function() { + this.int(); + }); + var ECPrivateKey = asn1.define("ECPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("privateKey").octstr(), this.key("parameters").optional().explicit(0).use(ECParameters), this.key("publicKey").optional().explicit(1).bitstr()); + }); + exports$g$1.ECPrivateKey = ECPrivateKey; + var ECParameters = asn1.define("ECParameters", function() { + this.choice({ + namedCurve: this.objid() + }); + }); + exports$g$1.signature = asn1.define("signature", function() { + this.seq().obj(this.key("r").int(), this.key("s").int()); + }); + return exports$g$1; + } + var _aesid$1 = { + "2.16.840.1.101.3.4.1.1": "aes-128-ecb", + "2.16.840.1.101.3.4.1.2": "aes-128-cbc", + "2.16.840.1.101.3.4.1.3": "aes-128-ofb", + "2.16.840.1.101.3.4.1.4": "aes-128-cfb", + "2.16.840.1.101.3.4.1.21": "aes-192-ecb", + "2.16.840.1.101.3.4.1.22": "aes-192-cbc", + "2.16.840.1.101.3.4.1.23": "aes-192-ofb", + "2.16.840.1.101.3.4.1.24": "aes-192-cfb", + "2.16.840.1.101.3.4.1.41": "aes-256-ecb", + "2.16.840.1.101.3.4.1.42": "aes-256-cbc", + "2.16.840.1.101.3.4.1.43": "aes-256-ofb", + "2.16.840.1.101.3.4.1.44": "aes-256-cfb" + }; + var exports$f$1 = {}; + var _dewExec$f$1 = false; + function dew$f$1() { + if (_dewExec$f$1) + return exports$f$1; + _dewExec$f$1 = true; + var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m; + var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m; + var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m; + var evp = dew$18(); + var ciphers = dew$15(); + var Buffer2 = dew$1T().Buffer; + exports$f$1 = function(okey, password) { + var key = okey.toString(); + var match10 = key.match(findProc); + var decrypted; + if (!match10) { + var match22 = key.match(fullRegex); + decrypted = Buffer2.from(match22[2].replace(/[\r\n]/g, ""), "base64"); + } else { + var suite = "aes" + match10[1]; + var iv = Buffer2.from(match10[2], "hex"); + var cipherText = Buffer2.from(match10[3].replace(/[\r\n]/g, ""), "base64"); + var cipherKey = evp(password, iv.slice(0, 8), parseInt(match10[1], 10)).key; + var out = []; + var cipher = ciphers.createDecipheriv(suite, cipherKey, iv); + out.push(cipher.update(cipherText)); + out.push(cipher.final()); + decrypted = Buffer2.concat(out); + } + var tag2 = key.match(startRegex)[1]; + return { + tag: tag2, + data: decrypted + }; + }; + return exports$f$1; + } + var exports$e$1 = {}; + var _dewExec$e$1 = false; + function dew$e$1() { + if (_dewExec$e$1) + return exports$e$1; + _dewExec$e$1 = true; + var asn1 = dew$g$1(); + var aesid = _aesid$1; + var fixProc = dew$f$1(); + var ciphers = dew$15(); + var compat = dew$1v(); + var Buffer2 = dew$1T().Buffer; + exports$e$1 = parseKeys; + function parseKeys(buffer4) { + var password; + if (typeof buffer4 === "object" && !Buffer2.isBuffer(buffer4)) { + password = buffer4.passphrase; + buffer4 = buffer4.key; + } + if (typeof buffer4 === "string") { + buffer4 = Buffer2.from(buffer4); + } + var stripped = fixProc(buffer4, password); + var type3 = stripped.tag; + var data = stripped.data; + var subtype, ndata; + switch (type3) { + case "CERTIFICATE": + ndata = asn1.certificate.decode(data, "der").tbsCertificate.subjectPublicKeyInfo; + case "PUBLIC KEY": + if (!ndata) { + ndata = asn1.PublicKey.decode(data, "der"); + } + subtype = ndata.algorithm.algorithm.join("."); + switch (subtype) { + case "1.2.840.113549.1.1.1": + return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, "der"); + case "1.2.840.10045.2.1": + ndata.subjectPrivateKey = ndata.subjectPublicKey; + return { + type: "ec", + data: ndata + }; + case "1.2.840.10040.4.1": + ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, "der"); + return { + type: "dsa", + data: ndata.algorithm.params + }; + default: + throw new Error("unknown key id " + subtype); + } + case "ENCRYPTED PRIVATE KEY": + data = asn1.EncryptedPrivateKey.decode(data, "der"); + data = decrypt3(data, password); + case "PRIVATE KEY": + ndata = asn1.PrivateKey.decode(data, "der"); + subtype = ndata.algorithm.algorithm.join("."); + switch (subtype) { + case "1.2.840.113549.1.1.1": + return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, "der"); + case "1.2.840.10045.2.1": + return { + curve: ndata.algorithm.curve, + privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, "der").privateKey + }; + case "1.2.840.10040.4.1": + ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, "der"); + return { + type: "dsa", + params: ndata.algorithm.params + }; + default: + throw new Error("unknown key id " + subtype); + } + case "RSA PUBLIC KEY": + return asn1.RSAPublicKey.decode(data, "der"); + case "RSA PRIVATE KEY": + return asn1.RSAPrivateKey.decode(data, "der"); + case "DSA PRIVATE KEY": + return { + type: "dsa", + params: asn1.DSAPrivateKey.decode(data, "der") + }; + case "EC PRIVATE KEY": + data = asn1.ECPrivateKey.decode(data, "der"); + return { + curve: data.parameters.value, + privateKey: data.privateKey + }; + default: + throw new Error("unknown key type " + type3); + } + } + parseKeys.signature = asn1.signature; + function decrypt3(data, password) { + var salt = data.algorithm.decrypt.kde.kdeparams.salt; + var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10); + var algo = aesid[data.algorithm.decrypt.cipher.algo.join(".")]; + var iv = data.algorithm.decrypt.cipher.iv; + var cipherText = data.subjectPrivateKey; + var keylen = parseInt(algo.split("-")[1], 10) / 8; + var key = compat.pbkdf2Sync(password, salt, iters, keylen, "sha1"); + var cipher = ciphers.createDecipheriv(algo, key, iv); + var out = []; + out.push(cipher.update(cipherText)); + out.push(cipher.final()); + return Buffer2.concat(out); + } + return exports$e$1; + } + var _curves$1 = { + "1.3.132.0.10": "secp256k1", + "1.3.132.0.33": "p224", + "1.2.840.10045.3.1.1": "p192", + "1.2.840.10045.3.1.7": "p256", + "1.3.132.0.34": "p384", + "1.3.132.0.35": "p521" + }; + var exports$d$1 = {}; + var _dewExec$d$1 = false; + function dew$d$1() { + if (_dewExec$d$1) + return exports$d$1; + _dewExec$d$1 = true; + var Buffer2 = dew$1T().Buffer; + var createHmac2 = dew$1C(); + var crt = dew$W$1(); + var EC = dew$y$1().ec; + var BN = dew$X$1(); + var parseKeys = dew$e$1(); + var curves = _curves$1; + function sign2(hash, key, hashType, signType, tag2) { + var priv = parseKeys(key); + if (priv.curve) { + if (signType !== "ecdsa" && signType !== "ecdsa/rsa") + throw new Error("wrong private key type"); + return ecSign(hash, priv); + } else if (priv.type === "dsa") { + if (signType !== "dsa") + throw new Error("wrong private key type"); + return dsaSign(hash, priv, hashType); + } else { + if (signType !== "rsa" && signType !== "ecdsa/rsa") + throw new Error("wrong private key type"); + } + hash = Buffer2.concat([tag2, hash]); + var len = priv.modulus.byteLength(); + var pad = [0, 1]; + while (hash.length + pad.length + 1 < len) + pad.push(255); + pad.push(0); + var i8 = -1; + while (++i8 < hash.length) + pad.push(hash[i8]); + var out = crt(pad, priv); + return out; + } + function ecSign(hash, priv) { + var curveId = curves[priv.curve.join(".")]; + if (!curveId) + throw new Error("unknown curve " + priv.curve.join(".")); + var curve = new EC(curveId); + var key = curve.keyFromPrivate(priv.privateKey); + var out = key.sign(hash); + return Buffer2.from(out.toDER()); + } + function dsaSign(hash, priv, algo) { + var x5 = priv.params.priv_key; + var p8 = priv.params.p; + var q4 = priv.params.q; + var g6 = priv.params.g; + var r10 = new BN(0); + var k5; + var H4 = bits2int(hash, q4).mod(q4); + var s7 = false; + var kv = getKey(x5, q4, hash, algo); + while (s7 === false) { + k5 = makeKey(q4, kv, algo); + r10 = makeR(g6, k5, p8, q4); + s7 = k5.invm(q4).imul(H4.add(x5.mul(r10))).mod(q4); + if (s7.cmpn(0) === 0) { + s7 = false; + r10 = new BN(0); + } + } + return toDER(r10, s7); + } + function toDER(r10, s7) { + r10 = r10.toArray(); + s7 = s7.toArray(); + if (r10[0] & 128) + r10 = [0].concat(r10); + if (s7[0] & 128) + s7 = [0].concat(s7); + var total = r10.length + s7.length + 4; + var res = [48, total, 2, r10.length]; + res = res.concat(r10, [2, s7.length], s7); + return Buffer2.from(res); + } + function getKey(x5, q4, hash, algo) { + x5 = Buffer2.from(x5.toArray()); + if (x5.length < q4.byteLength()) { + var zeros = Buffer2.alloc(q4.byteLength() - x5.length); + x5 = Buffer2.concat([zeros, x5]); + } + var hlen = hash.length; + var hbits = bits2octets(hash, q4); + var v7 = Buffer2.alloc(hlen); + v7.fill(1); + var k5 = Buffer2.alloc(hlen); + k5 = createHmac2(algo, k5).update(v7).update(Buffer2.from([0])).update(x5).update(hbits).digest(); + v7 = createHmac2(algo, k5).update(v7).digest(); + k5 = createHmac2(algo, k5).update(v7).update(Buffer2.from([1])).update(x5).update(hbits).digest(); + v7 = createHmac2(algo, k5).update(v7).digest(); + return { + k: k5, + v: v7 + }; + } + function bits2int(obits, q4) { + var bits = new BN(obits); + var shift = (obits.length << 3) - q4.bitLength(); + if (shift > 0) + bits.ishrn(shift); + return bits; + } + function bits2octets(bits, q4) { + bits = bits2int(bits, q4); + bits = bits.mod(q4); + var out = Buffer2.from(bits.toArray()); + if (out.length < q4.byteLength()) { + var zeros = Buffer2.alloc(q4.byteLength() - out.length); + out = Buffer2.concat([zeros, out]); + } + return out; + } + function makeKey(q4, kv, algo) { + var t9; + var k5; + do { + t9 = Buffer2.alloc(0); + while (t9.length * 8 < q4.bitLength()) { + kv.v = createHmac2(algo, kv.k).update(kv.v).digest(); + t9 = Buffer2.concat([t9, kv.v]); + } + k5 = bits2int(t9, q4); + kv.k = createHmac2(algo, kv.k).update(kv.v).update(Buffer2.from([0])).digest(); + kv.v = createHmac2(algo, kv.k).update(kv.v).digest(); + } while (k5.cmp(q4) !== -1); + return k5; + } + function makeR(g6, k5, p8, q4) { + return g6.toRed(BN.mont(p8)).redPow(k5).fromRed().mod(q4); + } + exports$d$1 = sign2; + exports$d$1.getKey = getKey; + exports$d$1.makeKey = makeKey; + return exports$d$1; + } + var exports$c$1 = {}; + var _dewExec$c$1 = false; + function dew$c$1() { + if (_dewExec$c$1) + return exports$c$1; + _dewExec$c$1 = true; + var Buffer2 = dew$1T().Buffer; + var BN = dew$X$1(); + var EC = dew$y$1().ec; + var parseKeys = dew$e$1(); + var curves = _curves$1; + function verify2(sig, hash, key, signType, tag2) { + var pub = parseKeys(key); + if (pub.type === "ec") { + if (signType !== "ecdsa" && signType !== "ecdsa/rsa") + throw new Error("wrong public key type"); + return ecVerify(sig, hash, pub); + } else if (pub.type === "dsa") { + if (signType !== "dsa") + throw new Error("wrong public key type"); + return dsaVerify(sig, hash, pub); + } else { + if (signType !== "rsa" && signType !== "ecdsa/rsa") + throw new Error("wrong public key type"); + } + hash = Buffer2.concat([tag2, hash]); + var len = pub.modulus.byteLength(); + var pad = [1]; + var padNum = 0; + while (hash.length + pad.length + 2 < len) { + pad.push(255); + padNum++; + } + pad.push(0); + var i8 = -1; + while (++i8 < hash.length) { + pad.push(hash[i8]); + } + pad = Buffer2.from(pad); + var red = BN.mont(pub.modulus); + sig = new BN(sig).toRed(red); + sig = sig.redPow(new BN(pub.publicExponent)); + sig = Buffer2.from(sig.fromRed().toArray()); + var out = padNum < 8 ? 1 : 0; + len = Math.min(sig.length, pad.length); + if (sig.length !== pad.length) + out = 1; + i8 = -1; + while (++i8 < len) + out |= sig[i8] ^ pad[i8]; + return out === 0; + } + function ecVerify(sig, hash, pub) { + var curveId = curves[pub.data.algorithm.curve.join(".")]; + if (!curveId) + throw new Error("unknown curve " + pub.data.algorithm.curve.join(".")); + var curve = new EC(curveId); + var pubkey = pub.data.subjectPrivateKey.data; + return curve.verify(hash, sig, pubkey); + } + function dsaVerify(sig, hash, pub) { + var p8 = pub.data.p; + var q4 = pub.data.q; + var g6 = pub.data.g; + var y7 = pub.data.pub_key; + var unpacked = parseKeys.signature.decode(sig, "der"); + var s7 = unpacked.s; + var r10 = unpacked.r; + checkValue(s7, q4); + checkValue(r10, q4); + var montp = BN.mont(p8); + var w5 = s7.invm(q4); + var v7 = g6.toRed(montp).redPow(new BN(hash).mul(w5).mod(q4)).fromRed().mul(y7.toRed(montp).redPow(r10.mul(w5).mod(q4)).fromRed()).mod(p8).mod(q4); + return v7.cmp(r10) === 0; + } + function checkValue(b6, q4) { + if (b6.cmpn(0) <= 0) + throw new Error("invalid sig"); + if (b6.cmp(q4) >= q4) + throw new Error("invalid sig"); + } + exports$c$1 = verify2; + return exports$c$1; + } + var exports$b$1 = {}; + var _dewExec$b$1 = false; + var _global$4$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$b$1() { + if (_dewExec$b$1) + return exports$b$1; + _dewExec$b$1 = true; + var Buffer2 = dew$1T().Buffer; + var createHash2 = dew$1F(); + var stream2 = dew$1V(); + var inherits3 = dew$f$2(); + var sign2 = dew$d$1(); + var verify2 = dew$c$1(); + var algorithms = _algorithms; + Object.keys(algorithms).forEach(function(key) { + algorithms[key].id = Buffer2.from(algorithms[key].id, "hex"); + algorithms[key.toLowerCase()] = algorithms[key]; + }); + function Sign2(algorithm2) { + stream2.Writable.call(this || _global$4$1); + var data = algorithms[algorithm2]; + if (!data) + throw new Error("Unknown message digest"); + (this || _global$4$1)._hashType = data.hash; + (this || _global$4$1)._hash = createHash2(data.hash); + (this || _global$4$1)._tag = data.id; + (this || _global$4$1)._signType = data.sign; + } + inherits3(Sign2, stream2.Writable); + Sign2.prototype._write = function _write(data, _5, done) { + (this || _global$4$1)._hash.update(data); + done(); + }; + Sign2.prototype.update = function update2(data, enc) { + if (typeof data === "string") + data = Buffer2.from(data, enc); + (this || _global$4$1)._hash.update(data); + return this || _global$4$1; + }; + Sign2.prototype.sign = function signMethod(key, enc) { + this.end(); + var hash = (this || _global$4$1)._hash.digest(); + var sig = sign2(hash, key, (this || _global$4$1)._hashType, (this || _global$4$1)._signType, (this || _global$4$1)._tag); + return enc ? sig.toString(enc) : sig; + }; + function Verify2(algorithm2) { + stream2.Writable.call(this || _global$4$1); + var data = algorithms[algorithm2]; + if (!data) + throw new Error("Unknown message digest"); + (this || _global$4$1)._hash = createHash2(data.hash); + (this || _global$4$1)._tag = data.id; + (this || _global$4$1)._signType = data.sign; + } + inherits3(Verify2, stream2.Writable); + Verify2.prototype._write = function _write(data, _5, done) { + (this || _global$4$1)._hash.update(data); + done(); + }; + Verify2.prototype.update = function update2(data, enc) { + if (typeof data === "string") + data = Buffer2.from(data, enc); + (this || _global$4$1)._hash.update(data); + return this || _global$4$1; + }; + Verify2.prototype.verify = function verifyMethod(key, sig, enc) { + if (typeof sig === "string") + sig = Buffer2.from(sig, enc); + this.end(); + var hash = (this || _global$4$1)._hash.digest(); + return verify2(sig, hash, key, (this || _global$4$1)._signType, (this || _global$4$1)._tag); + }; + function createSign2(algorithm2) { + return new Sign2(algorithm2); + } + function createVerify2(algorithm2) { + return new Verify2(algorithm2); + } + exports$b$1 = { + Sign: createSign2, + Verify: createVerify2, + createSign: createSign2, + createVerify: createVerify2 + }; + return exports$b$1; + } + var exports$a$1 = {}; + var _dewExec$a$1 = false; + var module$1$1 = { + exports: exports$a$1 + }; + var _global$3$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$a$1() { + if (_dewExec$a$1) + return module$1$1.exports; + _dewExec$a$1 = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$3$1).negative = 0; + (this || _global$3$1).words = null; + (this || _global$3$1).length = 0; + (this || _global$3$1).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = e$1$1.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$3$1).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$3$1).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$3$1).words = [number3 & 67108863]; + (this || _global$3$1).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$3$1).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$3$1).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$3$1).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$3$1).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$3$1).words = [0]; + (this || _global$3$1).length = 1; + return this || _global$3$1; + } + (this || _global$3$1).length = Math.ceil(number3.length / 3); + (this || _global$3$1).words = new Array((this || _global$3$1).length); + for (var i8 = 0; i8 < (this || _global$3$1).length; i8++) { + (this || _global$3$1).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$3$1).words[j5] |= w5 << off & 67108863; + (this || _global$3$1).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$3$1).words[j5] |= w5 << off & 67108863; + (this || _global$3$1).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$3$1).length = Math.ceil((number3.length - start) / 6); + (this || _global$3$1).words = new Array((this || _global$3$1).length); + for (var i8 = 0; i8 < (this || _global$3$1).length; i8++) { + (this || _global$3$1).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$3$1).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$3$1).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$3$1).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$3$1).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$3$1).words = [0]; + (this || _global$3$1).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$3$1).words[0] + word < 67108864) { + (this || _global$3$1).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$3$1).words[0] + word < 67108864) { + (this || _global$3$1).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$3$1).length); + for (var i8 = 0; i8 < (this || _global$3$1).length; i8++) { + dest.words[i8] = (this || _global$3$1).words[i8]; + } + dest.length = (this || _global$3$1).length; + dest.negative = (this || _global$3$1).negative; + dest.red = (this || _global$3$1).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$3$1).length < size4) { + (this || _global$3$1).words[(this || _global$3$1).length++] = 0; + } + return this || _global$3$1; + }; + BN.prototype.strip = function strip() { + while ((this || _global$3$1).length > 1 && (this || _global$3$1).words[(this || _global$3$1).length - 1] === 0) { + (this || _global$3$1).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$3$1).length === 1 && (this || _global$3$1).words[0] === 0) { + (this || _global$3$1).negative = 0; + } + return this || _global$3$1; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$3$1).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$3$1).length; i8++) { + var w5 = (this || _global$3$1).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$3$1).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$3$1).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$3$1).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$3$1).words[0]; + if ((this || _global$3$1).length === 2) { + ret += (this || _global$3$1).words[1] * 67108864; + } else if ((this || _global$3$1).length === 3 && (this || _global$3$1).words[2] === 1) { + ret += 4503599627370496 + (this || _global$3$1).words[1] * 67108864; + } else if ((this || _global$3$1).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$3$1).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$3$1).words[(this || _global$3$1).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$3$1).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$3$1).length; i8++) { + var b6 = this._zeroBits((this || _global$3$1).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$3$1).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$3$1).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$3$1).negative ^= 1; + } + return this || _global$3$1; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$3$1).length < num.length) { + (this || _global$3$1).words[(this || _global$3$1).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$3$1).words[i8] = (this || _global$3$1).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$3$1).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$3$1).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$3$1); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$3$1).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$3$1); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$3$1).length > num.length) { + b6 = num; + } else { + b6 = this || _global$3$1; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$3$1).words[i8] = (this || _global$3$1).words[i8] & num.words[i8]; + } + (this || _global$3$1).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$3$1).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$3$1).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$3$1); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$3$1).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$3$1); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$3$1).length > num.length) { + a8 = this || _global$3$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$3$1; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$3$1).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$3$1) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$3$1).words[i8] = a8.words[i8]; + } + } + (this || _global$3$1).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$3$1).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$3$1).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$3$1); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$3$1).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$3$1); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$3$1).words[i8] = ~(this || _global$3$1).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$3$1).words[i8] = ~(this || _global$3$1).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$3$1).words[off] = (this || _global$3$1).words[off] | 1 << wbit; + } else { + (this || _global$3$1).words[off] = (this || _global$3$1).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$3$1).negative !== 0 && num.negative === 0) { + (this || _global$3$1).negative = 0; + r10 = this.isub(num); + (this || _global$3$1).negative ^= 1; + return this._normSign(); + } else if ((this || _global$3$1).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$3$1).length > num.length) { + a8 = this || _global$3$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$3$1; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$3$1).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$3$1).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$3$1).length = a8.length; + if (carry !== 0) { + (this || _global$3$1).words[(this || _global$3$1).length] = carry; + (this || _global$3$1).length++; + } else if (a8 !== (this || _global$3$1)) { + for (; i8 < a8.length; i8++) { + (this || _global$3$1).words[i8] = a8.words[i8]; + } + } + return this || _global$3$1; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$3$1).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$3$1).negative !== 0) { + (this || _global$3$1).negative = 0; + res = num.sub(this || _global$3$1); + (this || _global$3$1).negative = 1; + return res; + } + if ((this || _global$3$1).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$3$1); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$3$1).negative !== 0) { + (this || _global$3$1).negative = 0; + this.iadd(num); + (this || _global$3$1).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$3$1).negative = 0; + (this || _global$3$1).length = 1; + (this || _global$3$1).words[0] = 0; + return this || _global$3$1; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$3$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$3$1; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$3$1).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$3$1).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$3$1)) { + for (; i8 < a8.length; i8++) { + (this || _global$3$1).words[i8] = a8.words[i8]; + } + } + (this || _global$3$1).length = Math.max((this || _global$3$1).length, i8); + if (a8 !== (this || _global$3$1)) { + (this || _global$3$1).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$3$1).length + num.length; + if ((this || _global$3$1).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$3$1, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$3$1, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$3$1, num, out); + } else { + res = jumboMulTo(this || _global$3$1, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$3$1).x = x5; + (this || _global$3$1).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$3$1).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$3$1).length + num.length); + return jumboMulTo(this || _global$3$1, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$3$1); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$3$1).length; i8++) { + var w5 = ((this || _global$3$1).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$3$1).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$3$1).words[i8] = carry; + (this || _global$3$1).length++; + } + return this || _global$3$1; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$3$1); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$3$1; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$3$1).length; i8++) { + var newCarry = (this || _global$3$1).words[i8] & carryMask; + var c8 = ((this || _global$3$1).words[i8] | 0) - newCarry << r10; + (this || _global$3$1).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$3$1).words[i8] = carry; + (this || _global$3$1).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$3$1).length - 1; i8 >= 0; i8--) { + (this || _global$3$1).words[i8 + s7] = (this || _global$3$1).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$3$1).words[i8] = 0; + } + (this || _global$3$1).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$3$1).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$3$1).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$3$1).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$3$1).length > s7) { + (this || _global$3$1).length -= s7; + for (i8 = 0; i8 < (this || _global$3$1).length; i8++) { + (this || _global$3$1).words[i8] = (this || _global$3$1).words[i8 + s7]; + } + } else { + (this || _global$3$1).words[0] = 0; + (this || _global$3$1).length = 1; + } + var carry = 0; + for (i8 = (this || _global$3$1).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$3$1).words[i8] | 0; + (this || _global$3$1).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$3$1).length === 0) { + (this || _global$3$1).words[0] = 0; + (this || _global$3$1).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$3$1).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$3$1).length <= s7) + return false; + var w5 = (this || _global$3$1).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$3$1).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$3$1).length <= s7) { + return this || _global$3$1; + } + if (r10 !== 0) { + s7++; + } + (this || _global$3$1).length = Math.min(s7, (this || _global$3$1).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$3$1).words[(this || _global$3$1).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$3$1).negative !== 0) { + if ((this || _global$3$1).length === 1 && ((this || _global$3$1).words[0] | 0) < num) { + (this || _global$3$1).words[0] = num - ((this || _global$3$1).words[0] | 0); + (this || _global$3$1).negative = 0; + return this || _global$3$1; + } + (this || _global$3$1).negative = 0; + this.isubn(num); + (this || _global$3$1).negative = 1; + return this || _global$3$1; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$3$1).words[0] += num; + for (var i8 = 0; i8 < (this || _global$3$1).length && (this || _global$3$1).words[i8] >= 67108864; i8++) { + (this || _global$3$1).words[i8] -= 67108864; + if (i8 === (this || _global$3$1).length - 1) { + (this || _global$3$1).words[i8 + 1] = 1; + } else { + (this || _global$3$1).words[i8 + 1]++; + } + } + (this || _global$3$1).length = Math.max((this || _global$3$1).length, i8 + 1); + return this || _global$3$1; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$3$1).negative !== 0) { + (this || _global$3$1).negative = 0; + this.iaddn(num); + (this || _global$3$1).negative = 1; + return this || _global$3$1; + } + (this || _global$3$1).words[0] -= num; + if ((this || _global$3$1).length === 1 && (this || _global$3$1).words[0] < 0) { + (this || _global$3$1).words[0] = -(this || _global$3$1).words[0]; + (this || _global$3$1).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$3$1).length && (this || _global$3$1).words[i8] < 0; i8++) { + (this || _global$3$1).words[i8] += 67108864; + (this || _global$3$1).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$3$1).negative = 0; + return this || _global$3$1; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$3$1).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$3$1).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$3$1).length - shift; i8++) { + w5 = ((this || _global$3$1).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$3$1).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$3$1).length; i8++) { + w5 = -((this || _global$3$1).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$3$1).words[i8] = w5 & 67108863; + } + (this || _global$3$1).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$3$1).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$3$1).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$3$1).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$3$1).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$3$1).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$3$1 + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$3$1).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$3$1).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$3$1).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$3$1).words[i8] | 0) + carry * 67108864; + (this || _global$3$1).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$3$1; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$3$1; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$3$1).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$3$1).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$3$1).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$3$1).length <= s7) { + this._expand(s7 + 1); + (this || _global$3$1).words[s7] |= q4; + return this || _global$3$1; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$3$1).length; i8++) { + var w5 = (this || _global$3$1).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$3$1).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$3$1).words[i8] = carry; + (this || _global$3$1).length++; + } + return this || _global$3$1; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$3$1).length === 1 && (this || _global$3$1).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$3$1).negative !== 0 && !negative) + return -1; + if ((this || _global$3$1).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$3$1).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$3$1).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$3$1).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$3$1).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$3$1).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$3$1).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$3$1).length > num.length) + return 1; + if ((this || _global$3$1).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$3$1).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$3$1).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$3$1).red, "Already a number in reduction context"); + assert((this || _global$3$1).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$3$1)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$3$1).red, "fromRed works only with numbers in reduction context"); + return (this || _global$3$1).red.convertFrom(this || _global$3$1); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$3$1).red = ctx; + return this || _global$3$1; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$3$1).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$3$1).red, "redAdd works only with red numbers"); + return (this || _global$3$1).red.add(this || _global$3$1, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$3$1).red, "redIAdd works only with red numbers"); + return (this || _global$3$1).red.iadd(this || _global$3$1, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$3$1).red, "redSub works only with red numbers"); + return (this || _global$3$1).red.sub(this || _global$3$1, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$3$1).red, "redISub works only with red numbers"); + return (this || _global$3$1).red.isub(this || _global$3$1, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$3$1).red, "redShl works only with red numbers"); + return (this || _global$3$1).red.shl(this || _global$3$1, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$3$1).red, "redMul works only with red numbers"); + (this || _global$3$1).red._verify2(this || _global$3$1, num); + return (this || _global$3$1).red.mul(this || _global$3$1, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$3$1).red, "redMul works only with red numbers"); + (this || _global$3$1).red._verify2(this || _global$3$1, num); + return (this || _global$3$1).red.imul(this || _global$3$1, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$3$1).red, "redSqr works only with red numbers"); + (this || _global$3$1).red._verify1(this || _global$3$1); + return (this || _global$3$1).red.sqr(this || _global$3$1); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$3$1).red, "redISqr works only with red numbers"); + (this || _global$3$1).red._verify1(this || _global$3$1); + return (this || _global$3$1).red.isqr(this || _global$3$1); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$3$1).red, "redSqrt works only with red numbers"); + (this || _global$3$1).red._verify1(this || _global$3$1); + return (this || _global$3$1).red.sqrt(this || _global$3$1); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$3$1).red, "redInvm works only with red numbers"); + (this || _global$3$1).red._verify1(this || _global$3$1); + return (this || _global$3$1).red.invm(this || _global$3$1); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$3$1).red, "redNeg works only with red numbers"); + (this || _global$3$1).red._verify1(this || _global$3$1); + return (this || _global$3$1).red.neg(this || _global$3$1); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$3$1).red && !num.red, "redPow(normalNum)"); + (this || _global$3$1).red._verify1(this || _global$3$1); + return (this || _global$3$1).red.pow(this || _global$3$1, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$3$1).name = name15; + (this || _global$3$1).p = new BN(p8, 16); + (this || _global$3$1).n = (this || _global$3$1).p.bitLength(); + (this || _global$3$1).k = new BN(1).iushln((this || _global$3$1).n).isub((this || _global$3$1).p); + (this || _global$3$1).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$3$1).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$3$1).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$3$1).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$3$1).n); + var cmp = rlen < (this || _global$3$1).n ? -1 : r10.ucmp((this || _global$3$1).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$3$1).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$3$1).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$3$1).k); + }; + function K256() { + MPrime.call(this || _global$3$1, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$3$1, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$3$1, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$3$1, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$3$1).m = prime.p; + (this || _global$3$1).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$3$1).m = m7; + (this || _global$3$1).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$3$1).prime) + return (this || _global$3$1).prime.ireduce(a8)._forceRed(this || _global$3$1); + return a8.umod((this || _global$3$1).m)._forceRed(this || _global$3$1); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$3$1).m.sub(a8)._forceRed(this || _global$3$1); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$3$1).m) >= 0) { + res.isub((this || _global$3$1).m); + } + return res._forceRed(this || _global$3$1); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$3$1).m) >= 0) { + res.isub((this || _global$3$1).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$3$1).m); + } + return res._forceRed(this || _global$3$1); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$3$1).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$3$1).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$3$1).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$3$1).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$3$1); + var nOne = one.redNeg(); + var lpow = (this || _global$3$1).m.subn(1).iushrn(1); + var z6 = (this || _global$3$1).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$3$1); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$3$1).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$3$1); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$3$1); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$3$1).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$3$1, m7); + (this || _global$3$1).shift = (this || _global$3$1).m.bitLength(); + if ((this || _global$3$1).shift % 26 !== 0) { + (this || _global$3$1).shift += 26 - (this || _global$3$1).shift % 26; + } + (this || _global$3$1).r = new BN(1).iushln((this || _global$3$1).shift); + (this || _global$3$1).r2 = this.imod((this || _global$3$1).r.sqr()); + (this || _global$3$1).rinv = (this || _global$3$1).r._invmp((this || _global$3$1).m); + (this || _global$3$1).minv = (this || _global$3$1).rinv.mul((this || _global$3$1).r).isubn(1).div((this || _global$3$1).m); + (this || _global$3$1).minv = (this || _global$3$1).minv.umod((this || _global$3$1).r); + (this || _global$3$1).minv = (this || _global$3$1).r.sub((this || _global$3$1).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$3$1).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$3$1).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$3$1).shift).mul((this || _global$3$1).minv).imaskn((this || _global$3$1).shift).mul((this || _global$3$1).m); + var u8 = t9.isub(c8).iushrn((this || _global$3$1).shift); + var res = u8; + if (u8.cmp((this || _global$3$1).m) >= 0) { + res = u8.isub((this || _global$3$1).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$3$1).m); + } + return res._forceRed(this || _global$3$1); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$3$1); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$3$1).shift).mul((this || _global$3$1).minv).imaskn((this || _global$3$1).shift).mul((this || _global$3$1).m); + var u8 = t9.isub(c8).iushrn((this || _global$3$1).shift); + var res = u8; + if (u8.cmp((this || _global$3$1).m) >= 0) { + res = u8.isub((this || _global$3$1).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$3$1).m); + } + return res._forceRed(this || _global$3$1); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$3$1).m).mul((this || _global$3$1).r2)); + return res._forceRed(this || _global$3$1); + }; + })(module$1$1, exports$a$1); + return module$1$1.exports; + } + var exports$9$1 = {}; + var _dewExec$9$1 = false; + var _global$2$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$9$1() { + if (_dewExec$9$1) + return exports$9$1; + _dewExec$9$1 = true; + var Buffer2 = e$1$1.Buffer; + var elliptic = dew$y$1(); + var BN = dew$a$1(); + exports$9$1 = function createECDH2(curve) { + return new ECDH(curve); + }; + var aliases = { + secp256k1: { + name: "secp256k1", + byteLength: 32 + }, + secp224r1: { + name: "p224", + byteLength: 28 + }, + prime256v1: { + name: "p256", + byteLength: 32 + }, + prime192v1: { + name: "p192", + byteLength: 24 + }, + ed25519: { + name: "ed25519", + byteLength: 32 + }, + secp384r1: { + name: "p384", + byteLength: 48 + }, + secp521r1: { + name: "p521", + byteLength: 66 + } + }; + aliases.p224 = aliases.secp224r1; + aliases.p256 = aliases.secp256r1 = aliases.prime256v1; + aliases.p192 = aliases.secp192r1 = aliases.prime192v1; + aliases.p384 = aliases.secp384r1; + aliases.p521 = aliases.secp521r1; + function ECDH(curve) { + (this || _global$2$1).curveType = aliases[curve]; + if (!(this || _global$2$1).curveType) { + (this || _global$2$1).curveType = { + name: curve + }; + } + (this || _global$2$1).curve = new elliptic.ec((this || _global$2$1).curveType.name); + (this || _global$2$1).keys = void 0; + } + ECDH.prototype.generateKeys = function(enc, format16) { + (this || _global$2$1).keys = (this || _global$2$1).curve.genKeyPair(); + return this.getPublicKey(enc, format16); + }; + ECDH.prototype.computeSecret = function(other, inenc, enc) { + inenc = inenc || "utf8"; + if (!Buffer2.isBuffer(other)) { + other = new Buffer2(other, inenc); + } + var otherPub = (this || _global$2$1).curve.keyFromPublic(other).getPublic(); + var out = otherPub.mul((this || _global$2$1).keys.getPrivate()).getX(); + return formatReturnValue(out, enc, (this || _global$2$1).curveType.byteLength); + }; + ECDH.prototype.getPublicKey = function(enc, format16) { + var key = (this || _global$2$1).keys.getPublic(format16 === "compressed", true); + if (format16 === "hybrid") { + if (key[key.length - 1] % 2) { + key[0] = 7; + } else { + key[0] = 6; + } + } + return formatReturnValue(key, enc); + }; + ECDH.prototype.getPrivateKey = function(enc) { + return formatReturnValue((this || _global$2$1).keys.getPrivate(), enc); + }; + ECDH.prototype.setPublicKey = function(pub, enc) { + enc = enc || "utf8"; + if (!Buffer2.isBuffer(pub)) { + pub = new Buffer2(pub, enc); + } + (this || _global$2$1).keys._importPublic(pub); + return this || _global$2$1; + }; + ECDH.prototype.setPrivateKey = function(priv, enc) { + enc = enc || "utf8"; + if (!Buffer2.isBuffer(priv)) { + priv = new Buffer2(priv, enc); + } + var _priv = new BN(priv); + _priv = _priv.toString(16); + (this || _global$2$1).keys = (this || _global$2$1).curve.genKeyPair(); + (this || _global$2$1).keys._importPrivate(_priv); + return this || _global$2$1; + }; + function formatReturnValue(bn, enc, len) { + if (!Array.isArray(bn)) { + bn = bn.toArray(); + } + var buf3 = new Buffer2(bn); + if (len && buf3.length < len) { + var zeros = new Buffer2(len - buf3.length); + zeros.fill(0); + buf3 = Buffer2.concat([zeros, buf3]); + } + if (!enc) { + return buf3; + } else { + return buf3.toString(enc); + } + } + return exports$9$1; + } + var exports$8$1 = {}; + var _dewExec$8$1 = false; + function dew$8$1() { + if (_dewExec$8$1) + return exports$8$1; + _dewExec$8$1 = true; + var createHash2 = dew$1F(); + var Buffer2 = dew$1T().Buffer; + exports$8$1 = function(seed, len) { + var t9 = Buffer2.alloc(0); + var i8 = 0; + var c8; + while (t9.length < len) { + c8 = i2ops(i8++); + t9 = Buffer2.concat([t9, createHash2("sha1").update(seed).update(c8).digest()]); + } + return t9.slice(0, len); + }; + function i2ops(c8) { + var out = Buffer2.allocUnsafe(4); + out.writeUInt32BE(c8, 0); + return out; + } + return exports$8$1; + } + var exports$7$1 = {}; + var _dewExec$7$1 = false; + function dew$7$1() { + if (_dewExec$7$1) + return exports$7$1; + _dewExec$7$1 = true; + exports$7$1 = function xor3(a8, b6) { + var len = a8.length; + var i8 = -1; + while (++i8 < len) { + a8[i8] ^= b6[i8]; + } + return a8; + }; + return exports$7$1; + } + var exports$6$1 = {}; + var _dewExec$6$1 = false; + var module$8 = { + exports: exports$6$1 + }; + var _global$1$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$6$1() { + if (_dewExec$6$1) + return module$8.exports; + _dewExec$6$1 = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$1$1).negative = 0; + (this || _global$1$1).words = null; + (this || _global$1$1).length = 0; + (this || _global$1$1).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = e$1$1.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$1$1).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$1$1).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$1$1).words = [number3 & 67108863]; + (this || _global$1$1).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$1$1).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$1$1).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$1$1).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$1$1).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$1$1).words = [0]; + (this || _global$1$1).length = 1; + return this || _global$1$1; + } + (this || _global$1$1).length = Math.ceil(number3.length / 3); + (this || _global$1$1).words = new Array((this || _global$1$1).length); + for (var i8 = 0; i8 < (this || _global$1$1).length; i8++) { + (this || _global$1$1).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$1$1).words[j5] |= w5 << off & 67108863; + (this || _global$1$1).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$1$1).words[j5] |= w5 << off & 67108863; + (this || _global$1$1).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$1$1).length = Math.ceil((number3.length - start) / 6); + (this || _global$1$1).words = new Array((this || _global$1$1).length); + for (var i8 = 0; i8 < (this || _global$1$1).length; i8++) { + (this || _global$1$1).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$1$1).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$1$1).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$1$1).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$1$1).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$1$1).words = [0]; + (this || _global$1$1).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$1$1).words[0] + word < 67108864) { + (this || _global$1$1).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$1$1).words[0] + word < 67108864) { + (this || _global$1$1).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$1$1).length); + for (var i8 = 0; i8 < (this || _global$1$1).length; i8++) { + dest.words[i8] = (this || _global$1$1).words[i8]; + } + dest.length = (this || _global$1$1).length; + dest.negative = (this || _global$1$1).negative; + dest.red = (this || _global$1$1).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$1$1).length < size4) { + (this || _global$1$1).words[(this || _global$1$1).length++] = 0; + } + return this || _global$1$1; + }; + BN.prototype.strip = function strip() { + while ((this || _global$1$1).length > 1 && (this || _global$1$1).words[(this || _global$1$1).length - 1] === 0) { + (this || _global$1$1).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$1$1).length === 1 && (this || _global$1$1).words[0] === 0) { + (this || _global$1$1).negative = 0; + } + return this || _global$1$1; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$1$1).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$1$1).length; i8++) { + var w5 = (this || _global$1$1).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$1$1).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$1$1).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$1$1).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$1$1).words[0]; + if ((this || _global$1$1).length === 2) { + ret += (this || _global$1$1).words[1] * 67108864; + } else if ((this || _global$1$1).length === 3 && (this || _global$1$1).words[2] === 1) { + ret += 4503599627370496 + (this || _global$1$1).words[1] * 67108864; + } else if ((this || _global$1$1).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$1$1).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$1$1).words[(this || _global$1$1).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$1$1).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$1$1).length; i8++) { + var b6 = this._zeroBits((this || _global$1$1).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$1$1).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$1$1).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$1$1).negative ^= 1; + } + return this || _global$1$1; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$1$1).length < num.length) { + (this || _global$1$1).words[(this || _global$1$1).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$1$1).words[i8] = (this || _global$1$1).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$1$1).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$1$1).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$1$1); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$1$1).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$1$1); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$1$1).length > num.length) { + b6 = num; + } else { + b6 = this || _global$1$1; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$1$1).words[i8] = (this || _global$1$1).words[i8] & num.words[i8]; + } + (this || _global$1$1).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$1$1).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$1$1).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$1$1); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$1$1).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$1$1); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$1$1).length > num.length) { + a8 = this || _global$1$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$1$1; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$1$1).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$1$1) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$1$1).words[i8] = a8.words[i8]; + } + } + (this || _global$1$1).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$1$1).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$1$1).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$1$1); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$1$1).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$1$1); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$1$1).words[i8] = ~(this || _global$1$1).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$1$1).words[i8] = ~(this || _global$1$1).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$1$1).words[off] = (this || _global$1$1).words[off] | 1 << wbit; + } else { + (this || _global$1$1).words[off] = (this || _global$1$1).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$1$1).negative !== 0 && num.negative === 0) { + (this || _global$1$1).negative = 0; + r10 = this.isub(num); + (this || _global$1$1).negative ^= 1; + return this._normSign(); + } else if ((this || _global$1$1).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$1$1).length > num.length) { + a8 = this || _global$1$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$1$1; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$1$1).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$1$1).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$1$1).length = a8.length; + if (carry !== 0) { + (this || _global$1$1).words[(this || _global$1$1).length] = carry; + (this || _global$1$1).length++; + } else if (a8 !== (this || _global$1$1)) { + for (; i8 < a8.length; i8++) { + (this || _global$1$1).words[i8] = a8.words[i8]; + } + } + return this || _global$1$1; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$1$1).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$1$1).negative !== 0) { + (this || _global$1$1).negative = 0; + res = num.sub(this || _global$1$1); + (this || _global$1$1).negative = 1; + return res; + } + if ((this || _global$1$1).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$1$1); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$1$1).negative !== 0) { + (this || _global$1$1).negative = 0; + this.iadd(num); + (this || _global$1$1).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$1$1).negative = 0; + (this || _global$1$1).length = 1; + (this || _global$1$1).words[0] = 0; + return this || _global$1$1; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$1$1; + b6 = num; + } else { + a8 = num; + b6 = this || _global$1$1; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$1$1).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$1$1).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$1$1)) { + for (; i8 < a8.length; i8++) { + (this || _global$1$1).words[i8] = a8.words[i8]; + } + } + (this || _global$1$1).length = Math.max((this || _global$1$1).length, i8); + if (a8 !== (this || _global$1$1)) { + (this || _global$1$1).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$1$1).length + num.length; + if ((this || _global$1$1).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$1$1, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$1$1, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$1$1, num, out); + } else { + res = jumboMulTo(this || _global$1$1, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$1$1).x = x5; + (this || _global$1$1).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$1$1).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$1$1).length + num.length); + return jumboMulTo(this || _global$1$1, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$1$1); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$1$1).length; i8++) { + var w5 = ((this || _global$1$1).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$1$1).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$1$1).words[i8] = carry; + (this || _global$1$1).length++; + } + return this || _global$1$1; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$1$1); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$1$1; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$1$1).length; i8++) { + var newCarry = (this || _global$1$1).words[i8] & carryMask; + var c8 = ((this || _global$1$1).words[i8] | 0) - newCarry << r10; + (this || _global$1$1).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$1$1).words[i8] = carry; + (this || _global$1$1).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$1$1).length - 1; i8 >= 0; i8--) { + (this || _global$1$1).words[i8 + s7] = (this || _global$1$1).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$1$1).words[i8] = 0; + } + (this || _global$1$1).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$1$1).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$1$1).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$1$1).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$1$1).length > s7) { + (this || _global$1$1).length -= s7; + for (i8 = 0; i8 < (this || _global$1$1).length; i8++) { + (this || _global$1$1).words[i8] = (this || _global$1$1).words[i8 + s7]; + } + } else { + (this || _global$1$1).words[0] = 0; + (this || _global$1$1).length = 1; + } + var carry = 0; + for (i8 = (this || _global$1$1).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$1$1).words[i8] | 0; + (this || _global$1$1).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$1$1).length === 0) { + (this || _global$1$1).words[0] = 0; + (this || _global$1$1).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$1$1).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$1$1).length <= s7) + return false; + var w5 = (this || _global$1$1).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$1$1).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$1$1).length <= s7) { + return this || _global$1$1; + } + if (r10 !== 0) { + s7++; + } + (this || _global$1$1).length = Math.min(s7, (this || _global$1$1).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$1$1).words[(this || _global$1$1).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$1$1).negative !== 0) { + if ((this || _global$1$1).length === 1 && ((this || _global$1$1).words[0] | 0) < num) { + (this || _global$1$1).words[0] = num - ((this || _global$1$1).words[0] | 0); + (this || _global$1$1).negative = 0; + return this || _global$1$1; + } + (this || _global$1$1).negative = 0; + this.isubn(num); + (this || _global$1$1).negative = 1; + return this || _global$1$1; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$1$1).words[0] += num; + for (var i8 = 0; i8 < (this || _global$1$1).length && (this || _global$1$1).words[i8] >= 67108864; i8++) { + (this || _global$1$1).words[i8] -= 67108864; + if (i8 === (this || _global$1$1).length - 1) { + (this || _global$1$1).words[i8 + 1] = 1; + } else { + (this || _global$1$1).words[i8 + 1]++; + } + } + (this || _global$1$1).length = Math.max((this || _global$1$1).length, i8 + 1); + return this || _global$1$1; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$1$1).negative !== 0) { + (this || _global$1$1).negative = 0; + this.iaddn(num); + (this || _global$1$1).negative = 1; + return this || _global$1$1; + } + (this || _global$1$1).words[0] -= num; + if ((this || _global$1$1).length === 1 && (this || _global$1$1).words[0] < 0) { + (this || _global$1$1).words[0] = -(this || _global$1$1).words[0]; + (this || _global$1$1).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$1$1).length && (this || _global$1$1).words[i8] < 0; i8++) { + (this || _global$1$1).words[i8] += 67108864; + (this || _global$1$1).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$1$1).negative = 0; + return this || _global$1$1; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$1$1).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$1$1).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$1$1).length - shift; i8++) { + w5 = ((this || _global$1$1).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$1$1).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$1$1).length; i8++) { + w5 = -((this || _global$1$1).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$1$1).words[i8] = w5 & 67108863; + } + (this || _global$1$1).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$1$1).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$1$1).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$1$1).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$1$1).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$1$1).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$1$1 + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$1$1).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$1$1).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$1$1).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$1$1).words[i8] | 0) + carry * 67108864; + (this || _global$1$1).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$1$1; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$1$1; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$1$1).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$1$1).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$1$1).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$1$1).length <= s7) { + this._expand(s7 + 1); + (this || _global$1$1).words[s7] |= q4; + return this || _global$1$1; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$1$1).length; i8++) { + var w5 = (this || _global$1$1).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$1$1).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$1$1).words[i8] = carry; + (this || _global$1$1).length++; + } + return this || _global$1$1; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$1$1).length === 1 && (this || _global$1$1).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$1$1).negative !== 0 && !negative) + return -1; + if ((this || _global$1$1).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$1$1).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$1$1).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$1$1).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$1$1).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$1$1).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$1$1).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$1$1).length > num.length) + return 1; + if ((this || _global$1$1).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$1$1).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$1$1).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$1$1).red, "Already a number in reduction context"); + assert((this || _global$1$1).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$1$1)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$1$1).red, "fromRed works only with numbers in reduction context"); + return (this || _global$1$1).red.convertFrom(this || _global$1$1); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$1$1).red = ctx; + return this || _global$1$1; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$1$1).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$1$1).red, "redAdd works only with red numbers"); + return (this || _global$1$1).red.add(this || _global$1$1, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$1$1).red, "redIAdd works only with red numbers"); + return (this || _global$1$1).red.iadd(this || _global$1$1, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$1$1).red, "redSub works only with red numbers"); + return (this || _global$1$1).red.sub(this || _global$1$1, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$1$1).red, "redISub works only with red numbers"); + return (this || _global$1$1).red.isub(this || _global$1$1, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$1$1).red, "redShl works only with red numbers"); + return (this || _global$1$1).red.shl(this || _global$1$1, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$1$1).red, "redMul works only with red numbers"); + (this || _global$1$1).red._verify2(this || _global$1$1, num); + return (this || _global$1$1).red.mul(this || _global$1$1, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$1$1).red, "redMul works only with red numbers"); + (this || _global$1$1).red._verify2(this || _global$1$1, num); + return (this || _global$1$1).red.imul(this || _global$1$1, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$1$1).red, "redSqr works only with red numbers"); + (this || _global$1$1).red._verify1(this || _global$1$1); + return (this || _global$1$1).red.sqr(this || _global$1$1); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$1$1).red, "redISqr works only with red numbers"); + (this || _global$1$1).red._verify1(this || _global$1$1); + return (this || _global$1$1).red.isqr(this || _global$1$1); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$1$1).red, "redSqrt works only with red numbers"); + (this || _global$1$1).red._verify1(this || _global$1$1); + return (this || _global$1$1).red.sqrt(this || _global$1$1); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$1$1).red, "redInvm works only with red numbers"); + (this || _global$1$1).red._verify1(this || _global$1$1); + return (this || _global$1$1).red.invm(this || _global$1$1); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$1$1).red, "redNeg works only with red numbers"); + (this || _global$1$1).red._verify1(this || _global$1$1); + return (this || _global$1$1).red.neg(this || _global$1$1); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$1$1).red && !num.red, "redPow(normalNum)"); + (this || _global$1$1).red._verify1(this || _global$1$1); + return (this || _global$1$1).red.pow(this || _global$1$1, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$1$1).name = name15; + (this || _global$1$1).p = new BN(p8, 16); + (this || _global$1$1).n = (this || _global$1$1).p.bitLength(); + (this || _global$1$1).k = new BN(1).iushln((this || _global$1$1).n).isub((this || _global$1$1).p); + (this || _global$1$1).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$1$1).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$1$1).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$1$1).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$1$1).n); + var cmp = rlen < (this || _global$1$1).n ? -1 : r10.ucmp((this || _global$1$1).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$1$1).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$1$1).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$1$1).k); + }; + function K256() { + MPrime.call(this || _global$1$1, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$1$1, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$1$1, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$1$1, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$1$1).m = prime.p; + (this || _global$1$1).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$1$1).m = m7; + (this || _global$1$1).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$1$1).prime) + return (this || _global$1$1).prime.ireduce(a8)._forceRed(this || _global$1$1); + return a8.umod((this || _global$1$1).m)._forceRed(this || _global$1$1); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$1$1).m.sub(a8)._forceRed(this || _global$1$1); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$1$1).m) >= 0) { + res.isub((this || _global$1$1).m); + } + return res._forceRed(this || _global$1$1); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$1$1).m) >= 0) { + res.isub((this || _global$1$1).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$1$1).m); + } + return res._forceRed(this || _global$1$1); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$1$1).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$1$1).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$1$1).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$1$1).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$1$1); + var nOne = one.redNeg(); + var lpow = (this || _global$1$1).m.subn(1).iushrn(1); + var z6 = (this || _global$1$1).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$1$1); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$1$1).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$1$1); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$1$1); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$1$1).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$1$1, m7); + (this || _global$1$1).shift = (this || _global$1$1).m.bitLength(); + if ((this || _global$1$1).shift % 26 !== 0) { + (this || _global$1$1).shift += 26 - (this || _global$1$1).shift % 26; + } + (this || _global$1$1).r = new BN(1).iushln((this || _global$1$1).shift); + (this || _global$1$1).r2 = this.imod((this || _global$1$1).r.sqr()); + (this || _global$1$1).rinv = (this || _global$1$1).r._invmp((this || _global$1$1).m); + (this || _global$1$1).minv = (this || _global$1$1).rinv.mul((this || _global$1$1).r).isubn(1).div((this || _global$1$1).m); + (this || _global$1$1).minv = (this || _global$1$1).minv.umod((this || _global$1$1).r); + (this || _global$1$1).minv = (this || _global$1$1).r.sub((this || _global$1$1).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$1$1).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$1$1).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$1$1).shift).mul((this || _global$1$1).minv).imaskn((this || _global$1$1).shift).mul((this || _global$1$1).m); + var u8 = t9.isub(c8).iushrn((this || _global$1$1).shift); + var res = u8; + if (u8.cmp((this || _global$1$1).m) >= 0) { + res = u8.isub((this || _global$1$1).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$1$1).m); + } + return res._forceRed(this || _global$1$1); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$1$1); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$1$1).shift).mul((this || _global$1$1).minv).imaskn((this || _global$1$1).shift).mul((this || _global$1$1).m); + var u8 = t9.isub(c8).iushrn((this || _global$1$1).shift); + var res = u8; + if (u8.cmp((this || _global$1$1).m) >= 0) { + res = u8.isub((this || _global$1$1).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$1$1).m); + } + return res._forceRed(this || _global$1$1); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$1$1).m).mul((this || _global$1$1).r2)); + return res._forceRed(this || _global$1$1); + }; + })(module$8, exports$6$1); + return module$8.exports; + } + var exports$5$1 = {}; + var _dewExec$5$1 = false; + function dew$5$1() { + if (_dewExec$5$1) + return exports$5$1; + _dewExec$5$1 = true; + var BN = dew$6$1(); + var Buffer2 = dew$1T().Buffer; + function withPublic(paddedMsg, key) { + return Buffer2.from(paddedMsg.toRed(BN.mont(key.modulus)).redPow(new BN(key.publicExponent)).fromRed().toArray()); + } + exports$5$1 = withPublic; + return exports$5$1; + } + var exports$4$1 = {}; + var _dewExec$4$1 = false; + function dew$4$1() { + if (_dewExec$4$1) + return exports$4$1; + _dewExec$4$1 = true; + var parseKeys = dew$e$1(); + var randomBytes3 = dew$1S(); + var createHash2 = dew$1F(); + var mgf = dew$8$1(); + var xor3 = dew$7$1(); + var BN = dew$6$1(); + var withPublic = dew$5$1(); + var crt = dew$W$1(); + var Buffer2 = dew$1T().Buffer; + exports$4$1 = function publicEncrypt2(publicKey, msg, reverse) { + var padding; + if (publicKey.padding) { + padding = publicKey.padding; + } else if (reverse) { + padding = 1; + } else { + padding = 4; + } + var key = parseKeys(publicKey); + var paddedMsg; + if (padding === 4) { + paddedMsg = oaep(key, msg); + } else if (padding === 1) { + paddedMsg = pkcs1(key, msg, reverse); + } else if (padding === 3) { + paddedMsg = new BN(msg); + if (paddedMsg.cmp(key.modulus) >= 0) { + throw new Error("data too long for modulus"); + } + } else { + throw new Error("unknown padding"); + } + if (reverse) { + return crt(paddedMsg, key); + } else { + return withPublic(paddedMsg, key); + } + }; + function oaep(key, msg) { + var k5 = key.modulus.byteLength(); + var mLen = msg.length; + var iHash = createHash2("sha1").update(Buffer2.alloc(0)).digest(); + var hLen = iHash.length; + var hLen2 = 2 * hLen; + if (mLen > k5 - hLen2 - 2) { + throw new Error("message too long"); + } + var ps = Buffer2.alloc(k5 - mLen - hLen2 - 2); + var dblen = k5 - hLen - 1; + var seed = randomBytes3(hLen); + var maskedDb = xor3(Buffer2.concat([iHash, ps, Buffer2.alloc(1, 1), msg], dblen), mgf(seed, dblen)); + var maskedSeed = xor3(seed, mgf(maskedDb, hLen)); + return new BN(Buffer2.concat([Buffer2.alloc(1), maskedSeed, maskedDb], k5)); + } + function pkcs1(key, msg, reverse) { + var mLen = msg.length; + var k5 = key.modulus.byteLength(); + if (mLen > k5 - 11) { + throw new Error("message too long"); + } + var ps; + if (reverse) { + ps = Buffer2.alloc(k5 - mLen - 3, 255); + } else { + ps = nonZero(k5 - mLen - 3); + } + return new BN(Buffer2.concat([Buffer2.from([0, reverse ? 1 : 2]), ps, Buffer2.alloc(1), msg], k5)); + } + function nonZero(len) { + var out = Buffer2.allocUnsafe(len); + var i8 = 0; + var cache3 = randomBytes3(len * 2); + var cur = 0; + var num; + while (i8 < len) { + if (cur === cache3.length) { + cache3 = randomBytes3(len * 2); + cur = 0; + } + num = cache3[cur++]; + if (num) { + out[i8++] = num; + } + } + return out; + } + return exports$4$1; + } + var exports$3$1 = {}; + var _dewExec$3$1 = false; + function dew$3$1() { + if (_dewExec$3$1) + return exports$3$1; + _dewExec$3$1 = true; + var parseKeys = dew$e$1(); + var mgf = dew$8$1(); + var xor3 = dew$7$1(); + var BN = dew$6$1(); + var crt = dew$W$1(); + var createHash2 = dew$1F(); + var withPublic = dew$5$1(); + var Buffer2 = dew$1T().Buffer; + exports$3$1 = function privateDecrypt2(privateKey, enc, reverse) { + var padding; + if (privateKey.padding) { + padding = privateKey.padding; + } else if (reverse) { + padding = 1; + } else { + padding = 4; + } + var key = parseKeys(privateKey); + var k5 = key.modulus.byteLength(); + if (enc.length > k5 || new BN(enc).cmp(key.modulus) >= 0) { + throw new Error("decryption error"); + } + var msg; + if (reverse) { + msg = withPublic(new BN(enc), key); + } else { + msg = crt(enc, key); + } + var zBuffer = Buffer2.alloc(k5 - msg.length); + msg = Buffer2.concat([zBuffer, msg], k5); + if (padding === 4) { + return oaep(key, msg); + } else if (padding === 1) { + return pkcs1(key, msg, reverse); + } else if (padding === 3) { + return msg; + } else { + throw new Error("unknown padding"); + } + }; + function oaep(key, msg) { + var k5 = key.modulus.byteLength(); + var iHash = createHash2("sha1").update(Buffer2.alloc(0)).digest(); + var hLen = iHash.length; + if (msg[0] !== 0) { + throw new Error("decryption error"); + } + var maskedSeed = msg.slice(1, hLen + 1); + var maskedDb = msg.slice(hLen + 1); + var seed = xor3(maskedSeed, mgf(maskedDb, hLen)); + var db = xor3(maskedDb, mgf(seed, k5 - hLen - 1)); + if (compare7(iHash, db.slice(0, hLen))) { + throw new Error("decryption error"); + } + var i8 = hLen; + while (db[i8] === 0) { + i8++; + } + if (db[i8++] !== 1) { + throw new Error("decryption error"); + } + return db.slice(i8); + } + function pkcs1(key, msg, reverse) { + var p1 = msg.slice(0, 2); + var i8 = 2; + var status = 0; + while (msg[i8++] !== 0) { + if (i8 >= msg.length) { + status++; + break; + } + } + var ps = msg.slice(2, i8 - 1); + if (p1.toString("hex") !== "0002" && !reverse || p1.toString("hex") !== "0001" && reverse) { + status++; + } + if (ps.length < 8) { + status++; + } + if (status) { + throw new Error("decryption error"); + } + return msg.slice(i8); + } + function compare7(a8, b6) { + a8 = Buffer2.from(a8); + b6 = Buffer2.from(b6); + var dif = 0; + var len = a8.length; + if (a8.length !== b6.length) { + dif++; + len = Math.min(a8.length, b6.length); + } + var i8 = -1; + while (++i8 < len) { + dif += a8[i8] ^ b6[i8]; + } + return dif; + } + return exports$3$1; + } + var exports$2$12 = {}; + var _dewExec$2$12 = false; + function dew$2$12() { + if (_dewExec$2$12) + return exports$2$12; + _dewExec$2$12 = true; + exports$2$12.publicEncrypt = dew$4$1(); + exports$2$12.privateDecrypt = dew$3$1(); + exports$2$12.privateEncrypt = function privateEncrypt2(key, buf3) { + return exports$2$12.publicEncrypt(key, buf3, true); + }; + exports$2$12.publicDecrypt = function publicDecrypt2(key, buf3) { + return exports$2$12.privateDecrypt(key, buf3, true); + }; + return exports$2$12; + } + var exports$1$12 = {}; + var _dewExec$1$12 = false; + var _global$x = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$1$12() { + if (_dewExec$1$12) + return exports$1$12; + _dewExec$1$12 = true; + var process3 = T; + function oldBrowser() { + throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11"); + } + var safeBuffer = dew$1T(); + var randombytes = dew$1S(); + var Buffer2 = safeBuffer.Buffer; + var kBufferMaxLength = safeBuffer.kMaxLength; + var crypto5 = _global$x.crypto || _global$x.msCrypto; + var kMaxUint32 = Math.pow(2, 32) - 1; + function assertOffset(offset2, length3) { + if (typeof offset2 !== "number" || offset2 !== offset2) { + throw new TypeError("offset must be a number"); + } + if (offset2 > kMaxUint32 || offset2 < 0) { + throw new TypeError("offset must be a uint32"); + } + if (offset2 > kBufferMaxLength || offset2 > length3) { + throw new RangeError("offset out of range"); + } + } + function assertSize(size4, offset2, length3) { + if (typeof size4 !== "number" || size4 !== size4) { + throw new TypeError("size must be a number"); + } + if (size4 > kMaxUint32 || size4 < 0) { + throw new TypeError("size must be a uint32"); + } + if (size4 + offset2 > length3 || size4 > kBufferMaxLength) { + throw new RangeError("buffer too small"); + } + } + if (crypto5 && crypto5.getRandomValues || !process3.browser) { + exports$1$12.randomFill = randomFill2; + exports$1$12.randomFillSync = randomFillSync2; + } else { + exports$1$12.randomFill = oldBrowser; + exports$1$12.randomFillSync = oldBrowser; + } + function randomFill2(buf3, offset2, size4, cb) { + if (!Buffer2.isBuffer(buf3) && !(buf3 instanceof _global$x.Uint8Array)) { + throw new TypeError('"buf" argument must be a Buffer or Uint8Array'); + } + if (typeof offset2 === "function") { + cb = offset2; + offset2 = 0; + size4 = buf3.length; + } else if (typeof size4 === "function") { + cb = size4; + size4 = buf3.length - offset2; + } else if (typeof cb !== "function") { + throw new TypeError('"cb" argument must be a function'); + } + assertOffset(offset2, buf3.length); + assertSize(size4, offset2, buf3.length); + return actualFill(buf3, offset2, size4, cb); + } + function actualFill(buf3, offset2, size4, cb) { + if (process3.browser) { + var ourBuf = buf3.buffer; + var uint = new Uint8Array(ourBuf, offset2, size4); + crypto5.getRandomValues(uint); + if (cb) { + process3.nextTick(function() { + cb(null, buf3); + }); + return; + } + return buf3; + } + if (cb) { + randombytes(size4, function(err, bytes3) { + if (err) { + return cb(err); + } + bytes3.copy(buf3, offset2); + cb(null, buf3); + }); + return; + } + var bytes2 = randombytes(size4); + bytes2.copy(buf3, offset2); + return buf3; + } + function randomFillSync2(buf3, offset2, size4) { + if (typeof offset2 === "undefined") { + offset2 = 0; + } + if (!Buffer2.isBuffer(buf3) && !(buf3 instanceof _global$x.Uint8Array)) { + throw new TypeError('"buf" argument must be a Buffer or Uint8Array'); + } + assertOffset(offset2, buf3.length); + if (size4 === void 0) + size4 = buf3.length - offset2; + assertSize(size4, offset2, buf3.length); + return actualFill(buf3, offset2, size4); + } + return exports$1$12; + } + var exports$1V = {}; + var _dewExec$1U = false; + function dew$1U() { + if (_dewExec$1U) + return exports$1V; + _dewExec$1U = true; + exports$1V.randomBytes = exports$1V.rng = exports$1V.pseudoRandomBytes = exports$1V.prng = dew$1S(); + exports$1V.createHash = exports$1V.Hash = dew$1F(); + exports$1V.createHmac = exports$1V.Hmac = dew$1C(); + var algos = dew$1B(); + var algoKeys = Object.keys(algos); + var hashes2 = ["sha1", "sha224", "sha256", "sha384", "sha512", "md5", "rmd160"].concat(algoKeys); + exports$1V.getHashes = function() { + return hashes2; + }; + var p8 = dew$1v(); + exports$1V.pbkdf2 = p8.pbkdf2; + exports$1V.pbkdf2Sync = p8.pbkdf2Sync; + var aes2 = dew$13(); + exports$1V.Cipher = aes2.Cipher; + exports$1V.createCipher = aes2.createCipher; + exports$1V.Cipheriv = aes2.Cipheriv; + exports$1V.createCipheriv = aes2.createCipheriv; + exports$1V.Decipher = aes2.Decipher; + exports$1V.createDecipher = aes2.createDecipher; + exports$1V.Decipheriv = aes2.Decipheriv; + exports$1V.createDecipheriv = aes2.createDecipheriv; + exports$1V.getCiphers = aes2.getCiphers; + exports$1V.listCiphers = aes2.listCiphers; + var dh = dew$Y$1(); + exports$1V.DiffieHellmanGroup = dh.DiffieHellmanGroup; + exports$1V.createDiffieHellmanGroup = dh.createDiffieHellmanGroup; + exports$1V.getDiffieHellman = dh.getDiffieHellman; + exports$1V.createDiffieHellman = dh.createDiffieHellman; + exports$1V.DiffieHellman = dh.DiffieHellman; + var sign2 = dew$b$1(); + exports$1V.createSign = sign2.createSign; + exports$1V.Sign = sign2.Sign; + exports$1V.createVerify = sign2.createVerify; + exports$1V.Verify = sign2.Verify; + exports$1V.createECDH = dew$9$1(); + var publicEncrypt2 = dew$2$12(); + exports$1V.publicEncrypt = publicEncrypt2.publicEncrypt; + exports$1V.privateEncrypt = publicEncrypt2.privateEncrypt; + exports$1V.publicDecrypt = publicEncrypt2.publicDecrypt; + exports$1V.privateDecrypt = publicEncrypt2.privateDecrypt; + var rf = dew$1$12(); + exports$1V.randomFill = rf.randomFill; + exports$1V.randomFillSync = rf.randomFillSync; + exports$1V.createCredentials = function() { + throw new Error(["sorry, createCredentials is not implemented yet", "we accept pull requests", "https://github.com/crypto-browserify/crypto-browserify"].join("\n")); + }; + exports$1V.constants = { + "DH_CHECK_P_NOT_SAFE_PRIME": 2, + "DH_CHECK_P_NOT_PRIME": 1, + "DH_UNABLE_TO_CHECK_GENERATOR": 4, + "DH_NOT_SUITABLE_GENERATOR": 8, + "NPN_ENABLED": 1, + "ALPN_ENABLED": 1, + "RSA_PKCS1_PADDING": 1, + "RSA_SSLV23_PADDING": 2, + "RSA_NO_PADDING": 3, + "RSA_PKCS1_OAEP_PADDING": 4, + "RSA_X931_PADDING": 5, + "RSA_PKCS1_PSS_PADDING": 6, + "POINT_CONVERSION_COMPRESSED": 2, + "POINT_CONVERSION_UNCOMPRESSED": 4, + "POINT_CONVERSION_HYBRID": 6 + }; + return exports$1V; + } + var crypto2 = dew$1U(); + crypto2.Cipher; + crypto2.Cipheriv; + crypto2.Decipher; + crypto2.Decipheriv; + crypto2.DiffieHellman; + crypto2.DiffieHellmanGroup; + crypto2.Hash; + crypto2.Hmac; + crypto2.Sign; + crypto2.Verify; + crypto2.constants; + crypto2.createCipher; + crypto2.createCipheriv; + crypto2.createCredentials; + crypto2.createDecipher; + crypto2.createDecipheriv; + crypto2.createDiffieHellman; + crypto2.createDiffieHellmanGroup; + crypto2.createECDH; + crypto2.createHash; + crypto2.createHmac; + crypto2.createSign; + crypto2.createVerify; + crypto2.getCiphers; + crypto2.getDiffieHellman; + crypto2.getHashes; + crypto2.listCiphers; + crypto2.pbkdf2; + crypto2.pbkdf2Sync; + crypto2.privateDecrypt; + crypto2.privateEncrypt; + crypto2.prng; + crypto2.pseudoRandomBytes; + crypto2.publicDecrypt; + crypto2.publicEncrypt; + crypto2.randomBytes; + crypto2.randomFill; + crypto2.randomFillSync; + crypto2.rng; + var exports$122 = {}; + var _dewExec$11 = false; + var _global$a = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$11() { + if (_dewExec$11) + return exports$122; + _dewExec$11 = true; + var r10; + exports$122 = function rand(len) { + if (!r10) + r10 = new Rand(null); + return r10.generate(len); + }; + function Rand(rand) { + (this || _global$a).rand = rand; + } + exports$122.Rand = Rand; + Rand.prototype.generate = function generate3(len) { + return this._rand(len); + }; + Rand.prototype._rand = function _rand(n9) { + if ((this || _global$a).rand.getBytes) + return (this || _global$a).rand.getBytes(n9); + var res = new Uint8Array(n9); + for (var i8 = 0; i8 < res.length; i8++) + res[i8] = (this || _global$a).rand.getByte(); + return res; + }; + if (typeof self === "object") { + if (self.crypto && self.crypto.getRandomValues) { + Rand.prototype._rand = function _rand(n9) { + var arr = new Uint8Array(n9); + self.crypto.getRandomValues(arr); + return arr; + }; + } else if (self.msCrypto && self.msCrypto.getRandomValues) { + Rand.prototype._rand = function _rand(n9) { + var arr = new Uint8Array(n9); + self.msCrypto.getRandomValues(arr); + return arr; + }; + } else if (typeof window === "object") { + Rand.prototype._rand = function() { + throw new Error("Not implemented yet"); + }; + } + } else { + try { + var crypto$1 = crypto2; + if (typeof crypto$1.randomBytes !== "function") + throw new Error("Not supported"); + Rand.prototype._rand = function _rand(n9) { + return crypto$1.randomBytes(n9); + }; + } catch (e12) { + } + } + return exports$122; + } + var exports$11 = {}; + var _dewExec$10 = false; + var _global$9 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$10() { + if (_dewExec$10) + return exports$11; + _dewExec$10 = true; + var bn = dew$1W(); + var brorand = dew$11(); + function MillerRabin(rand) { + (this || _global$9).rand = rand || new brorand.Rand(); + } + exports$11 = MillerRabin; + MillerRabin.create = function create21(rand) { + return new MillerRabin(rand); + }; + MillerRabin.prototype._randbelow = function _randbelow(n9) { + var len = n9.bitLength(); + var min_bytes = Math.ceil(len / 8); + do + var a8 = new bn((this || _global$9).rand.generate(min_bytes)); + while (a8.cmp(n9) >= 0); + return a8; + }; + MillerRabin.prototype._randrange = function _randrange(start, stop) { + var size4 = stop.sub(start); + return start.add(this._randbelow(size4)); + }; + MillerRabin.prototype.test = function test(n9, k5, cb) { + var len = n9.bitLength(); + var red = bn.mont(n9); + var rone = new bn(1).toRed(red); + if (!k5) + k5 = Math.max(1, len / 48 | 0); + var n1 = n9.subn(1); + for (var s7 = 0; !n1.testn(s7); s7++) { + } + var d7 = n9.shrn(s7); + var rn1 = n1.toRed(red); + var prime = true; + for (; k5 > 0; k5--) { + var a8 = this._randrange(new bn(2), n1); + if (cb) + cb(a8); + var x5 = a8.toRed(red).redPow(d7); + if (x5.cmp(rone) === 0 || x5.cmp(rn1) === 0) + continue; + for (var i8 = 1; i8 < s7; i8++) { + x5 = x5.redSqr(); + if (x5.cmp(rone) === 0) + return false; + if (x5.cmp(rn1) === 0) + break; + } + if (i8 === s7) + return false; + } + return prime; + }; + MillerRabin.prototype.getDivisor = function getDivisor(n9, k5) { + var len = n9.bitLength(); + var red = bn.mont(n9); + var rone = new bn(1).toRed(red); + if (!k5) + k5 = Math.max(1, len / 48 | 0); + var n1 = n9.subn(1); + for (var s7 = 0; !n1.testn(s7); s7++) { + } + var d7 = n9.shrn(s7); + var rn1 = n1.toRed(red); + for (; k5 > 0; k5--) { + var a8 = this._randrange(new bn(2), n1); + var g6 = n9.gcd(a8); + if (g6.cmpn(1) !== 0) + return g6; + var x5 = a8.toRed(red).redPow(d7); + if (x5.cmp(rone) === 0 || x5.cmp(rn1) === 0) + continue; + for (var i8 = 1; i8 < s7; i8++) { + x5 = x5.redSqr(); + if (x5.cmp(rone) === 0) + return x5.fromRed().subn(1).gcd(n9); + if (x5.cmp(rn1) === 0) + break; + } + if (i8 === s7) { + x5 = x5.redSqr(); + return x5.fromRed().subn(1).gcd(n9); + } + } + return false; + }; + return exports$11; + } + var exports$10 = {}; + var _dewExec$$ = false; + function dew$$() { + if (_dewExec$$) + return exports$10; + _dewExec$$ = true; + var randomBytes3 = dew$2O(); + exports$10 = findPrime; + findPrime.simpleSieve = simpleSieve; + findPrime.fermatTest = fermatTest; + var BN = dew$1X(); + var TWENTYFOUR = new BN(24); + var MillerRabin = dew$10(); + var millerRabin = new MillerRabin(); + var ONE = new BN(1); + var TWO = new BN(2); + var FIVE = new BN(5); + new BN(16); + new BN(8); + var TEN = new BN(10); + var THREE = new BN(3); + new BN(7); + var ELEVEN = new BN(11); + var FOUR = new BN(4); + new BN(12); + var primes = null; + function _getPrimes() { + if (primes !== null) + return primes; + var limit = 1048576; + var res = []; + res[0] = 2; + for (var i8 = 1, k5 = 3; k5 < limit; k5 += 2) { + var sqrt = Math.ceil(Math.sqrt(k5)); + for (var j5 = 0; j5 < i8 && res[j5] <= sqrt; j5++) + if (k5 % res[j5] === 0) + break; + if (i8 !== j5 && res[j5] <= sqrt) + continue; + res[i8++] = k5; + } + primes = res; + return res; + } + function simpleSieve(p8) { + var primes2 = _getPrimes(); + for (var i8 = 0; i8 < primes2.length; i8++) + if (p8.modn(primes2[i8]) === 0) { + if (p8.cmpn(primes2[i8]) === 0) { + return true; + } else { + return false; + } + } + return true; + } + function fermatTest(p8) { + var red = BN.mont(p8); + return TWO.toRed(red).redPow(p8.subn(1)).fromRed().cmpn(1) === 0; + } + function findPrime(bits, gen) { + if (bits < 16) { + if (gen === 2 || gen === 5) { + return new BN([140, 123]); + } else { + return new BN([140, 39]); + } + } + gen = new BN(gen); + var num, n22; + while (true) { + num = new BN(randomBytes3(Math.ceil(bits / 8))); + while (num.bitLength() > bits) { + num.ishrn(1); + } + if (num.isEven()) { + num.iadd(ONE); + } + if (!num.testn(1)) { + num.iadd(TWO); + } + if (!gen.cmp(TWO)) { + while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { + num.iadd(FOUR); + } + } else if (!gen.cmp(FIVE)) { + while (num.mod(TEN).cmp(THREE)) { + num.iadd(FOUR); + } + } + n22 = num.shrn(1); + if (simpleSieve(n22) && simpleSieve(num) && fermatTest(n22) && fermatTest(num) && millerRabin.test(n22) && millerRabin.test(num)) { + return num; + } + } + } + return exports$10; + } + var _primes = { + "modp1": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" + }, + "modp2": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" + }, + "modp5": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" + }, + "modp14": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" + }, + "modp15": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" + }, + "modp16": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" + }, + "modp17": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" + }, + "modp18": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" + } + }; + var exports$$ = {}; + var _dewExec$_ = false; + var _global$8 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$_() { + if (_dewExec$_) + return exports$$; + _dewExec$_ = true; + var Buffer2 = buffer3.Buffer; + var BN = dew$1X(); + var MillerRabin = dew$10(); + var millerRabin = new MillerRabin(); + var TWENTYFOUR = new BN(24); + var ELEVEN = new BN(11); + var TEN = new BN(10); + var THREE = new BN(3); + var SEVEN = new BN(7); + var primes = dew$$(); + var randomBytes3 = dew$2O(); + exports$$ = DH; + function setPublicKey(pub, enc) { + enc = enc || "utf8"; + if (!Buffer2.isBuffer(pub)) { + pub = new Buffer2(pub, enc); + } + (this || _global$8)._pub = new BN(pub); + return this || _global$8; + } + function setPrivateKey(priv, enc) { + enc = enc || "utf8"; + if (!Buffer2.isBuffer(priv)) { + priv = new Buffer2(priv, enc); + } + (this || _global$8)._priv = new BN(priv); + return this || _global$8; + } + var primeCache = {}; + function checkPrime(prime, generator) { + var gen = generator.toString("hex"); + var hex = [gen, prime.toString(16)].join("_"); + if (hex in primeCache) { + return primeCache[hex]; + } + var error7 = 0; + if (prime.isEven() || !primes.simpleSieve || !primes.fermatTest(prime) || !millerRabin.test(prime)) { + error7 += 1; + if (gen === "02" || gen === "05") { + error7 += 8; + } else { + error7 += 4; + } + primeCache[hex] = error7; + return error7; + } + if (!millerRabin.test(prime.shrn(1))) { + error7 += 2; + } + var rem; + switch (gen) { + case "02": + if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { + error7 += 8; + } + break; + case "05": + rem = prime.mod(TEN); + if (rem.cmp(THREE) && rem.cmp(SEVEN)) { + error7 += 8; + } + break; + default: + error7 += 4; + } + primeCache[hex] = error7; + return error7; + } + function DH(prime, generator, malleable) { + this.setGenerator(generator); + (this || _global$8).__prime = new BN(prime); + (this || _global$8)._prime = BN.mont((this || _global$8).__prime); + (this || _global$8)._primeLen = prime.length; + (this || _global$8)._pub = void 0; + (this || _global$8)._priv = void 0; + (this || _global$8)._primeCode = void 0; + if (malleable) { + (this || _global$8).setPublicKey = setPublicKey; + (this || _global$8).setPrivateKey = setPrivateKey; + } else { + (this || _global$8)._primeCode = 8; + } + } + Object.defineProperty(DH.prototype, "verifyError", { + enumerable: true, + get: function() { + if (typeof (this || _global$8)._primeCode !== "number") { + (this || _global$8)._primeCode = checkPrime((this || _global$8).__prime, (this || _global$8).__gen); + } + return (this || _global$8)._primeCode; + } + }); + DH.prototype.generateKeys = function() { + if (!(this || _global$8)._priv) { + (this || _global$8)._priv = new BN(randomBytes3((this || _global$8)._primeLen)); + } + (this || _global$8)._pub = (this || _global$8)._gen.toRed((this || _global$8)._prime).redPow((this || _global$8)._priv).fromRed(); + return this.getPublicKey(); + }; + DH.prototype.computeSecret = function(other) { + other = new BN(other); + other = other.toRed((this || _global$8)._prime); + var secret = other.redPow((this || _global$8)._priv).fromRed(); + var out = new Buffer2(secret.toArray()); + var prime = this.getPrime(); + if (out.length < prime.length) { + var front = new Buffer2(prime.length - out.length); + front.fill(0); + out = Buffer2.concat([front, out]); + } + return out; + }; + DH.prototype.getPublicKey = function getPublicKey2(enc) { + return formatReturnValue((this || _global$8)._pub, enc); + }; + DH.prototype.getPrivateKey = function getPrivateKey(enc) { + return formatReturnValue((this || _global$8)._priv, enc); + }; + DH.prototype.getPrime = function(enc) { + return formatReturnValue((this || _global$8).__prime, enc); + }; + DH.prototype.getGenerator = function(enc) { + return formatReturnValue((this || _global$8)._gen, enc); + }; + DH.prototype.setGenerator = function(gen, enc) { + enc = enc || "utf8"; + if (!Buffer2.isBuffer(gen)) { + gen = new Buffer2(gen, enc); + } + (this || _global$8).__gen = gen; + (this || _global$8)._gen = new BN(gen); + return this || _global$8; + }; + function formatReturnValue(bn, enc) { + var buf3 = new Buffer2(bn.toArray()); + if (!enc) { + return buf3; + } else { + return buf3.toString(enc); + } + } + return exports$$; + } + var exports$_ = {}; + var _dewExec$Z = false; + function dew$Z() { + if (_dewExec$Z) + return exports$_; + _dewExec$Z = true; + var Buffer2 = buffer3.Buffer; + var generatePrime = dew$$(); + var primes = _primes; + var DH = dew$_(); + function getDiffieHellman2(mod3) { + var prime = new Buffer2(primes[mod3].prime, "hex"); + var gen = new Buffer2(primes[mod3].gen, "hex"); + return new DH(prime, gen); + } + var ENCODINGS = { + "binary": true, + "hex": true, + "base64": true + }; + function createDiffieHellman2(prime, enc, generator, genc) { + if (Buffer2.isBuffer(enc) || ENCODINGS[enc] === void 0) { + return createDiffieHellman2(prime, "binary", enc, generator); + } + enc = enc || "binary"; + genc = genc || "binary"; + generator = generator || new Buffer2([2]); + if (!Buffer2.isBuffer(generator)) { + generator = new Buffer2(generator, genc); + } + if (typeof prime === "number") { + return new DH(generatePrime(prime, generator), generator, true); + } + if (!Buffer2.isBuffer(prime)) { + prime = new Buffer2(prime, enc); + } + return new DH(prime, generator, true); + } + exports$_.DiffieHellmanGroup = exports$_.createDiffieHellmanGroup = exports$_.getDiffieHellman = getDiffieHellman2; + exports$_.createDiffieHellman = exports$_.DiffieHellman = createDiffieHellman2; + return exports$_; + } + var exports$Z = {}; + var _dewExec$Y = false; + function dew$Y() { + if (_dewExec$Y) + return exports$Z; + _dewExec$Y = true; + var buffer$1 = buffer3; + var Buffer2 = buffer$1.Buffer; + function copyProps(src3, dst) { + for (var key in src3) { + dst[key] = src3[key]; + } + } + if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) { + exports$Z = buffer$1; + } else { + copyProps(buffer$1, exports$Z); + exports$Z.Buffer = SafeBuffer; + } + function SafeBuffer(arg, encodingOrOffset, length3) { + return Buffer2(arg, encodingOrOffset, length3); + } + SafeBuffer.prototype = Object.create(Buffer2.prototype); + copyProps(Buffer2, SafeBuffer); + SafeBuffer.from = function(arg, encodingOrOffset, length3) { + if (typeof arg === "number") { + throw new TypeError("Argument must not be a number"); + } + return Buffer2(arg, encodingOrOffset, length3); + }; + SafeBuffer.alloc = function(size4, fill, encoding) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + var buf3 = Buffer2(size4); + if (fill !== void 0) { + if (typeof encoding === "string") { + buf3.fill(fill, encoding); + } else { + buf3.fill(fill); + } + } else { + buf3.fill(0); + } + return buf3; + }; + SafeBuffer.allocUnsafe = function(size4) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + return Buffer2(size4); + }; + SafeBuffer.allocUnsafeSlow = function(size4) { + if (typeof size4 !== "number") { + throw new TypeError("Argument must be a number"); + } + return buffer$1.SlowBuffer(size4); + }; + return exports$Z; + } + var exports$Y = {}; + var _dewExec$X = false; + var module$4 = { + exports: exports$Y + }; + var _global$7 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$X() { + if (_dewExec$X) + return module$4.exports; + _dewExec$X = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$7).negative = 0; + (this || _global$7).words = null; + (this || _global$7).length = 0; + (this || _global$7).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = buffer3.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$7).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$7).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$7).words = [number3 & 67108863]; + (this || _global$7).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$7).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$7).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$7).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$7).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$7).words = [0]; + (this || _global$7).length = 1; + return this || _global$7; + } + (this || _global$7).length = Math.ceil(number3.length / 3); + (this || _global$7).words = new Array((this || _global$7).length); + for (var i8 = 0; i8 < (this || _global$7).length; i8++) { + (this || _global$7).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$7).words[j5] |= w5 << off & 67108863; + (this || _global$7).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$7).words[j5] |= w5 << off & 67108863; + (this || _global$7).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this._strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 48 && c8 <= 57) { + return c8 - 48; + } else if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + assert(false, "Invalid character in " + string4); + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$7).length = Math.ceil((number3.length - start) / 6); + (this || _global$7).words = new Array((this || _global$7).length); + for (var i8 = 0; i8 < (this || _global$7).length; i8++) { + (this || _global$7).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$7).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$7).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$7).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$7).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this._strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var b6 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + b6 = c8 - 49 + 10; + } else if (c8 >= 17) { + b6 = c8 - 17 + 10; + } else { + b6 = c8; + } + assert(c8 >= 0 && b6 < mul, "Invalid character"); + r10 += b6; + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$7).words = [0]; + (this || _global$7).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$7).words[0] + word < 67108864) { + (this || _global$7).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$7).words[0] + word < 67108864) { + (this || _global$7).words[0] += word; + } else { + this._iaddn(word); + } + } + this._strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$7).length); + for (var i8 = 0; i8 < (this || _global$7).length; i8++) { + dest.words[i8] = (this || _global$7).words[i8]; + } + dest.length = (this || _global$7).length; + dest.negative = (this || _global$7).negative; + dest.red = (this || _global$7).red; + }; + function move2(dest, src3) { + dest.words = src3.words; + dest.length = src3.length; + dest.negative = src3.negative; + dest.red = src3.red; + } + BN.prototype._move = function _move(dest) { + move2(dest, this || _global$7); + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$7).length < size4) { + (this || _global$7).words[(this || _global$7).length++] = 0; + } + return this || _global$7; + }; + BN.prototype._strip = function strip() { + while ((this || _global$7).length > 1 && (this || _global$7).words[(this || _global$7).length - 1] === 0) { + (this || _global$7).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$7).length === 1 && (this || _global$7).words[0] === 0) { + (this || _global$7).negative = 0; + } + return this || _global$7; + }; + if (typeof Symbol !== "undefined" && typeof Symbol.for === "function") { + try { + BN.prototype[Symbol.for("nodejs.util.inspect.custom")] = inspect3; + } catch (e12) { + BN.prototype.inspect = inspect3; + } + } else { + BN.prototype.inspect = inspect3; + } + function inspect3() { + return ((this || _global$7).red ? ""; + } + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$7).length; i8++) { + var w5 = (this || _global$7).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$7).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$7).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modrn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$7).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$7).words[0]; + if ((this || _global$7).length === 2) { + ret += (this || _global$7).words[1] * 67108864; + } else if ((this || _global$7).length === 3 && (this || _global$7).words[2] === 1) { + ret += 4503599627370496 + (this || _global$7).words[1] * 67108864; + } else if ((this || _global$7).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$7).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16, 2); + }; + if (Buffer2) { + BN.prototype.toBuffer = function toBuffer(endian, length3) { + return this.toArrayLike(Buffer2, endian, length3); + }; + } + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + var allocate3 = function allocate4(ArrayType, size4) { + if (ArrayType.allocUnsafe) { + return ArrayType.allocUnsafe(size4); + } + return new ArrayType(size4); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + this._strip(); + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + var res = allocate3(ArrayType, reqLength); + var postfix = endian === "le" ? "LE" : "BE"; + this["_toArrayLike" + postfix](res, byteLength); + return res; + }; + BN.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) { + var position = 0; + var carry = 0; + for (var i8 = 0, shift = 0; i8 < (this || _global$7).length; i8++) { + var word = (this || _global$7).words[i8] << shift | carry; + res[position++] = word & 255; + if (position < res.length) { + res[position++] = word >> 8 & 255; + } + if (position < res.length) { + res[position++] = word >> 16 & 255; + } + if (shift === 6) { + if (position < res.length) { + res[position++] = word >> 24 & 255; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } + if (position < res.length) { + res[position++] = carry; + while (position < res.length) { + res[position++] = 0; + } + } + }; + BN.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) { + var position = res.length - 1; + var carry = 0; + for (var i8 = 0, shift = 0; i8 < (this || _global$7).length; i8++) { + var word = (this || _global$7).words[i8] << shift | carry; + res[position--] = word & 255; + if (position >= 0) { + res[position--] = word >> 8 & 255; + } + if (position >= 0) { + res[position--] = word >> 16 & 255; + } + if (shift === 6) { + if (position >= 0) { + res[position--] = word >> 24 & 255; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } + if (position >= 0) { + res[position--] = carry; + while (position >= 0) { + res[position--] = 0; + } + } + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$7).words[(this || _global$7).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$7).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = num.words[off] >>> wbit & 1; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$7).length; i8++) { + var b6 = this._zeroBits((this || _global$7).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$7).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$7).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$7).negative ^= 1; + } + return this || _global$7; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$7).length < num.length) { + (this || _global$7).words[(this || _global$7).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$7).words[i8] = (this || _global$7).words[i8] | num.words[i8]; + } + return this._strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$7).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$7).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$7); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$7).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$7); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$7).length > num.length) { + b6 = num; + } else { + b6 = this || _global$7; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$7).words[i8] = (this || _global$7).words[i8] & num.words[i8]; + } + (this || _global$7).length = b6.length; + return this._strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$7).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$7).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$7); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$7).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$7); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$7).length > num.length) { + a8 = this || _global$7; + b6 = num; + } else { + a8 = num; + b6 = this || _global$7; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$7).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$7) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$7).words[i8] = a8.words[i8]; + } + } + (this || _global$7).length = a8.length; + return this._strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$7).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$7).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$7); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$7).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$7); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$7).words[i8] = ~(this || _global$7).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$7).words[i8] = ~(this || _global$7).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this._strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$7).words[off] = (this || _global$7).words[off] | 1 << wbit; + } else { + (this || _global$7).words[off] = (this || _global$7).words[off] & ~(1 << wbit); + } + return this._strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$7).negative !== 0 && num.negative === 0) { + (this || _global$7).negative = 0; + r10 = this.isub(num); + (this || _global$7).negative ^= 1; + return this._normSign(); + } else if ((this || _global$7).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$7).length > num.length) { + a8 = this || _global$7; + b6 = num; + } else { + a8 = num; + b6 = this || _global$7; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$7).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$7).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$7).length = a8.length; + if (carry !== 0) { + (this || _global$7).words[(this || _global$7).length] = carry; + (this || _global$7).length++; + } else if (a8 !== (this || _global$7)) { + for (; i8 < a8.length; i8++) { + (this || _global$7).words[i8] = a8.words[i8]; + } + } + return this || _global$7; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$7).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$7).negative !== 0) { + (this || _global$7).negative = 0; + res = num.sub(this || _global$7); + (this || _global$7).negative = 1; + return res; + } + if ((this || _global$7).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$7); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$7).negative !== 0) { + (this || _global$7).negative = 0; + this.iadd(num); + (this || _global$7).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$7).negative = 0; + (this || _global$7).length = 1; + (this || _global$7).words[0] = 0; + return this || _global$7; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$7; + b6 = num; + } else { + a8 = num; + b6 = this || _global$7; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$7).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$7).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$7)) { + for (; i8 < a8.length; i8++) { + (this || _global$7).words[i8] = a8.words[i8]; + } + } + (this || _global$7).length = Math.max((this || _global$7).length, i8); + if (a8 !== (this || _global$7)) { + (this || _global$7).negative = 1; + } + return this._strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out._strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out._strip(); + } + function jumboMulTo(self2, num, out) { + return bigMulTo(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$7).length + num.length; + if ((this || _global$7).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$7, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$7, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$7, num, out); + } else { + res = jumboMulTo(this || _global$7, num, out); + } + return res; + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$7).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$7).length + num.length); + return jumboMulTo(this || _global$7, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$7); + }; + BN.prototype.imuln = function imuln(num) { + var isNegNum = num < 0; + if (isNegNum) + num = -num; + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$7).length; i8++) { + var w5 = ((this || _global$7).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$7).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$7).words[i8] = carry; + (this || _global$7).length++; + } + return isNegNum ? this.ineg() : this || _global$7; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$7); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$7; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$7).length; i8++) { + var newCarry = (this || _global$7).words[i8] & carryMask; + var c8 = ((this || _global$7).words[i8] | 0) - newCarry << r10; + (this || _global$7).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$7).words[i8] = carry; + (this || _global$7).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$7).length - 1; i8 >= 0; i8--) { + (this || _global$7).words[i8 + s7] = (this || _global$7).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$7).words[i8] = 0; + } + (this || _global$7).length += s7; + } + return this._strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$7).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$7).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$7).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$7).length > s7) { + (this || _global$7).length -= s7; + for (i8 = 0; i8 < (this || _global$7).length; i8++) { + (this || _global$7).words[i8] = (this || _global$7).words[i8 + s7]; + } + } else { + (this || _global$7).words[0] = 0; + (this || _global$7).length = 1; + } + var carry = 0; + for (i8 = (this || _global$7).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$7).words[i8] | 0; + (this || _global$7).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$7).length === 0) { + (this || _global$7).words[0] = 0; + (this || _global$7).length = 1; + } + return this._strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$7).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$7).length <= s7) + return false; + var w5 = (this || _global$7).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$7).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$7).length <= s7) { + return this || _global$7; + } + if (r10 !== 0) { + s7++; + } + (this || _global$7).length = Math.min(s7, (this || _global$7).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$7).words[(this || _global$7).length - 1] &= mask2; + } + return this._strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$7).negative !== 0) { + if ((this || _global$7).length === 1 && ((this || _global$7).words[0] | 0) <= num) { + (this || _global$7).words[0] = num - ((this || _global$7).words[0] | 0); + (this || _global$7).negative = 0; + return this || _global$7; + } + (this || _global$7).negative = 0; + this.isubn(num); + (this || _global$7).negative = 1; + return this || _global$7; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$7).words[0] += num; + for (var i8 = 0; i8 < (this || _global$7).length && (this || _global$7).words[i8] >= 67108864; i8++) { + (this || _global$7).words[i8] -= 67108864; + if (i8 === (this || _global$7).length - 1) { + (this || _global$7).words[i8 + 1] = 1; + } else { + (this || _global$7).words[i8 + 1]++; + } + } + (this || _global$7).length = Math.max((this || _global$7).length, i8 + 1); + return this || _global$7; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$7).negative !== 0) { + (this || _global$7).negative = 0; + this.iaddn(num); + (this || _global$7).negative = 1; + return this || _global$7; + } + (this || _global$7).words[0] -= num; + if ((this || _global$7).length === 1 && (this || _global$7).words[0] < 0) { + (this || _global$7).words[0] = -(this || _global$7).words[0]; + (this || _global$7).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$7).length && (this || _global$7).words[i8] < 0; i8++) { + (this || _global$7).words[i8] += 67108864; + (this || _global$7).words[i8 + 1] -= 1; + } + } + return this._strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$7).negative = 0; + return this || _global$7; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$7).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$7).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$7).length - shift; i8++) { + w5 = ((this || _global$7).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$7).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this._strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$7).length; i8++) { + w5 = -((this || _global$7).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$7).words[i8] = w5 & 67108863; + } + (this || _global$7).negative = 1; + return this._strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$7).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4._strip(); + } + a8._strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$7).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$7).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$7).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$7).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$7 + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modrn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modrn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modrn = function modrn(num) { + var isNegNum = num < 0; + if (isNegNum) + num = -num; + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$7).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$7).words[i8] | 0)) % num; + } + return isNegNum ? -acc : acc; + }; + BN.prototype.modn = function modn(num) { + return this.modrn(num); + }; + BN.prototype.idivn = function idivn(num) { + var isNegNum = num < 0; + if (isNegNum) + num = -num; + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$7).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$7).words[i8] | 0) + carry * 67108864; + (this || _global$7).words[i8] = w5 / num | 0; + carry = w5 % num; + } + this._strip(); + return isNegNum ? this.ineg() : this || _global$7; + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$7; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$7; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$7).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$7).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$7).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$7).length <= s7) { + this._expand(s7 + 1); + (this || _global$7).words[s7] |= q4; + return this || _global$7; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$7).length; i8++) { + var w5 = (this || _global$7).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$7).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$7).words[i8] = carry; + (this || _global$7).length++; + } + return this || _global$7; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$7).length === 1 && (this || _global$7).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$7).negative !== 0 && !negative) + return -1; + if ((this || _global$7).negative === 0 && negative) + return 1; + this._strip(); + var res; + if ((this || _global$7).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$7).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$7).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$7).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$7).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$7).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$7).length > num.length) + return 1; + if ((this || _global$7).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$7).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$7).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$7).red, "Already a number in reduction context"); + assert((this || _global$7).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$7)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$7).red, "fromRed works only with numbers in reduction context"); + return (this || _global$7).red.convertFrom(this || _global$7); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$7).red = ctx; + return this || _global$7; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$7).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$7).red, "redAdd works only with red numbers"); + return (this || _global$7).red.add(this || _global$7, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$7).red, "redIAdd works only with red numbers"); + return (this || _global$7).red.iadd(this || _global$7, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$7).red, "redSub works only with red numbers"); + return (this || _global$7).red.sub(this || _global$7, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$7).red, "redISub works only with red numbers"); + return (this || _global$7).red.isub(this || _global$7, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$7).red, "redShl works only with red numbers"); + return (this || _global$7).red.shl(this || _global$7, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$7).red, "redMul works only with red numbers"); + (this || _global$7).red._verify2(this || _global$7, num); + return (this || _global$7).red.mul(this || _global$7, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$7).red, "redMul works only with red numbers"); + (this || _global$7).red._verify2(this || _global$7, num); + return (this || _global$7).red.imul(this || _global$7, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$7).red, "redSqr works only with red numbers"); + (this || _global$7).red._verify1(this || _global$7); + return (this || _global$7).red.sqr(this || _global$7); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$7).red, "redISqr works only with red numbers"); + (this || _global$7).red._verify1(this || _global$7); + return (this || _global$7).red.isqr(this || _global$7); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$7).red, "redSqrt works only with red numbers"); + (this || _global$7).red._verify1(this || _global$7); + return (this || _global$7).red.sqrt(this || _global$7); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$7).red, "redInvm works only with red numbers"); + (this || _global$7).red._verify1(this || _global$7); + return (this || _global$7).red.invm(this || _global$7); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$7).red, "redNeg works only with red numbers"); + (this || _global$7).red._verify1(this || _global$7); + return (this || _global$7).red.neg(this || _global$7); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$7).red && !num.red, "redPow(normalNum)"); + (this || _global$7).red._verify1(this || _global$7); + return (this || _global$7).red.pow(this || _global$7, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$7).name = name15; + (this || _global$7).p = new BN(p8, 16); + (this || _global$7).n = (this || _global$7).p.bitLength(); + (this || _global$7).k = new BN(1).iushln((this || _global$7).n).isub((this || _global$7).p); + (this || _global$7).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$7).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$7).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$7).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$7).n); + var cmp = rlen < (this || _global$7).n ? -1 : r10.ucmp((this || _global$7).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$7).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$7).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$7).k); + }; + function K256() { + MPrime.call(this || _global$7, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$7, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$7, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$7, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$7).m = prime.p; + (this || _global$7).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$7).m = m7; + (this || _global$7).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$7).prime) + return (this || _global$7).prime.ireduce(a8)._forceRed(this || _global$7); + move2(a8, a8.umod((this || _global$7).m)._forceRed(this || _global$7)); + return a8; + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$7).m.sub(a8)._forceRed(this || _global$7); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$7).m) >= 0) { + res.isub((this || _global$7).m); + } + return res._forceRed(this || _global$7); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$7).m) >= 0) { + res.isub((this || _global$7).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$7).m); + } + return res._forceRed(this || _global$7); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$7).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$7).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$7).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$7).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$7); + var nOne = one.redNeg(); + var lpow = (this || _global$7).m.subn(1).iushrn(1); + var z6 = (this || _global$7).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$7); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$7).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$7); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$7); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$7).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$7, m7); + (this || _global$7).shift = (this || _global$7).m.bitLength(); + if ((this || _global$7).shift % 26 !== 0) { + (this || _global$7).shift += 26 - (this || _global$7).shift % 26; + } + (this || _global$7).r = new BN(1).iushln((this || _global$7).shift); + (this || _global$7).r2 = this.imod((this || _global$7).r.sqr()); + (this || _global$7).rinv = (this || _global$7).r._invmp((this || _global$7).m); + (this || _global$7).minv = (this || _global$7).rinv.mul((this || _global$7).r).isubn(1).div((this || _global$7).m); + (this || _global$7).minv = (this || _global$7).minv.umod((this || _global$7).r); + (this || _global$7).minv = (this || _global$7).r.sub((this || _global$7).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$7).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$7).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$7).shift).mul((this || _global$7).minv).imaskn((this || _global$7).shift).mul((this || _global$7).m); + var u8 = t9.isub(c8).iushrn((this || _global$7).shift); + var res = u8; + if (u8.cmp((this || _global$7).m) >= 0) { + res = u8.isub((this || _global$7).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$7).m); + } + return res._forceRed(this || _global$7); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$7); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$7).shift).mul((this || _global$7).minv).imaskn((this || _global$7).shift).mul((this || _global$7).m); + var u8 = t9.isub(c8).iushrn((this || _global$7).shift); + var res = u8; + if (u8.cmp((this || _global$7).m) >= 0) { + res = u8.isub((this || _global$7).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$7).m); + } + return res._forceRed(this || _global$7); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$7).m).mul((this || _global$7).r2)); + return res._forceRed(this || _global$7); + }; + })(module$4, exports$Y); + return module$4.exports; + } + var exports$X = {}; + var _dewExec$W = false; + function dew$W() { + if (_dewExec$W) + return exports$X; + _dewExec$W = true; + var Buffer2 = buffer3.Buffer; + var BN = dew$X(); + var randomBytes3 = dew$2O(); + function blind(priv) { + var r10 = getr(priv); + var blinder = r10.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed(); + return { + blinder, + unblinder: r10.invm(priv.modulus) + }; + } + function getr(priv) { + var len = priv.modulus.byteLength(); + var r10; + do { + r10 = new BN(randomBytes3(len)); + } while (r10.cmp(priv.modulus) >= 0 || !r10.umod(priv.prime1) || !r10.umod(priv.prime2)); + return r10; + } + function crt(msg, priv) { + var blinds = blind(priv); + var len = priv.modulus.byteLength(); + var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus); + var c1 = blinded.toRed(BN.mont(priv.prime1)); + var c22 = blinded.toRed(BN.mont(priv.prime2)); + var qinv = priv.coefficient; + var p8 = priv.prime1; + var q4 = priv.prime2; + var m1 = c1.redPow(priv.exponent1).fromRed(); + var m22 = c22.redPow(priv.exponent2).fromRed(); + var h9 = m1.isub(m22).imul(qinv).umod(p8).imul(q4); + return m22.iadd(h9).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer2, "be", len); + } + crt.getr = getr; + exports$X = crt; + return exports$X; + } + var _package = { + "name": "elliptic", + "version": "6.5.4", + "description": "EC cryptography", + "main": "lib/elliptic.js", + "files": [ + "lib" + ], + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "test": "npm run lint && npm run unit", + "version": "grunt dist && git add dist/" + }, + "repository": { + "type": "git", + "url": "git@github.com:indutny/elliptic" + }, + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "author": "Fedor Indutny ", + "license": "MIT", + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "homepage": "https://github.com/indutny/elliptic", + "devDependencies": { + "brfs": "^2.0.2", + "coveralls": "^3.1.0", + "eslint": "^7.6.0", + "grunt": "^1.2.1", + "grunt-browserify": "^5.3.0", + "grunt-cli": "^1.3.2", + "grunt-contrib-connect": "^3.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^5.0.0", + "grunt-mocha-istanbul": "^5.0.2", + "grunt-saucelabs": "^9.0.1", + "istanbul": "^0.4.5", + "mocha": "^8.0.1" + }, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }; + var exports$W = {}; + var _dewExec$V = false; + var module$3 = { + exports: exports$W + }; + var _global$6 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$V() { + if (_dewExec$V) + return module$3.exports; + _dewExec$V = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$6).negative = 0; + (this || _global$6).words = null; + (this || _global$6).length = 0; + (this || _global$6).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = buffer3.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$6).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$6).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$6).words = [number3 & 67108863]; + (this || _global$6).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$6).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$6).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$6).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$6).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$6).words = [0]; + (this || _global$6).length = 1; + return this || _global$6; + } + (this || _global$6).length = Math.ceil(number3.length / 3); + (this || _global$6).words = new Array((this || _global$6).length); + for (var i8 = 0; i8 < (this || _global$6).length; i8++) { + (this || _global$6).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$6).words[j5] |= w5 << off & 67108863; + (this || _global$6).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$6).words[j5] |= w5 << off & 67108863; + (this || _global$6).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$6).length = Math.ceil((number3.length - start) / 6); + (this || _global$6).words = new Array((this || _global$6).length); + for (var i8 = 0; i8 < (this || _global$6).length; i8++) { + (this || _global$6).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$6).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$6).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$6).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$6).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$6).words = [0]; + (this || _global$6).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$6).words[0] + word < 67108864) { + (this || _global$6).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$6).words[0] + word < 67108864) { + (this || _global$6).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$6).length); + for (var i8 = 0; i8 < (this || _global$6).length; i8++) { + dest.words[i8] = (this || _global$6).words[i8]; + } + dest.length = (this || _global$6).length; + dest.negative = (this || _global$6).negative; + dest.red = (this || _global$6).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$6).length < size4) { + (this || _global$6).words[(this || _global$6).length++] = 0; + } + return this || _global$6; + }; + BN.prototype.strip = function strip() { + while ((this || _global$6).length > 1 && (this || _global$6).words[(this || _global$6).length - 1] === 0) { + (this || _global$6).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$6).length === 1 && (this || _global$6).words[0] === 0) { + (this || _global$6).negative = 0; + } + return this || _global$6; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$6).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$6).length; i8++) { + var w5 = (this || _global$6).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$6).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$6).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$6).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$6).words[0]; + if ((this || _global$6).length === 2) { + ret += (this || _global$6).words[1] * 67108864; + } else if ((this || _global$6).length === 3 && (this || _global$6).words[2] === 1) { + ret += 4503599627370496 + (this || _global$6).words[1] * 67108864; + } else if ((this || _global$6).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$6).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$6).words[(this || _global$6).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$6).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$6).length; i8++) { + var b6 = this._zeroBits((this || _global$6).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$6).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$6).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$6).negative ^= 1; + } + return this || _global$6; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$6).length < num.length) { + (this || _global$6).words[(this || _global$6).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$6).words[i8] = (this || _global$6).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$6).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$6).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$6); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$6).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$6); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$6).length > num.length) { + b6 = num; + } else { + b6 = this || _global$6; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$6).words[i8] = (this || _global$6).words[i8] & num.words[i8]; + } + (this || _global$6).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$6).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$6).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$6); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$6).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$6); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$6).length > num.length) { + a8 = this || _global$6; + b6 = num; + } else { + a8 = num; + b6 = this || _global$6; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$6).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$6) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$6).words[i8] = a8.words[i8]; + } + } + (this || _global$6).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$6).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$6).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$6); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$6).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$6); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$6).words[i8] = ~(this || _global$6).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$6).words[i8] = ~(this || _global$6).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$6).words[off] = (this || _global$6).words[off] | 1 << wbit; + } else { + (this || _global$6).words[off] = (this || _global$6).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$6).negative !== 0 && num.negative === 0) { + (this || _global$6).negative = 0; + r10 = this.isub(num); + (this || _global$6).negative ^= 1; + return this._normSign(); + } else if ((this || _global$6).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$6).length > num.length) { + a8 = this || _global$6; + b6 = num; + } else { + a8 = num; + b6 = this || _global$6; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$6).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$6).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$6).length = a8.length; + if (carry !== 0) { + (this || _global$6).words[(this || _global$6).length] = carry; + (this || _global$6).length++; + } else if (a8 !== (this || _global$6)) { + for (; i8 < a8.length; i8++) { + (this || _global$6).words[i8] = a8.words[i8]; + } + } + return this || _global$6; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$6).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$6).negative !== 0) { + (this || _global$6).negative = 0; + res = num.sub(this || _global$6); + (this || _global$6).negative = 1; + return res; + } + if ((this || _global$6).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$6); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$6).negative !== 0) { + (this || _global$6).negative = 0; + this.iadd(num); + (this || _global$6).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$6).negative = 0; + (this || _global$6).length = 1; + (this || _global$6).words[0] = 0; + return this || _global$6; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$6; + b6 = num; + } else { + a8 = num; + b6 = this || _global$6; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$6).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$6).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$6)) { + for (; i8 < a8.length; i8++) { + (this || _global$6).words[i8] = a8.words[i8]; + } + } + (this || _global$6).length = Math.max((this || _global$6).length, i8); + if (a8 !== (this || _global$6)) { + (this || _global$6).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$6).length + num.length; + if ((this || _global$6).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$6, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$6, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$6, num, out); + } else { + res = jumboMulTo(this || _global$6, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$6).x = x5; + (this || _global$6).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$6).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$6).length + num.length); + return jumboMulTo(this || _global$6, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$6); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$6).length; i8++) { + var w5 = ((this || _global$6).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$6).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$6).words[i8] = carry; + (this || _global$6).length++; + } + return this || _global$6; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$6); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$6; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$6).length; i8++) { + var newCarry = (this || _global$6).words[i8] & carryMask; + var c8 = ((this || _global$6).words[i8] | 0) - newCarry << r10; + (this || _global$6).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$6).words[i8] = carry; + (this || _global$6).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$6).length - 1; i8 >= 0; i8--) { + (this || _global$6).words[i8 + s7] = (this || _global$6).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$6).words[i8] = 0; + } + (this || _global$6).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$6).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$6).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$6).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$6).length > s7) { + (this || _global$6).length -= s7; + for (i8 = 0; i8 < (this || _global$6).length; i8++) { + (this || _global$6).words[i8] = (this || _global$6).words[i8 + s7]; + } + } else { + (this || _global$6).words[0] = 0; + (this || _global$6).length = 1; + } + var carry = 0; + for (i8 = (this || _global$6).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$6).words[i8] | 0; + (this || _global$6).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$6).length === 0) { + (this || _global$6).words[0] = 0; + (this || _global$6).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$6).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$6).length <= s7) + return false; + var w5 = (this || _global$6).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$6).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$6).length <= s7) { + return this || _global$6; + } + if (r10 !== 0) { + s7++; + } + (this || _global$6).length = Math.min(s7, (this || _global$6).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$6).words[(this || _global$6).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$6).negative !== 0) { + if ((this || _global$6).length === 1 && ((this || _global$6).words[0] | 0) < num) { + (this || _global$6).words[0] = num - ((this || _global$6).words[0] | 0); + (this || _global$6).negative = 0; + return this || _global$6; + } + (this || _global$6).negative = 0; + this.isubn(num); + (this || _global$6).negative = 1; + return this || _global$6; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$6).words[0] += num; + for (var i8 = 0; i8 < (this || _global$6).length && (this || _global$6).words[i8] >= 67108864; i8++) { + (this || _global$6).words[i8] -= 67108864; + if (i8 === (this || _global$6).length - 1) { + (this || _global$6).words[i8 + 1] = 1; + } else { + (this || _global$6).words[i8 + 1]++; + } + } + (this || _global$6).length = Math.max((this || _global$6).length, i8 + 1); + return this || _global$6; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$6).negative !== 0) { + (this || _global$6).negative = 0; + this.iaddn(num); + (this || _global$6).negative = 1; + return this || _global$6; + } + (this || _global$6).words[0] -= num; + if ((this || _global$6).length === 1 && (this || _global$6).words[0] < 0) { + (this || _global$6).words[0] = -(this || _global$6).words[0]; + (this || _global$6).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$6).length && (this || _global$6).words[i8] < 0; i8++) { + (this || _global$6).words[i8] += 67108864; + (this || _global$6).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$6).negative = 0; + return this || _global$6; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$6).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$6).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$6).length - shift; i8++) { + w5 = ((this || _global$6).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$6).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$6).length; i8++) { + w5 = -((this || _global$6).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$6).words[i8] = w5 & 67108863; + } + (this || _global$6).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$6).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$6).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$6).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$6).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$6).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$6 + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$6).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$6).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$6).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$6).words[i8] | 0) + carry * 67108864; + (this || _global$6).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$6; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$6; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$6).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$6).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$6).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$6).length <= s7) { + this._expand(s7 + 1); + (this || _global$6).words[s7] |= q4; + return this || _global$6; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$6).length; i8++) { + var w5 = (this || _global$6).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$6).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$6).words[i8] = carry; + (this || _global$6).length++; + } + return this || _global$6; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$6).length === 1 && (this || _global$6).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$6).negative !== 0 && !negative) + return -1; + if ((this || _global$6).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$6).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$6).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$6).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$6).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$6).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$6).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$6).length > num.length) + return 1; + if ((this || _global$6).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$6).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$6).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$6).red, "Already a number in reduction context"); + assert((this || _global$6).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$6)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$6).red, "fromRed works only with numbers in reduction context"); + return (this || _global$6).red.convertFrom(this || _global$6); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$6).red = ctx; + return this || _global$6; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$6).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$6).red, "redAdd works only with red numbers"); + return (this || _global$6).red.add(this || _global$6, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$6).red, "redIAdd works only with red numbers"); + return (this || _global$6).red.iadd(this || _global$6, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$6).red, "redSub works only with red numbers"); + return (this || _global$6).red.sub(this || _global$6, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$6).red, "redISub works only with red numbers"); + return (this || _global$6).red.isub(this || _global$6, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$6).red, "redShl works only with red numbers"); + return (this || _global$6).red.shl(this || _global$6, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$6).red, "redMul works only with red numbers"); + (this || _global$6).red._verify2(this || _global$6, num); + return (this || _global$6).red.mul(this || _global$6, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$6).red, "redMul works only with red numbers"); + (this || _global$6).red._verify2(this || _global$6, num); + return (this || _global$6).red.imul(this || _global$6, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$6).red, "redSqr works only with red numbers"); + (this || _global$6).red._verify1(this || _global$6); + return (this || _global$6).red.sqr(this || _global$6); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$6).red, "redISqr works only with red numbers"); + (this || _global$6).red._verify1(this || _global$6); + return (this || _global$6).red.isqr(this || _global$6); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$6).red, "redSqrt works only with red numbers"); + (this || _global$6).red._verify1(this || _global$6); + return (this || _global$6).red.sqrt(this || _global$6); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$6).red, "redInvm works only with red numbers"); + (this || _global$6).red._verify1(this || _global$6); + return (this || _global$6).red.invm(this || _global$6); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$6).red, "redNeg works only with red numbers"); + (this || _global$6).red._verify1(this || _global$6); + return (this || _global$6).red.neg(this || _global$6); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$6).red && !num.red, "redPow(normalNum)"); + (this || _global$6).red._verify1(this || _global$6); + return (this || _global$6).red.pow(this || _global$6, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$6).name = name15; + (this || _global$6).p = new BN(p8, 16); + (this || _global$6).n = (this || _global$6).p.bitLength(); + (this || _global$6).k = new BN(1).iushln((this || _global$6).n).isub((this || _global$6).p); + (this || _global$6).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$6).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$6).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$6).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$6).n); + var cmp = rlen < (this || _global$6).n ? -1 : r10.ucmp((this || _global$6).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$6).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$6).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$6).k); + }; + function K256() { + MPrime.call(this || _global$6, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$6, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$6, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$6, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$6).m = prime.p; + (this || _global$6).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$6).m = m7; + (this || _global$6).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$6).prime) + return (this || _global$6).prime.ireduce(a8)._forceRed(this || _global$6); + return a8.umod((this || _global$6).m)._forceRed(this || _global$6); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$6).m.sub(a8)._forceRed(this || _global$6); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$6).m) >= 0) { + res.isub((this || _global$6).m); + } + return res._forceRed(this || _global$6); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$6).m) >= 0) { + res.isub((this || _global$6).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$6).m); + } + return res._forceRed(this || _global$6); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$6).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$6).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$6).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$6).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$6); + var nOne = one.redNeg(); + var lpow = (this || _global$6).m.subn(1).iushrn(1); + var z6 = (this || _global$6).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$6); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$6).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$6); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$6); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$6).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$6, m7); + (this || _global$6).shift = (this || _global$6).m.bitLength(); + if ((this || _global$6).shift % 26 !== 0) { + (this || _global$6).shift += 26 - (this || _global$6).shift % 26; + } + (this || _global$6).r = new BN(1).iushln((this || _global$6).shift); + (this || _global$6).r2 = this.imod((this || _global$6).r.sqr()); + (this || _global$6).rinv = (this || _global$6).r._invmp((this || _global$6).m); + (this || _global$6).minv = (this || _global$6).rinv.mul((this || _global$6).r).isubn(1).div((this || _global$6).m); + (this || _global$6).minv = (this || _global$6).minv.umod((this || _global$6).r); + (this || _global$6).minv = (this || _global$6).r.sub((this || _global$6).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$6).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$6).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$6).shift).mul((this || _global$6).minv).imaskn((this || _global$6).shift).mul((this || _global$6).m); + var u8 = t9.isub(c8).iushrn((this || _global$6).shift); + var res = u8; + if (u8.cmp((this || _global$6).m) >= 0) { + res = u8.isub((this || _global$6).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$6).m); + } + return res._forceRed(this || _global$6); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$6); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$6).shift).mul((this || _global$6).minv).imaskn((this || _global$6).shift).mul((this || _global$6).m); + var u8 = t9.isub(c8).iushrn((this || _global$6).shift); + var res = u8; + if (u8.cmp((this || _global$6).m) >= 0) { + res = u8.isub((this || _global$6).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$6).m); + } + return res._forceRed(this || _global$6); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$6).m).mul((this || _global$6).r2)); + return res._forceRed(this || _global$6); + }; + })(module$3, exports$W); + return module$3.exports; + } + var exports$V = {}; + var _dewExec$U = false; + function dew$U() { + if (_dewExec$U) + return exports$V; + _dewExec$U = true; + var utils2 = exports$V; + function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg !== "string") { + for (var i8 = 0; i8 < msg.length; i8++) + res[i8] = msg[i8] | 0; + return res; + } + if (enc === "hex") { + msg = msg.replace(/[^a-z0-9]+/ig, ""); + if (msg.length % 2 !== 0) + msg = "0" + msg; + for (var i8 = 0; i8 < msg.length; i8 += 2) + res.push(parseInt(msg[i8] + msg[i8 + 1], 16)); + } else { + for (var i8 = 0; i8 < msg.length; i8++) { + var c8 = msg.charCodeAt(i8); + var hi = c8 >> 8; + var lo = c8 & 255; + if (hi) + res.push(hi, lo); + else + res.push(lo); + } + } + return res; + } + utils2.toArray = toArray; + function zero2(word) { + if (word.length === 1) + return "0" + word; + else + return word; + } + utils2.zero2 = zero2; + function toHex2(msg) { + var res = ""; + for (var i8 = 0; i8 < msg.length; i8++) + res += zero2(msg[i8].toString(16)); + return res; + } + utils2.toHex = toHex2; + utils2.encode = function encode41(arr, enc) { + if (enc === "hex") + return toHex2(arr); + else + return arr; + }; + return exports$V; + } + var exports$U = {}; + var _dewExec$T = false; + function dew$T() { + if (_dewExec$T) + return exports$U; + _dewExec$T = true; + var utils2 = exports$U; + var BN = dew$V(); + var minAssert = dew$2m(); + var minUtils = dew$U(); + utils2.assert = minAssert; + utils2.toArray = minUtils.toArray; + utils2.zero2 = minUtils.zero2; + utils2.toHex = minUtils.toHex; + utils2.encode = minUtils.encode; + function getNAF(num, w5, bits) { + var naf = new Array(Math.max(num.bitLength(), bits) + 1); + naf.fill(0); + var ws2 = 1 << w5 + 1; + var k5 = num.clone(); + for (var i8 = 0; i8 < naf.length; i8++) { + var z6; + var mod3 = k5.andln(ws2 - 1); + if (k5.isOdd()) { + if (mod3 > (ws2 >> 1) - 1) + z6 = (ws2 >> 1) - mod3; + else + z6 = mod3; + k5.isubn(z6); + } else { + z6 = 0; + } + naf[i8] = z6; + k5.iushrn(1); + } + return naf; + } + utils2.getNAF = getNAF; + function getJSF(k1, k22) { + var jsf = [[], []]; + k1 = k1.clone(); + k22 = k22.clone(); + var d1 = 0; + var d22 = 0; + var m8; + while (k1.cmpn(-d1) > 0 || k22.cmpn(-d22) > 0) { + var m14 = k1.andln(3) + d1 & 3; + var m24 = k22.andln(3) + d22 & 3; + if (m14 === 3) + m14 = -1; + if (m24 === 3) + m24 = -1; + var u1; + if ((m14 & 1) === 0) { + u1 = 0; + } else { + m8 = k1.andln(7) + d1 & 7; + if ((m8 === 3 || m8 === 5) && m24 === 2) + u1 = -m14; + else + u1 = m14; + } + jsf[0].push(u1); + var u22; + if ((m24 & 1) === 0) { + u22 = 0; + } else { + m8 = k22.andln(7) + d22 & 7; + if ((m8 === 3 || m8 === 5) && m14 === 2) + u22 = -m24; + else + u22 = m24; + } + jsf[1].push(u22); + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d22 === u22 + 1) + d22 = 1 - d22; + k1.iushrn(1); + k22.iushrn(1); + } + return jsf; + } + utils2.getJSF = getJSF; + function cachedProperty(obj, name15, computer) { + var key = "_" + name15; + obj.prototype[name15] = function cachedProperty2() { + return this[key] !== void 0 ? this[key] : this[key] = computer.call(this); + }; + } + utils2.cachedProperty = cachedProperty; + function parseBytes(bytes2) { + return typeof bytes2 === "string" ? utils2.toArray(bytes2, "hex") : bytes2; + } + utils2.parseBytes = parseBytes; + function intFromLE(bytes2) { + return new BN(bytes2, "hex", "le"); + } + utils2.intFromLE = intFromLE; + return exports$U; + } + var exports$T = {}; + var _dewExec$S = false; + function dew$S() { + if (_dewExec$S) + return exports$T; + _dewExec$S = true; + var BN = dew$V(); + var utils2 = dew$T(); + var getNAF = utils2.getNAF; + var getJSF = utils2.getJSF; + var assert = utils2.assert; + function BaseCurve(type3, conf) { + this.type = type3; + this.p = new BN(conf.p, 16); + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + this.zero = new BN(0).toRed(this.red); + this.one = new BN(1).toRed(this.red); + this.two = new BN(2).toRed(this.red); + this.n = conf.n && new BN(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + this._wnafT1 = new Array(4); + this._wnafT2 = new Array(4); + this._wnafT3 = new Array(4); + this._wnafT4 = new Array(4); + this._bitLength = this.n ? this.n.bitLength() : 0; + var adjustCount = this.n && this.p.div(this.n); + if (!adjustCount || adjustCount.cmpn(100) > 0) { + this.redN = null; + } else { + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); + } + } + exports$T = BaseCurve; + BaseCurve.prototype.point = function point() { + throw new Error("Not implemented"); + }; + BaseCurve.prototype.validate = function validate3() { + throw new Error("Not implemented"); + }; + BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p8, k5) { + assert(p8.precomputed); + var doubles = p8._getDoubles(); + var naf = getNAF(k5, 1, this._bitLength); + var I5 = (1 << doubles.step + 1) - (doubles.step % 2 === 0 ? 2 : 1); + I5 /= 3; + var repr = []; + var j5; + var nafW; + for (j5 = 0; j5 < naf.length; j5 += doubles.step) { + nafW = 0; + for (var l8 = j5 + doubles.step - 1; l8 >= j5; l8--) + nafW = (nafW << 1) + naf[l8]; + repr.push(nafW); + } + var a8 = this.jpoint(null, null, null); + var b6 = this.jpoint(null, null, null); + for (var i8 = I5; i8 > 0; i8--) { + for (j5 = 0; j5 < repr.length; j5++) { + nafW = repr[j5]; + if (nafW === i8) + b6 = b6.mixedAdd(doubles.points[j5]); + else if (nafW === -i8) + b6 = b6.mixedAdd(doubles.points[j5].neg()); + } + a8 = a8.add(b6); + } + return a8.toP(); + }; + BaseCurve.prototype._wnafMul = function _wnafMul(p8, k5) { + var w5 = 4; + var nafPoints = p8._getNAFPoints(w5); + w5 = nafPoints.wnd; + var wnd = nafPoints.points; + var naf = getNAF(k5, w5, this._bitLength); + var acc = this.jpoint(null, null, null); + for (var i8 = naf.length - 1; i8 >= 0; i8--) { + for (var l8 = 0; i8 >= 0 && naf[i8] === 0; i8--) + l8++; + if (i8 >= 0) + l8++; + acc = acc.dblp(l8); + if (i8 < 0) + break; + var z6 = naf[i8]; + assert(z6 !== 0); + if (p8.type === "affine") { + if (z6 > 0) + acc = acc.mixedAdd(wnd[z6 - 1 >> 1]); + else + acc = acc.mixedAdd(wnd[-z6 - 1 >> 1].neg()); + } else { + if (z6 > 0) + acc = acc.add(wnd[z6 - 1 >> 1]); + else + acc = acc.add(wnd[-z6 - 1 >> 1].neg()); + } + } + return p8.type === "affine" ? acc.toP() : acc; + }; + BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, points, coeffs, len, jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; + var max = 0; + var i8; + var j5; + var p8; + for (i8 = 0; i8 < len; i8++) { + p8 = points[i8]; + var nafPoints = p8._getNAFPoints(defW); + wndWidth[i8] = nafPoints.wnd; + wnd[i8] = nafPoints.points; + } + for (i8 = len - 1; i8 >= 1; i8 -= 2) { + var a8 = i8 - 1; + var b6 = i8; + if (wndWidth[a8] !== 1 || wndWidth[b6] !== 1) { + naf[a8] = getNAF(coeffs[a8], wndWidth[a8], this._bitLength); + naf[b6] = getNAF(coeffs[b6], wndWidth[b6], this._bitLength); + max = Math.max(naf[a8].length, max); + max = Math.max(naf[b6].length, max); + continue; + } + var comb = [ + points[a8], + /* 1 */ + null, + /* 3 */ + null, + /* 5 */ + points[b6] + /* 7 */ + ]; + if (points[a8].y.cmp(points[b6].y) === 0) { + comb[1] = points[a8].add(points[b6]); + comb[2] = points[a8].toJ().mixedAdd(points[b6].neg()); + } else if (points[a8].y.cmp(points[b6].y.redNeg()) === 0) { + comb[1] = points[a8].toJ().mixedAdd(points[b6]); + comb[2] = points[a8].add(points[b6].neg()); + } else { + comb[1] = points[a8].toJ().mixedAdd(points[b6]); + comb[2] = points[a8].toJ().mixedAdd(points[b6].neg()); + } + var index2 = [ + -3, + /* -1 -1 */ + -1, + /* -1 0 */ + -5, + /* -1 1 */ + -7, + /* 0 -1 */ + 0, + /* 0 0 */ + 7, + /* 0 1 */ + 5, + /* 1 -1 */ + 1, + /* 1 0 */ + 3 + /* 1 1 */ + ]; + var jsf = getJSF(coeffs[a8], coeffs[b6]); + max = Math.max(jsf[0].length, max); + naf[a8] = new Array(max); + naf[b6] = new Array(max); + for (j5 = 0; j5 < max; j5++) { + var ja = jsf[0][j5] | 0; + var jb = jsf[1][j5] | 0; + naf[a8][j5] = index2[(ja + 1) * 3 + (jb + 1)]; + naf[b6][j5] = 0; + wnd[a8] = comb; + } + } + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (i8 = max; i8 >= 0; i8--) { + var k5 = 0; + while (i8 >= 0) { + var zero2 = true; + for (j5 = 0; j5 < len; j5++) { + tmp[j5] = naf[j5][i8] | 0; + if (tmp[j5] !== 0) + zero2 = false; + } + if (!zero2) + break; + k5++; + i8--; + } + if (i8 >= 0) + k5++; + acc = acc.dblp(k5); + if (i8 < 0) + break; + for (j5 = 0; j5 < len; j5++) { + var z6 = tmp[j5]; + if (z6 === 0) + continue; + else if (z6 > 0) + p8 = wnd[j5][z6 - 1 >> 1]; + else if (z6 < 0) + p8 = wnd[j5][-z6 - 1 >> 1].neg(); + if (p8.type === "affine") + acc = acc.mixedAdd(p8); + else + acc = acc.add(p8); + } + } + for (i8 = 0; i8 < len; i8++) + wnd[i8] = null; + if (jacobianResult) + return acc; + else + return acc.toP(); + }; + function BasePoint(curve, type3) { + this.curve = curve; + this.type = type3; + this.precomputed = null; + } + BaseCurve.BasePoint = BasePoint; + BasePoint.prototype.eq = function eq() { + throw new Error("Not implemented"); + }; + BasePoint.prototype.validate = function validate3() { + return this.curve.validate(this); + }; + BaseCurve.prototype.decodePoint = function decodePoint(bytes2, enc) { + bytes2 = utils2.toArray(bytes2, enc); + var len = this.p.byteLength(); + if ((bytes2[0] === 4 || bytes2[0] === 6 || bytes2[0] === 7) && bytes2.length - 1 === 2 * len) { + if (bytes2[0] === 6) + assert(bytes2[bytes2.length - 1] % 2 === 0); + else if (bytes2[0] === 7) + assert(bytes2[bytes2.length - 1] % 2 === 1); + var res = this.point(bytes2.slice(1, 1 + len), bytes2.slice(1 + len, 1 + 2 * len)); + return res; + } else if ((bytes2[0] === 2 || bytes2[0] === 3) && bytes2.length - 1 === len) { + return this.pointFromX(bytes2.slice(1, 1 + len), bytes2[0] === 3); + } + throw new Error("Unknown point format"); + }; + BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); + }; + BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x5 = this.getX().toArray("be", len); + if (compact) + return [this.getY().isEven() ? 2 : 3].concat(x5); + return [4].concat(x5, this.getY().toArray("be", len)); + }; + BasePoint.prototype.encode = function encode41(enc, compact) { + return utils2.encode(this._encode(compact), enc); + }; + BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; + var precomputed = { + doubles: null, + naf: null, + beta: null + }; + precomputed.naf = this._getNAFPoints(8); + precomputed.doubles = this._getDoubles(4, power); + precomputed.beta = this._getBeta(); + this.precomputed = precomputed; + return this; + }; + BasePoint.prototype._hasDoubles = function _hasDoubles(k5) { + if (!this.precomputed) + return false; + var doubles = this.precomputed.doubles; + if (!doubles) + return false; + return doubles.points.length >= Math.ceil((k5.bitLength() + 1) / doubles.step); + }; + BasePoint.prototype._getDoubles = function _getDoubles(step2, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + var doubles = [this]; + var acc = this; + for (var i8 = 0; i8 < power; i8 += step2) { + for (var j5 = 0; j5 < step2; j5++) + acc = acc.dbl(); + doubles.push(acc); + } + return { + step: step2, + points: doubles + }; + }; + BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + var res = [this]; + var max = (1 << wnd) - 1; + var dbl = max === 1 ? null : this.dbl(); + for (var i8 = 1; i8 < max; i8++) + res[i8] = res[i8 - 1].add(dbl); + return { + wnd, + points: res + }; + }; + BasePoint.prototype._getBeta = function _getBeta() { + return null; + }; + BasePoint.prototype.dblp = function dblp(k5) { + var r10 = this; + for (var i8 = 0; i8 < k5; i8++) + r10 = r10.dbl(); + return r10; + }; + return exports$T; + } + var exports$S = {}; + var _dewExec$R = false; + function dew$R() { + if (_dewExec$R) + return exports$S; + _dewExec$R = true; + var utils2 = dew$T(); + var BN = dew$V(); + var inherits3 = dew$f(); + var Base2 = dew$S(); + var assert = utils2.assert; + function ShortCurve(conf) { + Base2.call(this, "short", conf); + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.tinv = this.two.redInvm(); + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + this.endo = this._getEndomorphism(conf); + this._endoWnafT1 = new Array(4); + this._endoWnafT2 = new Array(4); + } + inherits3(ShortCurve, Base2); + exports$S = ShortCurve; + ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; + var beta; + var lambda; + if (conf.beta) { + beta = new BN(conf.beta, 16).toRed(this.red); + } else { + var betas = this._getEndoRoots(this.p); + beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; + beta = beta.toRed(this.red); + } + if (conf.lambda) { + lambda = new BN(conf.lambda, 16); + } else { + var lambdas = this._getEndoRoots(this.n); + if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { + lambda = lambdas[0]; + } else { + lambda = lambdas[1]; + assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); + } + } + var basis; + if (conf.basis) { + basis = conf.basis.map(function(vec) { + return { + a: new BN(vec.a, 16), + b: new BN(vec.b, 16) + }; + }); + } else { + basis = this._getEndoBasis(lambda); + } + return { + beta, + lambda, + basis + }; + }; + ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { + var red = num === this.p ? this.red : BN.mont(num); + var tinv = new BN(2).toRed(red).redInvm(); + var ntinv = tinv.redNeg(); + var s7 = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); + var l1 = ntinv.redAdd(s7).fromRed(); + var l22 = ntinv.redSub(s7).fromRed(); + return [l1, l22]; + }; + ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); + var u8 = lambda; + var v7 = this.n.clone(); + var x1 = new BN(1); + var y1 = new BN(0); + var x22 = new BN(0); + var y22 = new BN(1); + var a0; + var b0; + var a1; + var b1; + var a22; + var b22; + var prevR; + var i8 = 0; + var r10; + var x5; + while (u8.cmpn(0) !== 0) { + var q4 = v7.div(u8); + r10 = v7.sub(q4.mul(u8)); + x5 = x22.sub(q4.mul(x1)); + var y7 = y22.sub(q4.mul(y1)); + if (!a1 && r10.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r10.neg(); + b1 = x5; + } else if (a1 && ++i8 === 2) { + break; + } + prevR = r10; + v7 = u8; + u8 = r10; + x22 = x1; + x1 = x5; + y22 = y1; + y1 = y7; + } + a22 = r10.neg(); + b22 = x5; + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a22.sqr().add(b22.sqr()); + if (len2.cmp(len1) >= 0) { + a22 = a0; + b22 = b0; + } + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a22.negative) { + a22 = a22.neg(); + b22 = b22.neg(); + } + return [{ + a: a1, + b: b1 + }, { + a: a22, + b: b22 + }]; + }; + ShortCurve.prototype._endoSplit = function _endoSplit(k5) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v22 = basis[1]; + var c1 = v22.b.mul(k5).divRound(this.n); + var c22 = v1.b.neg().mul(k5).divRound(this.n); + var p1 = c1.mul(v1.a); + var p22 = c22.mul(v22.a); + var q1 = c1.mul(v1.b); + var q22 = c22.mul(v22.b); + var k1 = k5.sub(p1).sub(p22); + var k22 = q1.add(q22).neg(); + return { + k1, + k2: k22 + }; + }; + ShortCurve.prototype.pointFromX = function pointFromX(x5, odd) { + x5 = new BN(x5, 16); + if (!x5.red) + x5 = x5.toRed(this.red); + var y22 = x5.redSqr().redMul(x5).redIAdd(x5.redMul(this.a)).redIAdd(this.b); + var y7 = y22.redSqrt(); + if (y7.redSqr().redSub(y22).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var isOdd = y7.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y7 = y7.redNeg(); + return this.point(x5, y7); + }; + ShortCurve.prototype.validate = function validate3(point) { + if (point.inf) + return true; + var x5 = point.x; + var y7 = point.y; + var ax = this.a.redMul(x5); + var rhs = x5.redSqr().redMul(x5).redIAdd(ax).redIAdd(this.b); + return y7.redSqr().redISub(rhs).cmpn(0) === 0; + }; + ShortCurve.prototype._endoWnafMulAdd = function _endoWnafMulAdd(points, coeffs, jacobianResult) { + var npoints = this._endoWnafT1; + var ncoeffs = this._endoWnafT2; + for (var i8 = 0; i8 < points.length; i8++) { + var split2 = this._endoSplit(coeffs[i8]); + var p8 = points[i8]; + var beta = p8._getBeta(); + if (split2.k1.negative) { + split2.k1.ineg(); + p8 = p8.neg(true); + } + if (split2.k2.negative) { + split2.k2.ineg(); + beta = beta.neg(true); + } + npoints[i8 * 2] = p8; + npoints[i8 * 2 + 1] = beta; + ncoeffs[i8 * 2] = split2.k1; + ncoeffs[i8 * 2 + 1] = split2.k2; + } + var res = this._wnafMulAdd(1, npoints, ncoeffs, i8 * 2, jacobianResult); + for (var j5 = 0; j5 < i8 * 2; j5++) { + npoints[j5] = null; + ncoeffs[j5] = null; + } + return res; + }; + function Point2(curve, x5, y7, isRed) { + Base2.BasePoint.call(this, curve, "affine"); + if (x5 === null && y7 === null) { + this.x = null; + this.y = null; + this.inf = true; + } else { + this.x = new BN(x5, 16); + this.y = new BN(y7, 16); + if (isRed) { + this.x.forceRed(this.curve.red); + this.y.forceRed(this.curve.red); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + this.inf = false; + } + } + inherits3(Point2, Base2.BasePoint); + ShortCurve.prototype.point = function point(x5, y7, isRed) { + return new Point2(this, x5, y7, isRed); + }; + ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point2.fromJSON(this, obj, red); + }; + Point2.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; + var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (pre) { + var curve = this.curve; + var endoMul = function(p8) { + return curve.point(p8.x.redMul(curve.endo.beta), p8.y); + }; + pre.beta = beta; + beta.precomputed = { + beta: null, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(endoMul) + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(endoMul) + } + }; + } + return beta; + }; + Point2.prototype.toJSON = function toJSON4() { + if (!this.precomputed) + return [this.x, this.y]; + return [this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1) + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1) + } + }]; + }; + Point2.fromJSON = function fromJSON3(curve, obj, red) { + if (typeof obj === "string") + obj = JSON.parse(obj); + var res = curve.point(obj[0], obj[1], red); + if (!obj[2]) + return res; + function obj2point(obj2) { + return curve.point(obj2[0], obj2[1], red); + } + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [res].concat(pre.doubles.points.map(obj2point)) + }, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [res].concat(pre.naf.points.map(obj2point)) + } + }; + return res; + }; + Point2.prototype.inspect = function inspect3() { + if (this.isInfinity()) + return ""; + return ""; + }; + Point2.prototype.isInfinity = function isInfinity() { + return this.inf; + }; + Point2.prototype.add = function add12(p8) { + if (this.inf) + return p8; + if (p8.inf) + return this; + if (this.eq(p8)) + return this.dbl(); + if (this.neg().eq(p8)) + return this.curve.point(null, null); + if (this.x.cmp(p8.x) === 0) + return this.curve.point(null, null); + var c8 = this.y.redSub(p8.y); + if (c8.cmpn(0) !== 0) + c8 = c8.redMul(this.x.redSub(p8.x).redInvm()); + var nx = c8.redSqr().redISub(this.x).redISub(p8.x); + var ny = c8.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); + }; + Point2.prototype.dbl = function dbl() { + if (this.inf) + return this; + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); + var a8 = this.curve.a; + var x22 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c8 = x22.redAdd(x22).redIAdd(x22).redIAdd(a8).redMul(dyinv); + var nx = c8.redSqr().redISub(this.x.redAdd(this.x)); + var ny = c8.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); + }; + Point2.prototype.getX = function getX() { + return this.x.fromRed(); + }; + Point2.prototype.getY = function getY() { + return this.y.fromRed(); + }; + Point2.prototype.mul = function mul(k5) { + k5 = new BN(k5, 16); + if (this.isInfinity()) + return this; + else if (this._hasDoubles(k5)) + return this.curve._fixedNafMul(this, k5); + else if (this.curve.endo) + return this.curve._endoWnafMulAdd([this], [k5]); + else + return this.curve._wnafMul(this, k5); + }; + Point2.prototype.mulAdd = function mulAdd(k1, p22, k22) { + var points = [this, p22]; + var coeffs = [k1, k22]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2); + }; + Point2.prototype.jmulAdd = function jmulAdd(k1, p22, k22) { + var points = [this, p22]; + var coeffs = [k1, k22]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs, true); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); + }; + Point2.prototype.eq = function eq(p8) { + return this === p8 || this.inf === p8.inf && (this.inf || this.x.cmp(p8.x) === 0 && this.y.cmp(p8.y) === 0); + }; + Point2.prototype.neg = function neg(_precompute) { + if (this.inf) + return this; + var res = this.curve.point(this.x, this.y.redNeg()); + if (_precompute && this.precomputed) { + var pre = this.precomputed; + var negate = function(p8) { + return p8.neg(); + }; + res.precomputed = { + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(negate) + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(negate) + } + }; + } + return res; + }; + Point2.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; + }; + function JPoint(curve, x5, y7, z6) { + Base2.BasePoint.call(this, curve, "jacobian"); + if (x5 === null && y7 === null && z6 === null) { + this.x = this.curve.one; + this.y = this.curve.one; + this.z = new BN(0); + } else { + this.x = new BN(x5, 16); + this.y = new BN(y7, 16); + this.z = new BN(z6, 16); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + this.zOne = this.z === this.curve.one; + } + inherits3(JPoint, Base2.BasePoint); + ShortCurve.prototype.jpoint = function jpoint(x5, y7, z6) { + return new JPoint(this, x5, y7, z6); + }; + JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); + return this.curve.point(ax, ay); + }; + JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); + }; + JPoint.prototype.add = function add12(p8) { + if (this.isInfinity()) + return p8; + if (p8.isInfinity()) + return this; + var pz2 = p8.z.redSqr(); + var z22 = this.z.redSqr(); + var u1 = this.x.redMul(pz2); + var u22 = p8.x.redMul(z22); + var s1 = this.y.redMul(pz2.redMul(p8.z)); + var s22 = p8.y.redMul(z22.redMul(this.z)); + var h9 = u1.redSub(u22); + var r10 = s1.redSub(s22); + if (h9.cmpn(0) === 0) { + if (r10.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + var h22 = h9.redSqr(); + var h32 = h22.redMul(h9); + var v7 = u1.redMul(h22); + var nx = r10.redSqr().redIAdd(h32).redISub(v7).redISub(v7); + var ny = r10.redMul(v7.redISub(nx)).redISub(s1.redMul(h32)); + var nz = this.z.redMul(p8.z).redMul(h9); + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype.mixedAdd = function mixedAdd(p8) { + if (this.isInfinity()) + return p8.toJ(); + if (p8.isInfinity()) + return this; + var z22 = this.z.redSqr(); + var u1 = this.x; + var u22 = p8.x.redMul(z22); + var s1 = this.y; + var s22 = p8.y.redMul(z22).redMul(this.z); + var h9 = u1.redSub(u22); + var r10 = s1.redSub(s22); + if (h9.cmpn(0) === 0) { + if (r10.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + var h22 = h9.redSqr(); + var h32 = h22.redMul(h9); + var v7 = u1.redMul(h22); + var nx = r10.redSqr().redIAdd(h32).redISub(v7).redISub(v7); + var ny = r10.redMul(v7.redISub(nx)).redISub(s1.redMul(h32)); + var nz = this.z.redMul(h9); + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); + var i8; + if (this.curve.zeroA || this.curve.threeA) { + var r10 = this; + for (i8 = 0; i8 < pow; i8++) + r10 = r10.dbl(); + return r10; + } + var a8 = this.curve.a; + var tinv = this.curve.tinv; + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + var jyd = jy.redAdd(jy); + for (i8 = 0; i8 < pow; i8++) { + var jx2 = jx.redSqr(); + var jyd2 = jyd.redSqr(); + var jyd4 = jyd2.redSqr(); + var c8 = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a8.redMul(jz4)); + var t1 = jx.redMul(jyd2); + var nx = c8.redSqr().redISub(t1.redAdd(t1)); + var t22 = t1.redISub(nx); + var dny = c8.redMul(t22); + dny = dny.redIAdd(dny).redISub(jyd4); + var nz = jyd.redMul(jz); + if (i8 + 1 < pow) + jz4 = jz4.redMul(jyd4); + jx = nx; + jz = nz; + jyd = dny; + } + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); + }; + JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); + else + return this._dbl(); + }; + JPoint.prototype._zeroDbl = function _zeroDbl() { + var nx; + var ny; + var nz; + if (this.zOne) { + var xx = this.x.redSqr(); + var yy = this.y.redSqr(); + var yyyy = yy.redSqr(); + var s7 = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s7 = s7.redIAdd(s7); + var m7 = xx.redAdd(xx).redIAdd(xx); + var t9 = m7.redSqr().redISub(s7).redISub(s7); + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + nx = t9; + ny = m7.redMul(s7.redISub(t9)).redISub(yyyy8); + nz = this.y.redAdd(this.y); + } else { + var a8 = this.x.redSqr(); + var b6 = this.y.redSqr(); + var c8 = b6.redSqr(); + var d7 = this.x.redAdd(b6).redSqr().redISub(a8).redISub(c8); + d7 = d7.redIAdd(d7); + var e12 = a8.redAdd(a8).redIAdd(a8); + var f9 = e12.redSqr(); + var c82 = c8.redIAdd(c8); + c82 = c82.redIAdd(c82); + c82 = c82.redIAdd(c82); + nx = f9.redISub(d7).redISub(d7); + ny = e12.redMul(d7.redISub(nx)).redISub(c82); + nz = this.y.redMul(this.z); + nz = nz.redIAdd(nz); + } + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype._threeDbl = function _threeDbl() { + var nx; + var ny; + var nz; + if (this.zOne) { + var xx = this.x.redSqr(); + var yy = this.y.redSqr(); + var yyyy = yy.redSqr(); + var s7 = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s7 = s7.redIAdd(s7); + var m7 = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); + var t9 = m7.redSqr().redISub(s7).redISub(s7); + nx = t9; + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + ny = m7.redMul(s7.redISub(t9)).redISub(yyyy8); + nz = this.y.redAdd(this.y); + } else { + var delta = this.z.redSqr(); + var gamma = this.y.redSqr(); + var beta = this.x.redMul(gamma); + var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); + alpha = alpha.redAdd(alpha).redIAdd(alpha); + var beta4 = beta.redIAdd(beta); + beta4 = beta4.redIAdd(beta4); + var beta8 = beta4.redAdd(beta4); + nx = alpha.redSqr().redISub(beta8); + nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); + var ggamma8 = gamma.redSqr(); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); + } + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype._dbl = function _dbl() { + var a8 = this.curve.a; + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); + var c8 = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a8.redMul(jz4)); + var jxd4 = jx.redAdd(jx); + jxd4 = jxd4.redIAdd(jxd4); + var t1 = jxd4.redMul(jy2); + var nx = c8.redSqr().redISub(t1.redAdd(t1)); + var t22 = t1.redISub(nx); + var jyd8 = jy2.redSqr(); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + var ny = c8.redMul(t22).redISub(jyd8); + var nz = jy.redAdd(jy).redMul(jz); + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var xx = this.x.redSqr(); + var yy = this.y.redSqr(); + var zz = this.z.redSqr(); + var yyyy = yy.redSqr(); + var m7 = xx.redAdd(xx).redIAdd(xx); + var mm = m7.redSqr(); + var e12 = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + e12 = e12.redIAdd(e12); + e12 = e12.redAdd(e12).redIAdd(e12); + e12 = e12.redISub(mm); + var ee3 = e12.redSqr(); + var t9 = yyyy.redIAdd(yyyy); + t9 = t9.redIAdd(t9); + t9 = t9.redIAdd(t9); + t9 = t9.redIAdd(t9); + var u8 = m7.redIAdd(e12).redSqr().redISub(mm).redISub(ee3).redISub(t9); + var yyu4 = yy.redMul(u8); + yyu4 = yyu4.redIAdd(yyu4); + yyu4 = yyu4.redIAdd(yyu4); + var nx = this.x.redMul(ee3).redISub(yyu4); + nx = nx.redIAdd(nx); + nx = nx.redIAdd(nx); + var ny = this.y.redMul(u8.redMul(t9.redISub(u8)).redISub(e12.redMul(ee3))); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + var nz = this.z.redAdd(e12).redSqr().redISub(zz).redISub(ee3); + return this.curve.jpoint(nx, ny, nz); + }; + JPoint.prototype.mul = function mul(k5, kbase) { + k5 = new BN(k5, kbase); + return this.curve._wnafMul(this, k5); + }; + JPoint.prototype.eq = function eq(p8) { + if (p8.type === "affine") + return this.eq(p8.toJ()); + if (this === p8) + return true; + var z22 = this.z.redSqr(); + var pz2 = p8.z.redSqr(); + if (this.x.redMul(pz2).redISub(p8.x.redMul(z22)).cmpn(0) !== 0) + return false; + var z32 = z22.redMul(this.z); + var pz3 = pz2.redMul(p8.z); + return this.y.redMul(pz3).redISub(p8.y.redMul(z32)).cmpn(0) === 0; + }; + JPoint.prototype.eqXToP = function eqXToP(x5) { + var zs = this.z.redSqr(); + var rx = x5.toRed(this.curve.red).redMul(zs); + if (this.x.cmp(rx) === 0) + return true; + var xc = x5.clone(); + var t9 = this.curve.redN.redMul(zs); + for (; ; ) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + rx.redIAdd(t9); + if (this.x.cmp(rx) === 0) + return true; + } + }; + JPoint.prototype.inspect = function inspect3() { + if (this.isInfinity()) + return ""; + return ""; + }; + JPoint.prototype.isInfinity = function isInfinity() { + return this.z.cmpn(0) === 0; + }; + return exports$S; + } + var exports$R = {}; + var _dewExec$Q = false; + function dew$Q() { + if (_dewExec$Q) + return exports$R; + _dewExec$Q = true; + var BN = dew$V(); + var inherits3 = dew$f(); + var Base2 = dew$S(); + var utils2 = dew$T(); + function MontCurve(conf) { + Base2.call(this, "mont", conf); + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.i4 = new BN(4).toRed(this.red).redInvm(); + this.two = new BN(2).toRed(this.red); + this.a24 = this.i4.redMul(this.a.redAdd(this.two)); + } + inherits3(MontCurve, Base2); + exports$R = MontCurve; + MontCurve.prototype.validate = function validate3(point) { + var x5 = point.normalize().x; + var x22 = x5.redSqr(); + var rhs = x22.redMul(x5).redAdd(x22.redMul(this.a)).redAdd(x5); + var y7 = rhs.redSqrt(); + return y7.redSqr().cmp(rhs) === 0; + }; + function Point2(curve, x5, z6) { + Base2.BasePoint.call(this, curve, "projective"); + if (x5 === null && z6 === null) { + this.x = this.curve.one; + this.z = this.curve.zero; + } else { + this.x = new BN(x5, 16); + this.z = new BN(z6, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + } + } + inherits3(Point2, Base2.BasePoint); + MontCurve.prototype.decodePoint = function decodePoint(bytes2, enc) { + return this.point(utils2.toArray(bytes2, enc), 1); + }; + MontCurve.prototype.point = function point(x5, z6) { + return new Point2(this, x5, z6); + }; + MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point2.fromJSON(this, obj); + }; + Point2.prototype.precompute = function precompute() { + }; + Point2.prototype._encode = function _encode() { + return this.getX().toArray("be", this.curve.p.byteLength()); + }; + Point2.fromJSON = function fromJSON3(curve, obj) { + return new Point2(curve, obj[0], obj[1] || curve.one); + }; + Point2.prototype.inspect = function inspect3() { + if (this.isInfinity()) + return ""; + return ""; + }; + Point2.prototype.isInfinity = function isInfinity() { + return this.z.cmpn(0) === 0; + }; + Point2.prototype.dbl = function dbl() { + var a8 = this.x.redAdd(this.z); + var aa = a8.redSqr(); + var b6 = this.x.redSub(this.z); + var bb = b6.redSqr(); + var c8 = aa.redSub(bb); + var nx = aa.redMul(bb); + var nz = c8.redMul(bb.redAdd(this.curve.a24.redMul(c8))); + return this.curve.point(nx, nz); + }; + Point2.prototype.add = function add12() { + throw new Error("Not supported on Montgomery curve"); + }; + Point2.prototype.diffAdd = function diffAdd(p8, diff) { + var a8 = this.x.redAdd(this.z); + var b6 = this.x.redSub(this.z); + var c8 = p8.x.redAdd(p8.z); + var d7 = p8.x.redSub(p8.z); + var da = d7.redMul(a8); + var cb = c8.redMul(b6); + var nx = diff.z.redMul(da.redAdd(cb).redSqr()); + var nz = diff.x.redMul(da.redISub(cb).redSqr()); + return this.curve.point(nx, nz); + }; + Point2.prototype.mul = function mul(k5) { + var t9 = k5.clone(); + var a8 = this; + var b6 = this.curve.point(null, null); + var c8 = this; + for (var bits = []; t9.cmpn(0) !== 0; t9.iushrn(1)) + bits.push(t9.andln(1)); + for (var i8 = bits.length - 1; i8 >= 0; i8--) { + if (bits[i8] === 0) { + a8 = a8.diffAdd(b6, c8); + b6 = b6.dbl(); + } else { + b6 = a8.diffAdd(b6, c8); + a8 = a8.dbl(); + } + } + return b6; + }; + Point2.prototype.mulAdd = function mulAdd() { + throw new Error("Not supported on Montgomery curve"); + }; + Point2.prototype.jumlAdd = function jumlAdd() { + throw new Error("Not supported on Montgomery curve"); + }; + Point2.prototype.eq = function eq(other) { + return this.getX().cmp(other.getX()) === 0; + }; + Point2.prototype.normalize = function normalize2() { + this.x = this.x.redMul(this.z.redInvm()); + this.z = this.curve.one; + return this; + }; + Point2.prototype.getX = function getX() { + this.normalize(); + return this.x.fromRed(); + }; + return exports$R; + } + var exports$Q = {}; + var _dewExec$P = false; + function dew$P() { + if (_dewExec$P) + return exports$Q; + _dewExec$P = true; + var utils2 = dew$T(); + var BN = dew$V(); + var inherits3 = dew$f(); + var Base2 = dew$S(); + var assert = utils2.assert; + function EdwardsCurve(conf) { + this.twisted = (conf.a | 0) !== 1; + this.mOneA = this.twisted && (conf.a | 0) === -1; + this.extended = this.mOneA; + Base2.call(this, "edwards", conf); + this.a = new BN(conf.a, 16).umod(this.red.m); + this.a = this.a.toRed(this.red); + this.c = new BN(conf.c, 16).toRed(this.red); + this.c2 = this.c.redSqr(); + this.d = new BN(conf.d, 16).toRed(this.red); + this.dd = this.d.redAdd(this.d); + assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); + this.oneC = (conf.c | 0) === 1; + } + inherits3(EdwardsCurve, Base2); + exports$Q = EdwardsCurve; + EdwardsCurve.prototype._mulA = function _mulA(num) { + if (this.mOneA) + return num.redNeg(); + else + return this.a.redMul(num); + }; + EdwardsCurve.prototype._mulC = function _mulC(num) { + if (this.oneC) + return num; + else + return this.c.redMul(num); + }; + EdwardsCurve.prototype.jpoint = function jpoint(x5, y7, z6, t9) { + return this.point(x5, y7, z6, t9); + }; + EdwardsCurve.prototype.pointFromX = function pointFromX(x5, odd) { + x5 = new BN(x5, 16); + if (!x5.red) + x5 = x5.toRed(this.red); + var x22 = x5.redSqr(); + var rhs = this.c2.redSub(this.a.redMul(x22)); + var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x22)); + var y22 = rhs.redMul(lhs.redInvm()); + var y7 = y22.redSqrt(); + if (y7.redSqr().redSub(y22).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var isOdd = y7.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y7 = y7.redNeg(); + return this.point(x5, y7); + }; + EdwardsCurve.prototype.pointFromY = function pointFromY(y7, odd) { + y7 = new BN(y7, 16); + if (!y7.red) + y7 = y7.toRed(this.red); + var y22 = y7.redSqr(); + var lhs = y22.redSub(this.c2); + var rhs = y22.redMul(this.d).redMul(this.c2).redSub(this.a); + var x22 = lhs.redMul(rhs.redInvm()); + if (x22.cmp(this.zero) === 0) { + if (odd) + throw new Error("invalid point"); + else + return this.point(this.zero, y7); + } + var x5 = x22.redSqrt(); + if (x5.redSqr().redSub(x22).cmp(this.zero) !== 0) + throw new Error("invalid point"); + if (x5.fromRed().isOdd() !== odd) + x5 = x5.redNeg(); + return this.point(x5, y7); + }; + EdwardsCurve.prototype.validate = function validate3(point) { + if (point.isInfinity()) + return true; + point.normalize(); + var x22 = point.x.redSqr(); + var y22 = point.y.redSqr(); + var lhs = x22.redMul(this.a).redAdd(y22); + var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x22).redMul(y22))); + return lhs.cmp(rhs) === 0; + }; + function Point2(curve, x5, y7, z6, t9) { + Base2.BasePoint.call(this, curve, "projective"); + if (x5 === null && y7 === null && z6 === null) { + this.x = this.curve.zero; + this.y = this.curve.one; + this.z = this.curve.one; + this.t = this.curve.zero; + this.zOne = true; + } else { + this.x = new BN(x5, 16); + this.y = new BN(y7, 16); + this.z = z6 ? new BN(z6, 16) : this.curve.one; + this.t = t9 && new BN(t9, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + if (this.t && !this.t.red) + this.t = this.t.toRed(this.curve.red); + this.zOne = this.z === this.curve.one; + if (this.curve.extended && !this.t) { + this.t = this.x.redMul(this.y); + if (!this.zOne) + this.t = this.t.redMul(this.z.redInvm()); + } + } + } + inherits3(Point2, Base2.BasePoint); + EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point2.fromJSON(this, obj); + }; + EdwardsCurve.prototype.point = function point(x5, y7, z6, t9) { + return new Point2(this, x5, y7, z6, t9); + }; + Point2.fromJSON = function fromJSON3(curve, obj) { + return new Point2(curve, obj[0], obj[1], obj[2]); + }; + Point2.prototype.inspect = function inspect3() { + if (this.isInfinity()) + return ""; + return ""; + }; + Point2.prototype.isInfinity = function isInfinity() { + return this.x.cmpn(0) === 0 && (this.y.cmp(this.z) === 0 || this.zOne && this.y.cmp(this.curve.c) === 0); + }; + Point2.prototype._extDbl = function _extDbl() { + var a8 = this.x.redSqr(); + var b6 = this.y.redSqr(); + var c8 = this.z.redSqr(); + c8 = c8.redIAdd(c8); + var d7 = this.curve._mulA(a8); + var e12 = this.x.redAdd(this.y).redSqr().redISub(a8).redISub(b6); + var g6 = d7.redAdd(b6); + var f9 = g6.redSub(c8); + var h9 = d7.redSub(b6); + var nx = e12.redMul(f9); + var ny = g6.redMul(h9); + var nt2 = e12.redMul(h9); + var nz = f9.redMul(g6); + return this.curve.point(nx, ny, nz, nt2); + }; + Point2.prototype._projDbl = function _projDbl() { + var b6 = this.x.redAdd(this.y).redSqr(); + var c8 = this.x.redSqr(); + var d7 = this.y.redSqr(); + var nx; + var ny; + var nz; + var e12; + var h9; + var j5; + if (this.curve.twisted) { + e12 = this.curve._mulA(c8); + var f9 = e12.redAdd(d7); + if (this.zOne) { + nx = b6.redSub(c8).redSub(d7).redMul(f9.redSub(this.curve.two)); + ny = f9.redMul(e12.redSub(d7)); + nz = f9.redSqr().redSub(f9).redSub(f9); + } else { + h9 = this.z.redSqr(); + j5 = f9.redSub(h9).redISub(h9); + nx = b6.redSub(c8).redISub(d7).redMul(j5); + ny = f9.redMul(e12.redSub(d7)); + nz = f9.redMul(j5); + } + } else { + e12 = c8.redAdd(d7); + h9 = this.curve._mulC(this.z).redSqr(); + j5 = e12.redSub(h9).redSub(h9); + nx = this.curve._mulC(b6.redISub(e12)).redMul(j5); + ny = this.curve._mulC(e12).redMul(c8.redISub(d7)); + nz = e12.redMul(j5); + } + return this.curve.point(nx, ny, nz); + }; + Point2.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + if (this.curve.extended) + return this._extDbl(); + else + return this._projDbl(); + }; + Point2.prototype._extAdd = function _extAdd(p8) { + var a8 = this.y.redSub(this.x).redMul(p8.y.redSub(p8.x)); + var b6 = this.y.redAdd(this.x).redMul(p8.y.redAdd(p8.x)); + var c8 = this.t.redMul(this.curve.dd).redMul(p8.t); + var d7 = this.z.redMul(p8.z.redAdd(p8.z)); + var e12 = b6.redSub(a8); + var f9 = d7.redSub(c8); + var g6 = d7.redAdd(c8); + var h9 = b6.redAdd(a8); + var nx = e12.redMul(f9); + var ny = g6.redMul(h9); + var nt2 = e12.redMul(h9); + var nz = f9.redMul(g6); + return this.curve.point(nx, ny, nz, nt2); + }; + Point2.prototype._projAdd = function _projAdd(p8) { + var a8 = this.z.redMul(p8.z); + var b6 = a8.redSqr(); + var c8 = this.x.redMul(p8.x); + var d7 = this.y.redMul(p8.y); + var e12 = this.curve.d.redMul(c8).redMul(d7); + var f9 = b6.redSub(e12); + var g6 = b6.redAdd(e12); + var tmp = this.x.redAdd(this.y).redMul(p8.x.redAdd(p8.y)).redISub(c8).redISub(d7); + var nx = a8.redMul(f9).redMul(tmp); + var ny; + var nz; + if (this.curve.twisted) { + ny = a8.redMul(g6).redMul(d7.redSub(this.curve._mulA(c8))); + nz = f9.redMul(g6); + } else { + ny = a8.redMul(g6).redMul(d7.redSub(c8)); + nz = this.curve._mulC(f9).redMul(g6); + } + return this.curve.point(nx, ny, nz); + }; + Point2.prototype.add = function add12(p8) { + if (this.isInfinity()) + return p8; + if (p8.isInfinity()) + return this; + if (this.curve.extended) + return this._extAdd(p8); + else + return this._projAdd(p8); + }; + Point2.prototype.mul = function mul(k5) { + if (this._hasDoubles(k5)) + return this.curve._fixedNafMul(this, k5); + else + return this.curve._wnafMul(this, k5); + }; + Point2.prototype.mulAdd = function mulAdd(k1, p8, k22) { + return this.curve._wnafMulAdd(1, [this, p8], [k1, k22], 2, false); + }; + Point2.prototype.jmulAdd = function jmulAdd(k1, p8, k22) { + return this.curve._wnafMulAdd(1, [this, p8], [k1, k22], 2, true); + }; + Point2.prototype.normalize = function normalize2() { + if (this.zOne) + return this; + var zi = this.z.redInvm(); + this.x = this.x.redMul(zi); + this.y = this.y.redMul(zi); + if (this.t) + this.t = this.t.redMul(zi); + this.z = this.curve.one; + this.zOne = true; + return this; + }; + Point2.prototype.neg = function neg() { + return this.curve.point(this.x.redNeg(), this.y, this.z, this.t && this.t.redNeg()); + }; + Point2.prototype.getX = function getX() { + this.normalize(); + return this.x.fromRed(); + }; + Point2.prototype.getY = function getY() { + this.normalize(); + return this.y.fromRed(); + }; + Point2.prototype.eq = function eq(other) { + return this === other || this.getX().cmp(other.getX()) === 0 && this.getY().cmp(other.getY()) === 0; + }; + Point2.prototype.eqXToP = function eqXToP(x5) { + var rx = x5.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(rx) === 0) + return true; + var xc = x5.clone(); + var t9 = this.curve.redN.redMul(this.z); + for (; ; ) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + rx.redIAdd(t9); + if (this.x.cmp(rx) === 0) + return true; + } + }; + Point2.prototype.toP = Point2.prototype.normalize; + Point2.prototype.mixedAdd = Point2.prototype.add; + return exports$Q; + } + var exports$P = {}; + var _dewExec$O = false; + function dew$O() { + if (_dewExec$O) + return exports$P; + _dewExec$O = true; + var curve = exports$P; + curve.base = dew$S(); + curve.short = dew$R(); + curve.mont = dew$Q(); + curve.edwards = dew$P(); + return exports$P; + } + var exports$O = {}; + var _dewExec$N = false; + function dew$N() { + if (_dewExec$N) + return exports$O; + _dewExec$N = true; + var assert = dew$2m(); + var inherits3 = dew$f(); + exports$O.inherits = inherits3; + function isSurrogatePair(msg, i8) { + if ((msg.charCodeAt(i8) & 64512) !== 55296) { + return false; + } + if (i8 < 0 || i8 + 1 >= msg.length) { + return false; + } + return (msg.charCodeAt(i8 + 1) & 64512) === 56320; + } + function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg === "string") { + if (!enc) { + var p8 = 0; + for (var i8 = 0; i8 < msg.length; i8++) { + var c8 = msg.charCodeAt(i8); + if (c8 < 128) { + res[p8++] = c8; + } else if (c8 < 2048) { + res[p8++] = c8 >> 6 | 192; + res[p8++] = c8 & 63 | 128; + } else if (isSurrogatePair(msg, i8)) { + c8 = 65536 + ((c8 & 1023) << 10) + (msg.charCodeAt(++i8) & 1023); + res[p8++] = c8 >> 18 | 240; + res[p8++] = c8 >> 12 & 63 | 128; + res[p8++] = c8 >> 6 & 63 | 128; + res[p8++] = c8 & 63 | 128; + } else { + res[p8++] = c8 >> 12 | 224; + res[p8++] = c8 >> 6 & 63 | 128; + res[p8++] = c8 & 63 | 128; + } + } + } else if (enc === "hex") { + msg = msg.replace(/[^a-z0-9]+/ig, ""); + if (msg.length % 2 !== 0) + msg = "0" + msg; + for (i8 = 0; i8 < msg.length; i8 += 2) + res.push(parseInt(msg[i8] + msg[i8 + 1], 16)); + } + } else { + for (i8 = 0; i8 < msg.length; i8++) + res[i8] = msg[i8] | 0; + } + return res; + } + exports$O.toArray = toArray; + function toHex2(msg) { + var res = ""; + for (var i8 = 0; i8 < msg.length; i8++) + res += zero2(msg[i8].toString(16)); + return res; + } + exports$O.toHex = toHex2; + function htonl(w5) { + var res = w5 >>> 24 | w5 >>> 8 & 65280 | w5 << 8 & 16711680 | (w5 & 255) << 24; + return res >>> 0; + } + exports$O.htonl = htonl; + function toHex32(msg, endian) { + var res = ""; + for (var i8 = 0; i8 < msg.length; i8++) { + var w5 = msg[i8]; + if (endian === "little") + w5 = htonl(w5); + res += zero8(w5.toString(16)); + } + return res; + } + exports$O.toHex32 = toHex32; + function zero2(word) { + if (word.length === 1) + return "0" + word; + else + return word; + } + exports$O.zero2 = zero2; + function zero8(word) { + if (word.length === 7) + return "0" + word; + else if (word.length === 6) + return "00" + word; + else if (word.length === 5) + return "000" + word; + else if (word.length === 4) + return "0000" + word; + else if (word.length === 3) + return "00000" + word; + else if (word.length === 2) + return "000000" + word; + else if (word.length === 1) + return "0000000" + word; + else + return word; + } + exports$O.zero8 = zero8; + function join32(msg, start, end, endian) { + var len = end - start; + assert(len % 4 === 0); + var res = new Array(len / 4); + for (var i8 = 0, k5 = start; i8 < res.length; i8++, k5 += 4) { + var w5; + if (endian === "big") + w5 = msg[k5] << 24 | msg[k5 + 1] << 16 | msg[k5 + 2] << 8 | msg[k5 + 3]; + else + w5 = msg[k5 + 3] << 24 | msg[k5 + 2] << 16 | msg[k5 + 1] << 8 | msg[k5]; + res[i8] = w5 >>> 0; + } + return res; + } + exports$O.join32 = join32; + function split32(msg, endian) { + var res = new Array(msg.length * 4); + for (var i8 = 0, k5 = 0; i8 < msg.length; i8++, k5 += 4) { + var m7 = msg[i8]; + if (endian === "big") { + res[k5] = m7 >>> 24; + res[k5 + 1] = m7 >>> 16 & 255; + res[k5 + 2] = m7 >>> 8 & 255; + res[k5 + 3] = m7 & 255; + } else { + res[k5 + 3] = m7 >>> 24; + res[k5 + 2] = m7 >>> 16 & 255; + res[k5 + 1] = m7 >>> 8 & 255; + res[k5] = m7 & 255; + } + } + return res; + } + exports$O.split32 = split32; + function rotr32(w5, b6) { + return w5 >>> b6 | w5 << 32 - b6; + } + exports$O.rotr32 = rotr32; + function rotl32(w5, b6) { + return w5 << b6 | w5 >>> 32 - b6; + } + exports$O.rotl32 = rotl32; + function sum32(a8, b6) { + return a8 + b6 >>> 0; + } + exports$O.sum32 = sum32; + function sum32_3(a8, b6, c8) { + return a8 + b6 + c8 >>> 0; + } + exports$O.sum32_3 = sum32_3; + function sum32_4(a8, b6, c8, d7) { + return a8 + b6 + c8 + d7 >>> 0; + } + exports$O.sum32_4 = sum32_4; + function sum32_5(a8, b6, c8, d7, e12) { + return a8 + b6 + c8 + d7 + e12 >>> 0; + } + exports$O.sum32_5 = sum32_5; + function sum64(buf3, pos, ah, al) { + var bh = buf3[pos]; + var bl = buf3[pos + 1]; + var lo = al + bl >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + buf3[pos] = hi >>> 0; + buf3[pos + 1] = lo; + } + exports$O.sum64 = sum64; + function sum64_hi(ah, al, bh, bl) { + var lo = al + bl >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + return hi >>> 0; + } + exports$O.sum64_hi = sum64_hi; + function sum64_lo(ah, al, bh, bl) { + var lo = al + bl; + return lo >>> 0; + } + exports$O.sum64_lo = sum64_lo; + function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { + var carry = 0; + var lo = al; + lo = lo + bl >>> 0; + carry += lo < al ? 1 : 0; + lo = lo + cl >>> 0; + carry += lo < cl ? 1 : 0; + lo = lo + dl >>> 0; + carry += lo < dl ? 1 : 0; + var hi = ah + bh + ch + dh + carry; + return hi >>> 0; + } + exports$O.sum64_4_hi = sum64_4_hi; + function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { + var lo = al + bl + cl + dl; + return lo >>> 0; + } + exports$O.sum64_4_lo = sum64_4_lo; + function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var carry = 0; + var lo = al; + lo = lo + bl >>> 0; + carry += lo < al ? 1 : 0; + lo = lo + cl >>> 0; + carry += lo < cl ? 1 : 0; + lo = lo + dl >>> 0; + carry += lo < dl ? 1 : 0; + lo = lo + el >>> 0; + carry += lo < el ? 1 : 0; + var hi = ah + bh + ch + dh + eh + carry; + return hi >>> 0; + } + exports$O.sum64_5_hi = sum64_5_hi; + function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var lo = al + bl + cl + dl + el; + return lo >>> 0; + } + exports$O.sum64_5_lo = sum64_5_lo; + function rotr64_hi(ah, al, num) { + var r10 = al << 32 - num | ah >>> num; + return r10 >>> 0; + } + exports$O.rotr64_hi = rotr64_hi; + function rotr64_lo(ah, al, num) { + var r10 = ah << 32 - num | al >>> num; + return r10 >>> 0; + } + exports$O.rotr64_lo = rotr64_lo; + function shr64_hi(ah, al, num) { + return ah >>> num; + } + exports$O.shr64_hi = shr64_hi; + function shr64_lo(ah, al, num) { + var r10 = ah << 32 - num | al >>> num; + return r10 >>> 0; + } + exports$O.shr64_lo = shr64_lo; + return exports$O; + } + var exports$N = {}; + var _dewExec$M = false; + function dew$M() { + if (_dewExec$M) + return exports$N; + _dewExec$M = true; + var utils2 = dew$N(); + var assert = dew$2m(); + function BlockHash() { + this.pending = null; + this.pendingTotal = 0; + this.blockSize = this.constructor.blockSize; + this.outSize = this.constructor.outSize; + this.hmacStrength = this.constructor.hmacStrength; + this.padLength = this.constructor.padLength / 8; + this.endian = "big"; + this._delta8 = this.blockSize / 8; + this._delta32 = this.blockSize / 32; + } + exports$N.BlockHash = BlockHash; + BlockHash.prototype.update = function update2(msg, enc) { + msg = utils2.toArray(msg, enc); + if (!this.pending) + this.pending = msg; + else + this.pending = this.pending.concat(msg); + this.pendingTotal += msg.length; + if (this.pending.length >= this._delta8) { + msg = this.pending; + var r10 = msg.length % this._delta8; + this.pending = msg.slice(msg.length - r10, msg.length); + if (this.pending.length === 0) + this.pending = null; + msg = utils2.join32(msg, 0, msg.length - r10, this.endian); + for (var i8 = 0; i8 < msg.length; i8 += this._delta32) + this._update(msg, i8, i8 + this._delta32); + } + return this; + }; + BlockHash.prototype.digest = function digest3(enc) { + this.update(this._pad()); + assert(this.pending === null); + return this._digest(enc); + }; + BlockHash.prototype._pad = function pad() { + var len = this.pendingTotal; + var bytes2 = this._delta8; + var k5 = bytes2 - (len + this.padLength) % bytes2; + var res = new Array(k5 + this.padLength); + res[0] = 128; + for (var i8 = 1; i8 < k5; i8++) + res[i8] = 0; + len <<= 3; + if (this.endian === "big") { + for (var t9 = 8; t9 < this.padLength; t9++) + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = len >>> 24 & 255; + res[i8++] = len >>> 16 & 255; + res[i8++] = len >>> 8 & 255; + res[i8++] = len & 255; + } else { + res[i8++] = len & 255; + res[i8++] = len >>> 8 & 255; + res[i8++] = len >>> 16 & 255; + res[i8++] = len >>> 24 & 255; + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = 0; + res[i8++] = 0; + for (t9 = 8; t9 < this.padLength; t9++) + res[i8++] = 0; + } + return res; + }; + return exports$N; + } + var exports$M = {}; + var _dewExec$L = false; + function dew$L() { + if (_dewExec$L) + return exports$M; + _dewExec$L = true; + return exports$M; + } + var exports$L = {}; + var _dewExec$K = false; + function dew$K() { + if (_dewExec$K) + return exports$L; + _dewExec$K = true; + var utils2 = dew$N(); + var common = dew$M(); + var rotl32 = utils2.rotl32; + var sum32 = utils2.sum32; + var sum32_3 = utils2.sum32_3; + var sum32_4 = utils2.sum32_4; + var BlockHash = common.BlockHash; + function RIPEMD160() { + if (!(this instanceof RIPEMD160)) + return new RIPEMD160(); + BlockHash.call(this); + this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520]; + this.endian = "little"; + } + utils2.inherits(RIPEMD160, BlockHash); + exports$L.ripemd160 = RIPEMD160; + RIPEMD160.blockSize = 512; + RIPEMD160.outSize = 160; + RIPEMD160.hmacStrength = 192; + RIPEMD160.padLength = 64; + RIPEMD160.prototype._update = function update2(msg, start) { + var A5 = this.h[0]; + var B5 = this.h[1]; + var C5 = this.h[2]; + var D5 = this.h[3]; + var E5 = this.h[4]; + var Ah = A5; + var Bh = B5; + var Ch = C5; + var Dh = D5; + var Eh = E5; + for (var j5 = 0; j5 < 80; j5++) { + var T6 = sum32(rotl32(sum32_4(A5, f9(j5, B5, C5, D5), msg[r10[j5] + start], K4(j5)), s7[j5]), E5); + A5 = E5; + E5 = D5; + D5 = rotl32(C5, 10); + C5 = B5; + B5 = T6; + T6 = sum32(rotl32(sum32_4(Ah, f9(79 - j5, Bh, Ch, Dh), msg[rh[j5] + start], Kh(j5)), sh[j5]), Eh); + Ah = Eh; + Eh = Dh; + Dh = rotl32(Ch, 10); + Ch = Bh; + Bh = T6; + } + T6 = sum32_3(this.h[1], C5, Dh); + this.h[1] = sum32_3(this.h[2], D5, Eh); + this.h[2] = sum32_3(this.h[3], E5, Ah); + this.h[3] = sum32_3(this.h[4], A5, Bh); + this.h[4] = sum32_3(this.h[0], B5, Ch); + this.h[0] = T6; + }; + RIPEMD160.prototype._digest = function digest3(enc) { + if (enc === "hex") + return utils2.toHex32(this.h, "little"); + else + return utils2.split32(this.h, "little"); + }; + function f9(j5, x5, y7, z6) { + if (j5 <= 15) + return x5 ^ y7 ^ z6; + else if (j5 <= 31) + return x5 & y7 | ~x5 & z6; + else if (j5 <= 47) + return (x5 | ~y7) ^ z6; + else if (j5 <= 63) + return x5 & z6 | y7 & ~z6; + else + return x5 ^ (y7 | ~z6); + } + function K4(j5) { + if (j5 <= 15) + return 0; + else if (j5 <= 31) + return 1518500249; + else if (j5 <= 47) + return 1859775393; + else if (j5 <= 63) + return 2400959708; + else + return 2840853838; + } + function Kh(j5) { + if (j5 <= 15) + return 1352829926; + else if (j5 <= 31) + return 1548603684; + else if (j5 <= 47) + return 1836072691; + else if (j5 <= 63) + return 2053994217; + else + return 0; + } + var r10 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]; + var rh = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]; + var s7 = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]; + var sh = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]; + return exports$L; + } + var exports$K = {}; + var _dewExec$J = false; + function dew$J() { + if (_dewExec$J) + return exports$K; + _dewExec$J = true; + var utils2 = dew$N(); + var assert = dew$2m(); + function Hmac2(hash, key, enc) { + if (!(this instanceof Hmac2)) + return new Hmac2(hash, key, enc); + this.Hash = hash; + this.blockSize = hash.blockSize / 8; + this.outSize = hash.outSize / 8; + this.inner = null; + this.outer = null; + this._init(utils2.toArray(key, enc)); + } + exports$K = Hmac2; + Hmac2.prototype._init = function init3(key) { + if (key.length > this.blockSize) + key = new this.Hash().update(key).digest(); + assert(key.length <= this.blockSize); + for (var i8 = key.length; i8 < this.blockSize; i8++) + key.push(0); + for (i8 = 0; i8 < key.length; i8++) + key[i8] ^= 54; + this.inner = new this.Hash().update(key); + for (i8 = 0; i8 < key.length; i8++) + key[i8] ^= 106; + this.outer = new this.Hash().update(key); + }; + Hmac2.prototype.update = function update2(msg, enc) { + this.inner.update(msg, enc); + return this; + }; + Hmac2.prototype.digest = function digest3(enc) { + this.outer.update(this.inner.digest()); + return this.outer.digest(enc); + }; + return exports$K; + } + var exports$J = {}; + var _dewExec$I = false; + function dew$I() { + if (_dewExec$I) + return exports$J; + _dewExec$I = true; + var hash = exports$J; + hash.utils = dew$N(); + hash.common = dew$M(); + hash.sha = dew$L(); + hash.ripemd = dew$K(); + hash.hmac = dew$J(); + hash.sha1 = hash.sha.sha1; + hash.sha256 = hash.sha.sha256; + hash.sha224 = hash.sha.sha224; + hash.sha384 = hash.sha.sha384; + hash.sha512 = hash.sha.sha512; + hash.ripemd160 = hash.ripemd.ripemd160; + return exports$J; + } + var exports$I = {}; + var _dewExec$H = false; + function dew$H() { + if (_dewExec$H) + return exports$I; + _dewExec$H = true; + exports$I = { + doubles: { + step: 4, + points: [["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a", "f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"], ["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508", "11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"], ["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739", "d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"], ["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640", "4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"], ["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c", "4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"], ["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda", "96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"], ["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa", "5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"], ["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0", "cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"], ["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d", "9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"], ["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d", "e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"], ["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1", "9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"], ["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0", "5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"], ["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047", "10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"], ["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862", "283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"], ["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7", "7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"], ["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd", "56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"], ["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83", "7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"], ["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a", "53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"], ["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8", "bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"], ["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d", "4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"], ["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725", "7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"], ["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754", "4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"], ["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c", "17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"], ["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6", "6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"], ["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39", "c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"], ["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891", "893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"], ["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b", "febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"], ["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03", "2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"], ["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d", "eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"], ["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070", "7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"], ["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4", "e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"], ["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da", "662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"], ["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11", "1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"], ["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e", "efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"], ["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41", "2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"], ["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef", "67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"], ["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8", "db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"], ["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d", "648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"], ["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96", "35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"], ["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd", "ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"], ["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5", "9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"], ["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266", "40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"], ["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71", "34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"], ["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac", "c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"], ["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751", "1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"], ["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e", "493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"], ["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241", "c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"], ["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3", "be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"], ["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f", "4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"], ["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19", "aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"], ["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be", "b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"], ["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9", "6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"], ["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2", "8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"], ["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13", "7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"], ["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c", "ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"], ["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba", "2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"], ["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151", "e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"], ["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073", "d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"], ["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458", "38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"], ["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b", "69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"], ["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366", "d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"], ["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa", "40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"], ["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0", "620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"], ["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787", "7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"], ["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e", "ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]] + }, + naf: { + wnd: 7, + points: [["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9", "388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"], ["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4", "d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"], ["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc", "6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"], ["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe", "cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"], ["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb", "d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"], ["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8", "ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"], ["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e", "581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"], ["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34", "4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"], ["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c", "85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"], ["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5", "321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"], ["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f", "2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"], ["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714", "73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"], ["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729", "a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"], ["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db", "2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"], ["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4", "e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"], ["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5", "b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"], ["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479", "2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"], ["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d", "80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"], ["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f", "1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"], ["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb", "d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"], ["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9", "eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"], ["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963", "758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"], ["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74", "958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"], ["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530", "e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"], ["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b", "5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"], ["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247", "cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"], ["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1", "cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"], ["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120", "4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"], ["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435", "91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"], ["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18", "673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"], ["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8", "59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"], ["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb", "3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"], ["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f", "55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"], ["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143", "efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"], ["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba", "e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"], ["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45", "f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"], ["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a", "744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"], ["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e", "c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"], ["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8", "e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"], ["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c", "30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"], ["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519", "e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"], ["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab", "100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"], ["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca", "ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"], ["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf", "8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"], ["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610", "68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"], ["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4", "f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"], ["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c", "d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"], ["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940", "edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"], ["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980", "a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"], ["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3", "66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"], ["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf", "9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"], ["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63", "4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"], ["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448", "fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"], ["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf", "5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"], ["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5", "8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"], ["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6", "8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"], ["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5", "5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"], ["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99", "f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"], ["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51", "f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"], ["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5", "42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"], ["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5", "204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"], ["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997", "4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"], ["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881", "73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"], ["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5", "39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"], ["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66", "d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"], ["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726", "ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"], ["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede", "6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"], ["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94", "60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"], ["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31", "3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"], ["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51", "b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"], ["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252", "ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"], ["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5", "cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"], ["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b", "6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"], ["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4", "322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"], ["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f", "6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"], ["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889", "2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"], ["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246", "b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"], ["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984", "998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"], ["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a", "b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"], ["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030", "bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"], ["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197", "6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"], ["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593", "c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"], ["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef", "21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"], ["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38", "60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"], ["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a", "49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"], ["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111", "5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"], ["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502", "7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"], ["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea", "be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"], ["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26", "8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"], ["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986", "39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"], ["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e", "62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"], ["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4", "25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"], ["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda", "ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"], ["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859", "cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"], ["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f", "f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"], ["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c", "6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"], ["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942", "fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"], ["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a", "1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"], ["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80", "5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"], ["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d", "438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"], ["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1", "cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"], ["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63", "c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"], ["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352", "6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"], ["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193", "ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"], ["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00", "9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"], ["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58", "ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"], ["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7", "d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"], ["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8", "c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"], ["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e", "67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"], ["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d", "cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"], ["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b", "299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"], ["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f", "f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"], ["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6", "462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"], ["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297", "62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"], ["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a", "7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"], ["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c", "ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"], ["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52", "4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"], ["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb", "bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"], ["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065", "bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"], ["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917", "603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"], ["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9", "cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"], ["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3", "553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"], ["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57", "712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"], ["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66", "ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"], ["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8", "9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"], ["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721", "9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"], ["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180", "4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]] + } + }; + return exports$I; + } + var exports$H = {}; + var _dewExec$G = false; + function dew$G() { + if (_dewExec$G) + return exports$H; + _dewExec$G = true; + var curves = exports$H; + var hash = dew$I(); + var curve = dew$O(); + var utils2 = dew$T(); + var assert = utils2.assert; + function PresetCurve(options) { + if (options.type === "short") + this.curve = new curve.short(options); + else if (options.type === "edwards") + this.curve = new curve.edwards(options); + else + this.curve = new curve.mont(options); + this.g = this.curve.g; + this.n = this.curve.n; + this.hash = options.hash; + assert(this.g.validate(), "Invalid curve"); + assert(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + curves.PresetCurve = PresetCurve; + function defineCurve(name15, options) { + Object.defineProperty(curves, name15, { + configurable: true, + enumerable: true, + get: function() { + var curve2 = new PresetCurve(options); + Object.defineProperty(curves, name15, { + configurable: true, + enumerable: true, + value: curve2 + }); + return curve2; + } + }); + } + defineCurve("p192", { + type: "short", + prime: "p192", + p: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff", + a: "ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc", + b: "64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1", + n: "ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831", + hash: hash.sha256, + gRed: false, + g: ["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"] + }); + defineCurve("p224", { + type: "short", + prime: "p224", + p: "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001", + a: "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe", + b: "b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4", + n: "ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d", + hash: hash.sha256, + gRed: false, + g: ["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"] + }); + defineCurve("p256", { + type: "short", + prime: null, + p: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff", + a: "ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc", + b: "5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b", + n: "ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551", + hash: hash.sha256, + gRed: false, + g: ["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"] + }); + defineCurve("p384", { + type: "short", + prime: null, + p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff", + a: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc", + b: "b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef", + n: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973", + hash: hash.sha384, + gRed: false, + g: ["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7", "3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"] + }); + defineCurve("p521", { + type: "short", + prime: null, + p: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff", + a: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc", + b: "00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00", + n: "000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409", + hash: hash.sha512, + gRed: false, + g: ["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66", "00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"] + }); + defineCurve("curve25519", { + type: "mont", + prime: "p25519", + p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", + a: "76d06", + b: "1", + n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", + hash: hash.sha256, + gRed: false, + g: ["9"] + }); + defineCurve("ed25519", { + type: "edwards", + prime: "p25519", + p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", + a: "-1", + c: "1", + // -121665 * (121666^(-1)) (mod P) + d: "52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3", + n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", + hash: hash.sha256, + gRed: false, + g: [ + "216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", + // 4/5 + "6666666666666666666666666666666666666666666666666666666666666658" + ] + }); + var pre; + try { + pre = dew$H(); + } catch (e12) { + pre = void 0; + } + defineCurve("secp256k1", { + type: "short", + prime: "k256", + p: "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f", + a: "0", + b: "7", + n: "ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141", + h: "1", + hash: hash.sha256, + // Precomputed endomorphism + beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", + lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", + basis: [{ + a: "3086d221a7d46bcde86c90e49284eb15", + b: "-e4437ed6010e88286f547fa90abfe4c3" + }, { + a: "114ca50f7a8e2f3f657c1108d9d44cfd8", + b: "3086d221a7d46bcde86c90e49284eb15" + }], + gRed: false, + g: ["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", pre] + }); + return exports$H; + } + var exports$G = {}; + var _dewExec$F = false; + function dew$F() { + if (_dewExec$F) + return exports$G; + _dewExec$F = true; + var hash = dew$I(); + var utils2 = dew$U(); + var assert = dew$2m(); + function HmacDRBG(options) { + if (!(this instanceof HmacDRBG)) + return new HmacDRBG(options); + this.hash = options.hash; + this.predResist = !!options.predResist; + this.outLen = this.hash.outSize; + this.minEntropy = options.minEntropy || this.hash.hmacStrength; + this._reseed = null; + this.reseedInterval = null; + this.K = null; + this.V = null; + var entropy = utils2.toArray(options.entropy, options.entropyEnc || "hex"); + var nonce = utils2.toArray(options.nonce, options.nonceEnc || "hex"); + var pers = utils2.toArray(options.pers, options.persEnc || "hex"); + assert(entropy.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"); + this._init(entropy, nonce, pers); + } + exports$G = HmacDRBG; + HmacDRBG.prototype._init = function init3(entropy, nonce, pers) { + var seed = entropy.concat(nonce).concat(pers); + this.K = new Array(this.outLen / 8); + this.V = new Array(this.outLen / 8); + for (var i8 = 0; i8 < this.V.length; i8++) { + this.K[i8] = 0; + this.V[i8] = 1; + } + this._update(seed); + this._reseed = 1; + this.reseedInterval = 281474976710656; + }; + HmacDRBG.prototype._hmac = function hmac() { + return new hash.hmac(this.hash, this.K); + }; + HmacDRBG.prototype._update = function update2(seed) { + var kmac = this._hmac().update(this.V).update([0]); + if (seed) + kmac = kmac.update(seed); + this.K = kmac.digest(); + this.V = this._hmac().update(this.V).digest(); + if (!seed) + return; + this.K = this._hmac().update(this.V).update([1]).update(seed).digest(); + this.V = this._hmac().update(this.V).digest(); + }; + HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add12, addEnc) { + if (typeof entropyEnc !== "string") { + addEnc = add12; + add12 = entropyEnc; + entropyEnc = null; + } + entropy = utils2.toArray(entropy, entropyEnc); + add12 = utils2.toArray(add12, addEnc); + assert(entropy.length >= this.minEntropy / 8, "Not enough entropy. Minimum is: " + this.minEntropy + " bits"); + this._update(entropy.concat(add12 || [])); + this._reseed = 1; + }; + HmacDRBG.prototype.generate = function generate3(len, enc, add12, addEnc) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + if (typeof enc !== "string") { + addEnc = add12; + add12 = enc; + enc = null; + } + if (add12) { + add12 = utils2.toArray(add12, addEnc || "hex"); + this._update(add12); + } + var temp = []; + while (temp.length < len) { + this.V = this._hmac().update(this.V).digest(); + temp = temp.concat(this.V); + } + var res = temp.slice(0, len); + this._update(add12); + this._reseed++; + return utils2.encode(res, enc); + }; + return exports$G; + } + var exports$F = {}; + var _dewExec$E = false; + function dew$E() { + if (_dewExec$E) + return exports$F; + _dewExec$E = true; + var BN = dew$V(); + var utils2 = dew$T(); + var assert = utils2.assert; + function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; + if (options.priv) + this._importPrivate(options.priv, options.privEnc); + if (options.pub) + this._importPublic(options.pub, options.pubEnc); + } + exports$F = KeyPair; + KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(ec, { + pub, + pubEnc: enc + }); + }; + KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; + return new KeyPair(ec, { + priv, + privEnc: enc + }); + }; + KeyPair.prototype.validate = function validate3() { + var pub = this.getPublic(); + if (pub.isInfinity()) + return { + result: false, + reason: "Invalid public key" + }; + if (!pub.validate()) + return { + result: false, + reason: "Public key is not a point" + }; + if (!pub.mul(this.ec.curve.n).isInfinity()) + return { + result: false, + reason: "Public key * N != O" + }; + return { + result: true, + reason: null + }; + }; + KeyPair.prototype.getPublic = function getPublic(compact, enc) { + if (typeof compact === "string") { + enc = compact; + compact = null; + } + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); + if (!enc) + return this.pub; + return this.pub.encode(enc, compact); + }; + KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === "hex") + return this.priv.toString(16, 2); + else + return this.priv; + }; + KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); + this.priv = this.priv.umod(this.ec.curve.n); + }; + KeyPair.prototype._importPublic = function _importPublic(key, enc) { + if (key.x || key.y) { + if (this.ec.curve.type === "mont") { + assert(key.x, "Need x coordinate"); + } else if (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") { + assert(key.x && key.y, "Need both x and y coordinate"); + } + this.pub = this.ec.curve.point(key.x, key.y); + return; + } + this.pub = this.ec.curve.decodePoint(key, enc); + }; + KeyPair.prototype.derive = function derive4(pub) { + if (!pub.validate()) { + assert(pub.validate(), "public point not validated"); + } + return pub.mul(this.priv).getX(); + }; + KeyPair.prototype.sign = function sign2(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); + }; + KeyPair.prototype.verify = function verify2(msg, signature) { + return this.ec.verify(msg, signature, this); + }; + KeyPair.prototype.inspect = function inspect3() { + return ""; + }; + return exports$F; + } + var exports$E = {}; + var _dewExec$D = false; + function dew$D() { + if (_dewExec$D) + return exports$E; + _dewExec$D = true; + var BN = dew$V(); + var utils2 = dew$T(); + var assert = utils2.assert; + function Signature3(options, enc) { + if (options instanceof Signature3) + return options; + if (this._importDER(options, enc)) + return; + assert(options.r && options.s, "Signature without r or s"); + this.r = new BN(options.r, 16); + this.s = new BN(options.s, 16); + if (options.recoveryParam === void 0) + this.recoveryParam = null; + else + this.recoveryParam = options.recoveryParam; + } + exports$E = Signature3; + function Position() { + this.place = 0; + } + function getLength(buf3, p8) { + var initial = buf3[p8.place++]; + if (!(initial & 128)) { + return initial; + } + var octetLen = initial & 15; + if (octetLen === 0 || octetLen > 4) { + return false; + } + var val = 0; + for (var i8 = 0, off = p8.place; i8 < octetLen; i8++, off++) { + val <<= 8; + val |= buf3[off]; + val >>>= 0; + } + if (val <= 127) { + return false; + } + p8.place = off; + return val; + } + function rmPadding(buf3) { + var i8 = 0; + var len = buf3.length - 1; + while (!buf3[i8] && !(buf3[i8 + 1] & 128) && i8 < len) { + i8++; + } + if (i8 === 0) { + return buf3; + } + return buf3.slice(i8); + } + Signature3.prototype._importDER = function _importDER(data, enc) { + data = utils2.toArray(data, enc); + var p8 = new Position(); + if (data[p8.place++] !== 48) { + return false; + } + var len = getLength(data, p8); + if (len === false) { + return false; + } + if (len + p8.place !== data.length) { + return false; + } + if (data[p8.place++] !== 2) { + return false; + } + var rlen = getLength(data, p8); + if (rlen === false) { + return false; + } + var r10 = data.slice(p8.place, rlen + p8.place); + p8.place += rlen; + if (data[p8.place++] !== 2) { + return false; + } + var slen = getLength(data, p8); + if (slen === false) { + return false; + } + if (data.length !== slen + p8.place) { + return false; + } + var s7 = data.slice(p8.place, slen + p8.place); + if (r10[0] === 0) { + if (r10[1] & 128) { + r10 = r10.slice(1); + } else { + return false; + } + } + if (s7[0] === 0) { + if (s7[1] & 128) { + s7 = s7.slice(1); + } else { + return false; + } + } + this.r = new BN(r10); + this.s = new BN(s7); + this.recoveryParam = null; + return true; + }; + function constructLength(arr, len) { + if (len < 128) { + arr.push(len); + return; + } + var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); + arr.push(octets | 128); + while (--octets) { + arr.push(len >>> (octets << 3) & 255); + } + arr.push(len); + } + Signature3.prototype.toDER = function toDER(enc) { + var r10 = this.r.toArray(); + var s7 = this.s.toArray(); + if (r10[0] & 128) + r10 = [0].concat(r10); + if (s7[0] & 128) + s7 = [0].concat(s7); + r10 = rmPadding(r10); + s7 = rmPadding(s7); + while (!s7[0] && !(s7[1] & 128)) { + s7 = s7.slice(1); + } + var arr = [2]; + constructLength(arr, r10.length); + arr = arr.concat(r10); + arr.push(2); + constructLength(arr, s7.length); + var backHalf = arr.concat(s7); + var res = [48]; + constructLength(res, backHalf.length); + res = res.concat(backHalf); + return utils2.encode(res, enc); + }; + return exports$E; + } + var exports$D = {}; + var _dewExec$C = false; + function dew$C() { + if (_dewExec$C) + return exports$D; + _dewExec$C = true; + var BN = dew$V(); + var HmacDRBG = dew$F(); + var utils2 = dew$T(); + var curves = dew$G(); + var rand = dew$11(); + var assert = utils2.assert; + var KeyPair = dew$E(); + var Signature3 = dew$D(); + function EC(options) { + if (!(this instanceof EC)) + return new EC(options); + if (typeof options === "string") { + assert(Object.prototype.hasOwnProperty.call(curves, options), "Unknown curve " + options); + options = curves[options]; + } + if (options instanceof curves.PresetCurve) + options = { + curve: options + }; + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); + this.hash = options.hash || options.curve.hash; + } + exports$D = EC; + EC.prototype.keyPair = function keyPair(options) { + return new KeyPair(this, options); + }; + EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); + }; + EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); + }; + EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; + var drbg = new HmacDRBG({ + hash: this.hash, + pers: options.pers, + persEnc: options.persEnc || "utf8", + entropy: options.entropy || rand(this.hash.hmacStrength), + entropyEnc: options.entropy && options.entropyEnc || "utf8", + nonce: this.n.toArray() + }); + var bytes2 = this.n.byteLength(); + var ns2 = this.n.sub(new BN(2)); + for (; ; ) { + var priv = new BN(drbg.generate(bytes2)); + if (priv.cmp(ns2) > 0) + continue; + priv.iaddn(1); + return this.keyFromPrivate(priv); + } + }; + EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) { + var delta = msg.byteLength() * 8 - this.n.bitLength(); + if (delta > 0) + msg = msg.ushrn(delta); + if (!truncOnly && msg.cmp(this.n) >= 0) + return msg.sub(this.n); + else + return msg; + }; + EC.prototype.sign = function sign2(msg, key, enc, options) { + if (typeof enc === "object") { + options = enc; + enc = null; + } + if (!options) + options = {}; + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); + var bytes2 = this.n.byteLength(); + var bkey = key.getPrivate().toArray("be", bytes2); + var nonce = msg.toArray("be", bytes2); + var drbg = new HmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce, + pers: options.pers, + persEnc: options.persEnc || "utf8" + }); + var ns1 = this.n.sub(new BN(1)); + for (var iter = 0; ; iter++) { + var k5 = options.k ? options.k(iter) : new BN(drbg.generate(this.n.byteLength())); + k5 = this._truncateToN(k5, true); + if (k5.cmpn(1) <= 0 || k5.cmp(ns1) >= 0) + continue; + var kp = this.g.mul(k5); + if (kp.isInfinity()) + continue; + var kpX = kp.getX(); + var r10 = kpX.umod(this.n); + if (r10.cmpn(0) === 0) + continue; + var s7 = k5.invm(this.n).mul(r10.mul(key.getPrivate()).iadd(msg)); + s7 = s7.umod(this.n); + if (s7.cmpn(0) === 0) + continue; + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | (kpX.cmp(r10) !== 0 ? 2 : 0); + if (options.canonical && s7.cmp(this.nh) > 0) { + s7 = this.n.sub(s7); + recoveryParam ^= 1; + } + return new Signature3({ + r: r10, + s: s7, + recoveryParam + }); + } + }; + EC.prototype.verify = function verify2(msg, signature, key, enc) { + msg = this._truncateToN(new BN(msg, 16)); + key = this.keyFromPublic(key, enc); + signature = new Signature3(signature, "hex"); + var r10 = signature.r; + var s7 = signature.s; + if (r10.cmpn(1) < 0 || r10.cmp(this.n) >= 0) + return false; + if (s7.cmpn(1) < 0 || s7.cmp(this.n) >= 0) + return false; + var sinv = s7.invm(this.n); + var u1 = sinv.mul(msg).umod(this.n); + var u22 = sinv.mul(r10).umod(this.n); + var p8; + if (!this.curve._maxwellTrick) { + p8 = this.g.mulAdd(u1, key.getPublic(), u22); + if (p8.isInfinity()) + return false; + return p8.getX().umod(this.n).cmp(r10) === 0; + } + p8 = this.g.jmulAdd(u1, key.getPublic(), u22); + if (p8.isInfinity()) + return false; + return p8.eqXToP(r10); + }; + EC.prototype.recoverPubKey = function(msg, signature, j5, enc) { + assert((3 & j5) === j5, "The recovery param is more than two bits"); + signature = new Signature3(signature, enc); + var n9 = this.n; + var e12 = new BN(msg); + var r10 = signature.r; + var s7 = signature.s; + var isYOdd = j5 & 1; + var isSecondKey = j5 >> 1; + if (r10.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) + throw new Error("Unable to find sencond key candinate"); + if (isSecondKey) + r10 = this.curve.pointFromX(r10.add(this.curve.n), isYOdd); + else + r10 = this.curve.pointFromX(r10, isYOdd); + var rInv = signature.r.invm(n9); + var s1 = n9.sub(e12).mul(rInv).umod(n9); + var s22 = s7.mul(rInv).umod(n9); + return this.g.mulAdd(s1, r10, s22); + }; + EC.prototype.getKeyRecoveryParam = function(e12, signature, Q4, enc) { + signature = new Signature3(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; + for (var i8 = 0; i8 < 4; i8++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e12, signature, i8); + } catch (e13) { + continue; + } + if (Qprime.eq(Q4)) + return i8; + } + throw new Error("Unable to find valid recovery factor"); + }; + return exports$D; + } + var exports$C = {}; + var _dewExec$B = false; + function dew$B() { + if (_dewExec$B) + return exports$C; + _dewExec$B = true; + var utils2 = dew$T(); + var assert = utils2.assert; + var parseBytes = utils2.parseBytes; + var cachedProperty = utils2.cachedProperty; + function KeyPair(eddsa, params) { + this.eddsa = eddsa; + this._secret = parseBytes(params.secret); + if (eddsa.isPoint(params.pub)) + this._pub = params.pub; + else + this._pubBytes = parseBytes(params.pub); + } + KeyPair.fromPublic = function fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(eddsa, { + pub + }); + }; + KeyPair.fromSecret = function fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) + return secret; + return new KeyPair(eddsa, { + secret + }); + }; + KeyPair.prototype.secret = function secret() { + return this._secret; + }; + cachedProperty(KeyPair, "pubBytes", function pubBytes() { + return this.eddsa.encodePoint(this.pub()); + }); + cachedProperty(KeyPair, "pub", function pub() { + if (this._pubBytes) + return this.eddsa.decodePoint(this._pubBytes); + return this.eddsa.g.mul(this.priv()); + }); + cachedProperty(KeyPair, "privBytes", function privBytes() { + var eddsa = this.eddsa; + var hash = this.hash(); + var lastIx = eddsa.encodingLength - 1; + var a8 = hash.slice(0, eddsa.encodingLength); + a8[0] &= 248; + a8[lastIx] &= 127; + a8[lastIx] |= 64; + return a8; + }); + cachedProperty(KeyPair, "priv", function priv() { + return this.eddsa.decodeInt(this.privBytes()); + }); + cachedProperty(KeyPair, "hash", function hash() { + return this.eddsa.hash().update(this.secret()).digest(); + }); + cachedProperty(KeyPair, "messagePrefix", function messagePrefix() { + return this.hash().slice(this.eddsa.encodingLength); + }); + KeyPair.prototype.sign = function sign2(message2) { + assert(this._secret, "KeyPair can only verify"); + return this.eddsa.sign(message2, this); + }; + KeyPair.prototype.verify = function verify2(message2, sig) { + return this.eddsa.verify(message2, sig, this); + }; + KeyPair.prototype.getSecret = function getSecret(enc) { + assert(this._secret, "KeyPair is public only"); + return utils2.encode(this.secret(), enc); + }; + KeyPair.prototype.getPublic = function getPublic(enc) { + return utils2.encode(this.pubBytes(), enc); + }; + exports$C = KeyPair; + return exports$C; + } + var exports$B = {}; + var _dewExec$A = false; + function dew$A() { + if (_dewExec$A) + return exports$B; + _dewExec$A = true; + var BN = dew$V(); + var utils2 = dew$T(); + var assert = utils2.assert; + var cachedProperty = utils2.cachedProperty; + var parseBytes = utils2.parseBytes; + function Signature3(eddsa, sig) { + this.eddsa = eddsa; + if (typeof sig !== "object") + sig = parseBytes(sig); + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength) + }; + } + assert(sig.R && sig.S, "Signature without R or S"); + if (eddsa.isPoint(sig.R)) + this._R = sig.R; + if (sig.S instanceof BN) + this._S = sig.S; + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; + } + cachedProperty(Signature3, "S", function S5() { + return this.eddsa.decodeInt(this.Sencoded()); + }); + cachedProperty(Signature3, "R", function R5() { + return this.eddsa.decodePoint(this.Rencoded()); + }); + cachedProperty(Signature3, "Rencoded", function Rencoded() { + return this.eddsa.encodePoint(this.R()); + }); + cachedProperty(Signature3, "Sencoded", function Sencoded() { + return this.eddsa.encodeInt(this.S()); + }); + Signature3.prototype.toBytes = function toBytes3() { + return this.Rencoded().concat(this.Sencoded()); + }; + Signature3.prototype.toHex = function toHex2() { + return utils2.encode(this.toBytes(), "hex").toUpperCase(); + }; + exports$B = Signature3; + return exports$B; + } + var exports$A = {}; + var _dewExec$z = false; + function dew$z() { + if (_dewExec$z) + return exports$A; + _dewExec$z = true; + var hash = dew$I(); + var curves = dew$G(); + var utils2 = dew$T(); + var assert = utils2.assert; + var parseBytes = utils2.parseBytes; + var KeyPair = dew$B(); + var Signature3 = dew$A(); + function EDDSA(curve) { + assert(curve === "ed25519", "only tested with ed25519 so far"); + if (!(this instanceof EDDSA)) + return new EDDSA(curve); + curve = curves[curve].curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 1); + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = hash.sha512; + } + exports$A = EDDSA; + EDDSA.prototype.sign = function sign2(message2, secret) { + message2 = parseBytes(message2); + var key = this.keyFromSecret(secret); + var r10 = this.hashInt(key.messagePrefix(), message2); + var R5 = this.g.mul(r10); + var Rencoded = this.encodePoint(R5); + var s_ = this.hashInt(Rencoded, key.pubBytes(), message2).mul(key.priv()); + var S5 = r10.add(s_).umod(this.curve.n); + return this.makeSignature({ + R: R5, + S: S5, + Rencoded + }); + }; + EDDSA.prototype.verify = function verify2(message2, sig, pub) { + message2 = parseBytes(message2); + sig = this.makeSignature(sig); + var key = this.keyFromPublic(pub); + var h9 = this.hashInt(sig.Rencoded(), key.pubBytes(), message2); + var SG = this.g.mul(sig.S()); + var RplusAh = sig.R().add(key.pub().mul(h9)); + return RplusAh.eq(SG); + }; + EDDSA.prototype.hashInt = function hashInt() { + var hash2 = this.hash(); + for (var i8 = 0; i8 < arguments.length; i8++) + hash2.update(arguments[i8]); + return utils2.intFromLE(hash2.digest()).umod(this.curve.n); + }; + EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { + return KeyPair.fromPublic(this, pub); + }; + EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { + return KeyPair.fromSecret(this, secret); + }; + EDDSA.prototype.makeSignature = function makeSignature(sig) { + if (sig instanceof Signature3) + return sig; + return new Signature3(this, sig); + }; + EDDSA.prototype.encodePoint = function encodePoint(point) { + var enc = point.getY().toArray("le", this.encodingLength); + enc[this.encodingLength - 1] |= point.getX().isOdd() ? 128 : 0; + return enc; + }; + EDDSA.prototype.decodePoint = function decodePoint(bytes2) { + bytes2 = utils2.parseBytes(bytes2); + var lastIx = bytes2.length - 1; + var normed = bytes2.slice(0, lastIx).concat(bytes2[lastIx] & ~128); + var xIsOdd = (bytes2[lastIx] & 128) !== 0; + var y7 = utils2.intFromLE(normed); + return this.curve.pointFromY(y7, xIsOdd); + }; + EDDSA.prototype.encodeInt = function encodeInt2(num) { + return num.toArray("le", this.encodingLength); + }; + EDDSA.prototype.decodeInt = function decodeInt(bytes2) { + return utils2.intFromLE(bytes2); + }; + EDDSA.prototype.isPoint = function isPoint(val) { + return val instanceof this.pointClass; + }; + return exports$A; + } + var exports$z = {}; + var _dewExec$y = false; + function dew$y() { + if (_dewExec$y) + return exports$z; + _dewExec$y = true; + var elliptic = exports$z; + elliptic.version = _package.version; + elliptic.utils = dew$T(); + elliptic.rand = dew$11(); + elliptic.curve = dew$O(); + elliptic.curves = dew$G(); + elliptic.ec = dew$C(); + elliptic.eddsa = dew$z(); + return exports$z; + } + var exports$y = {}; + var _dewExec$x = false; + var module$2 = { + exports: exports$y + }; + var _global$5 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$x() { + if (_dewExec$x) + return module$2.exports; + _dewExec$x = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$5).negative = 0; + (this || _global$5).words = null; + (this || _global$5).length = 0; + (this || _global$5).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = buffer3.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$5).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$5).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$5).words = [number3 & 67108863]; + (this || _global$5).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$5).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$5).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$5).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$5).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$5).words = [0]; + (this || _global$5).length = 1; + return this || _global$5; + } + (this || _global$5).length = Math.ceil(number3.length / 3); + (this || _global$5).words = new Array((this || _global$5).length); + for (var i8 = 0; i8 < (this || _global$5).length; i8++) { + (this || _global$5).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$5).words[j5] |= w5 << off & 67108863; + (this || _global$5).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$5).words[j5] |= w5 << off & 67108863; + (this || _global$5).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$5).length = Math.ceil((number3.length - start) / 6); + (this || _global$5).words = new Array((this || _global$5).length); + for (var i8 = 0; i8 < (this || _global$5).length; i8++) { + (this || _global$5).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$5).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$5).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$5).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$5).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$5).words = [0]; + (this || _global$5).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$5).words[0] + word < 67108864) { + (this || _global$5).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$5).words[0] + word < 67108864) { + (this || _global$5).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$5).length); + for (var i8 = 0; i8 < (this || _global$5).length; i8++) { + dest.words[i8] = (this || _global$5).words[i8]; + } + dest.length = (this || _global$5).length; + dest.negative = (this || _global$5).negative; + dest.red = (this || _global$5).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$5).length < size4) { + (this || _global$5).words[(this || _global$5).length++] = 0; + } + return this || _global$5; + }; + BN.prototype.strip = function strip() { + while ((this || _global$5).length > 1 && (this || _global$5).words[(this || _global$5).length - 1] === 0) { + (this || _global$5).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$5).length === 1 && (this || _global$5).words[0] === 0) { + (this || _global$5).negative = 0; + } + return this || _global$5; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$5).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$5).length; i8++) { + var w5 = (this || _global$5).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$5).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$5).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$5).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$5).words[0]; + if ((this || _global$5).length === 2) { + ret += (this || _global$5).words[1] * 67108864; + } else if ((this || _global$5).length === 3 && (this || _global$5).words[2] === 1) { + ret += 4503599627370496 + (this || _global$5).words[1] * 67108864; + } else if ((this || _global$5).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$5).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$5).words[(this || _global$5).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$5).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$5).length; i8++) { + var b6 = this._zeroBits((this || _global$5).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$5).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$5).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$5).negative ^= 1; + } + return this || _global$5; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$5).length < num.length) { + (this || _global$5).words[(this || _global$5).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$5).words[i8] = (this || _global$5).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$5).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$5).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$5); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$5).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$5); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$5).length > num.length) { + b6 = num; + } else { + b6 = this || _global$5; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$5).words[i8] = (this || _global$5).words[i8] & num.words[i8]; + } + (this || _global$5).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$5).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$5).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$5); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$5).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$5); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$5).length > num.length) { + a8 = this || _global$5; + b6 = num; + } else { + a8 = num; + b6 = this || _global$5; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$5).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$5) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$5).words[i8] = a8.words[i8]; + } + } + (this || _global$5).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$5).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$5).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$5); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$5).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$5); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$5).words[i8] = ~(this || _global$5).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$5).words[i8] = ~(this || _global$5).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$5).words[off] = (this || _global$5).words[off] | 1 << wbit; + } else { + (this || _global$5).words[off] = (this || _global$5).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$5).negative !== 0 && num.negative === 0) { + (this || _global$5).negative = 0; + r10 = this.isub(num); + (this || _global$5).negative ^= 1; + return this._normSign(); + } else if ((this || _global$5).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$5).length > num.length) { + a8 = this || _global$5; + b6 = num; + } else { + a8 = num; + b6 = this || _global$5; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$5).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$5).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$5).length = a8.length; + if (carry !== 0) { + (this || _global$5).words[(this || _global$5).length] = carry; + (this || _global$5).length++; + } else if (a8 !== (this || _global$5)) { + for (; i8 < a8.length; i8++) { + (this || _global$5).words[i8] = a8.words[i8]; + } + } + return this || _global$5; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$5).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$5).negative !== 0) { + (this || _global$5).negative = 0; + res = num.sub(this || _global$5); + (this || _global$5).negative = 1; + return res; + } + if ((this || _global$5).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$5); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$5).negative !== 0) { + (this || _global$5).negative = 0; + this.iadd(num); + (this || _global$5).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$5).negative = 0; + (this || _global$5).length = 1; + (this || _global$5).words[0] = 0; + return this || _global$5; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$5; + b6 = num; + } else { + a8 = num; + b6 = this || _global$5; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$5).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$5).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$5)) { + for (; i8 < a8.length; i8++) { + (this || _global$5).words[i8] = a8.words[i8]; + } + } + (this || _global$5).length = Math.max((this || _global$5).length, i8); + if (a8 !== (this || _global$5)) { + (this || _global$5).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$5).length + num.length; + if ((this || _global$5).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$5, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$5, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$5, num, out); + } else { + res = jumboMulTo(this || _global$5, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$5).x = x5; + (this || _global$5).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$5).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$5).length + num.length); + return jumboMulTo(this || _global$5, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$5); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$5).length; i8++) { + var w5 = ((this || _global$5).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$5).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$5).words[i8] = carry; + (this || _global$5).length++; + } + return this || _global$5; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$5); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$5; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$5).length; i8++) { + var newCarry = (this || _global$5).words[i8] & carryMask; + var c8 = ((this || _global$5).words[i8] | 0) - newCarry << r10; + (this || _global$5).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$5).words[i8] = carry; + (this || _global$5).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$5).length - 1; i8 >= 0; i8--) { + (this || _global$5).words[i8 + s7] = (this || _global$5).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$5).words[i8] = 0; + } + (this || _global$5).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$5).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$5).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$5).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$5).length > s7) { + (this || _global$5).length -= s7; + for (i8 = 0; i8 < (this || _global$5).length; i8++) { + (this || _global$5).words[i8] = (this || _global$5).words[i8 + s7]; + } + } else { + (this || _global$5).words[0] = 0; + (this || _global$5).length = 1; + } + var carry = 0; + for (i8 = (this || _global$5).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$5).words[i8] | 0; + (this || _global$5).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$5).length === 0) { + (this || _global$5).words[0] = 0; + (this || _global$5).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$5).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$5).length <= s7) + return false; + var w5 = (this || _global$5).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$5).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$5).length <= s7) { + return this || _global$5; + } + if (r10 !== 0) { + s7++; + } + (this || _global$5).length = Math.min(s7, (this || _global$5).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$5).words[(this || _global$5).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$5).negative !== 0) { + if ((this || _global$5).length === 1 && ((this || _global$5).words[0] | 0) < num) { + (this || _global$5).words[0] = num - ((this || _global$5).words[0] | 0); + (this || _global$5).negative = 0; + return this || _global$5; + } + (this || _global$5).negative = 0; + this.isubn(num); + (this || _global$5).negative = 1; + return this || _global$5; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$5).words[0] += num; + for (var i8 = 0; i8 < (this || _global$5).length && (this || _global$5).words[i8] >= 67108864; i8++) { + (this || _global$5).words[i8] -= 67108864; + if (i8 === (this || _global$5).length - 1) { + (this || _global$5).words[i8 + 1] = 1; + } else { + (this || _global$5).words[i8 + 1]++; + } + } + (this || _global$5).length = Math.max((this || _global$5).length, i8 + 1); + return this || _global$5; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$5).negative !== 0) { + (this || _global$5).negative = 0; + this.iaddn(num); + (this || _global$5).negative = 1; + return this || _global$5; + } + (this || _global$5).words[0] -= num; + if ((this || _global$5).length === 1 && (this || _global$5).words[0] < 0) { + (this || _global$5).words[0] = -(this || _global$5).words[0]; + (this || _global$5).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$5).length && (this || _global$5).words[i8] < 0; i8++) { + (this || _global$5).words[i8] += 67108864; + (this || _global$5).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$5).negative = 0; + return this || _global$5; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$5).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$5).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$5).length - shift; i8++) { + w5 = ((this || _global$5).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$5).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$5).length; i8++) { + w5 = -((this || _global$5).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$5).words[i8] = w5 & 67108863; + } + (this || _global$5).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$5).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$5).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$5).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$5).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$5).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$5 + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$5).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$5).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$5).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$5).words[i8] | 0) + carry * 67108864; + (this || _global$5).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$5; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$5; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$5).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$5).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$5).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$5).length <= s7) { + this._expand(s7 + 1); + (this || _global$5).words[s7] |= q4; + return this || _global$5; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$5).length; i8++) { + var w5 = (this || _global$5).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$5).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$5).words[i8] = carry; + (this || _global$5).length++; + } + return this || _global$5; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$5).length === 1 && (this || _global$5).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$5).negative !== 0 && !negative) + return -1; + if ((this || _global$5).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$5).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$5).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$5).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$5).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$5).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$5).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$5).length > num.length) + return 1; + if ((this || _global$5).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$5).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$5).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$5).red, "Already a number in reduction context"); + assert((this || _global$5).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$5)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$5).red, "fromRed works only with numbers in reduction context"); + return (this || _global$5).red.convertFrom(this || _global$5); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$5).red = ctx; + return this || _global$5; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$5).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$5).red, "redAdd works only with red numbers"); + return (this || _global$5).red.add(this || _global$5, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$5).red, "redIAdd works only with red numbers"); + return (this || _global$5).red.iadd(this || _global$5, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$5).red, "redSub works only with red numbers"); + return (this || _global$5).red.sub(this || _global$5, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$5).red, "redISub works only with red numbers"); + return (this || _global$5).red.isub(this || _global$5, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$5).red, "redShl works only with red numbers"); + return (this || _global$5).red.shl(this || _global$5, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$5).red, "redMul works only with red numbers"); + (this || _global$5).red._verify2(this || _global$5, num); + return (this || _global$5).red.mul(this || _global$5, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$5).red, "redMul works only with red numbers"); + (this || _global$5).red._verify2(this || _global$5, num); + return (this || _global$5).red.imul(this || _global$5, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$5).red, "redSqr works only with red numbers"); + (this || _global$5).red._verify1(this || _global$5); + return (this || _global$5).red.sqr(this || _global$5); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$5).red, "redISqr works only with red numbers"); + (this || _global$5).red._verify1(this || _global$5); + return (this || _global$5).red.isqr(this || _global$5); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$5).red, "redSqrt works only with red numbers"); + (this || _global$5).red._verify1(this || _global$5); + return (this || _global$5).red.sqrt(this || _global$5); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$5).red, "redInvm works only with red numbers"); + (this || _global$5).red._verify1(this || _global$5); + return (this || _global$5).red.invm(this || _global$5); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$5).red, "redNeg works only with red numbers"); + (this || _global$5).red._verify1(this || _global$5); + return (this || _global$5).red.neg(this || _global$5); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$5).red && !num.red, "redPow(normalNum)"); + (this || _global$5).red._verify1(this || _global$5); + return (this || _global$5).red.pow(this || _global$5, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$5).name = name15; + (this || _global$5).p = new BN(p8, 16); + (this || _global$5).n = (this || _global$5).p.bitLength(); + (this || _global$5).k = new BN(1).iushln((this || _global$5).n).isub((this || _global$5).p); + (this || _global$5).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$5).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$5).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$5).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$5).n); + var cmp = rlen < (this || _global$5).n ? -1 : r10.ucmp((this || _global$5).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$5).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$5).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$5).k); + }; + function K256() { + MPrime.call(this || _global$5, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$5, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$5, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$5, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$5).m = prime.p; + (this || _global$5).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$5).m = m7; + (this || _global$5).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$5).prime) + return (this || _global$5).prime.ireduce(a8)._forceRed(this || _global$5); + return a8.umod((this || _global$5).m)._forceRed(this || _global$5); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$5).m.sub(a8)._forceRed(this || _global$5); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$5).m) >= 0) { + res.isub((this || _global$5).m); + } + return res._forceRed(this || _global$5); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$5).m) >= 0) { + res.isub((this || _global$5).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$5).m); + } + return res._forceRed(this || _global$5); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$5).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$5).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$5).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$5).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$5); + var nOne = one.redNeg(); + var lpow = (this || _global$5).m.subn(1).iushrn(1); + var z6 = (this || _global$5).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$5); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$5).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$5); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$5); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$5).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$5, m7); + (this || _global$5).shift = (this || _global$5).m.bitLength(); + if ((this || _global$5).shift % 26 !== 0) { + (this || _global$5).shift += 26 - (this || _global$5).shift % 26; + } + (this || _global$5).r = new BN(1).iushln((this || _global$5).shift); + (this || _global$5).r2 = this.imod((this || _global$5).r.sqr()); + (this || _global$5).rinv = (this || _global$5).r._invmp((this || _global$5).m); + (this || _global$5).minv = (this || _global$5).rinv.mul((this || _global$5).r).isubn(1).div((this || _global$5).m); + (this || _global$5).minv = (this || _global$5).minv.umod((this || _global$5).r); + (this || _global$5).minv = (this || _global$5).r.sub((this || _global$5).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$5).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$5).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$5).shift).mul((this || _global$5).minv).imaskn((this || _global$5).shift).mul((this || _global$5).m); + var u8 = t9.isub(c8).iushrn((this || _global$5).shift); + var res = u8; + if (u8.cmp((this || _global$5).m) >= 0) { + res = u8.isub((this || _global$5).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$5).m); + } + return res._forceRed(this || _global$5); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$5); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$5).shift).mul((this || _global$5).minv).imaskn((this || _global$5).shift).mul((this || _global$5).m); + var u8 = t9.isub(c8).iushrn((this || _global$5).shift); + var res = u8; + if (u8.cmp((this || _global$5).m) >= 0) { + res = u8.isub((this || _global$5).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$5).m); + } + return res._forceRed(this || _global$5); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$5).m).mul((this || _global$5).r2)); + return res._forceRed(this || _global$5); + }; + })(module$2, exports$y); + return module$2.exports; + } + var exports$x = {}; + var _dewExec$w = false; + function dew$w() { + if (_dewExec$w) + return exports$x; + _dewExec$w = true; + var process$1 = process2; + var buffer$1 = buffer3; + var Buffer2 = buffer$1.Buffer; + var safer = {}; + var key; + for (key in buffer$1) { + if (!buffer$1.hasOwnProperty(key)) + continue; + if (key === "SlowBuffer" || key === "Buffer") + continue; + safer[key] = buffer$1[key]; + } + var Safer = safer.Buffer = {}; + for (key in Buffer2) { + if (!Buffer2.hasOwnProperty(key)) + continue; + if (key === "allocUnsafe" || key === "allocUnsafeSlow") + continue; + Safer[key] = Buffer2[key]; + } + safer.Buffer.prototype = Buffer2.prototype; + if (!Safer.from || Safer.from === Uint8Array.from) { + Safer.from = function(value, encodingOrOffset, length3) { + if (typeof value === "number") { + throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value); + } + if (value && typeof value.length === "undefined") { + throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); + } + return Buffer2(value, encodingOrOffset, length3); + }; + } + if (!Safer.alloc) { + Safer.alloc = function(size4, fill, encoding) { + if (typeof size4 !== "number") { + throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size4); + } + if (size4 < 0 || size4 >= 2 * (1 << 30)) { + throw new RangeError('The value "' + size4 + '" is invalid for option "size"'); + } + var buf3 = Buffer2(size4); + if (!fill || fill.length === 0) { + buf3.fill(0); + } else if (typeof encoding === "string") { + buf3.fill(fill, encoding); + } else { + buf3.fill(fill); + } + return buf3; + }; + } + if (!safer.kStringMaxLength) { + try { + safer.kStringMaxLength = process$1.binding("buffer").kStringMaxLength; + } catch (e12) { + } + } + if (!safer.constants) { + safer.constants = { + MAX_LENGTH: safer.kMaxLength + }; + if (safer.kStringMaxLength) { + safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength; + } + } + exports$x = safer; + return exports$x; + } + var exports$w = {}; + var _dewExec$v = false; + function dew$v() { + if (_dewExec$v) + return exports$w; + _dewExec$v = true; + const inherits3 = dew$f(); + function Reporter(options) { + this._reporterState = { + obj: null, + path: [], + options: options || {}, + errors: [] + }; + } + exports$w.Reporter = Reporter; + Reporter.prototype.isError = function isError3(obj) { + return obj instanceof ReporterError; + }; + Reporter.prototype.save = function save() { + const state = this._reporterState; + return { + obj: state.obj, + pathLen: state.path.length + }; + }; + Reporter.prototype.restore = function restore(data) { + const state = this._reporterState; + state.obj = data.obj; + state.path = state.path.slice(0, data.pathLen); + }; + Reporter.prototype.enterKey = function enterKey(key) { + return this._reporterState.path.push(key); + }; + Reporter.prototype.exitKey = function exitKey(index2) { + const state = this._reporterState; + state.path = state.path.slice(0, index2 - 1); + }; + Reporter.prototype.leaveKey = function leaveKey(index2, key, value) { + const state = this._reporterState; + this.exitKey(index2); + if (state.obj !== null) + state.obj[key] = value; + }; + Reporter.prototype.path = function path2() { + return this._reporterState.path.join("/"); + }; + Reporter.prototype.enterObject = function enterObject() { + const state = this._reporterState; + const prev = state.obj; + state.obj = {}; + return prev; + }; + Reporter.prototype.leaveObject = function leaveObject(prev) { + const state = this._reporterState; + const now2 = state.obj; + state.obj = prev; + return now2; + }; + Reporter.prototype.error = function error7(msg) { + let err; + const state = this._reporterState; + const inherited = msg instanceof ReporterError; + if (inherited) { + err = msg; + } else { + err = new ReporterError(state.path.map(function(elem) { + return "[" + JSON.stringify(elem) + "]"; + }).join(""), msg.message || msg, msg.stack); + } + if (!state.options.partial) + throw err; + if (!inherited) + state.errors.push(err); + return err; + }; + Reporter.prototype.wrapResult = function wrapResult(result) { + const state = this._reporterState; + if (!state.options.partial) + return result; + return { + result: this.isError(result) ? null : result, + errors: state.errors + }; + }; + function ReporterError(path2, msg) { + this.path = path2; + this.rethrow(msg); + } + inherits3(ReporterError, Error); + ReporterError.prototype.rethrow = function rethrow(msg) { + this.message = msg + " at: " + (this.path || "(shallow)"); + if (Error.captureStackTrace) + Error.captureStackTrace(this, ReporterError); + if (!this.stack) { + try { + throw new Error(this.message); + } catch (e12) { + this.stack = e12.stack; + } + } + return this; + }; + return exports$w; + } + var exports$v = {}; + var _dewExec$u = false; + function dew$u() { + if (_dewExec$u) + return exports$v; + _dewExec$u = true; + const inherits3 = dew$f(); + const Reporter = dew$v().Reporter; + const Buffer2 = dew$w().Buffer; + function DecoderBuffer(base3, options) { + Reporter.call(this, options); + if (!Buffer2.isBuffer(base3)) { + this.error("Input not Buffer"); + return; + } + this.base = base3; + this.offset = 0; + this.length = base3.length; + } + inherits3(DecoderBuffer, Reporter); + exports$v.DecoderBuffer = DecoderBuffer; + DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) { + if (data instanceof DecoderBuffer) { + return true; + } + const isCompatible = typeof data === "object" && Buffer2.isBuffer(data.base) && data.constructor.name === "DecoderBuffer" && typeof data.offset === "number" && typeof data.length === "number" && typeof data.save === "function" && typeof data.restore === "function" && typeof data.isEmpty === "function" && typeof data.readUInt8 === "function" && typeof data.skip === "function" && typeof data.raw === "function"; + return isCompatible; + }; + DecoderBuffer.prototype.save = function save() { + return { + offset: this.offset, + reporter: Reporter.prototype.save.call(this) + }; + }; + DecoderBuffer.prototype.restore = function restore(save) { + const res = new DecoderBuffer(this.base); + res.offset = save.offset; + res.length = this.offset; + this.offset = save.offset; + Reporter.prototype.restore.call(this, save.reporter); + return res; + }; + DecoderBuffer.prototype.isEmpty = function isEmpty3() { + return this.offset === this.length; + }; + DecoderBuffer.prototype.readUInt8 = function readUInt8(fail5) { + if (this.offset + 1 <= this.length) + return this.base.readUInt8(this.offset++, true); + else + return this.error(fail5 || "DecoderBuffer overrun"); + }; + DecoderBuffer.prototype.skip = function skip2(bytes2, fail5) { + if (!(this.offset + bytes2 <= this.length)) + return this.error(fail5 || "DecoderBuffer overrun"); + const res = new DecoderBuffer(this.base); + res._reporterState = this._reporterState; + res.offset = this.offset; + res.length = this.offset + bytes2; + this.offset += bytes2; + return res; + }; + DecoderBuffer.prototype.raw = function raw(save) { + return this.base.slice(save ? save.offset : this.offset, this.length); + }; + function EncoderBuffer(value, reporter) { + if (Array.isArray(value)) { + this.length = 0; + this.value = value.map(function(item) { + if (!EncoderBuffer.isEncoderBuffer(item)) + item = new EncoderBuffer(item, reporter); + this.length += item.length; + return item; + }, this); + } else if (typeof value === "number") { + if (!(0 <= value && value <= 255)) + return reporter.error("non-byte EncoderBuffer value"); + this.value = value; + this.length = 1; + } else if (typeof value === "string") { + this.value = value; + this.length = Buffer2.byteLength(value); + } else if (Buffer2.isBuffer(value)) { + this.value = value; + this.length = value.length; + } else { + return reporter.error("Unsupported type: " + typeof value); + } + } + exports$v.EncoderBuffer = EncoderBuffer; + EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) { + if (data instanceof EncoderBuffer) { + return true; + } + const isCompatible = typeof data === "object" && data.constructor.name === "EncoderBuffer" && typeof data.length === "number" && typeof data.join === "function"; + return isCompatible; + }; + EncoderBuffer.prototype.join = function join3(out, offset2) { + if (!out) + out = Buffer2.alloc(this.length); + if (!offset2) + offset2 = 0; + if (this.length === 0) + return out; + if (Array.isArray(this.value)) { + this.value.forEach(function(item) { + item.join(out, offset2); + offset2 += item.length; + }); + } else { + if (typeof this.value === "number") + out[offset2] = this.value; + else if (typeof this.value === "string") + out.write(this.value, offset2); + else if (Buffer2.isBuffer(this.value)) + this.value.copy(out, offset2); + offset2 += this.length; + } + return out; + }; + return exports$v; + } + var exports$u = {}; + var _dewExec$t = false; + function dew$t() { + if (_dewExec$t) + return exports$u; + _dewExec$t = true; + const Reporter = dew$v().Reporter; + const EncoderBuffer = dew$u().EncoderBuffer; + const DecoderBuffer = dew$u().DecoderBuffer; + const assert = dew$2m(); + const tags = ["seq", "seqof", "set", "setof", "objid", "bool", "gentime", "utctime", "null_", "enum", "int", "objDesc", "bitstr", "bmpstr", "charstr", "genstr", "graphstr", "ia5str", "iso646str", "numstr", "octstr", "printstr", "t61str", "unistr", "utf8str", "videostr"]; + const methods2 = ["key", "obj", "use", "optional", "explicit", "implicit", "def", "choice", "any", "contains"].concat(tags); + const overrided = ["_peekTag", "_decodeTag", "_use", "_decodeStr", "_decodeObjid", "_decodeTime", "_decodeNull", "_decodeInt", "_decodeBool", "_decodeList", "_encodeComposite", "_encodeStr", "_encodeObjid", "_encodeTime", "_encodeNull", "_encodeInt", "_encodeBool"]; + function Node3(enc, parent, name15) { + const state = {}; + this._baseState = state; + state.name = name15; + state.enc = enc; + state.parent = parent || null; + state.children = null; + state.tag = null; + state.args = null; + state.reverseArgs = null; + state.choice = null; + state.optional = false; + state.any = false; + state.obj = false; + state.use = null; + state.useDecoder = null; + state.key = null; + state["default"] = null; + state.explicit = null; + state.implicit = null; + state.contains = null; + if (!state.parent) { + state.children = []; + this._wrap(); + } + } + exports$u = Node3; + const stateProps = ["enc", "parent", "children", "tag", "args", "reverseArgs", "choice", "optional", "any", "obj", "use", "alteredUse", "key", "default", "explicit", "implicit", "contains"]; + Node3.prototype.clone = function clone() { + const state = this._baseState; + const cstate = {}; + stateProps.forEach(function(prop) { + cstate[prop] = state[prop]; + }); + const res = new this.constructor(cstate.parent); + res._baseState = cstate; + return res; + }; + Node3.prototype._wrap = function wrap2() { + const state = this._baseState; + methods2.forEach(function(method) { + this[method] = function _wrappedMethod() { + const clone = new this.constructor(this); + state.children.push(clone); + return clone[method].apply(clone, arguments); + }; + }, this); + }; + Node3.prototype._init = function init3(body) { + const state = this._baseState; + assert(state.parent === null); + body.call(this); + state.children = state.children.filter(function(child) { + return child._baseState.parent === this; + }, this); + assert.equal(state.children.length, 1, "Root node can have only one child"); + }; + Node3.prototype._useArgs = function useArgs(args) { + const state = this._baseState; + const children = args.filter(function(arg) { + return arg instanceof this.constructor; + }, this); + args = args.filter(function(arg) { + return !(arg instanceof this.constructor); + }, this); + if (children.length !== 0) { + assert(state.children === null); + state.children = children; + children.forEach(function(child) { + child._baseState.parent = this; + }, this); + } + if (args.length !== 0) { + assert(state.args === null); + state.args = args; + state.reverseArgs = args.map(function(arg) { + if (typeof arg !== "object" || arg.constructor !== Object) + return arg; + const res = {}; + Object.keys(arg).forEach(function(key) { + if (key == (key | 0)) + key |= 0; + const value = arg[key]; + res[value] = key; + }); + return res; + }); + } + }; + overrided.forEach(function(method) { + Node3.prototype[method] = function _overrided() { + const state = this._baseState; + throw new Error(method + " not implemented for encoding: " + state.enc); + }; + }); + tags.forEach(function(tag2) { + Node3.prototype[tag2] = function _tagMethod() { + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); + assert(state.tag === null); + state.tag = tag2; + this._useArgs(args); + return this; + }; + }); + Node3.prototype.use = function use(item) { + assert(item); + const state = this._baseState; + assert(state.use === null); + state.use = item; + return this; + }; + Node3.prototype.optional = function optional5() { + const state = this._baseState; + state.optional = true; + return this; + }; + Node3.prototype.def = function def(val) { + const state = this._baseState; + assert(state["default"] === null); + state["default"] = val; + state.optional = true; + return this; + }; + Node3.prototype.explicit = function explicit(num) { + const state = this._baseState; + assert(state.explicit === null && state.implicit === null); + state.explicit = num; + return this; + }; + Node3.prototype.implicit = function implicit(num) { + const state = this._baseState; + assert(state.explicit === null && state.implicit === null); + state.implicit = num; + return this; + }; + Node3.prototype.obj = function obj() { + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); + state.obj = true; + if (args.length !== 0) + this._useArgs(args); + return this; + }; + Node3.prototype.key = function key(newKey) { + const state = this._baseState; + assert(state.key === null); + state.key = newKey; + return this; + }; + Node3.prototype.any = function any() { + const state = this._baseState; + state.any = true; + return this; + }; + Node3.prototype.choice = function choice(obj) { + const state = this._baseState; + assert(state.choice === null); + state.choice = obj; + this._useArgs(Object.keys(obj).map(function(key) { + return obj[key]; + })); + return this; + }; + Node3.prototype.contains = function contains2(item) { + const state = this._baseState; + assert(state.use === null); + state.contains = item; + return this; + }; + Node3.prototype._decode = function decode46(input, options) { + const state = this._baseState; + if (state.parent === null) + return input.wrapResult(state.children[0]._decode(input, options)); + let result = state["default"]; + let present = true; + let prevKey = null; + if (state.key !== null) + prevKey = input.enterKey(state.key); + if (state.optional) { + let tag2 = null; + if (state.explicit !== null) + tag2 = state.explicit; + else if (state.implicit !== null) + tag2 = state.implicit; + else if (state.tag !== null) + tag2 = state.tag; + if (tag2 === null && !state.any) { + const save = input.save(); + try { + if (state.choice === null) + this._decodeGeneric(state.tag, input, options); + else + this._decodeChoice(input, options); + present = true; + } catch (e12) { + present = false; + } + input.restore(save); + } else { + present = this._peekTag(input, tag2, state.any); + if (input.isError(present)) + return present; + } + } + let prevObj; + if (state.obj && present) + prevObj = input.enterObject(); + if (present) { + if (state.explicit !== null) { + const explicit = this._decodeTag(input, state.explicit); + if (input.isError(explicit)) + return explicit; + input = explicit; + } + const start = input.offset; + if (state.use === null && state.choice === null) { + let save; + if (state.any) + save = input.save(); + const body = this._decodeTag(input, state.implicit !== null ? state.implicit : state.tag, state.any); + if (input.isError(body)) + return body; + if (state.any) + result = input.raw(save); + else + input = body; + } + if (options && options.track && state.tag !== null) + options.track(input.path(), start, input.length, "tagged"); + if (options && options.track && state.tag !== null) + options.track(input.path(), input.offset, input.length, "content"); + if (state.any) + ; + else if (state.choice === null) { + result = this._decodeGeneric(state.tag, input, options); + } else { + result = this._decodeChoice(input, options); + } + if (input.isError(result)) + return result; + if (!state.any && state.choice === null && state.children !== null) { + state.children.forEach(function decodeChildren(child) { + child._decode(input, options); + }); + } + if (state.contains && (state.tag === "octstr" || state.tag === "bitstr")) { + const data = new DecoderBuffer(result); + result = this._getUse(state.contains, input._reporterState.obj)._decode(data, options); + } + } + if (state.obj && present) + result = input.leaveObject(prevObj); + if (state.key !== null && (result !== null || present === true)) + input.leaveKey(prevKey, state.key, result); + else if (prevKey !== null) + input.exitKey(prevKey); + return result; + }; + Node3.prototype._decodeGeneric = function decodeGeneric(tag2, input, options) { + const state = this._baseState; + if (tag2 === "seq" || tag2 === "set") + return null; + if (tag2 === "seqof" || tag2 === "setof") + return this._decodeList(input, tag2, state.args[0], options); + else if (/str$/.test(tag2)) + return this._decodeStr(input, tag2, options); + else if (tag2 === "objid" && state.args) + return this._decodeObjid(input, state.args[0], state.args[1], options); + else if (tag2 === "objid") + return this._decodeObjid(input, null, null, options); + else if (tag2 === "gentime" || tag2 === "utctime") + return this._decodeTime(input, tag2, options); + else if (tag2 === "null_") + return this._decodeNull(input, options); + else if (tag2 === "bool") + return this._decodeBool(input, options); + else if (tag2 === "objDesc") + return this._decodeStr(input, tag2, options); + else if (tag2 === "int" || tag2 === "enum") + return this._decodeInt(input, state.args && state.args[0], options); + if (state.use !== null) { + return this._getUse(state.use, input._reporterState.obj)._decode(input, options); + } else { + return input.error("unknown tag: " + tag2); + } + }; + Node3.prototype._getUse = function _getUse(entity, obj) { + const state = this._baseState; + state.useDecoder = this._use(entity, obj); + assert(state.useDecoder._baseState.parent === null); + state.useDecoder = state.useDecoder._baseState.children[0]; + if (state.implicit !== state.useDecoder._baseState.implicit) { + state.useDecoder = state.useDecoder.clone(); + state.useDecoder._baseState.implicit = state.implicit; + } + return state.useDecoder; + }; + Node3.prototype._decodeChoice = function decodeChoice(input, options) { + const state = this._baseState; + let result = null; + let match10 = false; + Object.keys(state.choice).some(function(key) { + const save = input.save(); + const node = state.choice[key]; + try { + const value = node._decode(input, options); + if (input.isError(value)) + return false; + result = { + type: key, + value + }; + match10 = true; + } catch (e12) { + input.restore(save); + return false; + } + return true; + }, this); + if (!match10) + return input.error("Choice not matched"); + return result; + }; + Node3.prototype._createEncoderBuffer = function createEncoderBuffer(data) { + return new EncoderBuffer(data, this.reporter); + }; + Node3.prototype._encode = function encode41(data, reporter, parent) { + const state = this._baseState; + if (state["default"] !== null && state["default"] === data) + return; + const result = this._encodeValue(data, reporter, parent); + if (result === void 0) + return; + if (this._skipDefault(result, reporter, parent)) + return; + return result; + }; + Node3.prototype._encodeValue = function encode41(data, reporter, parent) { + const state = this._baseState; + if (state.parent === null) + return state.children[0]._encode(data, reporter || new Reporter()); + let result = null; + this.reporter = reporter; + if (state.optional && data === void 0) { + if (state["default"] !== null) + data = state["default"]; + else + return; + } + let content = null; + let primitive = false; + if (state.any) { + result = this._createEncoderBuffer(data); + } else if (state.choice) { + result = this._encodeChoice(data, reporter); + } else if (state.contains) { + content = this._getUse(state.contains, parent)._encode(data, reporter); + primitive = true; + } else if (state.children) { + content = state.children.map(function(child) { + if (child._baseState.tag === "null_") + return child._encode(null, reporter, data); + if (child._baseState.key === null) + return reporter.error("Child should have a key"); + const prevKey = reporter.enterKey(child._baseState.key); + if (typeof data !== "object") + return reporter.error("Child expected, but input is not object"); + const res = child._encode(data[child._baseState.key], reporter, data); + reporter.leaveKey(prevKey); + return res; + }, this).filter(function(child) { + return child; + }); + content = this._createEncoderBuffer(content); + } else { + if (state.tag === "seqof" || state.tag === "setof") { + if (!(state.args && state.args.length === 1)) + return reporter.error("Too many args for : " + state.tag); + if (!Array.isArray(data)) + return reporter.error("seqof/setof, but data is not Array"); + const child = this.clone(); + child._baseState.implicit = null; + content = this._createEncoderBuffer(data.map(function(item) { + const state2 = this._baseState; + return this._getUse(state2.args[0], data)._encode(item, reporter); + }, child)); + } else if (state.use !== null) { + result = this._getUse(state.use, parent)._encode(data, reporter); + } else { + content = this._encodePrimitive(state.tag, data); + primitive = true; + } + } + if (!state.any && state.choice === null) { + const tag2 = state.implicit !== null ? state.implicit : state.tag; + const cls = state.implicit === null ? "universal" : "context"; + if (tag2 === null) { + if (state.use === null) + reporter.error("Tag could be omitted only for .use()"); + } else { + if (state.use === null) + result = this._encodeComposite(tag2, primitive, cls, content); + } + } + if (state.explicit !== null) + result = this._encodeComposite(state.explicit, false, "context", result); + return result; + }; + Node3.prototype._encodeChoice = function encodeChoice(data, reporter) { + const state = this._baseState; + const node = state.choice[data.type]; + if (!node) { + assert(false, data.type + " not found in " + JSON.stringify(Object.keys(state.choice))); + } + return node._encode(data.value, reporter); + }; + Node3.prototype._encodePrimitive = function encodePrimitive(tag2, data) { + const state = this._baseState; + if (/str$/.test(tag2)) + return this._encodeStr(data, tag2); + else if (tag2 === "objid" && state.args) + return this._encodeObjid(data, state.reverseArgs[0], state.args[1]); + else if (tag2 === "objid") + return this._encodeObjid(data, null, null); + else if (tag2 === "gentime" || tag2 === "utctime") + return this._encodeTime(data, tag2); + else if (tag2 === "null_") + return this._encodeNull(); + else if (tag2 === "int" || tag2 === "enum") + return this._encodeInt(data, state.args && state.reverseArgs[0]); + else if (tag2 === "bool") + return this._encodeBool(data); + else if (tag2 === "objDesc") + return this._encodeStr(data, tag2); + else + throw new Error("Unsupported tag: " + tag2); + }; + Node3.prototype._isNumstr = function isNumstr(str) { + return /^[0-9 ]*$/.test(str); + }; + Node3.prototype._isPrintstr = function isPrintstr(str) { + return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str); + }; + return exports$u; + } + var exports$t = {}; + var _dewExec$s = false; + function dew$s() { + if (_dewExec$s) + return exports$t; + _dewExec$s = true; + function reverse(map2) { + const res = {}; + Object.keys(map2).forEach(function(key) { + if ((key | 0) == key) + key = key | 0; + const value = map2[key]; + res[value] = key; + }); + return res; + } + exports$t.tagClass = { + 0: "universal", + 1: "application", + 2: "context", + 3: "private" + }; + exports$t.tagClassByName = reverse(exports$t.tagClass); + exports$t.tag = { + 0: "end", + 1: "bool", + 2: "int", + 3: "bitstr", + 4: "octstr", + 5: "null_", + 6: "objid", + 7: "objDesc", + 8: "external", + 9: "real", + 10: "enum", + 11: "embed", + 12: "utf8str", + 13: "relativeOid", + 16: "seq", + 17: "set", + 18: "numstr", + 19: "printstr", + 20: "t61str", + 21: "videostr", + 22: "ia5str", + 23: "utctime", + 24: "gentime", + 25: "graphstr", + 26: "iso646str", + 27: "genstr", + 28: "unistr", + 29: "charstr", + 30: "bmpstr" + }; + exports$t.tagByName = reverse(exports$t.tag); + return exports$t; + } + var exports$s = {}; + var _dewExec$r = false; + function dew$r() { + if (_dewExec$r) + return exports$s; + _dewExec$r = true; + const inherits3 = dew$f(); + const Buffer2 = dew$w().Buffer; + const Node3 = dew$t(); + const der = dew$s(); + function DEREncoder(entity) { + this.enc = "der"; + this.name = entity.name; + this.entity = entity; + this.tree = new DERNode(); + this.tree._init(entity.body); + } + exports$s = DEREncoder; + DEREncoder.prototype.encode = function encode41(data, reporter) { + return this.tree._encode(data, reporter).join(); + }; + function DERNode(parent) { + Node3.call(this, "der", parent); + } + inherits3(DERNode, Node3); + DERNode.prototype._encodeComposite = function encodeComposite(tag2, primitive, cls, content) { + const encodedTag = encodeTag3(tag2, primitive, cls, this.reporter); + if (content.length < 128) { + const header2 = Buffer2.alloc(2); + header2[0] = encodedTag; + header2[1] = content.length; + return this._createEncoderBuffer([header2, content]); + } + let lenOctets = 1; + for (let i8 = content.length; i8 >= 256; i8 >>= 8) + lenOctets++; + const header = Buffer2.alloc(1 + 1 + lenOctets); + header[0] = encodedTag; + header[1] = 128 | lenOctets; + for (let i8 = 1 + lenOctets, j5 = content.length; j5 > 0; i8--, j5 >>= 8) + header[i8] = j5 & 255; + return this._createEncoderBuffer([header, content]); + }; + DERNode.prototype._encodeStr = function encodeStr(str, tag2) { + if (tag2 === "bitstr") { + return this._createEncoderBuffer([str.unused | 0, str.data]); + } else if (tag2 === "bmpstr") { + const buf3 = Buffer2.alloc(str.length * 2); + for (let i8 = 0; i8 < str.length; i8++) { + buf3.writeUInt16BE(str.charCodeAt(i8), i8 * 2); + } + return this._createEncoderBuffer(buf3); + } else if (tag2 === "numstr") { + if (!this._isNumstr(str)) { + return this.reporter.error("Encoding of string type: numstr supports only digits and space"); + } + return this._createEncoderBuffer(str); + } else if (tag2 === "printstr") { + if (!this._isPrintstr(str)) { + return this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"); + } + return this._createEncoderBuffer(str); + } else if (/str$/.test(tag2)) { + return this._createEncoderBuffer(str); + } else if (tag2 === "objDesc") { + return this._createEncoderBuffer(str); + } else { + return this.reporter.error("Encoding of string type: " + tag2 + " unsupported"); + } + }; + DERNode.prototype._encodeObjid = function encodeObjid(id, values2, relative2) { + if (typeof id === "string") { + if (!values2) + return this.reporter.error("string objid given, but no values map found"); + if (!values2.hasOwnProperty(id)) + return this.reporter.error("objid not found in values map"); + id = values2[id].split(/[\s.]+/g); + for (let i8 = 0; i8 < id.length; i8++) + id[i8] |= 0; + } else if (Array.isArray(id)) { + id = id.slice(); + for (let i8 = 0; i8 < id.length; i8++) + id[i8] |= 0; + } + if (!Array.isArray(id)) { + return this.reporter.error("objid() should be either array or string, got: " + JSON.stringify(id)); + } + if (!relative2) { + if (id[1] >= 40) + return this.reporter.error("Second objid identifier OOB"); + id.splice(0, 2, id[0] * 40 + id[1]); + } + let size4 = 0; + for (let i8 = 0; i8 < id.length; i8++) { + let ident = id[i8]; + for (size4++; ident >= 128; ident >>= 7) + size4++; + } + const objid = Buffer2.alloc(size4); + let offset2 = objid.length - 1; + for (let i8 = id.length - 1; i8 >= 0; i8--) { + let ident = id[i8]; + objid[offset2--] = ident & 127; + while ((ident >>= 7) > 0) + objid[offset2--] = 128 | ident & 127; + } + return this._createEncoderBuffer(objid); + }; + function two(num) { + if (num < 10) + return "0" + num; + else + return num; + } + DERNode.prototype._encodeTime = function encodeTime(time, tag2) { + let str; + const date = new Date(time); + if (tag2 === "gentime") { + str = [two(date.getUTCFullYear()), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), two(date.getUTCMinutes()), two(date.getUTCSeconds()), "Z"].join(""); + } else if (tag2 === "utctime") { + str = [two(date.getUTCFullYear() % 100), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), two(date.getUTCMinutes()), two(date.getUTCSeconds()), "Z"].join(""); + } else { + this.reporter.error("Encoding " + tag2 + " time is not supported yet"); + } + return this._encodeStr(str, "octstr"); + }; + DERNode.prototype._encodeNull = function encodeNull() { + return this._createEncoderBuffer(""); + }; + DERNode.prototype._encodeInt = function encodeInt2(num, values2) { + if (typeof num === "string") { + if (!values2) + return this.reporter.error("String int or enum given, but no values map"); + if (!values2.hasOwnProperty(num)) { + return this.reporter.error("Values map doesn't contain: " + JSON.stringify(num)); + } + num = values2[num]; + } + if (typeof num !== "number" && !Buffer2.isBuffer(num)) { + const numArray = num.toArray(); + if (!num.sign && numArray[0] & 128) { + numArray.unshift(0); + } + num = Buffer2.from(numArray); + } + if (Buffer2.isBuffer(num)) { + let size5 = num.length; + if (num.length === 0) + size5++; + const out2 = Buffer2.alloc(size5); + num.copy(out2); + if (num.length === 0) + out2[0] = 0; + return this._createEncoderBuffer(out2); + } + if (num < 128) + return this._createEncoderBuffer(num); + if (num < 256) + return this._createEncoderBuffer([0, num]); + let size4 = 1; + for (let i8 = num; i8 >= 256; i8 >>= 8) + size4++; + const out = new Array(size4); + for (let i8 = out.length - 1; i8 >= 0; i8--) { + out[i8] = num & 255; + num >>= 8; + } + if (out[0] & 128) { + out.unshift(0); + } + return this._createEncoderBuffer(Buffer2.from(out)); + }; + DERNode.prototype._encodeBool = function encodeBool(value) { + return this._createEncoderBuffer(value ? 255 : 0); + }; + DERNode.prototype._use = function use(entity, obj) { + if (typeof entity === "function") + entity = entity(obj); + return entity._getEncoder("der").tree; + }; + DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) { + const state = this._baseState; + let i8; + if (state["default"] === null) + return false; + const data = dataBuffer.join(); + if (state.defaultBuffer === void 0) + state.defaultBuffer = this._encodeValue(state["default"], reporter, parent).join(); + if (data.length !== state.defaultBuffer.length) + return false; + for (i8 = 0; i8 < data.length; i8++) + if (data[i8] !== state.defaultBuffer[i8]) + return false; + return true; + }; + function encodeTag3(tag2, primitive, cls, reporter) { + let res; + if (tag2 === "seqof") + tag2 = "seq"; + else if (tag2 === "setof") + tag2 = "set"; + if (der.tagByName.hasOwnProperty(tag2)) + res = der.tagByName[tag2]; + else if (typeof tag2 === "number" && (tag2 | 0) === tag2) + res = tag2; + else + return reporter.error("Unknown tag: " + tag2); + if (res >= 31) + return reporter.error("Multi-octet tag encoding unsupported"); + if (!primitive) + res |= 32; + res |= der.tagClassByName[cls || "universal"] << 6; + return res; + } + return exports$s; + } + var exports$r = {}; + var _dewExec$q = false; + function dew$q() { + if (_dewExec$q) + return exports$r; + _dewExec$q = true; + const inherits3 = dew$f(); + const DEREncoder = dew$r(); + function PEMEncoder(entity) { + DEREncoder.call(this, entity); + this.enc = "pem"; + } + inherits3(PEMEncoder, DEREncoder); + exports$r = PEMEncoder; + PEMEncoder.prototype.encode = function encode41(data, options) { + const buf3 = DEREncoder.prototype.encode.call(this, data); + const p8 = buf3.toString("base64"); + const out = ["-----BEGIN " + options.label + "-----"]; + for (let i8 = 0; i8 < p8.length; i8 += 64) + out.push(p8.slice(i8, i8 + 64)); + out.push("-----END " + options.label + "-----"); + return out.join("\n"); + }; + return exports$r; + } + var exports$q = {}; + var _dewExec$p = false; + function dew$p() { + if (_dewExec$p) + return exports$q; + _dewExec$p = true; + const encoders = exports$q; + encoders.der = dew$r(); + encoders.pem = dew$q(); + return exports$q; + } + var exports$p = {}; + var _dewExec$o = false; + function dew$o() { + if (_dewExec$o) + return exports$p; + _dewExec$o = true; + const inherits3 = dew$f(); + const bignum = dew$x(); + const DecoderBuffer = dew$u().DecoderBuffer; + const Node3 = dew$t(); + const der = dew$s(); + function DERDecoder(entity) { + this.enc = "der"; + this.name = entity.name; + this.entity = entity; + this.tree = new DERNode(); + this.tree._init(entity.body); + } + exports$p = DERDecoder; + DERDecoder.prototype.decode = function decode46(data, options) { + if (!DecoderBuffer.isDecoderBuffer(data)) { + data = new DecoderBuffer(data, options); + } + return this.tree._decode(data, options); + }; + function DERNode(parent) { + Node3.call(this, "der", parent); + } + inherits3(DERNode, Node3); + DERNode.prototype._peekTag = function peekTag(buffer4, tag2, any) { + if (buffer4.isEmpty()) + return false; + const state = buffer4.save(); + const decodedTag = derDecodeTag(buffer4, 'Failed to peek tag: "' + tag2 + '"'); + if (buffer4.isError(decodedTag)) + return decodedTag; + buffer4.restore(state); + return decodedTag.tag === tag2 || decodedTag.tagStr === tag2 || decodedTag.tagStr + "of" === tag2 || any; + }; + DERNode.prototype._decodeTag = function decodeTag(buffer4, tag2, any) { + const decodedTag = derDecodeTag(buffer4, 'Failed to decode tag of "' + tag2 + '"'); + if (buffer4.isError(decodedTag)) + return decodedTag; + let len = derDecodeLen(buffer4, decodedTag.primitive, 'Failed to get length of "' + tag2 + '"'); + if (buffer4.isError(len)) + return len; + if (!any && decodedTag.tag !== tag2 && decodedTag.tagStr !== tag2 && decodedTag.tagStr + "of" !== tag2) { + return buffer4.error('Failed to match tag: "' + tag2 + '"'); + } + if (decodedTag.primitive || len !== null) + return buffer4.skip(len, 'Failed to match body of: "' + tag2 + '"'); + const state = buffer4.save(); + const res = this._skipUntilEnd(buffer4, 'Failed to skip indefinite length body: "' + this.tag + '"'); + if (buffer4.isError(res)) + return res; + len = buffer4.offset - state.offset; + buffer4.restore(state); + return buffer4.skip(len, 'Failed to match body of: "' + tag2 + '"'); + }; + DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer4, fail5) { + for (; ; ) { + const tag2 = derDecodeTag(buffer4, fail5); + if (buffer4.isError(tag2)) + return tag2; + const len = derDecodeLen(buffer4, tag2.primitive, fail5); + if (buffer4.isError(len)) + return len; + let res; + if (tag2.primitive || len !== null) + res = buffer4.skip(len); + else + res = this._skipUntilEnd(buffer4, fail5); + if (buffer4.isError(res)) + return res; + if (tag2.tagStr === "end") + break; + } + }; + DERNode.prototype._decodeList = function decodeList(buffer4, tag2, decoder4, options) { + const result = []; + while (!buffer4.isEmpty()) { + const possibleEnd = this._peekTag(buffer4, "end"); + if (buffer4.isError(possibleEnd)) + return possibleEnd; + const res = decoder4.decode(buffer4, "der", options); + if (buffer4.isError(res) && possibleEnd) + break; + result.push(res); + } + return result; + }; + DERNode.prototype._decodeStr = function decodeStr(buffer4, tag2) { + if (tag2 === "bitstr") { + const unused = buffer4.readUInt8(); + if (buffer4.isError(unused)) + return unused; + return { + unused, + data: buffer4.raw() + }; + } else if (tag2 === "bmpstr") { + const raw = buffer4.raw(); + if (raw.length % 2 === 1) + return buffer4.error("Decoding of string type: bmpstr length mismatch"); + let str = ""; + for (let i8 = 0; i8 < raw.length / 2; i8++) { + str += String.fromCharCode(raw.readUInt16BE(i8 * 2)); + } + return str; + } else if (tag2 === "numstr") { + const numstr = buffer4.raw().toString("ascii"); + if (!this._isNumstr(numstr)) { + return buffer4.error("Decoding of string type: numstr unsupported characters"); + } + return numstr; + } else if (tag2 === "octstr") { + return buffer4.raw(); + } else if (tag2 === "objDesc") { + return buffer4.raw(); + } else if (tag2 === "printstr") { + const printstr = buffer4.raw().toString("ascii"); + if (!this._isPrintstr(printstr)) { + return buffer4.error("Decoding of string type: printstr unsupported characters"); + } + return printstr; + } else if (/str$/.test(tag2)) { + return buffer4.raw().toString(); + } else { + return buffer4.error("Decoding of string type: " + tag2 + " unsupported"); + } + }; + DERNode.prototype._decodeObjid = function decodeObjid(buffer4, values2, relative2) { + let result; + const identifiers = []; + let ident = 0; + let subident = 0; + while (!buffer4.isEmpty()) { + subident = buffer4.readUInt8(); + ident <<= 7; + ident |= subident & 127; + if ((subident & 128) === 0) { + identifiers.push(ident); + ident = 0; + } + } + if (subident & 128) + identifiers.push(ident); + const first = identifiers[0] / 40 | 0; + const second = identifiers[0] % 40; + if (relative2) + result = identifiers; + else + result = [first, second].concat(identifiers.slice(1)); + if (values2) { + let tmp = values2[result.join(" ")]; + if (tmp === void 0) + tmp = values2[result.join(".")]; + if (tmp !== void 0) + result = tmp; + } + return result; + }; + DERNode.prototype._decodeTime = function decodeTime(buffer4, tag2) { + const str = buffer4.raw().toString(); + let year; + let mon; + let day; + let hour; + let min; + let sec; + if (tag2 === "gentime") { + year = str.slice(0, 4) | 0; + mon = str.slice(4, 6) | 0; + day = str.slice(6, 8) | 0; + hour = str.slice(8, 10) | 0; + min = str.slice(10, 12) | 0; + sec = str.slice(12, 14) | 0; + } else if (tag2 === "utctime") { + year = str.slice(0, 2) | 0; + mon = str.slice(2, 4) | 0; + day = str.slice(4, 6) | 0; + hour = str.slice(6, 8) | 0; + min = str.slice(8, 10) | 0; + sec = str.slice(10, 12) | 0; + if (year < 70) + year = 2e3 + year; + else + year = 1900 + year; + } else { + return buffer4.error("Decoding " + tag2 + " time is not supported yet"); + } + return Date.UTC(year, mon - 1, day, hour, min, sec, 0); + }; + DERNode.prototype._decodeNull = function decodeNull() { + return null; + }; + DERNode.prototype._decodeBool = function decodeBool(buffer4) { + const res = buffer4.readUInt8(); + if (buffer4.isError(res)) + return res; + else + return res !== 0; + }; + DERNode.prototype._decodeInt = function decodeInt(buffer4, values2) { + const raw = buffer4.raw(); + let res = new bignum(raw); + if (values2) + res = values2[res.toString(10)] || res; + return res; + }; + DERNode.prototype._use = function use(entity, obj) { + if (typeof entity === "function") + entity = entity(obj); + return entity._getDecoder("der").tree; + }; + function derDecodeTag(buf3, fail5) { + let tag2 = buf3.readUInt8(fail5); + if (buf3.isError(tag2)) + return tag2; + const cls = der.tagClass[tag2 >> 6]; + const primitive = (tag2 & 32) === 0; + if ((tag2 & 31) === 31) { + let oct = tag2; + tag2 = 0; + while ((oct & 128) === 128) { + oct = buf3.readUInt8(fail5); + if (buf3.isError(oct)) + return oct; + tag2 <<= 7; + tag2 |= oct & 127; + } + } else { + tag2 &= 31; + } + const tagStr = der.tag[tag2]; + return { + cls, + primitive, + tag: tag2, + tagStr + }; + } + function derDecodeLen(buf3, primitive, fail5) { + let len = buf3.readUInt8(fail5); + if (buf3.isError(len)) + return len; + if (!primitive && len === 128) + return null; + if ((len & 128) === 0) { + return len; + } + const num = len & 127; + if (num > 4) + return buf3.error("length octect is too long"); + len = 0; + for (let i8 = 0; i8 < num; i8++) { + len <<= 8; + const j5 = buf3.readUInt8(fail5); + if (buf3.isError(j5)) + return j5; + len |= j5; + } + return len; + } + return exports$p; + } + var exports$o = {}; + var _dewExec$n = false; + function dew$n() { + if (_dewExec$n) + return exports$o; + _dewExec$n = true; + const inherits3 = dew$f(); + const Buffer2 = dew$w().Buffer; + const DERDecoder = dew$o(); + function PEMDecoder(entity) { + DERDecoder.call(this, entity); + this.enc = "pem"; + } + inherits3(PEMDecoder, DERDecoder); + exports$o = PEMDecoder; + PEMDecoder.prototype.decode = function decode46(data, options) { + const lines = data.toString().split(/[\r\n]+/g); + const label = options.label.toUpperCase(); + const re3 = /^-----(BEGIN|END) ([^-]+)-----$/; + let start = -1; + let end = -1; + for (let i8 = 0; i8 < lines.length; i8++) { + const match10 = lines[i8].match(re3); + if (match10 === null) + continue; + if (match10[2] !== label) + continue; + if (start === -1) { + if (match10[1] !== "BEGIN") + break; + start = i8; + } else { + if (match10[1] !== "END") + break; + end = i8; + break; + } + } + if (start === -1 || end === -1) + throw new Error("PEM section not found for: " + label); + const base643 = lines.slice(start + 1, end).join(""); + base643.replace(/[^a-z0-9+/=]+/gi, ""); + const input = Buffer2.from(base643, "base64"); + return DERDecoder.prototype.decode.call(this, input, options); + }; + return exports$o; + } + var exports$n = {}; + var _dewExec$m = false; + function dew$m() { + if (_dewExec$m) + return exports$n; + _dewExec$m = true; + const decoders = exports$n; + decoders.der = dew$o(); + decoders.pem = dew$n(); + return exports$n; + } + var exports$m = {}; + var _dewExec$l = false; + function dew$l() { + if (_dewExec$l) + return exports$m; + _dewExec$l = true; + const encoders = dew$p(); + const decoders = dew$m(); + const inherits3 = dew$f(); + const api = exports$m; + api.define = function define2(name15, body) { + return new Entity(name15, body); + }; + function Entity(name15, body) { + this.name = name15; + this.body = body; + this.decoders = {}; + this.encoders = {}; + } + Entity.prototype._createNamed = function createNamed2(Base2) { + const name15 = this.name; + function Generated(entity) { + this._initNamed(entity, name15); + } + inherits3(Generated, Base2); + Generated.prototype._initNamed = function _initNamed(entity, name16) { + Base2.call(this, entity, name16); + }; + return new Generated(this); + }; + Entity.prototype._getDecoder = function _getDecoder(enc) { + enc = enc || "der"; + if (!this.decoders.hasOwnProperty(enc)) + this.decoders[enc] = this._createNamed(decoders[enc]); + return this.decoders[enc]; + }; + Entity.prototype.decode = function decode46(data, enc, options) { + return this._getDecoder(enc).decode(data, options); + }; + Entity.prototype._getEncoder = function _getEncoder(enc) { + enc = enc || "der"; + if (!this.encoders.hasOwnProperty(enc)) + this.encoders[enc] = this._createNamed(encoders[enc]); + return this.encoders[enc]; + }; + Entity.prototype.encode = function encode41(data, enc, reporter) { + return this._getEncoder(enc).encode(data, reporter); + }; + return exports$m; + } + var exports$l = {}; + var _dewExec$k = false; + function dew$k() { + if (_dewExec$k) + return exports$l; + _dewExec$k = true; + const base3 = exports$l; + base3.Reporter = dew$v().Reporter; + base3.DecoderBuffer = dew$u().DecoderBuffer; + base3.EncoderBuffer = dew$u().EncoderBuffer; + base3.Node = dew$t(); + return exports$l; + } + var exports$k = {}; + var _dewExec$j = false; + function dew$j() { + if (_dewExec$j) + return exports$k; + _dewExec$j = true; + const constants4 = exports$k; + constants4._reverse = function reverse(map2) { + const res = {}; + Object.keys(map2).forEach(function(key) { + if ((key | 0) == key) + key = key | 0; + const value = map2[key]; + res[value] = key; + }); + return res; + }; + constants4.der = dew$s(); + return exports$k; + } + var exports$j = {}; + var _dewExec$i = false; + function dew$i() { + if (_dewExec$i) + return exports$j; + _dewExec$i = true; + const asn1 = exports$j; + asn1.bignum = dew$x(); + asn1.define = dew$l().define; + asn1.base = dew$k(); + asn1.constants = dew$j(); + asn1.decoders = dew$m(); + asn1.encoders = dew$p(); + return exports$j; + } + var exports$i = {}; + var _dewExec$h = false; + function dew$h() { + if (_dewExec$h) + return exports$i; + _dewExec$h = true; + var asn = dew$i(); + var Time = asn.define("Time", function() { + this.choice({ + utcTime: this.utctime(), + generalTime: this.gentime() + }); + }); + var AttributeTypeValue = asn.define("AttributeTypeValue", function() { + this.seq().obj(this.key("type").objid(), this.key("value").any()); + }); + var AlgorithmIdentifier2 = asn.define("AlgorithmIdentifier", function() { + this.seq().obj(this.key("algorithm").objid(), this.key("parameters").optional(), this.key("curve").objid().optional()); + }); + var SubjectPublicKeyInfo = asn.define("SubjectPublicKeyInfo", function() { + this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier2), this.key("subjectPublicKey").bitstr()); + }); + var RelativeDistinguishedName = asn.define("RelativeDistinguishedName", function() { + this.setof(AttributeTypeValue); + }); + var RDNSequence = asn.define("RDNSequence", function() { + this.seqof(RelativeDistinguishedName); + }); + var Name = asn.define("Name", function() { + this.choice({ + rdnSequence: this.use(RDNSequence) + }); + }); + var Validity = asn.define("Validity", function() { + this.seq().obj(this.key("notBefore").use(Time), this.key("notAfter").use(Time)); + }); + var Extension = asn.define("Extension", function() { + this.seq().obj(this.key("extnID").objid(), this.key("critical").bool().def(false), this.key("extnValue").octstr()); + }); + var TBSCertificate = asn.define("TBSCertificate", function() { + this.seq().obj(this.key("version").explicit(0).int().optional(), this.key("serialNumber").int(), this.key("signature").use(AlgorithmIdentifier2), this.key("issuer").use(Name), this.key("validity").use(Validity), this.key("subject").use(Name), this.key("subjectPublicKeyInfo").use(SubjectPublicKeyInfo), this.key("issuerUniqueID").implicit(1).bitstr().optional(), this.key("subjectUniqueID").implicit(2).bitstr().optional(), this.key("extensions").explicit(3).seqof(Extension).optional()); + }); + var X509Certificate = asn.define("X509Certificate", function() { + this.seq().obj(this.key("tbsCertificate").use(TBSCertificate), this.key("signatureAlgorithm").use(AlgorithmIdentifier2), this.key("signatureValue").bitstr()); + }); + exports$i = X509Certificate; + return exports$i; + } + var exports$h = {}; + var _dewExec$g2 = false; + function dew$g2() { + if (_dewExec$g2) + return exports$h; + _dewExec$g2 = true; + var asn1 = dew$i(); + exports$h.certificate = dew$h(); + var RSAPrivateKey = asn1.define("RSAPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("modulus").int(), this.key("publicExponent").int(), this.key("privateExponent").int(), this.key("prime1").int(), this.key("prime2").int(), this.key("exponent1").int(), this.key("exponent2").int(), this.key("coefficient").int()); + }); + exports$h.RSAPrivateKey = RSAPrivateKey; + var RSAPublicKey = asn1.define("RSAPublicKey", function() { + this.seq().obj(this.key("modulus").int(), this.key("publicExponent").int()); + }); + exports$h.RSAPublicKey = RSAPublicKey; + var PublicKey = asn1.define("SubjectPublicKeyInfo", function() { + this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier2), this.key("subjectPublicKey").bitstr()); + }); + exports$h.PublicKey = PublicKey; + var AlgorithmIdentifier2 = asn1.define("AlgorithmIdentifier", function() { + this.seq().obj(this.key("algorithm").objid(), this.key("none").null_().optional(), this.key("curve").objid().optional(), this.key("params").seq().obj(this.key("p").int(), this.key("q").int(), this.key("g").int()).optional()); + }); + var PrivateKeyInfo2 = asn1.define("PrivateKeyInfo", function() { + this.seq().obj(this.key("version").int(), this.key("algorithm").use(AlgorithmIdentifier2), this.key("subjectPrivateKey").octstr()); + }); + exports$h.PrivateKey = PrivateKeyInfo2; + var EncryptedPrivateKeyInfo = asn1.define("EncryptedPrivateKeyInfo", function() { + this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(), this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(), this.key("kdeparams").seq().obj(this.key("salt").octstr(), this.key("iters").int())), this.key("cipher").seq().obj(this.key("algo").objid(), this.key("iv").octstr()))), this.key("subjectPrivateKey").octstr()); + }); + exports$h.EncryptedPrivateKey = EncryptedPrivateKeyInfo; + var DSAPrivateKey = asn1.define("DSAPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("p").int(), this.key("q").int(), this.key("g").int(), this.key("pub_key").int(), this.key("priv_key").int()); + }); + exports$h.DSAPrivateKey = DSAPrivateKey; + exports$h.DSAparam = asn1.define("DSAparam", function() { + this.int(); + }); + var ECPrivateKey = asn1.define("ECPrivateKey", function() { + this.seq().obj(this.key("version").int(), this.key("privateKey").octstr(), this.key("parameters").optional().explicit(0).use(ECParameters), this.key("publicKey").optional().explicit(1).bitstr()); + }); + exports$h.ECPrivateKey = ECPrivateKey; + var ECParameters = asn1.define("ECParameters", function() { + this.choice({ + namedCurve: this.objid() + }); + }); + exports$h.signature = asn1.define("signature", function() { + this.seq().obj(this.key("r").int(), this.key("s").int()); + }); + return exports$h; + } + var _aesid = { + "2.16.840.1.101.3.4.1.1": "aes-128-ecb", + "2.16.840.1.101.3.4.1.2": "aes-128-cbc", + "2.16.840.1.101.3.4.1.3": "aes-128-ofb", + "2.16.840.1.101.3.4.1.4": "aes-128-cfb", + "2.16.840.1.101.3.4.1.21": "aes-192-ecb", + "2.16.840.1.101.3.4.1.22": "aes-192-cbc", + "2.16.840.1.101.3.4.1.23": "aes-192-ofb", + "2.16.840.1.101.3.4.1.24": "aes-192-cfb", + "2.16.840.1.101.3.4.1.41": "aes-256-ecb", + "2.16.840.1.101.3.4.1.42": "aes-256-cbc", + "2.16.840.1.101.3.4.1.43": "aes-256-ofb", + "2.16.840.1.101.3.4.1.44": "aes-256-cfb" + }; + var exports$g2 = {}; + var _dewExec$f2 = false; + function dew$f2() { + if (_dewExec$f2) + return exports$g2; + _dewExec$f2 = true; + var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m; + var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m; + var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m; + var evp = dew$21(); + var ciphers = dew$1_(); + var Buffer2 = dew$2P().Buffer; + exports$g2 = function(okey, password) { + var key = okey.toString(); + var match10 = key.match(findProc); + var decrypted; + if (!match10) { + var match22 = key.match(fullRegex); + decrypted = Buffer2.from(match22[2].replace(/[\r\n]/g, ""), "base64"); + } else { + var suite = "aes" + match10[1]; + var iv = Buffer2.from(match10[2], "hex"); + var cipherText = Buffer2.from(match10[3].replace(/[\r\n]/g, ""), "base64"); + var cipherKey = evp(password, iv.slice(0, 8), parseInt(match10[1], 10)).key; + var out = []; + var cipher = ciphers.createDecipheriv(suite, cipherKey, iv); + out.push(cipher.update(cipherText)); + out.push(cipher.final()); + decrypted = Buffer2.concat(out); + } + var tag2 = key.match(startRegex)[1]; + return { + tag: tag2, + data: decrypted + }; + }; + return exports$g2; + } + var exports$f2 = {}; + var _dewExec$e2 = false; + function dew$e2() { + if (_dewExec$e2) + return exports$f2; + _dewExec$e2 = true; + var asn1 = dew$g2(); + var aesid = _aesid; + var fixProc = dew$f2(); + var ciphers = dew$1_(); + var compat = dew$2o(); + var Buffer2 = dew$2P().Buffer; + exports$f2 = parseKeys; + function parseKeys(buffer4) { + var password; + if (typeof buffer4 === "object" && !Buffer2.isBuffer(buffer4)) { + password = buffer4.passphrase; + buffer4 = buffer4.key; + } + if (typeof buffer4 === "string") { + buffer4 = Buffer2.from(buffer4); + } + var stripped = fixProc(buffer4, password); + var type3 = stripped.tag; + var data = stripped.data; + var subtype, ndata; + switch (type3) { + case "CERTIFICATE": + ndata = asn1.certificate.decode(data, "der").tbsCertificate.subjectPublicKeyInfo; + case "PUBLIC KEY": + if (!ndata) { + ndata = asn1.PublicKey.decode(data, "der"); + } + subtype = ndata.algorithm.algorithm.join("."); + switch (subtype) { + case "1.2.840.113549.1.1.1": + return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, "der"); + case "1.2.840.10045.2.1": + ndata.subjectPrivateKey = ndata.subjectPublicKey; + return { + type: "ec", + data: ndata + }; + case "1.2.840.10040.4.1": + ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, "der"); + return { + type: "dsa", + data: ndata.algorithm.params + }; + default: + throw new Error("unknown key id " + subtype); + } + case "ENCRYPTED PRIVATE KEY": + data = asn1.EncryptedPrivateKey.decode(data, "der"); + data = decrypt3(data, password); + case "PRIVATE KEY": + ndata = asn1.PrivateKey.decode(data, "der"); + subtype = ndata.algorithm.algorithm.join("."); + switch (subtype) { + case "1.2.840.113549.1.1.1": + return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, "der"); + case "1.2.840.10045.2.1": + return { + curve: ndata.algorithm.curve, + privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, "der").privateKey + }; + case "1.2.840.10040.4.1": + ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, "der"); + return { + type: "dsa", + params: ndata.algorithm.params + }; + default: + throw new Error("unknown key id " + subtype); + } + case "RSA PUBLIC KEY": + return asn1.RSAPublicKey.decode(data, "der"); + case "RSA PRIVATE KEY": + return asn1.RSAPrivateKey.decode(data, "der"); + case "DSA PRIVATE KEY": + return { + type: "dsa", + params: asn1.DSAPrivateKey.decode(data, "der") + }; + case "EC PRIVATE KEY": + data = asn1.ECPrivateKey.decode(data, "der"); + return { + curve: data.parameters.value, + privateKey: data.privateKey + }; + default: + throw new Error("unknown key type " + type3); + } + } + parseKeys.signature = asn1.signature; + function decrypt3(data, password) { + var salt = data.algorithm.decrypt.kde.kdeparams.salt; + var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10); + var algo = aesid[data.algorithm.decrypt.cipher.algo.join(".")]; + var iv = data.algorithm.decrypt.cipher.iv; + var cipherText = data.subjectPrivateKey; + var keylen = parseInt(algo.split("-")[1], 10) / 8; + var key = compat.pbkdf2Sync(password, salt, iters, keylen, "sha1"); + var cipher = ciphers.createDecipheriv(algo, key, iv); + var out = []; + out.push(cipher.update(cipherText)); + out.push(cipher.final()); + return Buffer2.concat(out); + } + return exports$f2; + } + var _curves = { + "1.3.132.0.10": "secp256k1", + "1.3.132.0.33": "p224", + "1.2.840.10045.3.1.1": "p192", + "1.2.840.10045.3.1.7": "p256", + "1.3.132.0.34": "p384", + "1.3.132.0.35": "p521" + }; + var exports$e2 = {}; + var _dewExec$d2 = false; + function dew$d2() { + if (_dewExec$d2) + return exports$e2; + _dewExec$d2 = true; + var Buffer2 = dew$Y().Buffer; + var createHmac2 = dew$2v(); + var crt = dew$W(); + var EC = dew$y().ec; + var BN = dew$X(); + var parseKeys = dew$e2(); + var curves = _curves; + function sign2(hash, key, hashType, signType, tag2) { + var priv = parseKeys(key); + if (priv.curve) { + if (signType !== "ecdsa" && signType !== "ecdsa/rsa") + throw new Error("wrong private key type"); + return ecSign(hash, priv); + } else if (priv.type === "dsa") { + if (signType !== "dsa") + throw new Error("wrong private key type"); + return dsaSign(hash, priv, hashType); + } else { + if (signType !== "rsa" && signType !== "ecdsa/rsa") + throw new Error("wrong private key type"); + } + hash = Buffer2.concat([tag2, hash]); + var len = priv.modulus.byteLength(); + var pad = [0, 1]; + while (hash.length + pad.length + 1 < len) + pad.push(255); + pad.push(0); + var i8 = -1; + while (++i8 < hash.length) + pad.push(hash[i8]); + var out = crt(pad, priv); + return out; + } + function ecSign(hash, priv) { + var curveId = curves[priv.curve.join(".")]; + if (!curveId) + throw new Error("unknown curve " + priv.curve.join(".")); + var curve = new EC(curveId); + var key = curve.keyFromPrivate(priv.privateKey); + var out = key.sign(hash); + return Buffer2.from(out.toDER()); + } + function dsaSign(hash, priv, algo) { + var x5 = priv.params.priv_key; + var p8 = priv.params.p; + var q4 = priv.params.q; + var g6 = priv.params.g; + var r10 = new BN(0); + var k5; + var H4 = bits2int(hash, q4).mod(q4); + var s7 = false; + var kv = getKey(x5, q4, hash, algo); + while (s7 === false) { + k5 = makeKey(q4, kv, algo); + r10 = makeR(g6, k5, p8, q4); + s7 = k5.invm(q4).imul(H4.add(x5.mul(r10))).mod(q4); + if (s7.cmpn(0) === 0) { + s7 = false; + r10 = new BN(0); + } + } + return toDER(r10, s7); + } + function toDER(r10, s7) { + r10 = r10.toArray(); + s7 = s7.toArray(); + if (r10[0] & 128) + r10 = [0].concat(r10); + if (s7[0] & 128) + s7 = [0].concat(s7); + var total = r10.length + s7.length + 4; + var res = [48, total, 2, r10.length]; + res = res.concat(r10, [2, s7.length], s7); + return Buffer2.from(res); + } + function getKey(x5, q4, hash, algo) { + x5 = Buffer2.from(x5.toArray()); + if (x5.length < q4.byteLength()) { + var zeros = Buffer2.alloc(q4.byteLength() - x5.length); + x5 = Buffer2.concat([zeros, x5]); + } + var hlen = hash.length; + var hbits = bits2octets(hash, q4); + var v7 = Buffer2.alloc(hlen); + v7.fill(1); + var k5 = Buffer2.alloc(hlen); + k5 = createHmac2(algo, k5).update(v7).update(Buffer2.from([0])).update(x5).update(hbits).digest(); + v7 = createHmac2(algo, k5).update(v7).digest(); + k5 = createHmac2(algo, k5).update(v7).update(Buffer2.from([1])).update(x5).update(hbits).digest(); + v7 = createHmac2(algo, k5).update(v7).digest(); + return { + k: k5, + v: v7 + }; + } + function bits2int(obits, q4) { + var bits = new BN(obits); + var shift = (obits.length << 3) - q4.bitLength(); + if (shift > 0) + bits.ishrn(shift); + return bits; + } + function bits2octets(bits, q4) { + bits = bits2int(bits, q4); + bits = bits.mod(q4); + var out = Buffer2.from(bits.toArray()); + if (out.length < q4.byteLength()) { + var zeros = Buffer2.alloc(q4.byteLength() - out.length); + out = Buffer2.concat([zeros, out]); + } + return out; + } + function makeKey(q4, kv, algo) { + var t9; + var k5; + do { + t9 = Buffer2.alloc(0); + while (t9.length * 8 < q4.bitLength()) { + kv.v = createHmac2(algo, kv.k).update(kv.v).digest(); + t9 = Buffer2.concat([t9, kv.v]); + } + k5 = bits2int(t9, q4); + kv.k = createHmac2(algo, kv.k).update(kv.v).update(Buffer2.from([0])).digest(); + kv.v = createHmac2(algo, kv.k).update(kv.v).digest(); + } while (k5.cmp(q4) !== -1); + return k5; + } + function makeR(g6, k5, p8, q4) { + return g6.toRed(BN.mont(p8)).redPow(k5).fromRed().mod(q4); + } + exports$e2 = sign2; + exports$e2.getKey = getKey; + exports$e2.makeKey = makeKey; + return exports$e2; + } + var exports$d2 = {}; + var _dewExec$c2 = false; + function dew$c2() { + if (_dewExec$c2) + return exports$d2; + _dewExec$c2 = true; + var Buffer2 = dew$Y().Buffer; + var BN = dew$X(); + var EC = dew$y().ec; + var parseKeys = dew$e2(); + var curves = _curves; + function verify2(sig, hash, key, signType, tag2) { + var pub = parseKeys(key); + if (pub.type === "ec") { + if (signType !== "ecdsa" && signType !== "ecdsa/rsa") + throw new Error("wrong public key type"); + return ecVerify(sig, hash, pub); + } else if (pub.type === "dsa") { + if (signType !== "dsa") + throw new Error("wrong public key type"); + return dsaVerify(sig, hash, pub); + } else { + if (signType !== "rsa" && signType !== "ecdsa/rsa") + throw new Error("wrong public key type"); + } + hash = Buffer2.concat([tag2, hash]); + var len = pub.modulus.byteLength(); + var pad = [1]; + var padNum = 0; + while (hash.length + pad.length + 2 < len) { + pad.push(255); + padNum++; + } + pad.push(0); + var i8 = -1; + while (++i8 < hash.length) { + pad.push(hash[i8]); + } + pad = Buffer2.from(pad); + var red = BN.mont(pub.modulus); + sig = new BN(sig).toRed(red); + sig = sig.redPow(new BN(pub.publicExponent)); + sig = Buffer2.from(sig.fromRed().toArray()); + var out = padNum < 8 ? 1 : 0; + len = Math.min(sig.length, pad.length); + if (sig.length !== pad.length) + out = 1; + i8 = -1; + while (++i8 < len) + out |= sig[i8] ^ pad[i8]; + return out === 0; + } + function ecVerify(sig, hash, pub) { + var curveId = curves[pub.data.algorithm.curve.join(".")]; + if (!curveId) + throw new Error("unknown curve " + pub.data.algorithm.curve.join(".")); + var curve = new EC(curveId); + var pubkey = pub.data.subjectPrivateKey.data; + return curve.verify(hash, sig, pubkey); + } + function dsaVerify(sig, hash, pub) { + var p8 = pub.data.p; + var q4 = pub.data.q; + var g6 = pub.data.g; + var y7 = pub.data.pub_key; + var unpacked = parseKeys.signature.decode(sig, "der"); + var s7 = unpacked.s; + var r10 = unpacked.r; + checkValue(s7, q4); + checkValue(r10, q4); + var montp = BN.mont(p8); + var w5 = s7.invm(q4); + var v7 = g6.toRed(montp).redPow(new BN(hash).mul(w5).mod(q4)).fromRed().mul(y7.toRed(montp).redPow(r10.mul(w5).mod(q4)).fromRed()).mod(p8).mod(q4); + return v7.cmp(r10) === 0; + } + function checkValue(b6, q4) { + if (b6.cmpn(0) <= 0) + throw new Error("invalid sig"); + if (b6.cmp(q4) >= q4) + throw new Error("invalid sig"); + } + exports$d2 = verify2; + return exports$d2; + } + var exports$c2 = {}; + var _dewExec$b2 = false; + var _global$4 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$b2() { + if (_dewExec$b2) + return exports$c2; + _dewExec$b2 = true; + var Buffer2 = dew$Y().Buffer; + var createHash2 = dew$2y(); + var stream2 = dew4(); + var inherits3 = dew$f(); + var sign2 = dew$d2(); + var verify2 = dew$c2(); + var algorithms = _algorithms$1; + Object.keys(algorithms).forEach(function(key) { + algorithms[key].id = Buffer2.from(algorithms[key].id, "hex"); + algorithms[key.toLowerCase()] = algorithms[key]; + }); + function Sign2(algorithm2) { + stream2.Writable.call(this || _global$4); + var data = algorithms[algorithm2]; + if (!data) + throw new Error("Unknown message digest"); + (this || _global$4)._hashType = data.hash; + (this || _global$4)._hash = createHash2(data.hash); + (this || _global$4)._tag = data.id; + (this || _global$4)._signType = data.sign; + } + inherits3(Sign2, stream2.Writable); + Sign2.prototype._write = function _write(data, _5, done) { + (this || _global$4)._hash.update(data); + done(); + }; + Sign2.prototype.update = function update2(data, enc) { + if (typeof data === "string") + data = Buffer2.from(data, enc); + (this || _global$4)._hash.update(data); + return this || _global$4; + }; + Sign2.prototype.sign = function signMethod(key, enc) { + this.end(); + var hash = (this || _global$4)._hash.digest(); + var sig = sign2(hash, key, (this || _global$4)._hashType, (this || _global$4)._signType, (this || _global$4)._tag); + return enc ? sig.toString(enc) : sig; + }; + function Verify2(algorithm2) { + stream2.Writable.call(this || _global$4); + var data = algorithms[algorithm2]; + if (!data) + throw new Error("Unknown message digest"); + (this || _global$4)._hash = createHash2(data.hash); + (this || _global$4)._tag = data.id; + (this || _global$4)._signType = data.sign; + } + inherits3(Verify2, stream2.Writable); + Verify2.prototype._write = function _write(data, _5, done) { + (this || _global$4)._hash.update(data); + done(); + }; + Verify2.prototype.update = function update2(data, enc) { + if (typeof data === "string") + data = Buffer2.from(data, enc); + (this || _global$4)._hash.update(data); + return this || _global$4; + }; + Verify2.prototype.verify = function verifyMethod(key, sig, enc) { + if (typeof sig === "string") + sig = Buffer2.from(sig, enc); + this.end(); + var hash = (this || _global$4)._hash.digest(); + return verify2(sig, hash, key, (this || _global$4)._signType, (this || _global$4)._tag); + }; + function createSign2(algorithm2) { + return new Sign2(algorithm2); + } + function createVerify2(algorithm2) { + return new Verify2(algorithm2); + } + exports$c2 = { + Sign: createSign2, + Verify: createVerify2, + createSign: createSign2, + createVerify: createVerify2 + }; + return exports$c2; + } + var exports$b2 = {}; + var _dewExec$a2 = false; + var module$1 = { + exports: exports$b2 + }; + var _global$3 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$a2() { + if (_dewExec$a2) + return module$1.exports; + _dewExec$a2 = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$3).negative = 0; + (this || _global$3).words = null; + (this || _global$3).length = 0; + (this || _global$3).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = buffer3.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$3).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$3).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$3).words = [number3 & 67108863]; + (this || _global$3).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$3).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$3).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$3).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$3).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$3).words = [0]; + (this || _global$3).length = 1; + return this || _global$3; + } + (this || _global$3).length = Math.ceil(number3.length / 3); + (this || _global$3).words = new Array((this || _global$3).length); + for (var i8 = 0; i8 < (this || _global$3).length; i8++) { + (this || _global$3).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$3).words[j5] |= w5 << off & 67108863; + (this || _global$3).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$3).words[j5] |= w5 << off & 67108863; + (this || _global$3).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$3).length = Math.ceil((number3.length - start) / 6); + (this || _global$3).words = new Array((this || _global$3).length); + for (var i8 = 0; i8 < (this || _global$3).length; i8++) { + (this || _global$3).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$3).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$3).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$3).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$3).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$3).words = [0]; + (this || _global$3).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$3).words[0] + word < 67108864) { + (this || _global$3).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$3).words[0] + word < 67108864) { + (this || _global$3).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$3).length); + for (var i8 = 0; i8 < (this || _global$3).length; i8++) { + dest.words[i8] = (this || _global$3).words[i8]; + } + dest.length = (this || _global$3).length; + dest.negative = (this || _global$3).negative; + dest.red = (this || _global$3).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$3).length < size4) { + (this || _global$3).words[(this || _global$3).length++] = 0; + } + return this || _global$3; + }; + BN.prototype.strip = function strip() { + while ((this || _global$3).length > 1 && (this || _global$3).words[(this || _global$3).length - 1] === 0) { + (this || _global$3).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$3).length === 1 && (this || _global$3).words[0] === 0) { + (this || _global$3).negative = 0; + } + return this || _global$3; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$3).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$3).length; i8++) { + var w5 = (this || _global$3).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$3).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$3).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$3).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$3).words[0]; + if ((this || _global$3).length === 2) { + ret += (this || _global$3).words[1] * 67108864; + } else if ((this || _global$3).length === 3 && (this || _global$3).words[2] === 1) { + ret += 4503599627370496 + (this || _global$3).words[1] * 67108864; + } else if ((this || _global$3).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$3).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$3).words[(this || _global$3).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$3).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$3).length; i8++) { + var b6 = this._zeroBits((this || _global$3).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$3).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$3).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$3).negative ^= 1; + } + return this || _global$3; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$3).length < num.length) { + (this || _global$3).words[(this || _global$3).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$3).words[i8] = (this || _global$3).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$3).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$3).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$3); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$3).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$3); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$3).length > num.length) { + b6 = num; + } else { + b6 = this || _global$3; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$3).words[i8] = (this || _global$3).words[i8] & num.words[i8]; + } + (this || _global$3).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$3).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$3).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$3); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$3).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$3); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$3).length > num.length) { + a8 = this || _global$3; + b6 = num; + } else { + a8 = num; + b6 = this || _global$3; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$3).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$3) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$3).words[i8] = a8.words[i8]; + } + } + (this || _global$3).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$3).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$3).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$3); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$3).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$3); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$3).words[i8] = ~(this || _global$3).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$3).words[i8] = ~(this || _global$3).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$3).words[off] = (this || _global$3).words[off] | 1 << wbit; + } else { + (this || _global$3).words[off] = (this || _global$3).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$3).negative !== 0 && num.negative === 0) { + (this || _global$3).negative = 0; + r10 = this.isub(num); + (this || _global$3).negative ^= 1; + return this._normSign(); + } else if ((this || _global$3).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$3).length > num.length) { + a8 = this || _global$3; + b6 = num; + } else { + a8 = num; + b6 = this || _global$3; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$3).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$3).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$3).length = a8.length; + if (carry !== 0) { + (this || _global$3).words[(this || _global$3).length] = carry; + (this || _global$3).length++; + } else if (a8 !== (this || _global$3)) { + for (; i8 < a8.length; i8++) { + (this || _global$3).words[i8] = a8.words[i8]; + } + } + return this || _global$3; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$3).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$3).negative !== 0) { + (this || _global$3).negative = 0; + res = num.sub(this || _global$3); + (this || _global$3).negative = 1; + return res; + } + if ((this || _global$3).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$3); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$3).negative !== 0) { + (this || _global$3).negative = 0; + this.iadd(num); + (this || _global$3).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$3).negative = 0; + (this || _global$3).length = 1; + (this || _global$3).words[0] = 0; + return this || _global$3; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$3; + b6 = num; + } else { + a8 = num; + b6 = this || _global$3; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$3).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$3).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$3)) { + for (; i8 < a8.length; i8++) { + (this || _global$3).words[i8] = a8.words[i8]; + } + } + (this || _global$3).length = Math.max((this || _global$3).length, i8); + if (a8 !== (this || _global$3)) { + (this || _global$3).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$3).length + num.length; + if ((this || _global$3).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$3, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$3, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$3, num, out); + } else { + res = jumboMulTo(this || _global$3, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$3).x = x5; + (this || _global$3).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$3).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$3).length + num.length); + return jumboMulTo(this || _global$3, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$3); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$3).length; i8++) { + var w5 = ((this || _global$3).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$3).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$3).words[i8] = carry; + (this || _global$3).length++; + } + return this || _global$3; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$3); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$3; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$3).length; i8++) { + var newCarry = (this || _global$3).words[i8] & carryMask; + var c8 = ((this || _global$3).words[i8] | 0) - newCarry << r10; + (this || _global$3).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$3).words[i8] = carry; + (this || _global$3).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$3).length - 1; i8 >= 0; i8--) { + (this || _global$3).words[i8 + s7] = (this || _global$3).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$3).words[i8] = 0; + } + (this || _global$3).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$3).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$3).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$3).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$3).length > s7) { + (this || _global$3).length -= s7; + for (i8 = 0; i8 < (this || _global$3).length; i8++) { + (this || _global$3).words[i8] = (this || _global$3).words[i8 + s7]; + } + } else { + (this || _global$3).words[0] = 0; + (this || _global$3).length = 1; + } + var carry = 0; + for (i8 = (this || _global$3).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$3).words[i8] | 0; + (this || _global$3).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$3).length === 0) { + (this || _global$3).words[0] = 0; + (this || _global$3).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$3).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$3).length <= s7) + return false; + var w5 = (this || _global$3).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$3).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$3).length <= s7) { + return this || _global$3; + } + if (r10 !== 0) { + s7++; + } + (this || _global$3).length = Math.min(s7, (this || _global$3).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$3).words[(this || _global$3).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$3).negative !== 0) { + if ((this || _global$3).length === 1 && ((this || _global$3).words[0] | 0) < num) { + (this || _global$3).words[0] = num - ((this || _global$3).words[0] | 0); + (this || _global$3).negative = 0; + return this || _global$3; + } + (this || _global$3).negative = 0; + this.isubn(num); + (this || _global$3).negative = 1; + return this || _global$3; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$3).words[0] += num; + for (var i8 = 0; i8 < (this || _global$3).length && (this || _global$3).words[i8] >= 67108864; i8++) { + (this || _global$3).words[i8] -= 67108864; + if (i8 === (this || _global$3).length - 1) { + (this || _global$3).words[i8 + 1] = 1; + } else { + (this || _global$3).words[i8 + 1]++; + } + } + (this || _global$3).length = Math.max((this || _global$3).length, i8 + 1); + return this || _global$3; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$3).negative !== 0) { + (this || _global$3).negative = 0; + this.iaddn(num); + (this || _global$3).negative = 1; + return this || _global$3; + } + (this || _global$3).words[0] -= num; + if ((this || _global$3).length === 1 && (this || _global$3).words[0] < 0) { + (this || _global$3).words[0] = -(this || _global$3).words[0]; + (this || _global$3).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$3).length && (this || _global$3).words[i8] < 0; i8++) { + (this || _global$3).words[i8] += 67108864; + (this || _global$3).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$3).negative = 0; + return this || _global$3; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$3).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$3).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$3).length - shift; i8++) { + w5 = ((this || _global$3).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$3).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$3).length; i8++) { + w5 = -((this || _global$3).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$3).words[i8] = w5 & 67108863; + } + (this || _global$3).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$3).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$3).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$3).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$3).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$3).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$3 + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$3).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$3).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$3).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$3).words[i8] | 0) + carry * 67108864; + (this || _global$3).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$3; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$3; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$3).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$3).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$3).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$3).length <= s7) { + this._expand(s7 + 1); + (this || _global$3).words[s7] |= q4; + return this || _global$3; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$3).length; i8++) { + var w5 = (this || _global$3).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$3).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$3).words[i8] = carry; + (this || _global$3).length++; + } + return this || _global$3; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$3).length === 1 && (this || _global$3).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$3).negative !== 0 && !negative) + return -1; + if ((this || _global$3).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$3).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$3).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$3).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$3).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$3).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$3).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$3).length > num.length) + return 1; + if ((this || _global$3).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$3).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$3).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$3).red, "Already a number in reduction context"); + assert((this || _global$3).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$3)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$3).red, "fromRed works only with numbers in reduction context"); + return (this || _global$3).red.convertFrom(this || _global$3); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$3).red = ctx; + return this || _global$3; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$3).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$3).red, "redAdd works only with red numbers"); + return (this || _global$3).red.add(this || _global$3, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$3).red, "redIAdd works only with red numbers"); + return (this || _global$3).red.iadd(this || _global$3, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$3).red, "redSub works only with red numbers"); + return (this || _global$3).red.sub(this || _global$3, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$3).red, "redISub works only with red numbers"); + return (this || _global$3).red.isub(this || _global$3, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$3).red, "redShl works only with red numbers"); + return (this || _global$3).red.shl(this || _global$3, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$3).red, "redMul works only with red numbers"); + (this || _global$3).red._verify2(this || _global$3, num); + return (this || _global$3).red.mul(this || _global$3, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$3).red, "redMul works only with red numbers"); + (this || _global$3).red._verify2(this || _global$3, num); + return (this || _global$3).red.imul(this || _global$3, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$3).red, "redSqr works only with red numbers"); + (this || _global$3).red._verify1(this || _global$3); + return (this || _global$3).red.sqr(this || _global$3); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$3).red, "redISqr works only with red numbers"); + (this || _global$3).red._verify1(this || _global$3); + return (this || _global$3).red.isqr(this || _global$3); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$3).red, "redSqrt works only with red numbers"); + (this || _global$3).red._verify1(this || _global$3); + return (this || _global$3).red.sqrt(this || _global$3); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$3).red, "redInvm works only with red numbers"); + (this || _global$3).red._verify1(this || _global$3); + return (this || _global$3).red.invm(this || _global$3); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$3).red, "redNeg works only with red numbers"); + (this || _global$3).red._verify1(this || _global$3); + return (this || _global$3).red.neg(this || _global$3); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$3).red && !num.red, "redPow(normalNum)"); + (this || _global$3).red._verify1(this || _global$3); + return (this || _global$3).red.pow(this || _global$3, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$3).name = name15; + (this || _global$3).p = new BN(p8, 16); + (this || _global$3).n = (this || _global$3).p.bitLength(); + (this || _global$3).k = new BN(1).iushln((this || _global$3).n).isub((this || _global$3).p); + (this || _global$3).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$3).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$3).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$3).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$3).n); + var cmp = rlen < (this || _global$3).n ? -1 : r10.ucmp((this || _global$3).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$3).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$3).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$3).k); + }; + function K256() { + MPrime.call(this || _global$3, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$3, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$3, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$3, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$3).m = prime.p; + (this || _global$3).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$3).m = m7; + (this || _global$3).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$3).prime) + return (this || _global$3).prime.ireduce(a8)._forceRed(this || _global$3); + return a8.umod((this || _global$3).m)._forceRed(this || _global$3); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$3).m.sub(a8)._forceRed(this || _global$3); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$3).m) >= 0) { + res.isub((this || _global$3).m); + } + return res._forceRed(this || _global$3); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$3).m) >= 0) { + res.isub((this || _global$3).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$3).m); + } + return res._forceRed(this || _global$3); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$3).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$3).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$3).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$3).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$3); + var nOne = one.redNeg(); + var lpow = (this || _global$3).m.subn(1).iushrn(1); + var z6 = (this || _global$3).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$3); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$3).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$3); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$3); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$3).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$3, m7); + (this || _global$3).shift = (this || _global$3).m.bitLength(); + if ((this || _global$3).shift % 26 !== 0) { + (this || _global$3).shift += 26 - (this || _global$3).shift % 26; + } + (this || _global$3).r = new BN(1).iushln((this || _global$3).shift); + (this || _global$3).r2 = this.imod((this || _global$3).r.sqr()); + (this || _global$3).rinv = (this || _global$3).r._invmp((this || _global$3).m); + (this || _global$3).minv = (this || _global$3).rinv.mul((this || _global$3).r).isubn(1).div((this || _global$3).m); + (this || _global$3).minv = (this || _global$3).minv.umod((this || _global$3).r); + (this || _global$3).minv = (this || _global$3).r.sub((this || _global$3).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$3).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$3).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$3).shift).mul((this || _global$3).minv).imaskn((this || _global$3).shift).mul((this || _global$3).m); + var u8 = t9.isub(c8).iushrn((this || _global$3).shift); + var res = u8; + if (u8.cmp((this || _global$3).m) >= 0) { + res = u8.isub((this || _global$3).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$3).m); + } + return res._forceRed(this || _global$3); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$3); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$3).shift).mul((this || _global$3).minv).imaskn((this || _global$3).shift).mul((this || _global$3).m); + var u8 = t9.isub(c8).iushrn((this || _global$3).shift); + var res = u8; + if (u8.cmp((this || _global$3).m) >= 0) { + res = u8.isub((this || _global$3).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$3).m); + } + return res._forceRed(this || _global$3); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$3).m).mul((this || _global$3).r2)); + return res._forceRed(this || _global$3); + }; + })(module$1, exports$b2); + return module$1.exports; + } + var exports$a2 = {}; + var _dewExec$92 = false; + var _global$22 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$92() { + if (_dewExec$92) + return exports$a2; + _dewExec$92 = true; + var Buffer2 = buffer3.Buffer; + var elliptic = dew$y(); + var BN = dew$a2(); + exports$a2 = function createECDH2(curve) { + return new ECDH(curve); + }; + var aliases = { + secp256k1: { + name: "secp256k1", + byteLength: 32 + }, + secp224r1: { + name: "p224", + byteLength: 28 + }, + prime256v1: { + name: "p256", + byteLength: 32 + }, + prime192v1: { + name: "p192", + byteLength: 24 + }, + ed25519: { + name: "ed25519", + byteLength: 32 + }, + secp384r1: { + name: "p384", + byteLength: 48 + }, + secp521r1: { + name: "p521", + byteLength: 66 + } + }; + aliases.p224 = aliases.secp224r1; + aliases.p256 = aliases.secp256r1 = aliases.prime256v1; + aliases.p192 = aliases.secp192r1 = aliases.prime192v1; + aliases.p384 = aliases.secp384r1; + aliases.p521 = aliases.secp521r1; + function ECDH(curve) { + (this || _global$22).curveType = aliases[curve]; + if (!(this || _global$22).curveType) { + (this || _global$22).curveType = { + name: curve + }; + } + (this || _global$22).curve = new elliptic.ec((this || _global$22).curveType.name); + (this || _global$22).keys = void 0; + } + ECDH.prototype.generateKeys = function(enc, format16) { + (this || _global$22).keys = (this || _global$22).curve.genKeyPair(); + return this.getPublicKey(enc, format16); + }; + ECDH.prototype.computeSecret = function(other, inenc, enc) { + inenc = inenc || "utf8"; + if (!Buffer2.isBuffer(other)) { + other = new Buffer2(other, inenc); + } + var otherPub = (this || _global$22).curve.keyFromPublic(other).getPublic(); + var out = otherPub.mul((this || _global$22).keys.getPrivate()).getX(); + return formatReturnValue(out, enc, (this || _global$22).curveType.byteLength); + }; + ECDH.prototype.getPublicKey = function(enc, format16) { + var key = (this || _global$22).keys.getPublic(format16 === "compressed", true); + if (format16 === "hybrid") { + if (key[key.length - 1] % 2) { + key[0] = 7; + } else { + key[0] = 6; + } + } + return formatReturnValue(key, enc); + }; + ECDH.prototype.getPrivateKey = function(enc) { + return formatReturnValue((this || _global$22).keys.getPrivate(), enc); + }; + ECDH.prototype.setPublicKey = function(pub, enc) { + enc = enc || "utf8"; + if (!Buffer2.isBuffer(pub)) { + pub = new Buffer2(pub, enc); + } + (this || _global$22).keys._importPublic(pub); + return this || _global$22; + }; + ECDH.prototype.setPrivateKey = function(priv, enc) { + enc = enc || "utf8"; + if (!Buffer2.isBuffer(priv)) { + priv = new Buffer2(priv, enc); + } + var _priv = new BN(priv); + _priv = _priv.toString(16); + (this || _global$22).keys = (this || _global$22).curve.genKeyPair(); + (this || _global$22).keys._importPrivate(_priv); + return this || _global$22; + }; + function formatReturnValue(bn, enc, len) { + if (!Array.isArray(bn)) { + bn = bn.toArray(); + } + var buf3 = new Buffer2(bn); + if (len && buf3.length < len) { + var zeros = new Buffer2(len - buf3.length); + zeros.fill(0); + buf3 = Buffer2.concat([zeros, buf3]); + } + if (!enc) { + return buf3; + } else { + return buf3.toString(enc); + } + } + return exports$a2; + } + var exports$92 = {}; + var _dewExec$82 = false; + function dew$82() { + if (_dewExec$82) + return exports$92; + _dewExec$82 = true; + var createHash2 = dew$2y(); + var Buffer2 = dew$2P().Buffer; + exports$92 = function(seed, len) { + var t9 = Buffer2.alloc(0); + var i8 = 0; + var c8; + while (t9.length < len) { + c8 = i2ops(i8++); + t9 = Buffer2.concat([t9, createHash2("sha1").update(seed).update(c8).digest()]); + } + return t9.slice(0, len); + }; + function i2ops(c8) { + var out = Buffer2.allocUnsafe(4); + out.writeUInt32BE(c8, 0); + return out; + } + return exports$92; + } + var exports$82 = {}; + var _dewExec$72 = false; + function dew$72() { + if (_dewExec$72) + return exports$82; + _dewExec$72 = true; + exports$82 = function xor3(a8, b6) { + var len = a8.length; + var i8 = -1; + while (++i8 < len) { + a8[i8] ^= b6[i8]; + } + return a8; + }; + return exports$82; + } + var exports$72 = {}; + var _dewExec$62 = false; + var module2 = { + exports: exports$72 + }; + var _global$12 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$62() { + if (_dewExec$62) + return module2.exports; + _dewExec$62 = true; + (function(module3, exports12) { + function assert(val, msg) { + if (!val) + throw new Error(msg || "Assertion failed"); + } + function inherits3(ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function() { + }; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + function BN(number3, base3, endian) { + if (BN.isBN(number3)) { + return number3; + } + (this || _global$12).negative = 0; + (this || _global$12).words = null; + (this || _global$12).length = 0; + (this || _global$12).red = null; + if (number3 !== null) { + if (base3 === "le" || base3 === "be") { + endian = base3; + base3 = 10; + } + this._init(number3 || 0, base3 || 10, endian || "be"); + } + } + if (typeof module3 === "object") { + module3.exports = BN; + } else { + exports12.BN = BN; + } + BN.BN = BN; + BN.wordSize = 26; + var Buffer2; + try { + if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") { + Buffer2 = window.Buffer; + } else { + Buffer2 = buffer3.Buffer; + } + } catch (e12) { + } + BN.isBN = function isBN(num) { + if (num instanceof BN) { + return true; + } + return num !== null && typeof num === "object" && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + BN.max = function max(left, right) { + if (left.cmp(right) > 0) + return left; + return right; + }; + BN.min = function min(left, right) { + if (left.cmp(right) < 0) + return left; + return right; + }; + BN.prototype._init = function init3(number3, base3, endian) { + if (typeof number3 === "number") { + return this._initNumber(number3, base3, endian); + } + if (typeof number3 === "object") { + return this._initArray(number3, base3, endian); + } + if (base3 === "hex") { + base3 = 16; + } + assert(base3 === (base3 | 0) && base3 >= 2 && base3 <= 36); + number3 = number3.toString().replace(/\s+/g, ""); + var start = 0; + if (number3[0] === "-") { + start++; + (this || _global$12).negative = 1; + } + if (start < number3.length) { + if (base3 === 16) { + this._parseHex(number3, start, endian); + } else { + this._parseBase(number3, base3, start); + if (endian === "le") { + this._initArray(this.toArray(), base3, endian); + } + } + } + }; + BN.prototype._initNumber = function _initNumber(number3, base3, endian) { + if (number3 < 0) { + (this || _global$12).negative = 1; + number3 = -number3; + } + if (number3 < 67108864) { + (this || _global$12).words = [number3 & 67108863]; + (this || _global$12).length = 1; + } else if (number3 < 4503599627370496) { + (this || _global$12).words = [number3 & 67108863, number3 / 67108864 & 67108863]; + (this || _global$12).length = 2; + } else { + assert(number3 < 9007199254740992); + (this || _global$12).words = [number3 & 67108863, number3 / 67108864 & 67108863, 1]; + (this || _global$12).length = 3; + } + if (endian !== "le") + return; + this._initArray(this.toArray(), base3, endian); + }; + BN.prototype._initArray = function _initArray(number3, base3, endian) { + assert(typeof number3.length === "number"); + if (number3.length <= 0) { + (this || _global$12).words = [0]; + (this || _global$12).length = 1; + return this || _global$12; + } + (this || _global$12).length = Math.ceil(number3.length / 3); + (this || _global$12).words = new Array((this || _global$12).length); + for (var i8 = 0; i8 < (this || _global$12).length; i8++) { + (this || _global$12).words[i8] = 0; + } + var j5, w5; + var off = 0; + if (endian === "be") { + for (i8 = number3.length - 1, j5 = 0; i8 >= 0; i8 -= 3) { + w5 = number3[i8] | number3[i8 - 1] << 8 | number3[i8 - 2] << 16; + (this || _global$12).words[j5] |= w5 << off & 67108863; + (this || _global$12).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } else if (endian === "le") { + for (i8 = 0, j5 = 0; i8 < number3.length; i8 += 3) { + w5 = number3[i8] | number3[i8 + 1] << 8 | number3[i8 + 2] << 16; + (this || _global$12).words[j5] |= w5 << off & 67108863; + (this || _global$12).words[j5 + 1] = w5 >>> 26 - off & 67108863; + off += 24; + if (off >= 26) { + off -= 26; + j5++; + } + } + } + return this.strip(); + }; + function parseHex4Bits(string4, index2) { + var c8 = string4.charCodeAt(index2); + if (c8 >= 65 && c8 <= 70) { + return c8 - 55; + } else if (c8 >= 97 && c8 <= 102) { + return c8 - 87; + } else { + return c8 - 48 & 15; + } + } + function parseHexByte(string4, lowerBound2, index2) { + var r10 = parseHex4Bits(string4, index2); + if (index2 - 1 >= lowerBound2) { + r10 |= parseHex4Bits(string4, index2 - 1) << 4; + } + return r10; + } + BN.prototype._parseHex = function _parseHex(number3, start, endian) { + (this || _global$12).length = Math.ceil((number3.length - start) / 6); + (this || _global$12).words = new Array((this || _global$12).length); + for (var i8 = 0; i8 < (this || _global$12).length; i8++) { + (this || _global$12).words[i8] = 0; + } + var off = 0; + var j5 = 0; + var w5; + if (endian === "be") { + for (i8 = number3.length - 1; i8 >= start; i8 -= 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$12).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$12).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number3.length - start; + for (i8 = parseLength % 2 === 0 ? start + 1 : start; i8 < number3.length; i8 += 2) { + w5 = parseHexByte(number3, start, i8) << off; + (this || _global$12).words[j5] |= w5 & 67108863; + if (off >= 18) { + off -= 18; + j5 += 1; + (this || _global$12).words[j5] |= w5 >>> 26; + } else { + off += 8; + } + } + } + this.strip(); + }; + function parseBase(str, start, end, mul) { + var r10 = 0; + var len = Math.min(str.length, end); + for (var i8 = start; i8 < len; i8++) { + var c8 = str.charCodeAt(i8) - 48; + r10 *= mul; + if (c8 >= 49) { + r10 += c8 - 49 + 10; + } else if (c8 >= 17) { + r10 += c8 - 17 + 10; + } else { + r10 += c8; + } + } + return r10; + } + BN.prototype._parseBase = function _parseBase(number3, base3, start) { + (this || _global$12).words = [0]; + (this || _global$12).length = 1; + for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base3) { + limbLen++; + } + limbLen--; + limbPow = limbPow / base3 | 0; + var total = number3.length - start; + var mod3 = total % limbLen; + var end = Math.min(total, total - mod3) + start; + var word = 0; + for (var i8 = start; i8 < end; i8 += limbLen) { + word = parseBase(number3, i8, i8 + limbLen, base3); + this.imuln(limbPow); + if ((this || _global$12).words[0] + word < 67108864) { + (this || _global$12).words[0] += word; + } else { + this._iaddn(word); + } + } + if (mod3 !== 0) { + var pow = 1; + word = parseBase(number3, i8, number3.length, base3); + for (i8 = 0; i8 < mod3; i8++) { + pow *= base3; + } + this.imuln(pow); + if ((this || _global$12).words[0] + word < 67108864) { + (this || _global$12).words[0] += word; + } else { + this._iaddn(word); + } + } + this.strip(); + }; + BN.prototype.copy = function copy(dest) { + dest.words = new Array((this || _global$12).length); + for (var i8 = 0; i8 < (this || _global$12).length; i8++) { + dest.words[i8] = (this || _global$12).words[i8]; + } + dest.length = (this || _global$12).length; + dest.negative = (this || _global$12).negative; + dest.red = (this || _global$12).red; + }; + BN.prototype.clone = function clone() { + var r10 = new BN(null); + this.copy(r10); + return r10; + }; + BN.prototype._expand = function _expand(size4) { + while ((this || _global$12).length < size4) { + (this || _global$12).words[(this || _global$12).length++] = 0; + } + return this || _global$12; + }; + BN.prototype.strip = function strip() { + while ((this || _global$12).length > 1 && (this || _global$12).words[(this || _global$12).length - 1] === 0) { + (this || _global$12).length--; + } + return this._normSign(); + }; + BN.prototype._normSign = function _normSign() { + if ((this || _global$12).length === 1 && (this || _global$12).words[0] === 0) { + (this || _global$12).negative = 0; + } + return this || _global$12; + }; + BN.prototype.inspect = function inspect3() { + return ((this || _global$12).red ? ""; + }; + var zeros = ["", "0", "00", "000", "0000", "00000", "000000", "0000000", "00000000", "000000000", "0000000000", "00000000000", "000000000000", "0000000000000", "00000000000000", "000000000000000", "0000000000000000", "00000000000000000", "000000000000000000", "0000000000000000000", "00000000000000000000", "000000000000000000000", "0000000000000000000000", "00000000000000000000000", "000000000000000000000000", "0000000000000000000000000"]; + var groupSizes = [0, 0, 25, 16, 12, 11, 10, 9, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]; + var groupBases = [0, 0, 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, 43046721, 1e7, 19487171, 35831808, 62748517, 7529536, 11390625, 16777216, 24137569, 34012224, 47045881, 64e6, 4084101, 5153632, 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, 243e5, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176]; + BN.prototype.toString = function toString6(base3, padding) { + base3 = base3 || 10; + padding = padding | 0 || 1; + var out; + if (base3 === 16 || base3 === "hex") { + out = ""; + var off = 0; + var carry = 0; + for (var i8 = 0; i8 < (this || _global$12).length; i8++) { + var w5 = (this || _global$12).words[i8]; + var word = ((w5 << off | carry) & 16777215).toString(16); + carry = w5 >>> 24 - off & 16777215; + if (carry !== 0 || i8 !== (this || _global$12).length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i8--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$12).negative !== 0) { + out = "-" + out; + } + return out; + } + if (base3 === (base3 | 0) && base3 >= 2 && base3 <= 36) { + var groupSize = groupSizes[base3]; + var groupBase = groupBases[base3]; + out = ""; + var c8 = this.clone(); + c8.negative = 0; + while (!c8.isZero()) { + var r10 = c8.modn(groupBase).toString(base3); + c8 = c8.idivn(groupBase); + if (!c8.isZero()) { + out = zeros[groupSize - r10.length] + r10 + out; + } else { + out = r10 + out; + } + } + if (this.isZero()) { + out = "0" + out; + } + while (out.length % padding !== 0) { + out = "0" + out; + } + if ((this || _global$12).negative !== 0) { + out = "-" + out; + } + return out; + } + assert(false, "Base should be between 2 and 36"); + }; + BN.prototype.toNumber = function toNumber() { + var ret = (this || _global$12).words[0]; + if ((this || _global$12).length === 2) { + ret += (this || _global$12).words[1] * 67108864; + } else if ((this || _global$12).length === 3 && (this || _global$12).words[2] === 1) { + ret += 4503599627370496 + (this || _global$12).words[1] * 67108864; + } else if ((this || _global$12).length > 2) { + assert(false, "Number can only safely store up to 53 bits"); + } + return (this || _global$12).negative !== 0 ? -ret : ret; + }; + BN.prototype.toJSON = function toJSON4() { + return this.toString(16); + }; + BN.prototype.toBuffer = function toBuffer(endian, length3) { + assert(typeof Buffer2 !== "undefined"); + return this.toArrayLike(Buffer2, endian, length3); + }; + BN.prototype.toArray = function toArray(endian, length3) { + return this.toArrayLike(Array, endian, length3); + }; + BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length3) { + var byteLength = this.byteLength(); + var reqLength = length3 || Math.max(1, byteLength); + assert(byteLength <= reqLength, "byte array longer than desired length"); + assert(reqLength > 0, "Requested array length <= 0"); + this.strip(); + var littleEndian = endian === "le"; + var res = new ArrayType(reqLength); + var b6, i8; + var q4 = this.clone(); + if (!littleEndian) { + for (i8 = 0; i8 < reqLength - byteLength; i8++) { + res[i8] = 0; + } + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[reqLength - i8 - 1] = b6; + } + } else { + for (i8 = 0; !q4.isZero(); i8++) { + b6 = q4.andln(255); + q4.iushrn(8); + res[i8] = b6; + } + for (; i8 < reqLength; i8++) { + res[i8] = 0; + } + } + return res; + }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits(w5) { + return 32 - Math.clz32(w5); + }; + } else { + BN.prototype._countBits = function _countBits(w5) { + var t9 = w5; + var r10 = 0; + if (t9 >= 4096) { + r10 += 13; + t9 >>>= 13; + } + if (t9 >= 64) { + r10 += 7; + t9 >>>= 7; + } + if (t9 >= 8) { + r10 += 4; + t9 >>>= 4; + } + if (t9 >= 2) { + r10 += 2; + t9 >>>= 2; + } + return r10 + t9; + }; + } + BN.prototype._zeroBits = function _zeroBits(w5) { + if (w5 === 0) + return 26; + var t9 = w5; + var r10 = 0; + if ((t9 & 8191) === 0) { + r10 += 13; + t9 >>>= 13; + } + if ((t9 & 127) === 0) { + r10 += 7; + t9 >>>= 7; + } + if ((t9 & 15) === 0) { + r10 += 4; + t9 >>>= 4; + } + if ((t9 & 3) === 0) { + r10 += 2; + t9 >>>= 2; + } + if ((t9 & 1) === 0) { + r10++; + } + return r10; + }; + BN.prototype.bitLength = function bitLength() { + var w5 = (this || _global$12).words[(this || _global$12).length - 1]; + var hi = this._countBits(w5); + return ((this || _global$12).length - 1) * 26 + hi; + }; + function toBitArray(num) { + var w5 = new Array(num.bitLength()); + for (var bit = 0; bit < w5.length; bit++) { + var off = bit / 26 | 0; + var wbit = bit % 26; + w5[bit] = (num.words[off] & 1 << wbit) >>> wbit; + } + return w5; + } + BN.prototype.zeroBits = function zeroBits() { + if (this.isZero()) + return 0; + var r10 = 0; + for (var i8 = 0; i8 < (this || _global$12).length; i8++) { + var b6 = this._zeroBits((this || _global$12).words[i8]); + r10 += b6; + if (b6 !== 26) + break; + } + return r10; + }; + BN.prototype.byteLength = function byteLength() { + return Math.ceil(this.bitLength() / 8); + }; + BN.prototype.toTwos = function toTwos(width) { + if ((this || _global$12).negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + BN.prototype.fromTwos = function fromTwos(width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + BN.prototype.isNeg = function isNeg() { + return (this || _global$12).negative !== 0; + }; + BN.prototype.neg = function neg() { + return this.clone().ineg(); + }; + BN.prototype.ineg = function ineg() { + if (!this.isZero()) { + (this || _global$12).negative ^= 1; + } + return this || _global$12; + }; + BN.prototype.iuor = function iuor(num) { + while ((this || _global$12).length < num.length) { + (this || _global$12).words[(this || _global$12).length++] = 0; + } + for (var i8 = 0; i8 < num.length; i8++) { + (this || _global$12).words[i8] = (this || _global$12).words[i8] | num.words[i8]; + } + return this.strip(); + }; + BN.prototype.ior = function ior(num) { + assert(((this || _global$12).negative | num.negative) === 0); + return this.iuor(num); + }; + BN.prototype.or = function or14(num) { + if ((this || _global$12).length > num.length) + return this.clone().ior(num); + return num.clone().ior(this || _global$12); + }; + BN.prototype.uor = function uor(num) { + if ((this || _global$12).length > num.length) + return this.clone().iuor(num); + return num.clone().iuor(this || _global$12); + }; + BN.prototype.iuand = function iuand(num) { + var b6; + if ((this || _global$12).length > num.length) { + b6 = num; + } else { + b6 = this || _global$12; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$12).words[i8] = (this || _global$12).words[i8] & num.words[i8]; + } + (this || _global$12).length = b6.length; + return this.strip(); + }; + BN.prototype.iand = function iand(num) { + assert(((this || _global$12).negative | num.negative) === 0); + return this.iuand(num); + }; + BN.prototype.and = function and10(num) { + if ((this || _global$12).length > num.length) + return this.clone().iand(num); + return num.clone().iand(this || _global$12); + }; + BN.prototype.uand = function uand(num) { + if ((this || _global$12).length > num.length) + return this.clone().iuand(num); + return num.clone().iuand(this || _global$12); + }; + BN.prototype.iuxor = function iuxor(num) { + var a8; + var b6; + if ((this || _global$12).length > num.length) { + a8 = this || _global$12; + b6 = num; + } else { + a8 = num; + b6 = this || _global$12; + } + for (var i8 = 0; i8 < b6.length; i8++) { + (this || _global$12).words[i8] = a8.words[i8] ^ b6.words[i8]; + } + if ((this || _global$12) !== a8) { + for (; i8 < a8.length; i8++) { + (this || _global$12).words[i8] = a8.words[i8]; + } + } + (this || _global$12).length = a8.length; + return this.strip(); + }; + BN.prototype.ixor = function ixor(num) { + assert(((this || _global$12).negative | num.negative) === 0); + return this.iuxor(num); + }; + BN.prototype.xor = function xor3(num) { + if ((this || _global$12).length > num.length) + return this.clone().ixor(num); + return num.clone().ixor(this || _global$12); + }; + BN.prototype.uxor = function uxor(num) { + if ((this || _global$12).length > num.length) + return this.clone().iuxor(num); + return num.clone().iuxor(this || _global$12); + }; + BN.prototype.inotn = function inotn(width) { + assert(typeof width === "number" && width >= 0); + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + this._expand(bytesNeeded); + if (bitsLeft > 0) { + bytesNeeded--; + } + for (var i8 = 0; i8 < bytesNeeded; i8++) { + (this || _global$12).words[i8] = ~(this || _global$12).words[i8] & 67108863; + } + if (bitsLeft > 0) { + (this || _global$12).words[i8] = ~(this || _global$12).words[i8] & 67108863 >> 26 - bitsLeft; + } + return this.strip(); + }; + BN.prototype.notn = function notn(width) { + return this.clone().inotn(width); + }; + BN.prototype.setn = function setn(bit, val) { + assert(typeof bit === "number" && bit >= 0); + var off = bit / 26 | 0; + var wbit = bit % 26; + this._expand(off + 1); + if (val) { + (this || _global$12).words[off] = (this || _global$12).words[off] | 1 << wbit; + } else { + (this || _global$12).words[off] = (this || _global$12).words[off] & ~(1 << wbit); + } + return this.strip(); + }; + BN.prototype.iadd = function iadd(num) { + var r10; + if ((this || _global$12).negative !== 0 && num.negative === 0) { + (this || _global$12).negative = 0; + r10 = this.isub(num); + (this || _global$12).negative ^= 1; + return this._normSign(); + } else if ((this || _global$12).negative === 0 && num.negative !== 0) { + num.negative = 0; + r10 = this.isub(num); + num.negative = 1; + return r10._normSign(); + } + var a8, b6; + if ((this || _global$12).length > num.length) { + a8 = this || _global$12; + b6 = num; + } else { + a8 = num; + b6 = this || _global$12; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) + (b6.words[i8] | 0) + carry; + (this || _global$12).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + (this || _global$12).words[i8] = r10 & 67108863; + carry = r10 >>> 26; + } + (this || _global$12).length = a8.length; + if (carry !== 0) { + (this || _global$12).words[(this || _global$12).length] = carry; + (this || _global$12).length++; + } else if (a8 !== (this || _global$12)) { + for (; i8 < a8.length; i8++) { + (this || _global$12).words[i8] = a8.words[i8]; + } + } + return this || _global$12; + }; + BN.prototype.add = function add12(num) { + var res; + if (num.negative !== 0 && (this || _global$12).negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && (this || _global$12).negative !== 0) { + (this || _global$12).negative = 0; + res = num.sub(this || _global$12); + (this || _global$12).negative = 1; + return res; + } + if ((this || _global$12).length > num.length) + return this.clone().iadd(num); + return num.clone().iadd(this || _global$12); + }; + BN.prototype.isub = function isub(num) { + if (num.negative !== 0) { + num.negative = 0; + var r10 = this.iadd(num); + num.negative = 1; + return r10._normSign(); + } else if ((this || _global$12).negative !== 0) { + (this || _global$12).negative = 0; + this.iadd(num); + (this || _global$12).negative = 1; + return this._normSign(); + } + var cmp = this.cmp(num); + if (cmp === 0) { + (this || _global$12).negative = 0; + (this || _global$12).length = 1; + (this || _global$12).words[0] = 0; + return this || _global$12; + } + var a8, b6; + if (cmp > 0) { + a8 = this || _global$12; + b6 = num; + } else { + a8 = num; + b6 = this || _global$12; + } + var carry = 0; + for (var i8 = 0; i8 < b6.length; i8++) { + r10 = (a8.words[i8] | 0) - (b6.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$12).words[i8] = r10 & 67108863; + } + for (; carry !== 0 && i8 < a8.length; i8++) { + r10 = (a8.words[i8] | 0) + carry; + carry = r10 >> 26; + (this || _global$12).words[i8] = r10 & 67108863; + } + if (carry === 0 && i8 < a8.length && a8 !== (this || _global$12)) { + for (; i8 < a8.length; i8++) { + (this || _global$12).words[i8] = a8.words[i8]; + } + } + (this || _global$12).length = Math.max((this || _global$12).length, i8); + if (a8 !== (this || _global$12)) { + (this || _global$12).negative = 1; + } + return this.strip(); + }; + BN.prototype.sub = function sub(num) { + return this.clone().isub(num); + }; + function smallMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + var len = self2.length + num.length | 0; + out.length = len; + len = len - 1 | 0; + var a8 = self2.words[0] | 0; + var b6 = num.words[0] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + var carry = r10 / 67108864 | 0; + out.words[0] = lo; + for (var k5 = 1; k5 < len; k5++) { + var ncarry = carry >>> 26; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5 | 0; + a8 = self2.words[i8] | 0; + b6 = num.words[j5] | 0; + r10 = a8 * b6 + rword; + ncarry += r10 / 67108864 | 0; + rword = r10 & 67108863; + } + out.words[k5] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k5] = carry | 0; + } else { + out.length--; + } + return out.strip(); + } + var comb10MulTo = function comb10MulTo2(self2, num, out) { + var a8 = self2.words; + var b6 = num.words; + var o9 = out.words; + var c8 = 0; + var lo; + var mid; + var hi; + var a0 = a8[0] | 0; + var al0 = a0 & 8191; + var ah0 = a0 >>> 13; + var a1 = a8[1] | 0; + var al1 = a1 & 8191; + var ah1 = a1 >>> 13; + var a22 = a8[2] | 0; + var al2 = a22 & 8191; + var ah2 = a22 >>> 13; + var a32 = a8[3] | 0; + var al3 = a32 & 8191; + var ah3 = a32 >>> 13; + var a42 = a8[4] | 0; + var al4 = a42 & 8191; + var ah4 = a42 >>> 13; + var a52 = a8[5] | 0; + var al5 = a52 & 8191; + var ah5 = a52 >>> 13; + var a62 = a8[6] | 0; + var al6 = a62 & 8191; + var ah6 = a62 >>> 13; + var a72 = a8[7] | 0; + var al7 = a72 & 8191; + var ah7 = a72 >>> 13; + var a82 = a8[8] | 0; + var al8 = a82 & 8191; + var ah8 = a82 >>> 13; + var a9 = a8[9] | 0; + var al9 = a9 & 8191; + var ah9 = a9 >>> 13; + var b0 = b6[0] | 0; + var bl0 = b0 & 8191; + var bh0 = b0 >>> 13; + var b1 = b6[1] | 0; + var bl1 = b1 & 8191; + var bh1 = b1 >>> 13; + var b22 = b6[2] | 0; + var bl2 = b22 & 8191; + var bh2 = b22 >>> 13; + var b32 = b6[3] | 0; + var bl3 = b32 & 8191; + var bh3 = b32 >>> 13; + var b42 = b6[4] | 0; + var bl4 = b42 & 8191; + var bh4 = b42 >>> 13; + var b52 = b6[5] | 0; + var bl5 = b52 & 8191; + var bh5 = b52 >>> 13; + var b62 = b6[6] | 0; + var bl6 = b62 & 8191; + var bh6 = b62 >>> 13; + var b7 = b6[7] | 0; + var bl7 = b7 & 8191; + var bh7 = b7 >>> 13; + var b8 = b6[8] | 0; + var bl8 = b8 & 8191; + var bh8 = b8 >>> 13; + var b9 = b6[9] | 0; + var bl9 = b9 & 8191; + var bh9 = b9 >>> 13; + out.negative = self2.negative ^ num.negative; + out.length = 19; + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = mid + Math.imul(ah0, bl0) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0; + w0 &= 67108863; + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = mid + Math.imul(ah1, bl0) | 0; + hi = Math.imul(ah1, bh0); + lo = lo + Math.imul(al0, bl1) | 0; + mid = mid + Math.imul(al0, bh1) | 0; + mid = mid + Math.imul(ah0, bl1) | 0; + hi = hi + Math.imul(ah0, bh1) | 0; + var w1 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0; + w1 &= 67108863; + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = mid + Math.imul(ah2, bl0) | 0; + hi = Math.imul(ah2, bh0); + lo = lo + Math.imul(al1, bl1) | 0; + mid = mid + Math.imul(al1, bh1) | 0; + mid = mid + Math.imul(ah1, bl1) | 0; + hi = hi + Math.imul(ah1, bh1) | 0; + lo = lo + Math.imul(al0, bl2) | 0; + mid = mid + Math.imul(al0, bh2) | 0; + mid = mid + Math.imul(ah0, bl2) | 0; + hi = hi + Math.imul(ah0, bh2) | 0; + var w22 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w22 >>> 26) | 0; + w22 &= 67108863; + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = mid + Math.imul(ah3, bl0) | 0; + hi = Math.imul(ah3, bh0); + lo = lo + Math.imul(al2, bl1) | 0; + mid = mid + Math.imul(al2, bh1) | 0; + mid = mid + Math.imul(ah2, bl1) | 0; + hi = hi + Math.imul(ah2, bh1) | 0; + lo = lo + Math.imul(al1, bl2) | 0; + mid = mid + Math.imul(al1, bh2) | 0; + mid = mid + Math.imul(ah1, bl2) | 0; + hi = hi + Math.imul(ah1, bh2) | 0; + lo = lo + Math.imul(al0, bl3) | 0; + mid = mid + Math.imul(al0, bh3) | 0; + mid = mid + Math.imul(ah0, bl3) | 0; + hi = hi + Math.imul(ah0, bh3) | 0; + var w32 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w32 >>> 26) | 0; + w32 &= 67108863; + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = mid + Math.imul(ah4, bl0) | 0; + hi = Math.imul(ah4, bh0); + lo = lo + Math.imul(al3, bl1) | 0; + mid = mid + Math.imul(al3, bh1) | 0; + mid = mid + Math.imul(ah3, bl1) | 0; + hi = hi + Math.imul(ah3, bh1) | 0; + lo = lo + Math.imul(al2, bl2) | 0; + mid = mid + Math.imul(al2, bh2) | 0; + mid = mid + Math.imul(ah2, bl2) | 0; + hi = hi + Math.imul(ah2, bh2) | 0; + lo = lo + Math.imul(al1, bl3) | 0; + mid = mid + Math.imul(al1, bh3) | 0; + mid = mid + Math.imul(ah1, bl3) | 0; + hi = hi + Math.imul(ah1, bh3) | 0; + lo = lo + Math.imul(al0, bl4) | 0; + mid = mid + Math.imul(al0, bh4) | 0; + mid = mid + Math.imul(ah0, bl4) | 0; + hi = hi + Math.imul(ah0, bh4) | 0; + var w42 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w42 >>> 26) | 0; + w42 &= 67108863; + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = mid + Math.imul(ah5, bl0) | 0; + hi = Math.imul(ah5, bh0); + lo = lo + Math.imul(al4, bl1) | 0; + mid = mid + Math.imul(al4, bh1) | 0; + mid = mid + Math.imul(ah4, bl1) | 0; + hi = hi + Math.imul(ah4, bh1) | 0; + lo = lo + Math.imul(al3, bl2) | 0; + mid = mid + Math.imul(al3, bh2) | 0; + mid = mid + Math.imul(ah3, bl2) | 0; + hi = hi + Math.imul(ah3, bh2) | 0; + lo = lo + Math.imul(al2, bl3) | 0; + mid = mid + Math.imul(al2, bh3) | 0; + mid = mid + Math.imul(ah2, bl3) | 0; + hi = hi + Math.imul(ah2, bh3) | 0; + lo = lo + Math.imul(al1, bl4) | 0; + mid = mid + Math.imul(al1, bh4) | 0; + mid = mid + Math.imul(ah1, bl4) | 0; + hi = hi + Math.imul(ah1, bh4) | 0; + lo = lo + Math.imul(al0, bl5) | 0; + mid = mid + Math.imul(al0, bh5) | 0; + mid = mid + Math.imul(ah0, bl5) | 0; + hi = hi + Math.imul(ah0, bh5) | 0; + var w5 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0; + w5 &= 67108863; + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = mid + Math.imul(ah6, bl0) | 0; + hi = Math.imul(ah6, bh0); + lo = lo + Math.imul(al5, bl1) | 0; + mid = mid + Math.imul(al5, bh1) | 0; + mid = mid + Math.imul(ah5, bl1) | 0; + hi = hi + Math.imul(ah5, bh1) | 0; + lo = lo + Math.imul(al4, bl2) | 0; + mid = mid + Math.imul(al4, bh2) | 0; + mid = mid + Math.imul(ah4, bl2) | 0; + hi = hi + Math.imul(ah4, bh2) | 0; + lo = lo + Math.imul(al3, bl3) | 0; + mid = mid + Math.imul(al3, bh3) | 0; + mid = mid + Math.imul(ah3, bl3) | 0; + hi = hi + Math.imul(ah3, bh3) | 0; + lo = lo + Math.imul(al2, bl4) | 0; + mid = mid + Math.imul(al2, bh4) | 0; + mid = mid + Math.imul(ah2, bl4) | 0; + hi = hi + Math.imul(ah2, bh4) | 0; + lo = lo + Math.imul(al1, bl5) | 0; + mid = mid + Math.imul(al1, bh5) | 0; + mid = mid + Math.imul(ah1, bl5) | 0; + hi = hi + Math.imul(ah1, bh5) | 0; + lo = lo + Math.imul(al0, bl6) | 0; + mid = mid + Math.imul(al0, bh6) | 0; + mid = mid + Math.imul(ah0, bl6) | 0; + hi = hi + Math.imul(ah0, bh6) | 0; + var w6 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0; + w6 &= 67108863; + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = mid + Math.imul(ah7, bl0) | 0; + hi = Math.imul(ah7, bh0); + lo = lo + Math.imul(al6, bl1) | 0; + mid = mid + Math.imul(al6, bh1) | 0; + mid = mid + Math.imul(ah6, bl1) | 0; + hi = hi + Math.imul(ah6, bh1) | 0; + lo = lo + Math.imul(al5, bl2) | 0; + mid = mid + Math.imul(al5, bh2) | 0; + mid = mid + Math.imul(ah5, bl2) | 0; + hi = hi + Math.imul(ah5, bh2) | 0; + lo = lo + Math.imul(al4, bl3) | 0; + mid = mid + Math.imul(al4, bh3) | 0; + mid = mid + Math.imul(ah4, bl3) | 0; + hi = hi + Math.imul(ah4, bh3) | 0; + lo = lo + Math.imul(al3, bl4) | 0; + mid = mid + Math.imul(al3, bh4) | 0; + mid = mid + Math.imul(ah3, bl4) | 0; + hi = hi + Math.imul(ah3, bh4) | 0; + lo = lo + Math.imul(al2, bl5) | 0; + mid = mid + Math.imul(al2, bh5) | 0; + mid = mid + Math.imul(ah2, bl5) | 0; + hi = hi + Math.imul(ah2, bh5) | 0; + lo = lo + Math.imul(al1, bl6) | 0; + mid = mid + Math.imul(al1, bh6) | 0; + mid = mid + Math.imul(ah1, bl6) | 0; + hi = hi + Math.imul(ah1, bh6) | 0; + lo = lo + Math.imul(al0, bl7) | 0; + mid = mid + Math.imul(al0, bh7) | 0; + mid = mid + Math.imul(ah0, bl7) | 0; + hi = hi + Math.imul(ah0, bh7) | 0; + var w7 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0; + w7 &= 67108863; + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = mid + Math.imul(ah8, bl0) | 0; + hi = Math.imul(ah8, bh0); + lo = lo + Math.imul(al7, bl1) | 0; + mid = mid + Math.imul(al7, bh1) | 0; + mid = mid + Math.imul(ah7, bl1) | 0; + hi = hi + Math.imul(ah7, bh1) | 0; + lo = lo + Math.imul(al6, bl2) | 0; + mid = mid + Math.imul(al6, bh2) | 0; + mid = mid + Math.imul(ah6, bl2) | 0; + hi = hi + Math.imul(ah6, bh2) | 0; + lo = lo + Math.imul(al5, bl3) | 0; + mid = mid + Math.imul(al5, bh3) | 0; + mid = mid + Math.imul(ah5, bl3) | 0; + hi = hi + Math.imul(ah5, bh3) | 0; + lo = lo + Math.imul(al4, bl4) | 0; + mid = mid + Math.imul(al4, bh4) | 0; + mid = mid + Math.imul(ah4, bl4) | 0; + hi = hi + Math.imul(ah4, bh4) | 0; + lo = lo + Math.imul(al3, bl5) | 0; + mid = mid + Math.imul(al3, bh5) | 0; + mid = mid + Math.imul(ah3, bl5) | 0; + hi = hi + Math.imul(ah3, bh5) | 0; + lo = lo + Math.imul(al2, bl6) | 0; + mid = mid + Math.imul(al2, bh6) | 0; + mid = mid + Math.imul(ah2, bl6) | 0; + hi = hi + Math.imul(ah2, bh6) | 0; + lo = lo + Math.imul(al1, bl7) | 0; + mid = mid + Math.imul(al1, bh7) | 0; + mid = mid + Math.imul(ah1, bl7) | 0; + hi = hi + Math.imul(ah1, bh7) | 0; + lo = lo + Math.imul(al0, bl8) | 0; + mid = mid + Math.imul(al0, bh8) | 0; + mid = mid + Math.imul(ah0, bl8) | 0; + hi = hi + Math.imul(ah0, bh8) | 0; + var w8 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0; + w8 &= 67108863; + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = mid + Math.imul(ah9, bl0) | 0; + hi = Math.imul(ah9, bh0); + lo = lo + Math.imul(al8, bl1) | 0; + mid = mid + Math.imul(al8, bh1) | 0; + mid = mid + Math.imul(ah8, bl1) | 0; + hi = hi + Math.imul(ah8, bh1) | 0; + lo = lo + Math.imul(al7, bl2) | 0; + mid = mid + Math.imul(al7, bh2) | 0; + mid = mid + Math.imul(ah7, bl2) | 0; + hi = hi + Math.imul(ah7, bh2) | 0; + lo = lo + Math.imul(al6, bl3) | 0; + mid = mid + Math.imul(al6, bh3) | 0; + mid = mid + Math.imul(ah6, bl3) | 0; + hi = hi + Math.imul(ah6, bh3) | 0; + lo = lo + Math.imul(al5, bl4) | 0; + mid = mid + Math.imul(al5, bh4) | 0; + mid = mid + Math.imul(ah5, bl4) | 0; + hi = hi + Math.imul(ah5, bh4) | 0; + lo = lo + Math.imul(al4, bl5) | 0; + mid = mid + Math.imul(al4, bh5) | 0; + mid = mid + Math.imul(ah4, bl5) | 0; + hi = hi + Math.imul(ah4, bh5) | 0; + lo = lo + Math.imul(al3, bl6) | 0; + mid = mid + Math.imul(al3, bh6) | 0; + mid = mid + Math.imul(ah3, bl6) | 0; + hi = hi + Math.imul(ah3, bh6) | 0; + lo = lo + Math.imul(al2, bl7) | 0; + mid = mid + Math.imul(al2, bh7) | 0; + mid = mid + Math.imul(ah2, bl7) | 0; + hi = hi + Math.imul(ah2, bh7) | 0; + lo = lo + Math.imul(al1, bl8) | 0; + mid = mid + Math.imul(al1, bh8) | 0; + mid = mid + Math.imul(ah1, bl8) | 0; + hi = hi + Math.imul(ah1, bh8) | 0; + lo = lo + Math.imul(al0, bl9) | 0; + mid = mid + Math.imul(al0, bh9) | 0; + mid = mid + Math.imul(ah0, bl9) | 0; + hi = hi + Math.imul(ah0, bh9) | 0; + var w9 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0; + w9 &= 67108863; + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = mid + Math.imul(ah9, bl1) | 0; + hi = Math.imul(ah9, bh1); + lo = lo + Math.imul(al8, bl2) | 0; + mid = mid + Math.imul(al8, bh2) | 0; + mid = mid + Math.imul(ah8, bl2) | 0; + hi = hi + Math.imul(ah8, bh2) | 0; + lo = lo + Math.imul(al7, bl3) | 0; + mid = mid + Math.imul(al7, bh3) | 0; + mid = mid + Math.imul(ah7, bl3) | 0; + hi = hi + Math.imul(ah7, bh3) | 0; + lo = lo + Math.imul(al6, bl4) | 0; + mid = mid + Math.imul(al6, bh4) | 0; + mid = mid + Math.imul(ah6, bl4) | 0; + hi = hi + Math.imul(ah6, bh4) | 0; + lo = lo + Math.imul(al5, bl5) | 0; + mid = mid + Math.imul(al5, bh5) | 0; + mid = mid + Math.imul(ah5, bl5) | 0; + hi = hi + Math.imul(ah5, bh5) | 0; + lo = lo + Math.imul(al4, bl6) | 0; + mid = mid + Math.imul(al4, bh6) | 0; + mid = mid + Math.imul(ah4, bl6) | 0; + hi = hi + Math.imul(ah4, bh6) | 0; + lo = lo + Math.imul(al3, bl7) | 0; + mid = mid + Math.imul(al3, bh7) | 0; + mid = mid + Math.imul(ah3, bl7) | 0; + hi = hi + Math.imul(ah3, bh7) | 0; + lo = lo + Math.imul(al2, bl8) | 0; + mid = mid + Math.imul(al2, bh8) | 0; + mid = mid + Math.imul(ah2, bl8) | 0; + hi = hi + Math.imul(ah2, bh8) | 0; + lo = lo + Math.imul(al1, bl9) | 0; + mid = mid + Math.imul(al1, bh9) | 0; + mid = mid + Math.imul(ah1, bl9) | 0; + hi = hi + Math.imul(ah1, bh9) | 0; + var w10 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0; + w10 &= 67108863; + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = mid + Math.imul(ah9, bl2) | 0; + hi = Math.imul(ah9, bh2); + lo = lo + Math.imul(al8, bl3) | 0; + mid = mid + Math.imul(al8, bh3) | 0; + mid = mid + Math.imul(ah8, bl3) | 0; + hi = hi + Math.imul(ah8, bh3) | 0; + lo = lo + Math.imul(al7, bl4) | 0; + mid = mid + Math.imul(al7, bh4) | 0; + mid = mid + Math.imul(ah7, bl4) | 0; + hi = hi + Math.imul(ah7, bh4) | 0; + lo = lo + Math.imul(al6, bl5) | 0; + mid = mid + Math.imul(al6, bh5) | 0; + mid = mid + Math.imul(ah6, bl5) | 0; + hi = hi + Math.imul(ah6, bh5) | 0; + lo = lo + Math.imul(al5, bl6) | 0; + mid = mid + Math.imul(al5, bh6) | 0; + mid = mid + Math.imul(ah5, bl6) | 0; + hi = hi + Math.imul(ah5, bh6) | 0; + lo = lo + Math.imul(al4, bl7) | 0; + mid = mid + Math.imul(al4, bh7) | 0; + mid = mid + Math.imul(ah4, bl7) | 0; + hi = hi + Math.imul(ah4, bh7) | 0; + lo = lo + Math.imul(al3, bl8) | 0; + mid = mid + Math.imul(al3, bh8) | 0; + mid = mid + Math.imul(ah3, bl8) | 0; + hi = hi + Math.imul(ah3, bh8) | 0; + lo = lo + Math.imul(al2, bl9) | 0; + mid = mid + Math.imul(al2, bh9) | 0; + mid = mid + Math.imul(ah2, bl9) | 0; + hi = hi + Math.imul(ah2, bh9) | 0; + var w11 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0; + w11 &= 67108863; + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = mid + Math.imul(ah9, bl3) | 0; + hi = Math.imul(ah9, bh3); + lo = lo + Math.imul(al8, bl4) | 0; + mid = mid + Math.imul(al8, bh4) | 0; + mid = mid + Math.imul(ah8, bl4) | 0; + hi = hi + Math.imul(ah8, bh4) | 0; + lo = lo + Math.imul(al7, bl5) | 0; + mid = mid + Math.imul(al7, bh5) | 0; + mid = mid + Math.imul(ah7, bl5) | 0; + hi = hi + Math.imul(ah7, bh5) | 0; + lo = lo + Math.imul(al6, bl6) | 0; + mid = mid + Math.imul(al6, bh6) | 0; + mid = mid + Math.imul(ah6, bl6) | 0; + hi = hi + Math.imul(ah6, bh6) | 0; + lo = lo + Math.imul(al5, bl7) | 0; + mid = mid + Math.imul(al5, bh7) | 0; + mid = mid + Math.imul(ah5, bl7) | 0; + hi = hi + Math.imul(ah5, bh7) | 0; + lo = lo + Math.imul(al4, bl8) | 0; + mid = mid + Math.imul(al4, bh8) | 0; + mid = mid + Math.imul(ah4, bl8) | 0; + hi = hi + Math.imul(ah4, bh8) | 0; + lo = lo + Math.imul(al3, bl9) | 0; + mid = mid + Math.imul(al3, bh9) | 0; + mid = mid + Math.imul(ah3, bl9) | 0; + hi = hi + Math.imul(ah3, bh9) | 0; + var w12 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0; + w12 &= 67108863; + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = mid + Math.imul(ah9, bl4) | 0; + hi = Math.imul(ah9, bh4); + lo = lo + Math.imul(al8, bl5) | 0; + mid = mid + Math.imul(al8, bh5) | 0; + mid = mid + Math.imul(ah8, bl5) | 0; + hi = hi + Math.imul(ah8, bh5) | 0; + lo = lo + Math.imul(al7, bl6) | 0; + mid = mid + Math.imul(al7, bh6) | 0; + mid = mid + Math.imul(ah7, bl6) | 0; + hi = hi + Math.imul(ah7, bh6) | 0; + lo = lo + Math.imul(al6, bl7) | 0; + mid = mid + Math.imul(al6, bh7) | 0; + mid = mid + Math.imul(ah6, bl7) | 0; + hi = hi + Math.imul(ah6, bh7) | 0; + lo = lo + Math.imul(al5, bl8) | 0; + mid = mid + Math.imul(al5, bh8) | 0; + mid = mid + Math.imul(ah5, bl8) | 0; + hi = hi + Math.imul(ah5, bh8) | 0; + lo = lo + Math.imul(al4, bl9) | 0; + mid = mid + Math.imul(al4, bh9) | 0; + mid = mid + Math.imul(ah4, bl9) | 0; + hi = hi + Math.imul(ah4, bh9) | 0; + var w13 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0; + w13 &= 67108863; + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = mid + Math.imul(ah9, bl5) | 0; + hi = Math.imul(ah9, bh5); + lo = lo + Math.imul(al8, bl6) | 0; + mid = mid + Math.imul(al8, bh6) | 0; + mid = mid + Math.imul(ah8, bl6) | 0; + hi = hi + Math.imul(ah8, bh6) | 0; + lo = lo + Math.imul(al7, bl7) | 0; + mid = mid + Math.imul(al7, bh7) | 0; + mid = mid + Math.imul(ah7, bl7) | 0; + hi = hi + Math.imul(ah7, bh7) | 0; + lo = lo + Math.imul(al6, bl8) | 0; + mid = mid + Math.imul(al6, bh8) | 0; + mid = mid + Math.imul(ah6, bl8) | 0; + hi = hi + Math.imul(ah6, bh8) | 0; + lo = lo + Math.imul(al5, bl9) | 0; + mid = mid + Math.imul(al5, bh9) | 0; + mid = mid + Math.imul(ah5, bl9) | 0; + hi = hi + Math.imul(ah5, bh9) | 0; + var w14 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0; + w14 &= 67108863; + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = mid + Math.imul(ah9, bl6) | 0; + hi = Math.imul(ah9, bh6); + lo = lo + Math.imul(al8, bl7) | 0; + mid = mid + Math.imul(al8, bh7) | 0; + mid = mid + Math.imul(ah8, bl7) | 0; + hi = hi + Math.imul(ah8, bh7) | 0; + lo = lo + Math.imul(al7, bl8) | 0; + mid = mid + Math.imul(al7, bh8) | 0; + mid = mid + Math.imul(ah7, bl8) | 0; + hi = hi + Math.imul(ah7, bh8) | 0; + lo = lo + Math.imul(al6, bl9) | 0; + mid = mid + Math.imul(al6, bh9) | 0; + mid = mid + Math.imul(ah6, bl9) | 0; + hi = hi + Math.imul(ah6, bh9) | 0; + var w15 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0; + w15 &= 67108863; + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = mid + Math.imul(ah9, bl7) | 0; + hi = Math.imul(ah9, bh7); + lo = lo + Math.imul(al8, bl8) | 0; + mid = mid + Math.imul(al8, bh8) | 0; + mid = mid + Math.imul(ah8, bl8) | 0; + hi = hi + Math.imul(ah8, bh8) | 0; + lo = lo + Math.imul(al7, bl9) | 0; + mid = mid + Math.imul(al7, bh9) | 0; + mid = mid + Math.imul(ah7, bl9) | 0; + hi = hi + Math.imul(ah7, bh9) | 0; + var w16 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0; + w16 &= 67108863; + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = mid + Math.imul(ah9, bl8) | 0; + hi = Math.imul(ah9, bh8); + lo = lo + Math.imul(al8, bl9) | 0; + mid = mid + Math.imul(al8, bh9) | 0; + mid = mid + Math.imul(ah8, bl9) | 0; + hi = hi + Math.imul(ah8, bh9) | 0; + var w17 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0; + w17 &= 67108863; + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = mid + Math.imul(ah9, bl9) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (c8 + lo | 0) + ((mid & 8191) << 13) | 0; + c8 = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0; + w18 &= 67108863; + o9[0] = w0; + o9[1] = w1; + o9[2] = w22; + o9[3] = w32; + o9[4] = w42; + o9[5] = w5; + o9[6] = w6; + o9[7] = w7; + o9[8] = w8; + o9[9] = w9; + o9[10] = w10; + o9[11] = w11; + o9[12] = w12; + o9[13] = w13; + o9[14] = w14; + o9[15] = w15; + o9[16] = w16; + o9[17] = w17; + o9[18] = w18; + if (c8 !== 0) { + o9[19] = c8; + out.length++; + } + return out; + }; + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + function bigMulTo(self2, num, out) { + out.negative = num.negative ^ self2.negative; + out.length = self2.length + num.length; + var carry = 0; + var hncarry = 0; + for (var k5 = 0; k5 < out.length - 1; k5++) { + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 67108863; + var maxJ = Math.min(k5, num.length - 1); + for (var j5 = Math.max(0, k5 - self2.length + 1); j5 <= maxJ; j5++) { + var i8 = k5 - j5; + var a8 = self2.words[i8] | 0; + var b6 = num.words[j5] | 0; + var r10 = a8 * b6; + var lo = r10 & 67108863; + ncarry = ncarry + (r10 / 67108864 | 0) | 0; + lo = lo + rword | 0; + rword = lo & 67108863; + ncarry = ncarry + (lo >>> 26) | 0; + hncarry += ncarry >>> 26; + ncarry &= 67108863; + } + out.words[k5] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k5] = carry; + } else { + out.length--; + } + return out.strip(); + } + function jumboMulTo(self2, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self2, num, out); + } + BN.prototype.mulTo = function mulTo(num, out) { + var res; + var len = (this || _global$12).length + num.length; + if ((this || _global$12).length === 10 && num.length === 10) { + res = comb10MulTo(this || _global$12, num, out); + } else if (len < 63) { + res = smallMulTo(this || _global$12, num, out); + } else if (len < 1024) { + res = bigMulTo(this || _global$12, num, out); + } else { + res = jumboMulTo(this || _global$12, num, out); + } + return res; + }; + function FFTM(x5, y7) { + (this || _global$12).x = x5; + (this || _global$12).y = y7; + } + FFTM.prototype.makeRBT = function makeRBT(N14) { + var t9 = new Array(N14); + var l8 = BN.prototype._countBits(N14) - 1; + for (var i8 = 0; i8 < N14; i8++) { + t9[i8] = this.revBin(i8, l8, N14); + } + return t9; + }; + FFTM.prototype.revBin = function revBin(x5, l8, N14) { + if (x5 === 0 || x5 === N14 - 1) + return x5; + var rb2 = 0; + for (var i8 = 0; i8 < l8; i8++) { + rb2 |= (x5 & 1) << l8 - i8 - 1; + x5 >>= 1; + } + return rb2; + }; + FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N14) { + for (var i8 = 0; i8 < N14; i8++) { + rtws[i8] = rws[rbt[i8]]; + itws[i8] = iws[rbt[i8]]; + } + }; + FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N14, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N14); + for (var s7 = 1; s7 < N14; s7 <<= 1) { + var l8 = s7 << 1; + var rtwdf = Math.cos(2 * Math.PI / l8); + var itwdf = Math.sin(2 * Math.PI / l8); + for (var p8 = 0; p8 < N14; p8 += l8) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + for (var j5 = 0; j5 < s7; j5++) { + var re3 = rtws[p8 + j5]; + var ie2 = itws[p8 + j5]; + var ro = rtws[p8 + j5 + s7]; + var io = itws[p8 + j5 + s7]; + var rx = rtwdf_ * ro - itwdf_ * io; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + rtws[p8 + j5] = re3 + ro; + itws[p8 + j5] = ie2 + io; + rtws[p8 + j5 + s7] = re3 - ro; + itws[p8 + j5 + s7] = ie2 - io; + if (j5 !== l8) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b(n9, m7) { + var N14 = Math.max(m7, n9) | 1; + var odd = N14 & 1; + var i8 = 0; + for (N14 = N14 / 2 | 0; N14; N14 = N14 >>> 1) { + i8++; + } + return 1 << i8 + 1 + odd; + }; + FFTM.prototype.conjugate = function conjugate(rws, iws, N14) { + if (N14 <= 1) + return; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var t9 = rws[i8]; + rws[i8] = rws[N14 - i8 - 1]; + rws[N14 - i8 - 1] = t9; + t9 = iws[i8]; + iws[i8] = -iws[N14 - i8 - 1]; + iws[N14 - i8 - 1] = -t9; + } + }; + FFTM.prototype.normalize13b = function normalize13b(ws2, N14) { + var carry = 0; + for (var i8 = 0; i8 < N14 / 2; i8++) { + var w5 = Math.round(ws2[2 * i8 + 1] / N14) * 8192 + Math.round(ws2[2 * i8] / N14) + carry; + ws2[i8] = w5 & 67108863; + if (w5 < 67108864) { + carry = 0; + } else { + carry = w5 / 67108864 | 0; + } + } + return ws2; + }; + FFTM.prototype.convert13b = function convert13b(ws2, len, rws, N14) { + var carry = 0; + for (var i8 = 0; i8 < len; i8++) { + carry = carry + (ws2[i8] | 0); + rws[2 * i8] = carry & 8191; + carry = carry >>> 13; + rws[2 * i8 + 1] = carry & 8191; + carry = carry >>> 13; + } + for (i8 = 2 * len; i8 < N14; ++i8) { + rws[i8] = 0; + } + assert(carry === 0); + assert((carry & ~8191) === 0); + }; + FFTM.prototype.stub = function stub(N14) { + var ph = new Array(N14); + for (var i8 = 0; i8 < N14; i8++) { + ph[i8] = 0; + } + return ph; + }; + FFTM.prototype.mulp = function mulp(x5, y7, out) { + var N14 = 2 * this.guessLen13b(x5.length, y7.length); + var rbt = this.makeRBT(N14); + var _5 = this.stub(N14); + var rws = new Array(N14); + var rwst = new Array(N14); + var iwst = new Array(N14); + var nrws = new Array(N14); + var nrwst = new Array(N14); + var niwst = new Array(N14); + var rmws = out.words; + rmws.length = N14; + this.convert13b(x5.words, x5.length, rws, N14); + this.convert13b(y7.words, y7.length, nrws, N14); + this.transform(rws, _5, rwst, iwst, N14, rbt); + this.transform(nrws, _5, nrwst, niwst, N14, rbt); + for (var i8 = 0; i8 < N14; i8++) { + var rx = rwst[i8] * nrwst[i8] - iwst[i8] * niwst[i8]; + iwst[i8] = rwst[i8] * niwst[i8] + iwst[i8] * nrwst[i8]; + rwst[i8] = rx; + } + this.conjugate(rwst, iwst, N14); + this.transform(rwst, iwst, rmws, _5, N14, rbt); + this.conjugate(rmws, _5, N14); + this.normalize13b(rmws, N14); + out.negative = x5.negative ^ y7.negative; + out.length = x5.length + y7.length; + return out.strip(); + }; + BN.prototype.mul = function mul(num) { + var out = new BN(null); + out.words = new Array((this || _global$12).length + num.length); + return this.mulTo(num, out); + }; + BN.prototype.mulf = function mulf(num) { + var out = new BN(null); + out.words = new Array((this || _global$12).length + num.length); + return jumboMulTo(this || _global$12, num, out); + }; + BN.prototype.imul = function imul(num) { + return this.clone().mulTo(num, this || _global$12); + }; + BN.prototype.imuln = function imuln(num) { + assert(typeof num === "number"); + assert(num < 67108864); + var carry = 0; + for (var i8 = 0; i8 < (this || _global$12).length; i8++) { + var w5 = ((this || _global$12).words[i8] | 0) * num; + var lo = (w5 & 67108863) + (carry & 67108863); + carry >>= 26; + carry += w5 / 67108864 | 0; + carry += lo >>> 26; + (this || _global$12).words[i8] = lo & 67108863; + } + if (carry !== 0) { + (this || _global$12).words[i8] = carry; + (this || _global$12).length++; + } + return this || _global$12; + }; + BN.prototype.muln = function muln(num) { + return this.clone().imuln(num); + }; + BN.prototype.sqr = function sqr() { + return this.mul(this || _global$12); + }; + BN.prototype.isqr = function isqr() { + return this.imul(this.clone()); + }; + BN.prototype.pow = function pow(num) { + var w5 = toBitArray(num); + if (w5.length === 0) + return new BN(1); + var res = this || _global$12; + for (var i8 = 0; i8 < w5.length; i8++, res = res.sqr()) { + if (w5[i8] !== 0) + break; + } + if (++i8 < w5.length) { + for (var q4 = res.sqr(); i8 < w5.length; i8++, q4 = q4.sqr()) { + if (w5[i8] === 0) + continue; + res = res.mul(q4); + } + } + return res; + }; + BN.prototype.iushln = function iushln(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + var carryMask = 67108863 >>> 26 - r10 << 26 - r10; + var i8; + if (r10 !== 0) { + var carry = 0; + for (i8 = 0; i8 < (this || _global$12).length; i8++) { + var newCarry = (this || _global$12).words[i8] & carryMask; + var c8 = ((this || _global$12).words[i8] | 0) - newCarry << r10; + (this || _global$12).words[i8] = c8 | carry; + carry = newCarry >>> 26 - r10; + } + if (carry) { + (this || _global$12).words[i8] = carry; + (this || _global$12).length++; + } + } + if (s7 !== 0) { + for (i8 = (this || _global$12).length - 1; i8 >= 0; i8--) { + (this || _global$12).words[i8 + s7] = (this || _global$12).words[i8]; + } + for (i8 = 0; i8 < s7; i8++) { + (this || _global$12).words[i8] = 0; + } + (this || _global$12).length += s7; + } + return this.strip(); + }; + BN.prototype.ishln = function ishln(bits) { + assert((this || _global$12).negative === 0); + return this.iushln(bits); + }; + BN.prototype.iushrn = function iushrn(bits, hint, extended) { + assert(typeof bits === "number" && bits >= 0); + var h9; + if (hint) { + h9 = (hint - hint % 26) / 26; + } else { + h9 = 0; + } + var r10 = bits % 26; + var s7 = Math.min((bits - r10) / 26, (this || _global$12).length); + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + var maskedWords = extended; + h9 -= s7; + h9 = Math.max(0, h9); + if (maskedWords) { + for (var i8 = 0; i8 < s7; i8++) { + maskedWords.words[i8] = (this || _global$12).words[i8]; + } + maskedWords.length = s7; + } + if (s7 === 0) + ; + else if ((this || _global$12).length > s7) { + (this || _global$12).length -= s7; + for (i8 = 0; i8 < (this || _global$12).length; i8++) { + (this || _global$12).words[i8] = (this || _global$12).words[i8 + s7]; + } + } else { + (this || _global$12).words[0] = 0; + (this || _global$12).length = 1; + } + var carry = 0; + for (i8 = (this || _global$12).length - 1; i8 >= 0 && (carry !== 0 || i8 >= h9); i8--) { + var word = (this || _global$12).words[i8] | 0; + (this || _global$12).words[i8] = carry << 26 - r10 | word >>> r10; + carry = word & mask2; + } + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + if ((this || _global$12).length === 0) { + (this || _global$12).words[0] = 0; + (this || _global$12).length = 1; + } + return this.strip(); + }; + BN.prototype.ishrn = function ishrn(bits, hint, extended) { + assert((this || _global$12).negative === 0); + return this.iushrn(bits, hint, extended); + }; + BN.prototype.shln = function shln(bits) { + return this.clone().ishln(bits); + }; + BN.prototype.ushln = function ushln(bits) { + return this.clone().iushln(bits); + }; + BN.prototype.shrn = function shrn(bits) { + return this.clone().ishrn(bits); + }; + BN.prototype.ushrn = function ushrn(bits) { + return this.clone().iushrn(bits); + }; + BN.prototype.testn = function testn(bit) { + assert(typeof bit === "number" && bit >= 0); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$12).length <= s7) + return false; + var w5 = (this || _global$12).words[s7]; + return !!(w5 & q4); + }; + BN.prototype.imaskn = function imaskn(bits) { + assert(typeof bits === "number" && bits >= 0); + var r10 = bits % 26; + var s7 = (bits - r10) / 26; + assert((this || _global$12).negative === 0, "imaskn works only with positive numbers"); + if ((this || _global$12).length <= s7) { + return this || _global$12; + } + if (r10 !== 0) { + s7++; + } + (this || _global$12).length = Math.min(s7, (this || _global$12).length); + if (r10 !== 0) { + var mask2 = 67108863 ^ 67108863 >>> r10 << r10; + (this || _global$12).words[(this || _global$12).length - 1] &= mask2; + } + return this.strip(); + }; + BN.prototype.maskn = function maskn(bits) { + return this.clone().imaskn(bits); + }; + BN.prototype.iaddn = function iaddn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.isubn(-num); + if ((this || _global$12).negative !== 0) { + if ((this || _global$12).length === 1 && ((this || _global$12).words[0] | 0) < num) { + (this || _global$12).words[0] = num - ((this || _global$12).words[0] | 0); + (this || _global$12).negative = 0; + return this || _global$12; + } + (this || _global$12).negative = 0; + this.isubn(num); + (this || _global$12).negative = 1; + return this || _global$12; + } + return this._iaddn(num); + }; + BN.prototype._iaddn = function _iaddn(num) { + (this || _global$12).words[0] += num; + for (var i8 = 0; i8 < (this || _global$12).length && (this || _global$12).words[i8] >= 67108864; i8++) { + (this || _global$12).words[i8] -= 67108864; + if (i8 === (this || _global$12).length - 1) { + (this || _global$12).words[i8 + 1] = 1; + } else { + (this || _global$12).words[i8 + 1]++; + } + } + (this || _global$12).length = Math.max((this || _global$12).length, i8 + 1); + return this || _global$12; + }; + BN.prototype.isubn = function isubn(num) { + assert(typeof num === "number"); + assert(num < 67108864); + if (num < 0) + return this.iaddn(-num); + if ((this || _global$12).negative !== 0) { + (this || _global$12).negative = 0; + this.iaddn(num); + (this || _global$12).negative = 1; + return this || _global$12; + } + (this || _global$12).words[0] -= num; + if ((this || _global$12).length === 1 && (this || _global$12).words[0] < 0) { + (this || _global$12).words[0] = -(this || _global$12).words[0]; + (this || _global$12).negative = 1; + } else { + for (var i8 = 0; i8 < (this || _global$12).length && (this || _global$12).words[i8] < 0; i8++) { + (this || _global$12).words[i8] += 67108864; + (this || _global$12).words[i8 + 1] -= 1; + } + } + return this.strip(); + }; + BN.prototype.addn = function addn(num) { + return this.clone().iaddn(num); + }; + BN.prototype.subn = function subn(num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs() { + (this || _global$12).negative = 0; + return this || _global$12; + }; + BN.prototype.abs = function abs() { + return this.clone().iabs(); + }; + BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { + var len = num.length + shift; + var i8; + this._expand(len); + var w5; + var carry = 0; + for (i8 = 0; i8 < num.length; i8++) { + w5 = ((this || _global$12).words[i8 + shift] | 0) + carry; + var right = (num.words[i8] | 0) * mul; + w5 -= right & 67108863; + carry = (w5 >> 26) - (right / 67108864 | 0); + (this || _global$12).words[i8 + shift] = w5 & 67108863; + } + for (; i8 < (this || _global$12).length - shift; i8++) { + w5 = ((this || _global$12).words[i8 + shift] | 0) + carry; + carry = w5 >> 26; + (this || _global$12).words[i8 + shift] = w5 & 67108863; + } + if (carry === 0) + return this.strip(); + assert(carry === -1); + carry = 0; + for (i8 = 0; i8 < (this || _global$12).length; i8++) { + w5 = -((this || _global$12).words[i8] | 0) + carry; + carry = w5 >> 26; + (this || _global$12).words[i8] = w5 & 67108863; + } + (this || _global$12).negative = 1; + return this.strip(); + }; + BN.prototype._wordDiv = function _wordDiv(num, mode) { + var shift = (this || _global$12).length - num.length; + var a8 = this.clone(); + var b6 = num; + var bhi = b6.words[b6.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b6 = b6.ushln(shift); + a8.iushln(shift); + bhi = b6.words[b6.length - 1] | 0; + } + var m7 = a8.length - b6.length; + var q4; + if (mode !== "mod") { + q4 = new BN(null); + q4.length = m7 + 1; + q4.words = new Array(q4.length); + for (var i8 = 0; i8 < q4.length; i8++) { + q4.words[i8] = 0; + } + } + var diff = a8.clone()._ishlnsubmul(b6, 1, m7); + if (diff.negative === 0) { + a8 = diff; + if (q4) { + q4.words[m7] = 1; + } + } + for (var j5 = m7 - 1; j5 >= 0; j5--) { + var qj = (a8.words[b6.length + j5] | 0) * 67108864 + (a8.words[b6.length + j5 - 1] | 0); + qj = Math.min(qj / bhi | 0, 67108863); + a8._ishlnsubmul(b6, qj, j5); + while (a8.negative !== 0) { + qj--; + a8.negative = 0; + a8._ishlnsubmul(b6, 1, j5); + if (!a8.isZero()) { + a8.negative ^= 1; + } + } + if (q4) { + q4.words[j5] = qj; + } + } + if (q4) { + q4.strip(); + } + a8.strip(); + if (mode !== "div" && shift !== 0) { + a8.iushrn(shift); + } + return { + div: q4 || null, + mod: a8 + }; + }; + BN.prototype.divmod = function divmod(num, mode, positive) { + assert(!num.isZero()); + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + var div, mod3, res; + if ((this || _global$12).negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + if (mode !== "mod") { + div = res.div.neg(); + } + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.iadd(num); + } + } + return { + div, + mod: mod3 + }; + } + if ((this || _global$12).negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + if (mode !== "mod") { + div = res.div.neg(); + } + return { + div, + mod: res.mod + }; + } + if (((this || _global$12).negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== "div") { + mod3 = res.mod.neg(); + if (positive && mod3.negative !== 0) { + mod3.isub(num); + } + } + return { + div: res.div, + mod: mod3 + }; + } + if (num.length > (this || _global$12).length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this || _global$12 + }; + } + if (num.length === 1) { + if (mode === "div") { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + if (mode === "mod") { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + return this._wordDiv(num, mode); + }; + BN.prototype.div = function div(num) { + return this.divmod(num, "div", false).div; + }; + BN.prototype.mod = function mod3(num) { + return this.divmod(num, "mod", false).mod; + }; + BN.prototype.umod = function umod(num) { + return this.divmod(num, "mod", true).mod; + }; + BN.prototype.divRound = function divRound(num) { + var dm = this.divmod(num); + if (dm.mod.isZero()) + return dm.div; + var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + var half = num.ushrn(1); + var r22 = num.andln(1); + var cmp = mod3.cmp(half); + if (cmp < 0 || r22 === 1 && cmp === 0) + return dm.div; + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + BN.prototype.modn = function modn(num) { + assert(num <= 67108863); + var p8 = (1 << 26) % num; + var acc = 0; + for (var i8 = (this || _global$12).length - 1; i8 >= 0; i8--) { + acc = (p8 * acc + ((this || _global$12).words[i8] | 0)) % num; + } + return acc; + }; + BN.prototype.idivn = function idivn(num) { + assert(num <= 67108863); + var carry = 0; + for (var i8 = (this || _global$12).length - 1; i8 >= 0; i8--) { + var w5 = ((this || _global$12).words[i8] | 0) + carry * 67108864; + (this || _global$12).words[i8] = w5 / num | 0; + carry = w5 % num; + } + return this.strip(); + }; + BN.prototype.divn = function divn(num) { + return this.clone().idivn(num); + }; + BN.prototype.egcd = function egcd(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var x5 = this || _global$12; + var y7 = p8.clone(); + if (x5.negative !== 0) { + x5 = x5.umod(p8); + } else { + x5 = x5.clone(); + } + var A5 = new BN(1); + var B5 = new BN(0); + var C5 = new BN(0); + var D5 = new BN(1); + var g6 = 0; + while (x5.isEven() && y7.isEven()) { + x5.iushrn(1); + y7.iushrn(1); + ++g6; + } + var yp = y7.clone(); + var xp = x5.clone(); + while (!x5.isZero()) { + for (var i8 = 0, im = 1; (x5.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + x5.iushrn(i8); + while (i8-- > 0) { + if (A5.isOdd() || B5.isOdd()) { + A5.iadd(yp); + B5.isub(xp); + } + A5.iushrn(1); + B5.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (y7.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + y7.iushrn(j5); + while (j5-- > 0) { + if (C5.isOdd() || D5.isOdd()) { + C5.iadd(yp); + D5.isub(xp); + } + C5.iushrn(1); + D5.iushrn(1); + } + } + if (x5.cmp(y7) >= 0) { + x5.isub(y7); + A5.isub(C5); + B5.isub(D5); + } else { + y7.isub(x5); + C5.isub(A5); + D5.isub(B5); + } + } + return { + a: C5, + b: D5, + gcd: y7.iushln(g6) + }; + }; + BN.prototype._invmp = function _invmp(p8) { + assert(p8.negative === 0); + assert(!p8.isZero()); + var a8 = this || _global$12; + var b6 = p8.clone(); + if (a8.negative !== 0) { + a8 = a8.umod(p8); + } else { + a8 = a8.clone(); + } + var x1 = new BN(1); + var x22 = new BN(0); + var delta = b6.clone(); + while (a8.cmpn(1) > 0 && b6.cmpn(1) > 0) { + for (var i8 = 0, im = 1; (a8.words[0] & im) === 0 && i8 < 26; ++i8, im <<= 1) + ; + if (i8 > 0) { + a8.iushrn(i8); + while (i8-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + x1.iushrn(1); + } + } + for (var j5 = 0, jm = 1; (b6.words[0] & jm) === 0 && j5 < 26; ++j5, jm <<= 1) + ; + if (j5 > 0) { + b6.iushrn(j5); + while (j5-- > 0) { + if (x22.isOdd()) { + x22.iadd(delta); + } + x22.iushrn(1); + } + } + if (a8.cmp(b6) >= 0) { + a8.isub(b6); + x1.isub(x22); + } else { + b6.isub(a8); + x22.isub(x1); + } + } + var res; + if (a8.cmpn(1) === 0) { + res = x1; + } else { + res = x22; + } + if (res.cmpn(0) < 0) { + res.iadd(p8); + } + return res; + }; + BN.prototype.gcd = function gcd(num) { + if (this.isZero()) + return num.abs(); + if (num.isZero()) + return this.abs(); + var a8 = this.clone(); + var b6 = num.clone(); + a8.negative = 0; + b6.negative = 0; + for (var shift = 0; a8.isEven() && b6.isEven(); shift++) { + a8.iushrn(1); + b6.iushrn(1); + } + do { + while (a8.isEven()) { + a8.iushrn(1); + } + while (b6.isEven()) { + b6.iushrn(1); + } + var r10 = a8.cmp(b6); + if (r10 < 0) { + var t9 = a8; + a8 = b6; + b6 = t9; + } else if (r10 === 0 || b6.cmpn(1) === 0) { + break; + } + a8.isub(b6); + } while (true); + return b6.iushln(shift); + }; + BN.prototype.invm = function invm(num) { + return this.egcd(num).a.umod(num); + }; + BN.prototype.isEven = function isEven() { + return ((this || _global$12).words[0] & 1) === 0; + }; + BN.prototype.isOdd = function isOdd() { + return ((this || _global$12).words[0] & 1) === 1; + }; + BN.prototype.andln = function andln(num) { + return (this || _global$12).words[0] & num; + }; + BN.prototype.bincn = function bincn(bit) { + assert(typeof bit === "number"); + var r10 = bit % 26; + var s7 = (bit - r10) / 26; + var q4 = 1 << r10; + if ((this || _global$12).length <= s7) { + this._expand(s7 + 1); + (this || _global$12).words[s7] |= q4; + return this || _global$12; + } + var carry = q4; + for (var i8 = s7; carry !== 0 && i8 < (this || _global$12).length; i8++) { + var w5 = (this || _global$12).words[i8] | 0; + w5 += carry; + carry = w5 >>> 26; + w5 &= 67108863; + (this || _global$12).words[i8] = w5; + } + if (carry !== 0) { + (this || _global$12).words[i8] = carry; + (this || _global$12).length++; + } + return this || _global$12; + }; + BN.prototype.isZero = function isZero() { + return (this || _global$12).length === 1 && (this || _global$12).words[0] === 0; + }; + BN.prototype.cmpn = function cmpn(num) { + var negative = num < 0; + if ((this || _global$12).negative !== 0 && !negative) + return -1; + if ((this || _global$12).negative === 0 && negative) + return 1; + this.strip(); + var res; + if ((this || _global$12).length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 67108863, "Number is too big"); + var w5 = (this || _global$12).words[0] | 0; + res = w5 === num ? 0 : w5 < num ? -1 : 1; + } + if ((this || _global$12).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.cmp = function cmp(num) { + if ((this || _global$12).negative !== 0 && num.negative === 0) + return -1; + if ((this || _global$12).negative === 0 && num.negative !== 0) + return 1; + var res = this.ucmp(num); + if ((this || _global$12).negative !== 0) + return -res | 0; + return res; + }; + BN.prototype.ucmp = function ucmp(num) { + if ((this || _global$12).length > num.length) + return 1; + if ((this || _global$12).length < num.length) + return -1; + var res = 0; + for (var i8 = (this || _global$12).length - 1; i8 >= 0; i8--) { + var a8 = (this || _global$12).words[i8] | 0; + var b6 = num.words[i8] | 0; + if (a8 === b6) + continue; + if (a8 < b6) { + res = -1; + } else if (a8 > b6) { + res = 1; + } + break; + } + return res; + }; + BN.prototype.gtn = function gtn(num) { + return this.cmpn(num) === 1; + }; + BN.prototype.gt = function gt(num) { + return this.cmp(num) === 1; + }; + BN.prototype.gten = function gten(num) { + return this.cmpn(num) >= 0; + }; + BN.prototype.gte = function gte(num) { + return this.cmp(num) >= 0; + }; + BN.prototype.ltn = function ltn(num) { + return this.cmpn(num) === -1; + }; + BN.prototype.lt = function lt(num) { + return this.cmp(num) === -1; + }; + BN.prototype.lten = function lten(num) { + return this.cmpn(num) <= 0; + }; + BN.prototype.lte = function lte(num) { + return this.cmp(num) <= 0; + }; + BN.prototype.eqn = function eqn(num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq(num) { + return this.cmp(num) === 0; + }; + BN.red = function red(num) { + return new Red(num); + }; + BN.prototype.toRed = function toRed(ctx) { + assert(!(this || _global$12).red, "Already a number in reduction context"); + assert((this || _global$12).negative === 0, "red works only with positives"); + return ctx.convertTo(this || _global$12)._forceRed(ctx); + }; + BN.prototype.fromRed = function fromRed() { + assert((this || _global$12).red, "fromRed works only with numbers in reduction context"); + return (this || _global$12).red.convertFrom(this || _global$12); + }; + BN.prototype._forceRed = function _forceRed(ctx) { + (this || _global$12).red = ctx; + return this || _global$12; + }; + BN.prototype.forceRed = function forceRed(ctx) { + assert(!(this || _global$12).red, "Already a number in reduction context"); + return this._forceRed(ctx); + }; + BN.prototype.redAdd = function redAdd(num) { + assert((this || _global$12).red, "redAdd works only with red numbers"); + return (this || _global$12).red.add(this || _global$12, num); + }; + BN.prototype.redIAdd = function redIAdd(num) { + assert((this || _global$12).red, "redIAdd works only with red numbers"); + return (this || _global$12).red.iadd(this || _global$12, num); + }; + BN.prototype.redSub = function redSub(num) { + assert((this || _global$12).red, "redSub works only with red numbers"); + return (this || _global$12).red.sub(this || _global$12, num); + }; + BN.prototype.redISub = function redISub(num) { + assert((this || _global$12).red, "redISub works only with red numbers"); + return (this || _global$12).red.isub(this || _global$12, num); + }; + BN.prototype.redShl = function redShl(num) { + assert((this || _global$12).red, "redShl works only with red numbers"); + return (this || _global$12).red.shl(this || _global$12, num); + }; + BN.prototype.redMul = function redMul(num) { + assert((this || _global$12).red, "redMul works only with red numbers"); + (this || _global$12).red._verify2(this || _global$12, num); + return (this || _global$12).red.mul(this || _global$12, num); + }; + BN.prototype.redIMul = function redIMul(num) { + assert((this || _global$12).red, "redMul works only with red numbers"); + (this || _global$12).red._verify2(this || _global$12, num); + return (this || _global$12).red.imul(this || _global$12, num); + }; + BN.prototype.redSqr = function redSqr() { + assert((this || _global$12).red, "redSqr works only with red numbers"); + (this || _global$12).red._verify1(this || _global$12); + return (this || _global$12).red.sqr(this || _global$12); + }; + BN.prototype.redISqr = function redISqr() { + assert((this || _global$12).red, "redISqr works only with red numbers"); + (this || _global$12).red._verify1(this || _global$12); + return (this || _global$12).red.isqr(this || _global$12); + }; + BN.prototype.redSqrt = function redSqrt() { + assert((this || _global$12).red, "redSqrt works only with red numbers"); + (this || _global$12).red._verify1(this || _global$12); + return (this || _global$12).red.sqrt(this || _global$12); + }; + BN.prototype.redInvm = function redInvm() { + assert((this || _global$12).red, "redInvm works only with red numbers"); + (this || _global$12).red._verify1(this || _global$12); + return (this || _global$12).red.invm(this || _global$12); + }; + BN.prototype.redNeg = function redNeg() { + assert((this || _global$12).red, "redNeg works only with red numbers"); + (this || _global$12).red._verify1(this || _global$12); + return (this || _global$12).red.neg(this || _global$12); + }; + BN.prototype.redPow = function redPow(num) { + assert((this || _global$12).red && !num.red, "redPow(normalNum)"); + (this || _global$12).red._verify1(this || _global$12); + return (this || _global$12).red.pow(this || _global$12, num); + }; + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function MPrime(name15, p8) { + (this || _global$12).name = name15; + (this || _global$12).p = new BN(p8, 16); + (this || _global$12).n = (this || _global$12).p.bitLength(); + (this || _global$12).k = new BN(1).iushln((this || _global$12).n).isub((this || _global$12).p); + (this || _global$12).tmp = this._tmp(); + } + MPrime.prototype._tmp = function _tmp() { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil((this || _global$12).n / 13)); + return tmp; + }; + MPrime.prototype.ireduce = function ireduce(num) { + var r10 = num; + var rlen; + do { + this.split(r10, (this || _global$12).tmp); + r10 = this.imulK(r10); + r10 = r10.iadd((this || _global$12).tmp); + rlen = r10.bitLength(); + } while (rlen > (this || _global$12).n); + var cmp = rlen < (this || _global$12).n ? -1 : r10.ucmp((this || _global$12).p); + if (cmp === 0) { + r10.words[0] = 0; + r10.length = 1; + } else if (cmp > 0) { + r10.isub((this || _global$12).p); + } else { + if (r10.strip !== void 0) { + r10.strip(); + } else { + r10._strip(); + } + } + return r10; + }; + MPrime.prototype.split = function split2(input, out) { + input.iushrn((this || _global$12).n, 0, out); + }; + MPrime.prototype.imulK = function imulK(num) { + return num.imul((this || _global$12).k); + }; + function K256() { + MPrime.call(this || _global$12, "k256", "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f"); + } + inherits3(K256, MPrime); + K256.prototype.split = function split2(input, output) { + var mask2 = 4194303; + var outLen = Math.min(input.length, 9); + for (var i8 = 0; i8 < outLen; i8++) { + output.words[i8] = input.words[i8]; + } + output.length = outLen; + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + var prev = input.words[9]; + output.words[output.length++] = prev & mask2; + for (i8 = 10; i8 < input.length; i8++) { + var next = input.words[i8] | 0; + input.words[i8 - 10] = (next & mask2) << 4 | prev >>> 22; + prev = next; + } + prev >>>= 22; + input.words[i8 - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + K256.prototype.imulK = function imulK(num) { + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + var lo = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var w5 = num.words[i8] | 0; + lo += w5 * 977; + num.words[i8] = lo & 67108863; + lo = w5 * 64 + (lo / 67108864 | 0); + } + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + function P224() { + MPrime.call(this || _global$12, "p224", "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001"); + } + inherits3(P224, MPrime); + function P192() { + MPrime.call(this || _global$12, "p192", "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff"); + } + inherits3(P192, MPrime); + function P25519() { + MPrime.call(this || _global$12, "25519", "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed"); + } + inherits3(P25519, MPrime); + P25519.prototype.imulK = function imulK(num) { + var carry = 0; + for (var i8 = 0; i8 < num.length; i8++) { + var hi = (num.words[i8] | 0) * 19 + carry; + var lo = hi & 67108863; + hi >>>= 26; + num.words[i8] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + BN._prime = function prime(name15) { + if (primes[name15]) + return primes[name15]; + var prime2; + if (name15 === "k256") { + prime2 = new K256(); + } else if (name15 === "p224") { + prime2 = new P224(); + } else if (name15 === "p192") { + prime2 = new P192(); + } else if (name15 === "p25519") { + prime2 = new P25519(); + } else { + throw new Error("Unknown prime " + name15); + } + primes[name15] = prime2; + return prime2; + }; + function Red(m7) { + if (typeof m7 === "string") { + var prime = BN._prime(m7); + (this || _global$12).m = prime.p; + (this || _global$12).prime = prime; + } else { + assert(m7.gtn(1), "modulus must be greater than 1"); + (this || _global$12).m = m7; + (this || _global$12).prime = null; + } + } + Red.prototype._verify1 = function _verify1(a8) { + assert(a8.negative === 0, "red works only with positives"); + assert(a8.red, "red works only with red numbers"); + }; + Red.prototype._verify2 = function _verify2(a8, b6) { + assert((a8.negative | b6.negative) === 0, "red works only with positives"); + assert(a8.red && a8.red === b6.red, "red works only with red numbers"); + }; + Red.prototype.imod = function imod(a8) { + if ((this || _global$12).prime) + return (this || _global$12).prime.ireduce(a8)._forceRed(this || _global$12); + return a8.umod((this || _global$12).m)._forceRed(this || _global$12); + }; + Red.prototype.neg = function neg(a8) { + if (a8.isZero()) { + return a8.clone(); + } + return (this || _global$12).m.sub(a8)._forceRed(this || _global$12); + }; + Red.prototype.add = function add12(a8, b6) { + this._verify2(a8, b6); + var res = a8.add(b6); + if (res.cmp((this || _global$12).m) >= 0) { + res.isub((this || _global$12).m); + } + return res._forceRed(this || _global$12); + }; + Red.prototype.iadd = function iadd(a8, b6) { + this._verify2(a8, b6); + var res = a8.iadd(b6); + if (res.cmp((this || _global$12).m) >= 0) { + res.isub((this || _global$12).m); + } + return res; + }; + Red.prototype.sub = function sub(a8, b6) { + this._verify2(a8, b6); + var res = a8.sub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$12).m); + } + return res._forceRed(this || _global$12); + }; + Red.prototype.isub = function isub(a8, b6) { + this._verify2(a8, b6); + var res = a8.isub(b6); + if (res.cmpn(0) < 0) { + res.iadd((this || _global$12).m); + } + return res; + }; + Red.prototype.shl = function shl(a8, num) { + this._verify1(a8); + return this.imod(a8.ushln(num)); + }; + Red.prototype.imul = function imul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.imul(b6)); + }; + Red.prototype.mul = function mul(a8, b6) { + this._verify2(a8, b6); + return this.imod(a8.mul(b6)); + }; + Red.prototype.isqr = function isqr(a8) { + return this.imul(a8, a8.clone()); + }; + Red.prototype.sqr = function sqr(a8) { + return this.mul(a8, a8); + }; + Red.prototype.sqrt = function sqrt(a8) { + if (a8.isZero()) + return a8.clone(); + var mod3 = (this || _global$12).m.andln(3); + assert(mod3 % 2 === 1); + if (mod3 === 3) { + var pow = (this || _global$12).m.add(new BN(1)).iushrn(2); + return this.pow(a8, pow); + } + var q4 = (this || _global$12).m.subn(1); + var s7 = 0; + while (!q4.isZero() && q4.andln(1) === 0) { + s7++; + q4.iushrn(1); + } + assert(!q4.isZero()); + var one = new BN(1).toRed(this || _global$12); + var nOne = one.redNeg(); + var lpow = (this || _global$12).m.subn(1).iushrn(1); + var z6 = (this || _global$12).m.bitLength(); + z6 = new BN(2 * z6 * z6).toRed(this || _global$12); + while (this.pow(z6, lpow).cmp(nOne) !== 0) { + z6.redIAdd(nOne); + } + var c8 = this.pow(z6, q4); + var r10 = this.pow(a8, q4.addn(1).iushrn(1)); + var t9 = this.pow(a8, q4); + var m7 = s7; + while (t9.cmp(one) !== 0) { + var tmp = t9; + for (var i8 = 0; tmp.cmp(one) !== 0; i8++) { + tmp = tmp.redSqr(); + } + assert(i8 < m7); + var b6 = this.pow(c8, new BN(1).iushln(m7 - i8 - 1)); + r10 = r10.redMul(b6); + c8 = b6.redSqr(); + t9 = t9.redMul(c8); + m7 = i8; + } + return r10; + }; + Red.prototype.invm = function invm(a8) { + var inv = a8._invmp((this || _global$12).m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + Red.prototype.pow = function pow(a8, num) { + if (num.isZero()) + return new BN(1).toRed(this || _global$12); + if (num.cmpn(1) === 0) + return a8.clone(); + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this || _global$12); + wnd[1] = a8; + for (var i8 = 2; i8 < wnd.length; i8++) { + wnd[i8] = this.mul(wnd[i8 - 1], a8); + } + var res = wnd[0]; + var current2 = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + for (i8 = num.length - 1; i8 >= 0; i8--) { + var word = num.words[i8]; + for (var j5 = start - 1; j5 >= 0; j5--) { + var bit = word >> j5 & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current2 === 0) { + currentLen = 0; + continue; + } + current2 <<= 1; + current2 |= bit; + currentLen++; + if (currentLen !== windowSize && (i8 !== 0 || j5 !== 0)) + continue; + res = this.mul(res, wnd[current2]); + currentLen = 0; + current2 = 0; + } + start = 26; + } + return res; + }; + Red.prototype.convertTo = function convertTo(num) { + var r10 = num.umod((this || _global$12).m); + return r10 === num ? r10.clone() : r10; + }; + Red.prototype.convertFrom = function convertFrom(num) { + var res = num.clone(); + res.red = null; + return res; + }; + BN.mont = function mont(num) { + return new Mont(num); + }; + function Mont(m7) { + Red.call(this || _global$12, m7); + (this || _global$12).shift = (this || _global$12).m.bitLength(); + if ((this || _global$12).shift % 26 !== 0) { + (this || _global$12).shift += 26 - (this || _global$12).shift % 26; + } + (this || _global$12).r = new BN(1).iushln((this || _global$12).shift); + (this || _global$12).r2 = this.imod((this || _global$12).r.sqr()); + (this || _global$12).rinv = (this || _global$12).r._invmp((this || _global$12).m); + (this || _global$12).minv = (this || _global$12).rinv.mul((this || _global$12).r).isubn(1).div((this || _global$12).m); + (this || _global$12).minv = (this || _global$12).minv.umod((this || _global$12).r); + (this || _global$12).minv = (this || _global$12).r.sub((this || _global$12).minv); + } + inherits3(Mont, Red); + Mont.prototype.convertTo = function convertTo(num) { + return this.imod(num.ushln((this || _global$12).shift)); + }; + Mont.prototype.convertFrom = function convertFrom(num) { + var r10 = this.imod(num.mul((this || _global$12).rinv)); + r10.red = null; + return r10; + }; + Mont.prototype.imul = function imul(a8, b6) { + if (a8.isZero() || b6.isZero()) { + a8.words[0] = 0; + a8.length = 1; + return a8; + } + var t9 = a8.imul(b6); + var c8 = t9.maskn((this || _global$12).shift).mul((this || _global$12).minv).imaskn((this || _global$12).shift).mul((this || _global$12).m); + var u8 = t9.isub(c8).iushrn((this || _global$12).shift); + var res = u8; + if (u8.cmp((this || _global$12).m) >= 0) { + res = u8.isub((this || _global$12).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$12).m); + } + return res._forceRed(this || _global$12); + }; + Mont.prototype.mul = function mul(a8, b6) { + if (a8.isZero() || b6.isZero()) + return new BN(0)._forceRed(this || _global$12); + var t9 = a8.mul(b6); + var c8 = t9.maskn((this || _global$12).shift).mul((this || _global$12).minv).imaskn((this || _global$12).shift).mul((this || _global$12).m); + var u8 = t9.isub(c8).iushrn((this || _global$12).shift); + var res = u8; + if (u8.cmp((this || _global$12).m) >= 0) { + res = u8.isub((this || _global$12).m); + } else if (u8.cmpn(0) < 0) { + res = u8.iadd((this || _global$12).m); + } + return res._forceRed(this || _global$12); + }; + Mont.prototype.invm = function invm(a8) { + var res = this.imod(a8._invmp((this || _global$12).m).mul((this || _global$12).r2)); + return res._forceRed(this || _global$12); + }; + })(module2, exports$72); + return module2.exports; + } + var exports$62 = {}; + var _dewExec$52 = false; + function dew$52() { + if (_dewExec$52) + return exports$62; + _dewExec$52 = true; + var BN = dew$62(); + var Buffer2 = dew$2P().Buffer; + function withPublic(paddedMsg, key) { + return Buffer2.from(paddedMsg.toRed(BN.mont(key.modulus)).redPow(new BN(key.publicExponent)).fromRed().toArray()); + } + exports$62 = withPublic; + return exports$62; + } + var exports$52 = {}; + var _dewExec$42 = false; + function dew$42() { + if (_dewExec$42) + return exports$52; + _dewExec$42 = true; + var parseKeys = dew$e2(); + var randomBytes3 = dew$2O(); + var createHash2 = dew$2y(); + var mgf = dew$82(); + var xor3 = dew$72(); + var BN = dew$62(); + var withPublic = dew$52(); + var crt = dew$W(); + var Buffer2 = dew$2P().Buffer; + exports$52 = function publicEncrypt2(publicKey, msg, reverse) { + var padding; + if (publicKey.padding) { + padding = publicKey.padding; + } else if (reverse) { + padding = 1; + } else { + padding = 4; + } + var key = parseKeys(publicKey); + var paddedMsg; + if (padding === 4) { + paddedMsg = oaep(key, msg); + } else if (padding === 1) { + paddedMsg = pkcs1(key, msg, reverse); + } else if (padding === 3) { + paddedMsg = new BN(msg); + if (paddedMsg.cmp(key.modulus) >= 0) { + throw new Error("data too long for modulus"); + } + } else { + throw new Error("unknown padding"); + } + if (reverse) { + return crt(paddedMsg, key); + } else { + return withPublic(paddedMsg, key); + } + }; + function oaep(key, msg) { + var k5 = key.modulus.byteLength(); + var mLen = msg.length; + var iHash = createHash2("sha1").update(Buffer2.alloc(0)).digest(); + var hLen = iHash.length; + var hLen2 = 2 * hLen; + if (mLen > k5 - hLen2 - 2) { + throw new Error("message too long"); + } + var ps = Buffer2.alloc(k5 - mLen - hLen2 - 2); + var dblen = k5 - hLen - 1; + var seed = randomBytes3(hLen); + var maskedDb = xor3(Buffer2.concat([iHash, ps, Buffer2.alloc(1, 1), msg], dblen), mgf(seed, dblen)); + var maskedSeed = xor3(seed, mgf(maskedDb, hLen)); + return new BN(Buffer2.concat([Buffer2.alloc(1), maskedSeed, maskedDb], k5)); + } + function pkcs1(key, msg, reverse) { + var mLen = msg.length; + var k5 = key.modulus.byteLength(); + if (mLen > k5 - 11) { + throw new Error("message too long"); + } + var ps; + if (reverse) { + ps = Buffer2.alloc(k5 - mLen - 3, 255); + } else { + ps = nonZero(k5 - mLen - 3); + } + return new BN(Buffer2.concat([Buffer2.from([0, reverse ? 1 : 2]), ps, Buffer2.alloc(1), msg], k5)); + } + function nonZero(len) { + var out = Buffer2.allocUnsafe(len); + var i8 = 0; + var cache3 = randomBytes3(len * 2); + var cur = 0; + var num; + while (i8 < len) { + if (cur === cache3.length) { + cache3 = randomBytes3(len * 2); + cur = 0; + } + num = cache3[cur++]; + if (num) { + out[i8++] = num; + } + } + return out; + } + return exports$52; + } + var exports$42 = {}; + var _dewExec$32 = false; + function dew$32() { + if (_dewExec$32) + return exports$42; + _dewExec$32 = true; + var parseKeys = dew$e2(); + var mgf = dew$82(); + var xor3 = dew$72(); + var BN = dew$62(); + var crt = dew$W(); + var createHash2 = dew$2y(); + var withPublic = dew$52(); + var Buffer2 = dew$2P().Buffer; + exports$42 = function privateDecrypt2(privateKey, enc, reverse) { + var padding; + if (privateKey.padding) { + padding = privateKey.padding; + } else if (reverse) { + padding = 1; + } else { + padding = 4; + } + var key = parseKeys(privateKey); + var k5 = key.modulus.byteLength(); + if (enc.length > k5 || new BN(enc).cmp(key.modulus) >= 0) { + throw new Error("decryption error"); + } + var msg; + if (reverse) { + msg = withPublic(new BN(enc), key); + } else { + msg = crt(enc, key); + } + var zBuffer = Buffer2.alloc(k5 - msg.length); + msg = Buffer2.concat([zBuffer, msg], k5); + if (padding === 4) { + return oaep(key, msg); + } else if (padding === 1) { + return pkcs1(key, msg, reverse); + } else if (padding === 3) { + return msg; + } else { + throw new Error("unknown padding"); + } + }; + function oaep(key, msg) { + var k5 = key.modulus.byteLength(); + var iHash = createHash2("sha1").update(Buffer2.alloc(0)).digest(); + var hLen = iHash.length; + if (msg[0] !== 0) { + throw new Error("decryption error"); + } + var maskedSeed = msg.slice(1, hLen + 1); + var maskedDb = msg.slice(hLen + 1); + var seed = xor3(maskedSeed, mgf(maskedDb, hLen)); + var db = xor3(maskedDb, mgf(seed, k5 - hLen - 1)); + if (compare7(iHash, db.slice(0, hLen))) { + throw new Error("decryption error"); + } + var i8 = hLen; + while (db[i8] === 0) { + i8++; + } + if (db[i8++] !== 1) { + throw new Error("decryption error"); + } + return db.slice(i8); + } + function pkcs1(key, msg, reverse) { + var p1 = msg.slice(0, 2); + var i8 = 2; + var status = 0; + while (msg[i8++] !== 0) { + if (i8 >= msg.length) { + status++; + break; + } + } + var ps = msg.slice(2, i8 - 1); + if (p1.toString("hex") !== "0002" && !reverse || p1.toString("hex") !== "0001" && reverse) { + status++; + } + if (ps.length < 8) { + status++; + } + if (status) { + throw new Error("decryption error"); + } + return msg.slice(i8); + } + function compare7(a8, b6) { + a8 = Buffer2.from(a8); + b6 = Buffer2.from(b6); + var dif = 0; + var len = a8.length; + if (a8.length !== b6.length) { + dif++; + len = Math.min(a8.length, b6.length); + } + var i8 = -1; + while (++i8 < len) { + dif += a8[i8] ^ b6[i8]; + } + return dif; + } + return exports$42; + } + var exports$33 = {}; + var _dewExec$210 = false; + function dew$210() { + if (_dewExec$210) + return exports$33; + _dewExec$210 = true; + exports$33.publicEncrypt = dew$42(); + exports$33.privateDecrypt = dew$32(); + exports$33.privateEncrypt = function privateEncrypt2(key, buf3) { + return exports$33.publicEncrypt(key, buf3, true); + }; + exports$33.publicDecrypt = function publicDecrypt2(key, buf3) { + return exports$33.privateDecrypt(key, buf3, true); + }; + return exports$33; + } + var exports$210 = {}; + var _dewExec$110 = false; + var _global3 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global; + function dew$110() { + if (_dewExec$110) + return exports$210; + _dewExec$110 = true; + var process$1 = process2; + function oldBrowser() { + throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11"); + } + var safeBuffer = dew$2P(); + var randombytes = dew$2O(); + var Buffer2 = safeBuffer.Buffer; + var kBufferMaxLength = safeBuffer.kMaxLength; + var crypto5 = _global3.crypto || _global3.msCrypto; + var kMaxUint32 = Math.pow(2, 32) - 1; + function assertOffset(offset2, length3) { + if (typeof offset2 !== "number" || offset2 !== offset2) { + throw new TypeError("offset must be a number"); + } + if (offset2 > kMaxUint32 || offset2 < 0) { + throw new TypeError("offset must be a uint32"); + } + if (offset2 > kBufferMaxLength || offset2 > length3) { + throw new RangeError("offset out of range"); + } + } + function assertSize(size4, offset2, length3) { + if (typeof size4 !== "number" || size4 !== size4) { + throw new TypeError("size must be a number"); + } + if (size4 > kMaxUint32 || size4 < 0) { + throw new TypeError("size must be a uint32"); + } + if (size4 + offset2 > length3 || size4 > kBufferMaxLength) { + throw new RangeError("buffer too small"); + } + } + if (crypto5 && crypto5.getRandomValues || !process$1.browser) { + exports$210.randomFill = randomFill2; + exports$210.randomFillSync = randomFillSync2; + } else { + exports$210.randomFill = oldBrowser; + exports$210.randomFillSync = oldBrowser; + } + function randomFill2(buf3, offset2, size4, cb) { + if (!Buffer2.isBuffer(buf3) && !(buf3 instanceof _global3.Uint8Array)) { + throw new TypeError('"buf" argument must be a Buffer or Uint8Array'); + } + if (typeof offset2 === "function") { + cb = offset2; + offset2 = 0; + size4 = buf3.length; + } else if (typeof size4 === "function") { + cb = size4; + size4 = buf3.length - offset2; + } else if (typeof cb !== "function") { + throw new TypeError('"cb" argument must be a function'); + } + assertOffset(offset2, buf3.length); + assertSize(size4, offset2, buf3.length); + return actualFill(buf3, offset2, size4, cb); + } + function actualFill(buf3, offset2, size4, cb) { + if (process$1.browser) { + var ourBuf = buf3.buffer; + var uint = new Uint8Array(ourBuf, offset2, size4); + crypto5.getRandomValues(uint); + if (cb) { + process$1.nextTick(function() { + cb(null, buf3); + }); + return; + } + return buf3; + } + if (cb) { + randombytes(size4, function(err, bytes3) { + if (err) { + return cb(err); + } + bytes3.copy(buf3, offset2); + cb(null, buf3); + }); + return; + } + var bytes2 = randombytes(size4); + bytes2.copy(buf3, offset2); + return buf3; + } + function randomFillSync2(buf3, offset2, size4) { + if (typeof offset2 === "undefined") { + offset2 = 0; + } + if (!Buffer2.isBuffer(buf3) && !(buf3 instanceof _global3.Uint8Array)) { + throw new TypeError('"buf" argument must be a Buffer or Uint8Array'); + } + assertOffset(offset2, buf3.length); + if (size4 === void 0) + size4 = buf3.length - offset2; + assertSize(size4, offset2, buf3.length); + return actualFill(buf3, offset2, size4); + } + return exports$210; + } + var exports$110 = {}; + var _dewExec5 = false; + function dew5() { + if (_dewExec5) + return exports$110; + _dewExec5 = true; + exports$110.randomBytes = exports$110.rng = exports$110.pseudoRandomBytes = exports$110.prng = dew$2O(); + exports$110.createHash = exports$110.Hash = dew$2y(); + exports$110.createHmac = exports$110.Hmac = dew$2v(); + var algos = dew$2u(); + var algoKeys = Object.keys(algos); + var hashes2 = ["sha1", "sha224", "sha256", "sha384", "sha512", "md5", "rmd160"].concat(algoKeys); + exports$110.getHashes = function() { + return hashes2; + }; + var p8 = dew$2o(); + exports$110.pbkdf2 = p8.pbkdf2; + exports$110.pbkdf2Sync = p8.pbkdf2Sync; + var aes2 = dew$1Y(); + exports$110.Cipher = aes2.Cipher; + exports$110.createCipher = aes2.createCipher; + exports$110.Cipheriv = aes2.Cipheriv; + exports$110.createCipheriv = aes2.createCipheriv; + exports$110.Decipher = aes2.Decipher; + exports$110.createDecipher = aes2.createDecipher; + exports$110.Decipheriv = aes2.Decipheriv; + exports$110.createDecipheriv = aes2.createDecipheriv; + exports$110.getCiphers = aes2.getCiphers; + exports$110.listCiphers = aes2.listCiphers; + var dh = dew$Z(); + exports$110.DiffieHellmanGroup = dh.DiffieHellmanGroup; + exports$110.createDiffieHellmanGroup = dh.createDiffieHellmanGroup; + exports$110.getDiffieHellman = dh.getDiffieHellman; + exports$110.createDiffieHellman = dh.createDiffieHellman; + exports$110.DiffieHellman = dh.DiffieHellman; + var sign2 = dew$b2(); + exports$110.createSign = sign2.createSign; + exports$110.Sign = sign2.Sign; + exports$110.createVerify = sign2.createVerify; + exports$110.Verify = sign2.Verify; + exports$110.createECDH = dew$92(); + var publicEncrypt2 = dew$210(); + exports$110.publicEncrypt = publicEncrypt2.publicEncrypt; + exports$110.privateEncrypt = publicEncrypt2.privateEncrypt; + exports$110.publicDecrypt = publicEncrypt2.publicDecrypt; + exports$110.privateDecrypt = publicEncrypt2.privateDecrypt; + var rf = dew$110(); + exports$110.randomFill = rf.randomFill; + exports$110.randomFillSync = rf.randomFillSync; + exports$110.createCredentials = function() { + throw new Error(["sorry, createCredentials is not implemented yet", "we accept pull requests", "https://github.com/crypto-browserify/crypto-browserify"].join("\n")); + }; + exports$110.constants = { + "DH_CHECK_P_NOT_SAFE_PRIME": 2, + "DH_CHECK_P_NOT_PRIME": 1, + "DH_UNABLE_TO_CHECK_GENERATOR": 4, + "DH_NOT_SUITABLE_GENERATOR": 8, + "NPN_ENABLED": 1, + "ALPN_ENABLED": 1, + "RSA_PKCS1_PADDING": 1, + "RSA_SSLV23_PADDING": 2, + "RSA_NO_PADDING": 3, + "RSA_PKCS1_OAEP_PADDING": 4, + "RSA_X931_PADDING": 5, + "RSA_PKCS1_PSS_PADDING": 6, + "POINT_CONVERSION_COMPRESSED": 2, + "POINT_CONVERSION_UNCOMPRESSED": 4, + "POINT_CONVERSION_HYBRID": 6 + }; + return exports$110; + } + var exports6 = dew5(); + exports6["randomBytes"]; + exports6["rng"]; + exports6["pseudoRandomBytes"]; + exports6["prng"]; + exports6["createHash"]; + exports6["Hash"]; + exports6["createHmac"]; + exports6["Hmac"]; + exports6["getHashes"]; + exports6["pbkdf2"]; + exports6["pbkdf2Sync"]; + exports6["Cipher"]; + exports6["createCipher"]; + exports6["Cipheriv"]; + exports6["createCipheriv"]; + exports6["Decipher"]; + exports6["createDecipher"]; + exports6["Decipheriv"]; + exports6["createDecipheriv"]; + exports6["getCiphers"]; + exports6["listCiphers"]; + exports6["DiffieHellmanGroup"]; + exports6["createDiffieHellmanGroup"]; + exports6["getDiffieHellman"]; + exports6["createDiffieHellman"]; + exports6["DiffieHellman"]; + exports6["createSign"]; + exports6["Sign"]; + exports6["createVerify"]; + exports6["Verify"]; + exports6["createECDH"]; + exports6["publicEncrypt"]; + exports6["privateEncrypt"]; + exports6["publicDecrypt"]; + exports6["privateDecrypt"]; + exports6["randomFill"]; + exports6["randomFillSync"]; + exports6["createCredentials"]; + exports6["constants"]; + exports6.webcrypto = globalThis.crypto; + var Cipher = exports6.Cipher; + var Cipheriv = exports6.Cipheriv; + var Decipher = exports6.Decipher; + var Decipheriv = exports6.Decipheriv; + var DiffieHellman = exports6.DiffieHellman; + var DiffieHellmanGroup = exports6.DiffieHellmanGroup; + var Hash = exports6.Hash; + var Hmac = exports6.Hmac; + var Sign = exports6.Sign; + var Verify = exports6.Verify; + var constants = exports6.constants; + var createCipher = exports6.createCipher; + var createCipheriv = exports6.createCipheriv; + var createCredentials = exports6.createCredentials; + var createDecipher = exports6.createDecipher; + var createDecipheriv = exports6.createDecipheriv; + var createDiffieHellman = exports6.createDiffieHellman; + var createDiffieHellmanGroup = exports6.createDiffieHellmanGroup; + var createECDH = exports6.createECDH; + var createHash = exports6.createHash; + var createHmac = exports6.createHmac; + var createSign = exports6.createSign; + var createVerify = exports6.createVerify; + var getCiphers = exports6.getCiphers; + var getDiffieHellman = exports6.getDiffieHellman; + var getHashes = exports6.getHashes; + var listCiphers = exports6.listCiphers; + var pbkdf2 = exports6.pbkdf2; + var pbkdf2Sync = exports6.pbkdf2Sync; + var privateDecrypt = exports6.privateDecrypt; + var privateEncrypt = exports6.privateEncrypt; + var prng = exports6.prng; + var pseudoRandomBytes = exports6.pseudoRandomBytes; + var publicDecrypt = exports6.publicDecrypt; + var publicEncrypt = exports6.publicEncrypt; + var randomBytes = exports6.randomBytes; + var randomFill = exports6.randomFill; + var randomFillSync = exports6.randomFillSync; + var rng = exports6.rng; + var webcrypto = exports6.webcrypto; + + // ../../node_modules/.pnpm/@noble+ed25519@1.7.3/node_modules/@noble/ed25519/lib/esm/index.js + var _0n = BigInt(0); + var _1n = BigInt(1); + var _2n = BigInt(2); + var _8n = BigInt(8); + var CU_O = BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"); + var CURVE = Object.freeze({ + a: BigInt(-1), + d: BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"), + P: BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"), + l: CU_O, + n: CU_O, + h: BigInt(8), + Gx: BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"), + Gy: BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960") + }); + var POW_2_256 = BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"); + var SQRT_M1 = BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"); + var SQRT_D = BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"); + var SQRT_AD_MINUS_ONE = BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"); + var INVSQRT_A_MINUS_D = BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"); + var ONE_MINUS_D_SQ = BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"); + var D_MINUS_ONE_SQ = BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"); + var ExtendedPoint = class _ExtendedPoint { + constructor(x5, y7, z6, t9) { + this.x = x5; + this.y = y7; + this.z = z6; + this.t = t9; + } + static fromAffine(p8) { + if (!(p8 instanceof Point)) { + throw new TypeError("ExtendedPoint#fromAffine: expected Point"); + } + if (p8.equals(Point.ZERO)) + return _ExtendedPoint.ZERO; + return new _ExtendedPoint(p8.x, p8.y, _1n, mod2(p8.x * p8.y)); + } + static toAffineBatch(points) { + const toInv = invertBatch(points.map((p8) => p8.z)); + return points.map((p8, i8) => p8.toAffine(toInv[i8])); + } + static normalizeZ(points) { + return this.toAffineBatch(points).map(this.fromAffine); + } + equals(other) { + assertExtPoint(other); + const { x: X1, y: Y1, z: Z1 } = this; + const { x: X22, y: Y22, z: Z22 } = other; + const X1Z2 = mod2(X1 * Z22); + const X2Z1 = mod2(X22 * Z1); + const Y1Z2 = mod2(Y1 * Z22); + const Y2Z1 = mod2(Y22 * Z1); + return X1Z2 === X2Z1 && Y1Z2 === Y2Z1; + } + negate() { + return new _ExtendedPoint(mod2(-this.x), this.y, this.z, mod2(-this.t)); + } + double() { + const { x: X1, y: Y1, z: Z1 } = this; + const { a: a8 } = CURVE; + const A5 = mod2(X1 * X1); + const B5 = mod2(Y1 * Y1); + const C5 = mod2(_2n * mod2(Z1 * Z1)); + const D5 = mod2(a8 * A5); + const x1y1 = X1 + Y1; + const E5 = mod2(mod2(x1y1 * x1y1) - A5 - B5); + const G4 = D5 + B5; + const F5 = G4 - C5; + const H4 = D5 - B5; + const X32 = mod2(E5 * F5); + const Y32 = mod2(G4 * H4); + const T32 = mod2(E5 * H4); + const Z32 = mod2(F5 * G4); + return new _ExtendedPoint(X32, Y32, Z32, T32); + } + add(other) { + assertExtPoint(other); + const { x: X1, y: Y1, z: Z1, t: T1 } = this; + const { x: X22, y: Y22, z: Z22, t: T22 } = other; + const A5 = mod2((Y1 - X1) * (Y22 + X22)); + const B5 = mod2((Y1 + X1) * (Y22 - X22)); + const F5 = mod2(B5 - A5); + if (F5 === _0n) + return this.double(); + const C5 = mod2(Z1 * _2n * T22); + const D5 = mod2(T1 * _2n * Z22); + const E5 = D5 + C5; + const G4 = B5 + A5; + const H4 = D5 - C5; + const X32 = mod2(E5 * F5); + const Y32 = mod2(G4 * H4); + const T32 = mod2(E5 * H4); + const Z32 = mod2(F5 * G4); + return new _ExtendedPoint(X32, Y32, Z32, T32); + } + subtract(other) { + return this.add(other.negate()); + } + precomputeWindow(W4) { + const windows = 1 + 256 / W4; + const points = []; + let p8 = this; + let base3 = p8; + for (let window2 = 0; window2 < windows; window2++) { + base3 = p8; + points.push(base3); + for (let i8 = 1; i8 < 2 ** (W4 - 1); i8++) { + base3 = base3.add(p8); + points.push(base3); + } + p8 = base3.double(); + } + return points; + } + wNAF(n9, affinePoint) { + if (!affinePoint && this.equals(_ExtendedPoint.BASE)) + affinePoint = Point.BASE; + const W4 = affinePoint && affinePoint._WINDOW_SIZE || 1; + if (256 % W4) { + throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2"); + } + let precomputes = affinePoint && pointPrecomputes.get(affinePoint); + if (!precomputes) { + precomputes = this.precomputeWindow(W4); + if (affinePoint && W4 !== 1) { + precomputes = _ExtendedPoint.normalizeZ(precomputes); + pointPrecomputes.set(affinePoint, precomputes); + } + } + let p8 = _ExtendedPoint.ZERO; + let f9 = _ExtendedPoint.BASE; + const windows = 1 + 256 / W4; + const windowSize = 2 ** (W4 - 1); + const mask2 = BigInt(2 ** W4 - 1); + const maxNumber = 2 ** W4; + const shiftBy = BigInt(W4); + for (let window2 = 0; window2 < windows; window2++) { + const offset2 = window2 * windowSize; + let wbits = Number(n9 & mask2); + n9 >>= shiftBy; + if (wbits > windowSize) { + wbits -= maxNumber; + n9 += _1n; + } + const offset1 = offset2; + const offset22 = offset2 + Math.abs(wbits) - 1; + const cond1 = window2 % 2 !== 0; + const cond2 = wbits < 0; + if (wbits === 0) { + f9 = f9.add(constTimeNegate(cond1, precomputes[offset1])); + } else { + p8 = p8.add(constTimeNegate(cond2, precomputes[offset22])); + } + } + return _ExtendedPoint.normalizeZ([p8, f9])[0]; + } + multiply(scalar, affinePoint) { + return this.wNAF(normalizeScalar(scalar, CURVE.l), affinePoint); + } + multiplyUnsafe(scalar) { + let n9 = normalizeScalar(scalar, CURVE.l, false); + const G4 = _ExtendedPoint.BASE; + const P0 = _ExtendedPoint.ZERO; + if (n9 === _0n) + return P0; + if (this.equals(P0) || n9 === _1n) + return this; + if (this.equals(G4)) + return this.wNAF(n9); + let p8 = P0; + let d7 = this; + while (n9 > _0n) { + if (n9 & _1n) + p8 = p8.add(d7); + d7 = d7.double(); + n9 >>= _1n; + } + return p8; + } + isSmallOrder() { + return this.multiplyUnsafe(CURVE.h).equals(_ExtendedPoint.ZERO); + } + isTorsionFree() { + let p8 = this.multiplyUnsafe(CURVE.l / _2n).double(); + if (CURVE.l % _2n) + p8 = p8.add(this); + return p8.equals(_ExtendedPoint.ZERO); + } + toAffine(invZ) { + const { x: x5, y: y7, z: z6 } = this; + const is0 = this.equals(_ExtendedPoint.ZERO); + if (invZ == null) + invZ = is0 ? _8n : invert(z6); + const ax = mod2(x5 * invZ); + const ay = mod2(y7 * invZ); + const zz = mod2(z6 * invZ); + if (is0) + return Point.ZERO; + if (zz !== _1n) + throw new Error("invZ was invalid"); + return new Point(ax, ay); + } + fromRistrettoBytes() { + legacyRist(); + } + toRistrettoBytes() { + legacyRist(); + } + fromRistrettoHash() { + legacyRist(); + } + }; + ExtendedPoint.BASE = new ExtendedPoint(CURVE.Gx, CURVE.Gy, _1n, mod2(CURVE.Gx * CURVE.Gy)); + ExtendedPoint.ZERO = new ExtendedPoint(_0n, _1n, _1n, _0n); + function constTimeNegate(condition, item) { + const neg = item.negate(); + return condition ? neg : item; + } + function assertExtPoint(other) { + if (!(other instanceof ExtendedPoint)) + throw new TypeError("ExtendedPoint expected"); + } + function assertRstPoint(other) { + if (!(other instanceof RistrettoPoint)) + throw new TypeError("RistrettoPoint expected"); + } + function legacyRist() { + throw new Error("Legacy method: switch to RistrettoPoint"); + } + var RistrettoPoint = class _RistrettoPoint { + constructor(ep) { + this.ep = ep; + } + static calcElligatorRistrettoMap(r0) { + const { d: d7 } = CURVE; + const r10 = mod2(SQRT_M1 * r0 * r0); + const Ns = mod2((r10 + _1n) * ONE_MINUS_D_SQ); + let c8 = BigInt(-1); + const D5 = mod2((c8 - d7 * r10) * mod2(r10 + d7)); + let { isValid: Ns_D_is_sq, value: s7 } = uvRatio(Ns, D5); + let s_ = mod2(s7 * r0); + if (!edIsNegative(s_)) + s_ = mod2(-s_); + if (!Ns_D_is_sq) + s7 = s_; + if (!Ns_D_is_sq) + c8 = r10; + const Nt = mod2(c8 * (r10 - _1n) * D_MINUS_ONE_SQ - D5); + const s22 = s7 * s7; + const W0 = mod2((s7 + s7) * D5); + const W1 = mod2(Nt * SQRT_AD_MINUS_ONE); + const W22 = mod2(_1n - s22); + const W32 = mod2(_1n + s22); + return new ExtendedPoint(mod2(W0 * W32), mod2(W22 * W1), mod2(W1 * W32), mod2(W0 * W22)); + } + static hashToCurve(hex) { + hex = ensureBytes(hex, 64); + const r1 = bytes255ToNumberLE(hex.slice(0, 32)); + const R1 = this.calcElligatorRistrettoMap(r1); + const r22 = bytes255ToNumberLE(hex.slice(32, 64)); + const R22 = this.calcElligatorRistrettoMap(r22); + return new _RistrettoPoint(R1.add(R22)); + } + static fromHex(hex) { + hex = ensureBytes(hex, 32); + const { a: a8, d: d7 } = CURVE; + const emsg = "RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint"; + const s7 = bytes255ToNumberLE(hex); + if (!equalBytes(numberTo32BytesLE(s7), hex) || edIsNegative(s7)) + throw new Error(emsg); + const s22 = mod2(s7 * s7); + const u1 = mod2(_1n + a8 * s22); + const u22 = mod2(_1n - a8 * s22); + const u1_2 = mod2(u1 * u1); + const u2_2 = mod2(u22 * u22); + const v7 = mod2(a8 * d7 * u1_2 - u2_2); + const { isValid: isValid2, value: I5 } = invertSqrt(mod2(v7 * u2_2)); + const Dx = mod2(I5 * u22); + const Dy = mod2(I5 * Dx * v7); + let x5 = mod2((s7 + s7) * Dx); + if (edIsNegative(x5)) + x5 = mod2(-x5); + const y7 = mod2(u1 * Dy); + const t9 = mod2(x5 * y7); + if (!isValid2 || edIsNegative(t9) || y7 === _0n) + throw new Error(emsg); + return new _RistrettoPoint(new ExtendedPoint(x5, y7, _1n, t9)); + } + toRawBytes() { + let { x: x5, y: y7, z: z6, t: t9 } = this.ep; + const u1 = mod2(mod2(z6 + y7) * mod2(z6 - y7)); + const u22 = mod2(x5 * y7); + const u2sq = mod2(u22 * u22); + const { value: invsqrt } = invertSqrt(mod2(u1 * u2sq)); + const D1 = mod2(invsqrt * u1); + const D22 = mod2(invsqrt * u22); + const zInv = mod2(D1 * D22 * t9); + let D5; + if (edIsNegative(t9 * zInv)) { + let _x = mod2(y7 * SQRT_M1); + let _y = mod2(x5 * SQRT_M1); + x5 = _x; + y7 = _y; + D5 = mod2(D1 * INVSQRT_A_MINUS_D); + } else { + D5 = D22; + } + if (edIsNegative(x5 * zInv)) + y7 = mod2(-y7); + let s7 = mod2((z6 - y7) * D5); + if (edIsNegative(s7)) + s7 = mod2(-s7); + return numberTo32BytesLE(s7); + } + toHex() { + return bytesToHex(this.toRawBytes()); + } + toString() { + return this.toHex(); + } + equals(other) { + assertRstPoint(other); + const a8 = this.ep; + const b6 = other.ep; + const one = mod2(a8.x * b6.y) === mod2(a8.y * b6.x); + const two = mod2(a8.y * b6.y) === mod2(a8.x * b6.x); + return one || two; + } + add(other) { + assertRstPoint(other); + return new _RistrettoPoint(this.ep.add(other.ep)); + } + subtract(other) { + assertRstPoint(other); + return new _RistrettoPoint(this.ep.subtract(other.ep)); + } + multiply(scalar) { + return new _RistrettoPoint(this.ep.multiply(scalar)); + } + multiplyUnsafe(scalar) { + return new _RistrettoPoint(this.ep.multiplyUnsafe(scalar)); + } + }; + RistrettoPoint.BASE = new RistrettoPoint(ExtendedPoint.BASE); + RistrettoPoint.ZERO = new RistrettoPoint(ExtendedPoint.ZERO); + var pointPrecomputes = /* @__PURE__ */ new WeakMap(); + var Point = class _Point { + constructor(x5, y7) { + this.x = x5; + this.y = y7; + } + _setWindowSize(windowSize) { + this._WINDOW_SIZE = windowSize; + pointPrecomputes.delete(this); + } + static fromHex(hex, strict2 = true) { + const { d: d7, P: P5 } = CURVE; + hex = ensureBytes(hex, 32); + const normed = hex.slice(); + normed[31] = hex[31] & ~128; + const y7 = bytesToNumberLE(normed); + if (strict2 && y7 >= P5) + throw new Error("Expected 0 < hex < P"); + if (!strict2 && y7 >= POW_2_256) + throw new Error("Expected 0 < hex < 2**256"); + const y22 = mod2(y7 * y7); + const u8 = mod2(y22 - _1n); + const v7 = mod2(d7 * y22 + _1n); + let { isValid: isValid2, value: x5 } = uvRatio(u8, v7); + if (!isValid2) + throw new Error("Point.fromHex: invalid y coordinate"); + const isXOdd = (x5 & _1n) === _1n; + const isLastByteOdd = (hex[31] & 128) !== 0; + if (isLastByteOdd !== isXOdd) { + x5 = mod2(-x5); + } + return new _Point(x5, y7); + } + static async fromPrivateKey(privateKey) { + return (await getExtendedPublicKey(privateKey)).point; + } + toRawBytes() { + const bytes2 = numberTo32BytesLE(this.y); + bytes2[31] |= this.x & _1n ? 128 : 0; + return bytes2; + } + toHex() { + return bytesToHex(this.toRawBytes()); + } + toX25519() { + const { y: y7 } = this; + const u8 = mod2((_1n + y7) * invert(_1n - y7)); + return numberTo32BytesLE(u8); + } + isTorsionFree() { + return ExtendedPoint.fromAffine(this).isTorsionFree(); + } + equals(other) { + return this.x === other.x && this.y === other.y; + } + negate() { + return new _Point(mod2(-this.x), this.y); + } + add(other) { + return ExtendedPoint.fromAffine(this).add(ExtendedPoint.fromAffine(other)).toAffine(); + } + subtract(other) { + return this.add(other.negate()); + } + multiply(scalar) { + return ExtendedPoint.fromAffine(this).multiply(scalar, this).toAffine(); + } + }; + Point.BASE = new Point(CURVE.Gx, CURVE.Gy); + Point.ZERO = new Point(_0n, _1n); + var Signature2 = class _Signature { + constructor(r10, s7) { + this.r = r10; + this.s = s7; + this.assertValidity(); + } + static fromHex(hex) { + const bytes2 = ensureBytes(hex, 64); + const r10 = Point.fromHex(bytes2.slice(0, 32), false); + const s7 = bytesToNumberLE(bytes2.slice(32, 64)); + return new _Signature(r10, s7); + } + assertValidity() { + const { r: r10, s: s7 } = this; + if (!(r10 instanceof Point)) + throw new Error("Expected Point instance"); + normalizeScalar(s7, CURVE.l, false); + return this; + } + toRawBytes() { + const u8 = new Uint8Array(64); + u8.set(this.r.toRawBytes()); + u8.set(numberTo32BytesLE(this.s), 32); + return u8; + } + toHex() { + return bytesToHex(this.toRawBytes()); + } + }; + function concatBytes(...arrays) { + if (!arrays.every((a8) => a8 instanceof Uint8Array)) + throw new Error("Expected Uint8Array list"); + if (arrays.length === 1) + return arrays[0]; + const length3 = arrays.reduce((a8, arr) => a8 + arr.length, 0); + const result = new Uint8Array(length3); + for (let i8 = 0, pad = 0; i8 < arrays.length; i8++) { + const arr = arrays[i8]; + result.set(arr, pad); + pad += arr.length; + } + return result; + } + var hexes = Array.from({ length: 256 }, (v7, i8) => i8.toString(16).padStart(2, "0")); + function bytesToHex(uint8a) { + if (!(uint8a instanceof Uint8Array)) + throw new Error("Uint8Array expected"); + let hex = ""; + for (let i8 = 0; i8 < uint8a.length; i8++) { + hex += hexes[uint8a[i8]]; + } + return hex; + } + function hexToBytes(hex) { + if (typeof hex !== "string") { + throw new TypeError("hexToBytes: expected string, got " + typeof hex); + } + if (hex.length % 2) + throw new Error("hexToBytes: received invalid unpadded hex"); + const array3 = new Uint8Array(hex.length / 2); + for (let i8 = 0; i8 < array3.length; i8++) { + const j5 = i8 * 2; + const hexByte = hex.slice(j5, j5 + 2); + const byte = Number.parseInt(hexByte, 16); + if (Number.isNaN(byte) || byte < 0) + throw new Error("Invalid byte sequence"); + array3[i8] = byte; + } + return array3; + } + function numberTo32BytesBE(num) { + const length3 = 32; + const hex = num.toString(16).padStart(length3 * 2, "0"); + return hexToBytes(hex); + } + function numberTo32BytesLE(num) { + return numberTo32BytesBE(num).reverse(); + } + function edIsNegative(num) { + return (mod2(num) & _1n) === _1n; + } + function bytesToNumberLE(uint8a) { + if (!(uint8a instanceof Uint8Array)) + throw new Error("Expected Uint8Array"); + return BigInt("0x" + bytesToHex(Uint8Array.from(uint8a).reverse())); + } + var MAX_255B = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + function bytes255ToNumberLE(bytes2) { + return mod2(bytesToNumberLE(bytes2) & MAX_255B); + } + function mod2(a8, b6 = CURVE.P) { + const res = a8 % b6; + return res >= _0n ? res : b6 + res; + } + function invert(number3, modulo = CURVE.P) { + if (number3 === _0n || modulo <= _0n) { + throw new Error(`invert: expected positive integers, got n=${number3} mod=${modulo}`); + } + let a8 = mod2(number3, modulo); + let b6 = modulo; + let x5 = _0n, y7 = _1n, u8 = _1n, v7 = _0n; + while (a8 !== _0n) { + const q4 = b6 / a8; + const r10 = b6 % a8; + const m7 = x5 - u8 * q4; + const n9 = y7 - v7 * q4; + b6 = a8, a8 = r10, x5 = u8, y7 = v7, u8 = m7, v7 = n9; + } + const gcd = b6; + if (gcd !== _1n) + throw new Error("invert: does not exist"); + return mod2(x5, modulo); + } + function invertBatch(nums, p8 = CURVE.P) { + const tmp = new Array(nums.length); + const lastMultiplied = nums.reduce((acc, num, i8) => { + if (num === _0n) + return acc; + tmp[i8] = acc; + return mod2(acc * num, p8); + }, _1n); + const inverted = invert(lastMultiplied, p8); + nums.reduceRight((acc, num, i8) => { + if (num === _0n) + return acc; + tmp[i8] = mod2(acc * tmp[i8], p8); + return mod2(acc * num, p8); + }, inverted); + return tmp; + } + function pow2(x5, power) { + const { P: P5 } = CURVE; + let res = x5; + while (power-- > _0n) { + res *= res; + res %= P5; + } + return res; + } + function pow_2_252_3(x5) { + const { P: P5 } = CURVE; + const _5n = BigInt(5); + const _10n = BigInt(10); + const _20n = BigInt(20); + const _40n = BigInt(40); + const _80n = BigInt(80); + const x22 = x5 * x5 % P5; + const b22 = x22 * x5 % P5; + const b42 = pow2(b22, _2n) * b22 % P5; + const b52 = pow2(b42, _1n) * x5 % P5; + const b10 = pow2(b52, _5n) * b52 % P5; + const b20 = pow2(b10, _10n) * b10 % P5; + const b40 = pow2(b20, _20n) * b20 % P5; + const b80 = pow2(b40, _40n) * b40 % P5; + const b160 = pow2(b80, _80n) * b80 % P5; + const b240 = pow2(b160, _80n) * b80 % P5; + const b250 = pow2(b240, _10n) * b10 % P5; + const pow_p_5_8 = pow2(b250, _2n) * x5 % P5; + return { pow_p_5_8, b2: b22 }; + } + function uvRatio(u8, v7) { + const v32 = mod2(v7 * v7 * v7); + const v72 = mod2(v32 * v32 * v7); + const pow = pow_2_252_3(u8 * v72).pow_p_5_8; + let x5 = mod2(u8 * v32 * pow); + const vx2 = mod2(v7 * x5 * x5); + const root1 = x5; + const root22 = mod2(x5 * SQRT_M1); + const useRoot1 = vx2 === u8; + const useRoot2 = vx2 === mod2(-u8); + const noRoot = vx2 === mod2(-u8 * SQRT_M1); + if (useRoot1) + x5 = root1; + if (useRoot2 || noRoot) + x5 = root22; + if (edIsNegative(x5)) + x5 = mod2(-x5); + return { isValid: useRoot1 || useRoot2, value: x5 }; + } + function invertSqrt(number3) { + return uvRatio(_1n, number3); + } + function modlLE(hash) { + return mod2(bytesToNumberLE(hash), CURVE.l); + } + function equalBytes(b1, b22) { + if (b1.length !== b22.length) { + return false; + } + for (let i8 = 0; i8 < b1.length; i8++) { + if (b1[i8] !== b22[i8]) { + return false; + } + } + return true; + } + function ensureBytes(hex, expectedLength) { + const bytes2 = hex instanceof Uint8Array ? Uint8Array.from(hex) : hexToBytes(hex); + if (typeof expectedLength === "number" && bytes2.length !== expectedLength) + throw new Error(`Expected ${expectedLength} bytes`); + return bytes2; + } + function normalizeScalar(num, max, strict2 = true) { + if (!max) + throw new TypeError("Specify max value"); + if (typeof num === "number" && Number.isSafeInteger(num)) + num = BigInt(num); + if (typeof num === "bigint" && num < max) { + if (strict2) { + if (_0n < num) + return num; + } else { + if (_0n <= num) + return num; + } + } + throw new TypeError("Expected valid scalar: 0 < scalar < max"); + } + function adjustBytes25519(bytes2) { + bytes2[0] &= 248; + bytes2[31] &= 127; + bytes2[31] |= 64; + return bytes2; + } + function checkPrivateKey(key) { + key = typeof key === "bigint" || typeof key === "number" ? numberTo32BytesBE(normalizeScalar(key, POW_2_256)) : ensureBytes(key); + if (key.length !== 32) + throw new Error(`Expected 32 bytes`); + return key; + } + function getKeyFromHash(hashed) { + const head2 = adjustBytes25519(hashed.slice(0, 32)); + const prefix = hashed.slice(32, 64); + const scalar = modlLE(head2); + const point = Point.BASE.multiply(scalar); + const pointBytes = point.toRawBytes(); + return { head: head2, prefix, scalar, point, pointBytes }; + } + var _sha512Sync; + async function getExtendedPublicKey(key) { + return getKeyFromHash(await utils.sha512(checkPrivateKey(key))); + } + async function getPublicKey(privateKey) { + return (await getExtendedPublicKey(privateKey)).pointBytes; + } + async function sign(message2, privateKey) { + message2 = ensureBytes(message2); + const { prefix, scalar, pointBytes } = await getExtendedPublicKey(privateKey); + const r10 = modlLE(await utils.sha512(prefix, message2)); + const R5 = Point.BASE.multiply(r10); + const k5 = modlLE(await utils.sha512(R5.toRawBytes(), pointBytes, message2)); + const s7 = mod2(r10 + k5 * scalar, CURVE.l); + return new Signature2(R5, s7).toRawBytes(); + } + function prepareVerification(sig, message2, publicKey) { + message2 = ensureBytes(message2); + if (!(publicKey instanceof Point)) + publicKey = Point.fromHex(publicKey, false); + const { r: r10, s: s7 } = sig instanceof Signature2 ? sig.assertValidity() : Signature2.fromHex(sig); + const SB = ExtendedPoint.BASE.multiplyUnsafe(s7); + return { r: r10, s: s7, SB, pub: publicKey, msg: message2 }; + } + function finishVerification(publicKey, r10, SB, hashed) { + const k5 = modlLE(hashed); + const kA = ExtendedPoint.fromAffine(publicKey).multiplyUnsafe(k5); + const RkA = ExtendedPoint.fromAffine(r10).add(kA); + return RkA.subtract(SB).multiplyUnsafe(CURVE.h).equals(ExtendedPoint.ZERO); + } + async function verify(sig, message2, publicKey) { + const { r: r10, SB, msg, pub } = prepareVerification(sig, message2, publicKey); + const hashed = await utils.sha512(r10.toRawBytes(), pub.toRawBytes(), msg); + return finishVerification(pub, r10, SB, hashed); + } + Point.BASE._setWindowSize(8); + var crypto3 = { + node: crypto_exports, + web: typeof self === "object" && "crypto" in self ? self.crypto : void 0 + }; + var utils = { + bytesToHex, + hexToBytes, + concatBytes, + getExtendedPublicKey, + mod: mod2, + invert, + TORSION_SUBGROUP: [ + "0100000000000000000000000000000000000000000000000000000000000000", + "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a", + "0000000000000000000000000000000000000000000000000000000000000080", + "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05", + "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", + "26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85", + "0000000000000000000000000000000000000000000000000000000000000000", + "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa" + ], + hashToPrivateScalar: (hash) => { + hash = ensureBytes(hash); + if (hash.length < 40 || hash.length > 1024) + throw new Error("Expected 40-1024 bytes of private key as per FIPS 186"); + return mod2(bytesToNumberLE(hash), CURVE.l - _1n) + _1n; + }, + randomBytes: (bytesLength = 32) => { + if (crypto3.web) { + return crypto3.web.getRandomValues(new Uint8Array(bytesLength)); + } else if (crypto3.node) { + const { randomBytes: randomBytes3 } = crypto3.node; + return new Uint8Array(randomBytes3(bytesLength).buffer); + } else { + throw new Error("The environment doesn't have randomBytes function"); + } + }, + randomPrivateKey: () => { + return utils.randomBytes(32); + }, + sha512: async (...messages) => { + const message2 = concatBytes(...messages); + if (crypto3.web) { + const buffer4 = await crypto3.web.subtle.digest("SHA-512", message2.buffer); + return new Uint8Array(buffer4); + } else if (crypto3.node) { + return Uint8Array.from(crypto3.node.createHash("sha512").update(message2).digest()); + } else { + throw new Error("The environment doesn't have sha512 function"); + } + }, + precompute(windowSize = 8, point = Point.BASE) { + const cached = point.equals(Point.BASE) ? point : new Point(point.x, point.y); + cached._setWindowSize(windowSize); + cached.multiply(_2n); + return cached; + }, + sha512Sync: void 0 + }; + Object.defineProperties(utils, { + sha512Sync: { + configurable: false, + get() { + return _sha512Sync; + }, + set(val) { + if (!_sha512Sync) + _sha512Sync = val; + } + } + }); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/ed25519/type.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/ed25519/verifier.js + var verifier_exports = {}; + __export(verifier_exports, { + code: () => code6, + decode: () => decode26, + encode: () => encode21, + format: () => format9, + name: () => name6, + or: () => or5, + parse: () => parse6, + signatureAlgorithm: () => signatureAlgorithm, + signatureCode: () => signatureCode + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/verifier.js + init_dirname(); + init_buffer2(); + init_process(); + var parseWith = (did3, parsers) => { + if (did3.startsWith("did:")) { + for (const parser of parsers) { + try { + return parser.parse(did3); + } catch (_5) { + } + } + throw new Error(`Unsupported did ${did3}`); + } else { + throw new Error(`Expected did instead got ${did3}`); + } + }; + var or4 = (left, right) => new Parser([left, right]); + var Parser = class _Parser { + /** + * @param {API.PrincipalParser[]} variants + */ + constructor(variants) { + this.variants = variants; + } + /** + * @param {API.DID} did + */ + parse(did3) { + return parseWith(did3, this.variants); + } + /** + * @param {API.PrincipalParser} parser + */ + or(parser) { + return new _Parser([...this.variants, parser]); + } + }; + var withDID = (key, id) => new VerifierWithDID(id, key); + var VerifierWithDID = class { + /** + * @param {ID} id + * @param {API.VerifierKey} key + */ + constructor(id, key) { + this.id = id; + this.key = key; + } + did() { + return this.id; + } + toDIDKey() { + return this.key.toDIDKey(); + } + /** + * @template T + * @param {API.ByteView} payload + * @param {API.Signature} signature + * @returns {API.Await} + */ + verify(payload, signature) { + return this.key.verify(payload, signature); + } + /** + * @template {API.DID} ID + * @param {ID} id + */ + withDID(id) { + return withDID(this.key, id); + } + }; + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/ed25519/verifier.js + var code6 = 237; + var name6 = "Ed25519"; + var signatureCode = EdDSA; + var signatureAlgorithm = "EdDSA"; + var PUBLIC_TAG_SIZE = varint_exports2.encodingLength(code6); + var SIZE = 32 + PUBLIC_TAG_SIZE; + var parse6 = (did3) => decode26(parse2(did3)); + var decode26 = (bytes2) => { + const [algorithm2] = varint_exports2.decode(bytes2); + if (algorithm2 !== code6) { + throw new RangeError( + `Unsupported key algorithm with multicode 0x${code6.toString(16)}` + ); + } else if (bytes2.byteLength !== SIZE) { + throw new RangeError( + `Expected Uint8Array with byteLength ${SIZE}, instead got Uint8Array with byteLength ${bytes2.byteLength}` + ); + } else { + return new Ed25519Verifier(bytes2.buffer, bytes2.byteOffset, bytes2.byteLength); + } + }; + var format9 = (principal) => format3(principal); + var encode21 = (principal) => encode9(principal); + var Ed25519Verifier = class extends Uint8Array { + /** @type {typeof code} */ + get code() { + return code6; + } + /** @type {typeof signatureCode} */ + get signatureCode() { + return signatureCode; + } + /** @type {typeof signatureAlgorithm} */ + get signatureAlgorithm() { + return signatureAlgorithm; + } + /** + * Raw public key without a multiformat code. + * + * @readonly + */ + get publicKey() { + const key = new Uint8Array(this.buffer, this.byteOffset + PUBLIC_TAG_SIZE); + Object.defineProperties(this, { + publicKey: { + value: key + } + }); + return key; + } + /** + * DID of the Principal in `did:key` format. + * @returns {API.DID<"key">} + */ + did() { + return `did:key:${base58btc2.encode(this)}`; + } + /** + * @template T + * @param {API.ByteView} payload + * @param {API.Signature} signature + * @returns {API.Await} + */ + verify(payload, signature) { + return signature.code === signatureCode && verify(signature.raw, payload, this.publicKey); + } + /** + * @template {API.DID} ID + * @param {ID} id + * @returns {API.Verifier} + */ + withDID(id) { + return withDID(this, id); + } + toDIDKey() { + return this.did(); + } + }; + var or5 = (other) => or4({ parse: parse6 }, other); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/signer.js + init_dirname(); + init_buffer2(); + init_process(); + var or6 = (left, right) => new Importer([left, right]); + var Importer = class _Importer { + /** + * @param {Importers} variants + */ + constructor(variants) { + this.variants = variants; + this.from = create7(variants); + } + /** + * @template {API.SignerImporter} Other + * @param {Other} other + * @returns {API.CompositeImporter<[Other, ...Importers]>} + */ + or(other) { + return new _Importer([other, ...this.variants]); + } + }; + var create7 = (importers) => { + const from18 = (archive2) => { + if (archive2.id.startsWith("did:key:")) { + return ( + /** @type {API.Signer} */ + importWith(archive2, importers) + ); + } else { + for (const [name15, key] of Object.entries(archive2.keys)) { + const id = ( + /** @type {API.DIDKey} */ + name15 + ); + const signer = ( + /** @type {API.Signer} */ + importWith( + { + id, + keys: { [id]: key } + }, + importers + ) + ); + return signer.withDID(archive2.id); + } + throw new Error(`Archive ${archive2.id} contains no keys`); + } + }; + return ( + /** @type {API.Intersection} */ + from18 + ); + }; + var importWith = (archive2, importers) => { + for (const importer of importers) { + try { + return importer.from(archive2); + } catch (_5) { + } + } + throw new Error(`Unsupported signer`); + }; + var withDID2 = ({ signer, verifier }, id) => new SignerWithDID(signer, verifier.withDID(id)); + var SignerWithDID = class { + /** + * @param {API.Signer, Code>} key + * @param {API.Verifier} verifier + */ + constructor(key, verifier) { + this.key = key; + this.verifier = verifier; + } + /** @type {API.Signer} */ + get signer() { + return this; + } + get signatureAlgorithm() { + return this.key.signatureAlgorithm; + } + get signatureCode() { + return this.key.signatureCode; + } + /** + * @returns {ID} + */ + did() { + return this.verifier.did(); + } + toDIDKey() { + return this.verifier.toDIDKey(); + } + /** + * @template {API.DID} ID + * @param {ID} id + */ + withDID(id) { + return withDID2(this.key, id); + } + /** + * @template T + * @param {API.ByteView} payload + */ + sign(payload) { + return this.key.sign(payload); + } + /** + * @template T + * @param {API.ByteView} payload + * @param {API.Signature} signature + */ + verify(payload, signature) { + return this.verifier.verify(payload, signature); + } + toArchive() { + const { keys: keys2 } = this.key.toArchive(); + return { + id: this.did(), + keys: keys2 + }; + } + }; + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/ed25519/signer.js + var code7 = 4864; + var name7 = name6; + var signatureAlgorithm2 = signatureAlgorithm; + var signatureCode2 = signatureCode; + var PRIVATE_TAG_SIZE = varint_exports2.encodingLength(code7); + var PUBLIC_TAG_SIZE2 = varint_exports2.encodingLength(code6); + var KEY_SIZE = 32; + var SIZE2 = PRIVATE_TAG_SIZE + KEY_SIZE + PUBLIC_TAG_SIZE2 + KEY_SIZE; + var PUB_KEY_OFFSET = PRIVATE_TAG_SIZE + KEY_SIZE; + var generate = () => derive(utils.randomPrivateKey()); + var derive = async (secret) => { + if (secret.byteLength !== KEY_SIZE) { + throw new Error( + `Expected Uint8Array with byteLength of ${KEY_SIZE} instead not ${secret.byteLength}` + ); + } + const publicKey = await getPublicKey(secret); + const signer = new Ed25519Signer(SIZE2); + varint_exports2.encodeTo(code7, signer, 0); + signer.set(secret, PRIVATE_TAG_SIZE); + varint_exports2.encodeTo(code6, signer, PRIVATE_TAG_SIZE + KEY_SIZE); + signer.set(publicKey, PRIVATE_TAG_SIZE + KEY_SIZE + PUBLIC_TAG_SIZE2); + return signer; + }; + var from10 = ({ id, keys: keys2 }) => { + if (id.startsWith("did:key:")) { + const key = keys2[ + /** @type {API.DIDKey} */ + id + ]; + if (key instanceof Uint8Array) { + return decode27(key); + } + } + throw new TypeError(`Unsupported archive format`); + }; + var or7 = (other) => or6({ from: from10 }, other); + var decode27 = (bytes2) => { + if (bytes2.byteLength !== SIZE2) { + throw new Error( + `Expected Uint8Array with byteLength of ${SIZE2} instead not ${bytes2.byteLength}` + ); + } + { + const [keyCode] = varint_exports2.decode(bytes2); + if (keyCode !== code7) { + throw new Error(`Given bytes must be a multiformat with ${code7} tag`); + } + } + { + const [code15] = varint_exports2.decode(bytes2.subarray(PUB_KEY_OFFSET)); + if (code15 !== code6) { + throw new Error( + `Given bytes must contain public key in multiformats with ${code6} tag` + ); + } + } + return new Ed25519Signer(bytes2); + }; + var encode22 = (signer) => signer.encode(); + var format10 = (signer, encoder4) => (encoder4 || base64pad).encode(encode22(signer)); + var parse7 = (principal, decoder4) => decode27((decoder4 || base64pad).decode(principal)); + var Ed25519Signer = class extends Uint8Array { + /** @type {typeof code} */ + get code() { + return code7; + } + get signer() { + return this; + } + /** @type {API.EdVerifier} */ + get verifier() { + const bytes2 = new Uint8Array(this.buffer, PRIVATE_TAG_SIZE + KEY_SIZE); + const verifier = decode26(bytes2); + Object.defineProperties(this, { + verifier: { + value: verifier + } + }); + return verifier; + } + /** + * Raw public key without multiformat code. + */ + get secret() { + const secret = new Uint8Array(this.buffer, PRIVATE_TAG_SIZE, KEY_SIZE); + Object.defineProperties(this, { + secret: { + value: secret + } + }); + return secret; + } + /** + * DID of this principal in `did:key` format. + */ + did() { + return this.verifier.did(); + } + toDIDKey() { + return this.verifier.toDIDKey(); + } + /** + * @template {API.DID} ID + * @param {ID} id + * @returns {API.Signer} + */ + withDID(id) { + return withDID2(this, id); + } + /** + * @template T + * @param {API.ByteView} payload + * @returns {Promise>} + */ + async sign(payload) { + const raw = await sign(payload, this.secret); + return create4(this.signatureCode, raw); + } + /** + * @template T + * @param {API.ByteView} payload + * @param {API.Signature} signature + */ + verify(payload, signature) { + return this.verifier.verify(payload, signature); + } + get signatureAlgorithm() { + return signatureAlgorithm2; + } + get signatureCode() { + return EdDSA; + } + encode() { + return this; + } + toArchive() { + const id = this.did(); + return { + id, + keys: { [id]: this.encode() } + }; + } + }; + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/compare.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/concat.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/alloc.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/util/as-uint8array.js + init_dirname(); + init_buffer2(); + init_process(); + function asUint8Array(buf3) { + if (globalThis.Buffer != null) { + return new Uint8Array(buf3.buffer, buf3.byteOffset, buf3.byteLength); + } + return buf3; + } + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/alloc.js + function allocUnsafe(size4 = 0) { + if (globalThis.Buffer?.allocUnsafe != null) { + return asUint8Array(globalThis.Buffer.allocUnsafe(size4)); + } + return new Uint8Array(size4); + } + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/concat.js + function concat3(arrays, length3) { + if (length3 == null) { + length3 = arrays.reduce((acc, curr) => acc + curr.length, 0); + } + const output = allocUnsafe(length3); + let offset2 = 0; + for (const arr of arrays) { + output.set(arr, offset2); + offset2 += arr.length; + } + return asUint8Array(output); + } + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/equals.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/from-string.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/util/bases.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/basics.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/identity.js + var identity_exports2 = {}; + __export(identity_exports2, { + identity: () => identity2 + }); + init_dirname(); + init_buffer2(); + init_process(); + var identity2 = from2({ + prefix: "\0", + name: "identity", + encode: (buf3) => toString3(buf3), + decode: (str) => fromString3(str) + }); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base2.js + var base2_exports = {}; + __export(base2_exports, { + base2: () => base22 + }); + init_dirname(); + init_buffer2(); + init_process(); + var base22 = rfc46482({ + prefix: "0", + name: "base2", + alphabet: "01", + bitsPerChar: 1 + }); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base8.js + var base8_exports = {}; + __export(base8_exports, { + base8: () => base8 + }); + init_dirname(); + init_buffer2(); + init_process(); + var base8 = rfc46482({ + prefix: "7", + name: "base8", + alphabet: "01234567", + bitsPerChar: 3 + }); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base10.js + var base10_exports = {}; + __export(base10_exports, { + base10: () => base10 + }); + init_dirname(); + init_buffer2(); + init_process(); + var base10 = baseX2({ + prefix: "9", + name: "base10", + alphabet: "0123456789" + }); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base16.js + var base16_exports = {}; + __export(base16_exports, { + base16: () => base16, + base16upper: () => base16upper + }); + init_dirname(); + init_buffer2(); + init_process(); + var base16 = rfc46482({ + prefix: "f", + name: "base16", + alphabet: "0123456789abcdef", + bitsPerChar: 4 + }); + var base16upper = rfc46482({ + prefix: "F", + name: "base16upper", + alphabet: "0123456789ABCDEF", + bitsPerChar: 4 + }); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base36.js + var base36_exports = {}; + __export(base36_exports, { + base36: () => base36, + base36upper: () => base36upper + }); + init_dirname(); + init_buffer2(); + init_process(); + var base36 = baseX2({ + prefix: "k", + name: "base36", + alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" + }); + var base36upper = baseX2({ + prefix: "K", + name: "base36upper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + }); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/bases/base256emoji.js + var base256emoji_exports = {}; + __export(base256emoji_exports, { + base256emoji: () => base256emoji + }); + init_dirname(); + init_buffer2(); + init_process(); + var alphabet = Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"); + var alphabetBytesToChars = ( + /** @type {string[]} */ + alphabet.reduce( + (p8, c8, i8) => { + p8[i8] = c8; + return p8; + }, + /** @type {string[]} */ + [] + ) + ); + var alphabetCharsToBytes = ( + /** @type {number[]} */ + alphabet.reduce( + (p8, c8, i8) => { + p8[ + /** @type {number} */ + c8.codePointAt(0) + ] = i8; + return p8; + }, + /** @type {number[]} */ + [] + ) + ); + function encode23(data) { + return data.reduce((p8, c8) => { + p8 += alphabetBytesToChars[c8]; + return p8; + }, ""); + } + function decode28(str) { + const byts = []; + for (const char of str) { + const byt = alphabetCharsToBytes[ + /** @type {number} */ + char.codePointAt(0) + ]; + if (byt === void 0) { + throw new Error(`Non-base256emoji character: ${char}`); + } + byts.push(byt); + } + return new Uint8Array(byts); + } + var base256emoji = from2({ + prefix: "\u{1F680}", + name: "base256emoji", + encode: encode23, + decode: decode28 + }); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/codecs/json.js + init_dirname(); + init_buffer2(); + init_process(); + var textEncoder3 = new TextEncoder(); + var textDecoder3 = new TextDecoder(); + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/basics.js + var bases = { ...identity_exports2, ...base2_exports, ...base8_exports, ...base10_exports, ...base16_exports, ...base32_exports, ...base36_exports, ...base58_exports, ...base64_exports, ...base256emoji_exports }; + var hashes = { ...sha2_browser_exports, ...identity_exports }; + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/util/bases.js + function createCodec(name15, prefix, encode41, decode46) { + return { + name: name15, + prefix, + encoder: { + name: name15, + prefix, + encode: encode41 + }, + decoder: { + decode: decode46 + } + }; + } + var string2 = createCodec("utf8", "u", (buf3) => { + const decoder4 = new TextDecoder("utf8"); + return "u" + decoder4.decode(buf3); + }, (str) => { + const encoder4 = new TextEncoder(); + return encoder4.encode(str.substring(1)); + }); + var ascii = createCodec("ascii", "a", (buf3) => { + let string4 = "a"; + for (let i8 = 0; i8 < buf3.length; i8++) { + string4 += String.fromCharCode(buf3[i8]); + } + return string4; + }, (str) => { + str = str.substring(1); + const buf3 = allocUnsafe(str.length); + for (let i8 = 0; i8 < str.length; i8++) { + buf3[i8] = str.charCodeAt(i8); + } + return buf3; + }); + var BASES = { + utf8: string2, + "utf-8": string2, + hex: bases.base16, + latin1: ascii, + ascii, + binary: ascii, + ...bases + }; + var bases_default = BASES; + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/from-string.js + function fromString5(string4, encoding = "utf8") { + const base3 = bases_default[encoding]; + if (base3 == null) { + throw new Error(`Unsupported encoding "${encoding}"`); + } + if ((encoding === "utf8" || encoding === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null) { + return asUint8Array(globalThis.Buffer.from(string4, "utf-8")); + } + return base3.decoder.decode(`${base3.prefix}${string4}`); + } + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/to-string.js + init_dirname(); + init_buffer2(); + init_process(); + function toString5(array3, encoding = "utf8") { + const base3 = bases_default[encoding]; + if (base3 == null) { + throw new Error(`Unsupported encoding "${encoding}"`); + } + if ((encoding === "utf8" || encoding === "utf-8") && globalThis.Buffer != null && globalThis.Buffer.from != null) { + return globalThis.Buffer.from(array3.buffer, array3.byteOffset, array3.byteLength).toString("utf8"); + } + return base3.encoder.encode(array3).substring(1); + } + + // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/xor.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/encoding.js + init_dirname(); + init_buffer2(); + init_process(); + function delegationsToBytes(delegations) { + if (!Array.isArray(delegations) || delegations.length === 0) { + throw new Error("Delegations required to be an non empty array."); + } + const roots = delegations.map( + (d7) => ( + /** @type {CarBufferWriter.CID} */ + d7.root.cid + ) + ); + const cids = /* @__PURE__ */ new Set(); + const blocks = []; + let byteLength = 0; + for (const delegation of delegations) { + for (const block of delegation.export()) { + const cid = block.cid.toV1().toString(); + if (!cids.has(cid)) { + byteLength += blockLength( + /** @type {CarBufferWriter.Block} */ + block + ); + blocks.push( + /** @type {CarBufferWriter.Block} */ + block + ); + cids.add(cid); + } + } + } + const headerLength2 = estimateHeaderLength(roots.length); + const writer2 = createWriter( + new ArrayBuffer(headerLength2 + byteLength), + { roots } + ); + for (const block of blocks) { + writer2.write(block); + } + return writer2.close(); + } + function bytesToDelegations(bytes2) { + if (!(bytes2 instanceof Uint8Array) || bytes2.length === 0) { + throw new TypeError("Input should be a non-empty Uint8Array."); + } + const reader2 = CarBufferReader.fromBytes(bytes2); + const roots = reader2.getRoots(); + const delegations = []; + for (const root3 of roots) { + const rootBlock = reader2.get(root3); + if (rootBlock) { + const blocks = /* @__PURE__ */ new Map(); + for (const block of reader2.blocks()) { + if (block.cid.toString() !== root3.toString()) + blocks.set(block.cid.toString(), block); + } + delegations.push(new Delegation(rootBlock, blocks)); + } else { + throw new Error("Failed to find root from raw delegation."); + } + } + return delegations; + } + function delegationsToString(delegations, encoding = "base64url") { + const bytes2 = delegationsToBytes(delegations); + return toString5(bytes2, encoding); + } + function stringToDelegations(raw, encoding = "base64url") { + const bytes2 = fromString5(raw, encoding); + return bytesToDelegations(bytes2); + } + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/awake/messages.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/zod@3.21.0/node_modules/zod/lib/index.mjs + init_dirname(); + init_buffer2(); + init_process(); + var util; + (function(util3) { + util3.assertEqual = (val) => val; + function assertIs(_arg) { + } + util3.assertIs = assertIs; + function assertNever(_x) { + throw new Error(); + } + util3.assertNever = assertNever; + util3.arrayToEnum = (items) => { + const obj = {}; + for (const item of items) { + obj[item] = item; + } + return obj; + }; + util3.getValidEnumValues = (obj) => { + const validKeys = util3.objectKeys(obj).filter((k5) => typeof obj[obj[k5]] !== "number"); + const filtered = {}; + for (const k5 of validKeys) { + filtered[k5] = obj[k5]; + } + return util3.objectValues(filtered); + }; + util3.objectValues = (obj) => { + return util3.objectKeys(obj).map(function(e12) { + return obj[e12]; + }); + }; + util3.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => { + const keys2 = []; + for (const key in object) { + if (Object.prototype.hasOwnProperty.call(object, key)) { + keys2.push(key); + } + } + return keys2; + }; + util3.find = (arr, checker) => { + for (const item of arr) { + if (checker(item)) + return item; + } + return void 0; + }; + util3.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val; + function joinValues(array3, separator = " | ") { + return array3.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator); + } + util3.joinValues = joinValues; + util3.jsonStringifyReplacer = (_5, value) => { + if (typeof value === "bigint") { + return value.toString(); + } + return value; + }; + })(util || (util = {})); + var ZodParsedType = util.arrayToEnum([ + "string", + "nan", + "number", + "integer", + "float", + "boolean", + "date", + "bigint", + "symbol", + "function", + "undefined", + "null", + "array", + "object", + "unknown", + "promise", + "void", + "never", + "map", + "set" + ]); + var getParsedType = (data) => { + const t9 = typeof data; + switch (t9) { + case "undefined": + return ZodParsedType.undefined; + case "string": + return ZodParsedType.string; + case "number": + return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number; + case "boolean": + return ZodParsedType.boolean; + case "function": + return ZodParsedType.function; + case "bigint": + return ZodParsedType.bigint; + case "symbol": + return ZodParsedType.symbol; + case "object": + if (Array.isArray(data)) { + return ZodParsedType.array; + } + if (data === null) { + return ZodParsedType.null; + } + if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { + return ZodParsedType.promise; + } + if (typeof Map !== "undefined" && data instanceof Map) { + return ZodParsedType.map; + } + if (typeof Set !== "undefined" && data instanceof Set) { + return ZodParsedType.set; + } + if (typeof Date !== "undefined" && data instanceof Date) { + return ZodParsedType.date; + } + return ZodParsedType.object; + default: + return ZodParsedType.unknown; + } + }; + var ZodIssueCode = util.arrayToEnum([ + "invalid_type", + "invalid_literal", + "custom", + "invalid_union", + "invalid_union_discriminator", + "invalid_enum_value", + "unrecognized_keys", + "invalid_arguments", + "invalid_return_type", + "invalid_date", + "invalid_string", + "too_small", + "too_big", + "invalid_intersection_types", + "not_multiple_of", + "not_finite" + ]); + var quotelessJson = (obj) => { + const json = JSON.stringify(obj, null, 2); + return json.replace(/"([^"]+)":/g, "$1:"); + }; + var ZodError = class extends Error { + constructor(issues) { + super(); + this.issues = []; + this.addIssue = (sub) => { + this.issues = [...this.issues, sub]; + }; + this.addIssues = (subs = []) => { + this.issues = [...this.issues, ...subs]; + }; + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } else { + this.__proto__ = actualProto; + } + this.name = "ZodError"; + this.issues = issues; + } + get errors() { + return this.issues; + } + format(_mapper) { + const mapper = _mapper || function(issue4) { + return issue4.message; + }; + const fieldErrors = { _errors: [] }; + const processError = (error7) => { + for (const issue4 of error7.issues) { + if (issue4.code === "invalid_union") { + issue4.unionErrors.map(processError); + } else if (issue4.code === "invalid_return_type") { + processError(issue4.returnTypeError); + } else if (issue4.code === "invalid_arguments") { + processError(issue4.argumentsError); + } else if (issue4.path.length === 0) { + fieldErrors._errors.push(mapper(issue4)); + } else { + let curr = fieldErrors; + let i8 = 0; + while (i8 < issue4.path.length) { + const el = issue4.path[i8]; + const terminal = i8 === issue4.path.length - 1; + if (!terminal) { + curr[el] = curr[el] || { _errors: [] }; + } else { + curr[el] = curr[el] || { _errors: [] }; + curr[el]._errors.push(mapper(issue4)); + } + curr = curr[el]; + i8++; + } + } + } + }; + processError(this); + return fieldErrors; + } + toString() { + return this.message; + } + get message() { + return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2); + } + get isEmpty() { + return this.issues.length === 0; + } + flatten(mapper = (issue4) => issue4.message) { + const fieldErrors = {}; + const formErrors = []; + for (const sub of this.issues) { + if (sub.path.length > 0) { + fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; + fieldErrors[sub.path[0]].push(mapper(sub)); + } else { + formErrors.push(mapper(sub)); + } + } + return { formErrors, fieldErrors }; + } + get formErrors() { + return this.flatten(); + } + }; + ZodError.create = (issues) => { + const error7 = new ZodError(issues); + return error7; + }; + var errorMap = (issue4, _ctx) => { + let message2; + switch (issue4.code) { + case ZodIssueCode.invalid_type: + if (issue4.received === ZodParsedType.undefined) { + message2 = "Required"; + } else { + message2 = `Expected ${issue4.expected}, received ${issue4.received}`; + } + break; + case ZodIssueCode.invalid_literal: + message2 = `Invalid literal value, expected ${JSON.stringify(issue4.expected, util.jsonStringifyReplacer)}`; + break; + case ZodIssueCode.unrecognized_keys: + message2 = `Unrecognized key(s) in object: ${util.joinValues(issue4.keys, ", ")}`; + break; + case ZodIssueCode.invalid_union: + message2 = `Invalid input`; + break; + case ZodIssueCode.invalid_union_discriminator: + message2 = `Invalid discriminator value. Expected ${util.joinValues(issue4.options)}`; + break; + case ZodIssueCode.invalid_enum_value: + message2 = `Invalid enum value. Expected ${util.joinValues(issue4.options)}, received '${issue4.received}'`; + break; + case ZodIssueCode.invalid_arguments: + message2 = `Invalid function arguments`; + break; + case ZodIssueCode.invalid_return_type: + message2 = `Invalid function return type`; + break; + case ZodIssueCode.invalid_date: + message2 = `Invalid date`; + break; + case ZodIssueCode.invalid_string: + if (typeof issue4.validation === "object") { + if ("startsWith" in issue4.validation) { + message2 = `Invalid input: must start with "${issue4.validation.startsWith}"`; + } else if ("endsWith" in issue4.validation) { + message2 = `Invalid input: must end with "${issue4.validation.endsWith}"`; + } else { + util.assertNever(issue4.validation); + } + } else if (issue4.validation !== "regex") { + message2 = `Invalid ${issue4.validation}`; + } else { + message2 = "Invalid"; + } + break; + case ZodIssueCode.too_small: + if (issue4.type === "array") + message2 = `Array must contain ${issue4.exact ? "exactly" : issue4.inclusive ? `at least` : `more than`} ${issue4.minimum} element(s)`; + else if (issue4.type === "string") + message2 = `String must contain ${issue4.exact ? "exactly" : issue4.inclusive ? `at least` : `over`} ${issue4.minimum} character(s)`; + else if (issue4.type === "number") + message2 = `Number must be ${issue4.exact ? `exactly equal to ` : issue4.inclusive ? `greater than or equal to ` : `greater than `}${issue4.minimum}`; + else if (issue4.type === "date") + message2 = `Date must be ${issue4.exact ? `exactly equal to ` : issue4.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue4.minimum))}`; + else + message2 = "Invalid input"; + break; + case ZodIssueCode.too_big: + if (issue4.type === "array") + message2 = `Array must contain ${issue4.exact ? `exactly` : issue4.inclusive ? `at most` : `less than`} ${issue4.maximum} element(s)`; + else if (issue4.type === "string") + message2 = `String must contain ${issue4.exact ? `exactly` : issue4.inclusive ? `at most` : `under`} ${issue4.maximum} character(s)`; + else if (issue4.type === "number") + message2 = `Number must be ${issue4.exact ? `exactly` : issue4.inclusive ? `less than or equal to` : `less than`} ${issue4.maximum}`; + else if (issue4.type === "bigint") + message2 = `BigInt must be ${issue4.exact ? `exactly` : issue4.inclusive ? `less than or equal to` : `less than`} ${issue4.maximum}`; + else if (issue4.type === "date") + message2 = `Date must be ${issue4.exact ? `exactly` : issue4.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue4.maximum))}`; + else + message2 = "Invalid input"; + break; + case ZodIssueCode.custom: + message2 = `Invalid input`; + break; + case ZodIssueCode.invalid_intersection_types: + message2 = `Intersection results could not be merged`; + break; + case ZodIssueCode.not_multiple_of: + message2 = `Number must be a multiple of ${issue4.multipleOf}`; + break; + case ZodIssueCode.not_finite: + message2 = "Number must be finite"; + break; + default: + message2 = _ctx.defaultError; + util.assertNever(issue4); + } + return { message: message2 }; + }; + var overrideErrorMap = errorMap; + function setErrorMap(map2) { + overrideErrorMap = map2; + } + function getErrorMap() { + return overrideErrorMap; + } + var makeIssue = (params) => { + const { data, path: path2, errorMaps, issueData } = params; + const fullPath = [...path2, ...issueData.path || []]; + const fullIssue = { + ...issueData, + path: fullPath + }; + let errorMessage = ""; + const maps = errorMaps.filter((m7) => !!m7).slice().reverse(); + for (const map2 of maps) { + errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message; + } + return { + ...issueData, + path: fullPath, + message: issueData.message || errorMessage + }; + }; + var EMPTY_PATH = []; + function addIssueToContext(ctx, issueData) { + const issue4 = makeIssue({ + issueData, + data: ctx.data, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + // then global default map + ].filter((x5) => !!x5) + }); + ctx.common.issues.push(issue4); + } + var ParseStatus = class _ParseStatus { + constructor() { + this.value = "valid"; + } + dirty() { + if (this.value === "valid") + this.value = "dirty"; + } + abort() { + if (this.value !== "aborted") + this.value = "aborted"; + } + static mergeArray(status, results) { + const arrayValue = []; + for (const s7 of results) { + if (s7.status === "aborted") + return INVALID; + if (s7.status === "dirty") + status.dirty(); + arrayValue.push(s7.value); + } + return { status: status.value, value: arrayValue }; + } + static async mergeObjectAsync(status, pairs) { + const syncPairs = []; + for (const pair of pairs) { + syncPairs.push({ + key: await pair.key, + value: await pair.value + }); + } + return _ParseStatus.mergeObjectSync(status, syncPairs); + } + static mergeObjectSync(status, pairs) { + const finalObject = {}; + for (const pair of pairs) { + const { key, value } = pair; + if (key.status === "aborted") + return INVALID; + if (value.status === "aborted") + return INVALID; + if (key.status === "dirty") + status.dirty(); + if (value.status === "dirty") + status.dirty(); + if (typeof value.value !== "undefined" || pair.alwaysSet) { + finalObject[key.value] = value.value; + } + } + return { status: status.value, value: finalObject }; + } + }; + var INVALID = Object.freeze({ + status: "aborted" + }); + var DIRTY = (value) => ({ status: "dirty", value }); + var OK = (value) => ({ status: "valid", value }); + var isAborted = (x5) => x5.status === "aborted"; + var isDirty = (x5) => x5.status === "dirty"; + var isValid = (x5) => x5.status === "valid"; + var isAsync = (x5) => typeof Promise !== "undefined" && x5 instanceof Promise; + var errorUtil; + (function(errorUtil2) { + errorUtil2.errToObj = (message2) => typeof message2 === "string" ? { message: message2 } : message2 || {}; + errorUtil2.toString = (message2) => typeof message2 === "string" ? message2 : message2 === null || message2 === void 0 ? void 0 : message2.message; + })(errorUtil || (errorUtil = {})); + var ParseInputLazyPath = class { + constructor(parent, value, path2, key) { + this.parent = parent; + this.data = value; + this._path = path2; + this._key = key; + } + get path() { + return this._path.concat(this._key); + } + }; + var handleResult = (ctx, result) => { + if (isValid(result)) { + return { success: true, data: result.value }; + } else { + if (!ctx.common.issues.length) { + throw new Error("Validation failed but no issues detected."); + } + const error7 = new ZodError(ctx.common.issues); + return { success: false, error: error7 }; + } + }; + function processCreateParams(params) { + if (!params) + return {}; + const { errorMap: errorMap2, invalid_type_error, required_error, description } = params; + if (errorMap2 && (invalid_type_error || required_error)) { + throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); + } + if (errorMap2) + return { errorMap: errorMap2, description }; + const customMap = (iss, ctx) => { + if (iss.code !== "invalid_type") + return { message: ctx.defaultError }; + if (typeof ctx.data === "undefined") { + return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError }; + } + return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError }; + }; + return { errorMap: customMap, description }; + } + var ZodType = class { + constructor(def) { + this.spa = this.safeParseAsync; + this._def = def; + this.parse = this.parse.bind(this); + this.safeParse = this.safeParse.bind(this); + this.parseAsync = this.parseAsync.bind(this); + this.safeParseAsync = this.safeParseAsync.bind(this); + this.spa = this.spa.bind(this); + this.refine = this.refine.bind(this); + this.refinement = this.refinement.bind(this); + this.superRefine = this.superRefine.bind(this); + this.optional = this.optional.bind(this); + this.nullable = this.nullable.bind(this); + this.nullish = this.nullish.bind(this); + this.array = this.array.bind(this); + this.promise = this.promise.bind(this); + this.or = this.or.bind(this); + this.and = this.and.bind(this); + this.transform = this.transform.bind(this); + this.brand = this.brand.bind(this); + this.default = this.default.bind(this); + this.catch = this.catch.bind(this); + this.describe = this.describe.bind(this); + this.pipe = this.pipe.bind(this); + this.isNullable = this.isNullable.bind(this); + this.isOptional = this.isOptional.bind(this); + } + get description() { + return this._def.description; + } + _getType(input) { + return getParsedType(input.data); + } + _getOrReturnCtx(input, ctx) { + return ctx || { + common: input.parent.common, + data: input.data, + parsedType: getParsedType(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent + }; + } + _processInputParams(input) { + return { + status: new ParseStatus(), + ctx: { + common: input.parent.common, + data: input.data, + parsedType: getParsedType(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent + } + }; + } + _parseSync(input) { + const result = this._parse(input); + if (isAsync(result)) { + throw new Error("Synchronous parse encountered promise."); + } + return result; + } + _parseAsync(input) { + const result = this._parse(input); + return Promise.resolve(result); + } + parse(data, params) { + const result = this.safeParse(data, params); + if (result.success) + return result.data; + throw result.error; + } + safeParse(data, params) { + var _a2; + const ctx = { + common: { + issues: [], + async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false, + contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap + }, + path: (params === null || params === void 0 ? void 0 : params.path) || [], + schemaErrorMap: this._def.errorMap, + parent: null, + data, + parsedType: getParsedType(data) + }; + const result = this._parseSync({ data, path: ctx.path, parent: ctx }); + return handleResult(ctx, result); + } + async parseAsync(data, params) { + const result = await this.safeParseAsync(data, params); + if (result.success) + return result.data; + throw result.error; + } + async safeParseAsync(data, params) { + const ctx = { + common: { + issues: [], + contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap, + async: true + }, + path: (params === null || params === void 0 ? void 0 : params.path) || [], + schemaErrorMap: this._def.errorMap, + parent: null, + data, + parsedType: getParsedType(data) + }; + const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }); + const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult)); + return handleResult(ctx, result); + } + refine(check, message2) { + const getIssueProperties = (val) => { + if (typeof message2 === "string" || typeof message2 === "undefined") { + return { message: message2 }; + } else if (typeof message2 === "function") { + return message2(val); + } else { + return message2; + } + }; + return this._refinement((val, ctx) => { + const result = check(val); + const setError = () => ctx.addIssue({ + code: ZodIssueCode.custom, + ...getIssueProperties(val) + }); + if (typeof Promise !== "undefined" && result instanceof Promise) { + return result.then((data) => { + if (!data) { + setError(); + return false; + } else { + return true; + } + }); + } + if (!result) { + setError(); + return false; + } else { + return true; + } + }); + } + refinement(check, refinementData) { + return this._refinement((val, ctx) => { + if (!check(val)) { + ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData); + return false; + } else { + return true; + } + }); + } + _refinement(refinement) { + return new ZodEffects({ + schema: this, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect: { type: "refinement", refinement } + }); + } + superRefine(refinement) { + return this._refinement(refinement); + } + optional() { + return ZodOptional.create(this, this._def); + } + nullable() { + return ZodNullable.create(this, this._def); + } + nullish() { + return this.nullable().optional(); + } + array() { + return ZodArray.create(this, this._def); + } + promise() { + return ZodPromise.create(this, this._def); + } + or(option) { + return ZodUnion.create([this, option], this._def); + } + and(incoming) { + return ZodIntersection.create(this, incoming, this._def); + } + transform(transform) { + return new ZodEffects({ + ...processCreateParams(this._def), + schema: this, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect: { type: "transform", transform } + }); + } + default(def) { + const defaultValueFunc = typeof def === "function" ? def : () => def; + return new ZodDefault({ + ...processCreateParams(this._def), + innerType: this, + defaultValue: defaultValueFunc, + typeName: ZodFirstPartyTypeKind.ZodDefault + }); + } + brand() { + return new ZodBranded({ + typeName: ZodFirstPartyTypeKind.ZodBranded, + type: this, + ...processCreateParams(this._def) + }); + } + catch(def) { + const catchValueFunc = typeof def === "function" ? def : () => def; + return new ZodCatch({ + ...processCreateParams(this._def), + innerType: this, + catchValue: catchValueFunc, + typeName: ZodFirstPartyTypeKind.ZodCatch + }); + } + describe(description) { + const This = this.constructor; + return new This({ + ...this._def, + description + }); + } + pipe(target) { + return ZodPipeline.create(this, target); + } + isOptional() { + return this.safeParse(void 0).success; + } + isNullable() { + return this.safeParse(null).success; + } + }; + var cuidRegex = /^c[^\s-]{8,}$/i; + var cuid2Regex = /^[a-z][a-z0-9]*$/; + var uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i; + var emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/; + var emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u; + var ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/; + var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/; + var datetimeRegex = (args) => { + if (args.precision) { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`); + } + } else if (args.precision === 0) { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`); + } + } else { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`); + } + } + }; + function isValidIP(ip, version3) { + if ((version3 === "v4" || !version3) && ipv4Regex.test(ip)) { + return true; + } + if ((version3 === "v6" || !version3) && ipv6Regex.test(ip)) { + return true; + } + return false; + } + var ZodString = class _ZodString extends ZodType { + constructor() { + super(...arguments); + this._regex = (regex, validation, message2) => this.refinement((data) => regex.test(data), { + validation, + code: ZodIssueCode.invalid_string, + ...errorUtil.errToObj(message2) + }); + this.nonempty = (message2) => this.min(1, errorUtil.errToObj(message2)); + this.trim = () => new _ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "trim" }] + }); + this.toLowerCase = () => new _ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "toLowerCase" }] + }); + this.toUpperCase = () => new _ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "toUpperCase" }] + }); + } + _parse(input) { + if (this._def.coerce) { + input.data = String(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.string) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext( + ctx2, + { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.string, + received: ctx2.parsedType + } + // + ); + return INVALID; + } + const status = new ParseStatus(); + let ctx = void 0; + for (const check of this._def.checks) { + if (check.kind === "min") { + if (input.data.length < check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "string", + inclusive: true, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + if (input.data.length > check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "string", + inclusive: true, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "length") { + const tooBig = input.data.length > check.value; + const tooSmall = input.data.length < check.value; + if (tooBig || tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + if (tooBig) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "string", + inclusive: true, + exact: true, + message: check.message + }); + } else if (tooSmall) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "string", + inclusive: true, + exact: true, + message: check.message + }); + } + status.dirty(); + } + } else if (check.kind === "email") { + if (!emailRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "email", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "emoji") { + if (!emojiRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "emoji", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "uuid") { + if (!uuidRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "uuid", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "cuid") { + if (!cuidRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "cuid", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "cuid2") { + if (!cuid2Regex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "cuid2", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "url") { + try { + new URL(input.data); + } catch (_a2) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "url", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "regex") { + check.regex.lastIndex = 0; + const testResult = check.regex.test(input.data); + if (!testResult) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "regex", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "trim") { + input.data = input.data.trim(); + } else if (check.kind === "toLowerCase") { + input.data = input.data.toLowerCase(); + } else if (check.kind === "toUpperCase") { + input.data = input.data.toUpperCase(); + } else if (check.kind === "startsWith") { + if (!input.data.startsWith(check.value)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { startsWith: check.value }, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "endsWith") { + if (!input.data.endsWith(check.value)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { endsWith: check.value }, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "datetime") { + const regex = datetimeRegex(check); + if (!regex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: "datetime", + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "ip") { + if (!isValidIP(input.data, check.version)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "ip", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + _addCheck(check) { + return new _ZodString({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + email(message2) { + return this._addCheck({ kind: "email", ...errorUtil.errToObj(message2) }); + } + url(message2) { + return this._addCheck({ kind: "url", ...errorUtil.errToObj(message2) }); + } + emoji(message2) { + return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message2) }); + } + uuid(message2) { + return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message2) }); + } + cuid(message2) { + return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message2) }); + } + cuid2(message2) { + return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message2) }); + } + ip(options) { + return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) }); + } + datetime(options) { + var _a2; + if (typeof options === "string") { + return this._addCheck({ + kind: "datetime", + precision: null, + offset: false, + message: options + }); + } + return this._addCheck({ + kind: "datetime", + precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, + offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false, + ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) + }); + } + regex(regex, message2) { + return this._addCheck({ + kind: "regex", + regex, + ...errorUtil.errToObj(message2) + }); + } + startsWith(value, message2) { + return this._addCheck({ + kind: "startsWith", + value, + ...errorUtil.errToObj(message2) + }); + } + endsWith(value, message2) { + return this._addCheck({ + kind: "endsWith", + value, + ...errorUtil.errToObj(message2) + }); + } + min(minLength, message2) { + return this._addCheck({ + kind: "min", + value: minLength, + ...errorUtil.errToObj(message2) + }); + } + max(maxLength, message2) { + return this._addCheck({ + kind: "max", + value: maxLength, + ...errorUtil.errToObj(message2) + }); + } + length(len, message2) { + return this._addCheck({ + kind: "length", + value: len, + ...errorUtil.errToObj(message2) + }); + } + get isDatetime() { + return !!this._def.checks.find((ch) => ch.kind === "datetime"); + } + get isEmail() { + return !!this._def.checks.find((ch) => ch.kind === "email"); + } + get isURL() { + return !!this._def.checks.find((ch) => ch.kind === "url"); + } + get isEmoji() { + return !!this._def.checks.find((ch) => ch.kind === "emoji"); + } + get isUUID() { + return !!this._def.checks.find((ch) => ch.kind === "uuid"); + } + get isCUID() { + return !!this._def.checks.find((ch) => ch.kind === "cuid"); + } + get isCUID2() { + return !!this._def.checks.find((ch) => ch.kind === "cuid2"); + } + get isIP() { + return !!this._def.checks.find((ch) => ch.kind === "ip"); + } + get minLength() { + let min = null; + for (const ch of this._def.checks) { + if (ch.kind === "min") { + if (min === null || ch.value > min) + min = ch.value; + } + } + return min; + } + get maxLength() { + let max = null; + for (const ch of this._def.checks) { + if (ch.kind === "max") { + if (max === null || ch.value < max) + max = ch.value; + } + } + return max; + } + }; + ZodString.create = (params) => { + var _a2; + return new ZodString({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodString, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams(params) + }); + }; + function floatSafeRemainder(val, step2) { + const valDecCount = (val.toString().split(".")[1] || "").length; + const stepDecCount = (step2.toString().split(".")[1] || "").length; + const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; + const valInt = parseInt(val.toFixed(decCount).replace(".", "")); + const stepInt = parseInt(step2.toFixed(decCount).replace(".", "")); + return valInt % stepInt / Math.pow(10, decCount); + } + var ZodNumber = class _ZodNumber extends ZodType { + constructor() { + super(...arguments); + this.min = this.gte; + this.max = this.lte; + this.step = this.multipleOf; + } + _parse(input) { + if (this._def.coerce) { + input.data = Number(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.number) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.number, + received: ctx2.parsedType + }); + return INVALID; + } + let ctx = void 0; + const status = new ParseStatus(); + for (const check of this._def.checks) { + if (check.kind === "int") { + if (!util.isInteger(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: "integer", + received: "float", + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "min") { + const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; + if (tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; + if (tooBig) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "multipleOf") { + if (floatSafeRemainder(input.data, check.value) !== 0) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_multiple_of, + multipleOf: check.value, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "finite") { + if (!Number.isFinite(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_finite, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + gte(value, message2) { + return this.setLimit("min", value, true, errorUtil.toString(message2)); + } + gt(value, message2) { + return this.setLimit("min", value, false, errorUtil.toString(message2)); + } + lte(value, message2) { + return this.setLimit("max", value, true, errorUtil.toString(message2)); + } + lt(value, message2) { + return this.setLimit("max", value, false, errorUtil.toString(message2)); + } + setLimit(kind, value, inclusive, message2) { + return new _ZodNumber({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil.toString(message2) + } + ] + }); + } + _addCheck(check) { + return new _ZodNumber({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + int(message2) { + return this._addCheck({ + kind: "int", + message: errorUtil.toString(message2) + }); + } + positive(message2) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: false, + message: errorUtil.toString(message2) + }); + } + negative(message2) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: false, + message: errorUtil.toString(message2) + }); + } + nonpositive(message2) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: true, + message: errorUtil.toString(message2) + }); + } + nonnegative(message2) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: true, + message: errorUtil.toString(message2) + }); + } + multipleOf(value, message2) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil.toString(message2) + }); + } + finite(message2) { + return this._addCheck({ + kind: "finite", + message: errorUtil.toString(message2) + }); + } + safe(message2) { + return this._addCheck({ + kind: "min", + inclusive: true, + value: Number.MIN_SAFE_INTEGER, + message: errorUtil.toString(message2) + })._addCheck({ + kind: "max", + inclusive: true, + value: Number.MAX_SAFE_INTEGER, + message: errorUtil.toString(message2) + }); + } + get minValue() { + let min = null; + for (const ch of this._def.checks) { + if (ch.kind === "min") { + if (min === null || ch.value > min) + min = ch.value; + } + } + return min; + } + get maxValue() { + let max = null; + for (const ch of this._def.checks) { + if (ch.kind === "max") { + if (max === null || ch.value < max) + max = ch.value; + } + } + return max; + } + get isInt() { + return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value)); + } + get isFinite() { + let max = null, min = null; + for (const ch of this._def.checks) { + if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { + return true; + } else if (ch.kind === "min") { + if (min === null || ch.value > min) + min = ch.value; + } else if (ch.kind === "max") { + if (max === null || ch.value < max) + max = ch.value; + } + } + return Number.isFinite(min) && Number.isFinite(max); + } + }; + ZodNumber.create = (params) => { + return new ZodNumber({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodNumber, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ...processCreateParams(params) + }); + }; + var ZodBigInt = class _ZodBigInt extends ZodType { + constructor() { + super(...arguments); + this.min = this.gte; + this.max = this.lte; + } + _parse(input) { + if (this._def.coerce) { + input.data = BigInt(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.bigint) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.bigint, + received: ctx2.parsedType + }); + return INVALID; + } + let ctx = void 0; + const status = new ParseStatus(); + for (const check of this._def.checks) { + if (check.kind === "min") { + const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; + if (tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + type: "bigint", + minimum: check.value, + inclusive: check.inclusive, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; + if (tooBig) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + type: "bigint", + maximum: check.value, + inclusive: check.inclusive, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "multipleOf") { + if (input.data % check.value !== BigInt(0)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_multiple_of, + multipleOf: check.value, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + gte(value, message2) { + return this.setLimit("min", value, true, errorUtil.toString(message2)); + } + gt(value, message2) { + return this.setLimit("min", value, false, errorUtil.toString(message2)); + } + lte(value, message2) { + return this.setLimit("max", value, true, errorUtil.toString(message2)); + } + lt(value, message2) { + return this.setLimit("max", value, false, errorUtil.toString(message2)); + } + setLimit(kind, value, inclusive, message2) { + return new _ZodBigInt({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil.toString(message2) + } + ] + }); + } + _addCheck(check) { + return new _ZodBigInt({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + positive(message2) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: false, + message: errorUtil.toString(message2) + }); + } + negative(message2) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: false, + message: errorUtil.toString(message2) + }); + } + nonpositive(message2) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: true, + message: errorUtil.toString(message2) + }); + } + nonnegative(message2) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: true, + message: errorUtil.toString(message2) + }); + } + multipleOf(value, message2) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil.toString(message2) + }); + } + get minValue() { + let min = null; + for (const ch of this._def.checks) { + if (ch.kind === "min") { + if (min === null || ch.value > min) + min = ch.value; + } + } + return min; + } + get maxValue() { + let max = null; + for (const ch of this._def.checks) { + if (ch.kind === "max") { + if (max === null || ch.value < max) + max = ch.value; + } + } + return max; + } + }; + ZodBigInt.create = (params) => { + var _a2; + return new ZodBigInt({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodBigInt, + coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false, + ...processCreateParams(params) + }); + }; + var ZodBoolean = class extends ZodType { + _parse(input) { + if (this._def.coerce) { + input.data = Boolean(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.boolean) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.boolean, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } + }; + ZodBoolean.create = (params) => { + return new ZodBoolean({ + typeName: ZodFirstPartyTypeKind.ZodBoolean, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ...processCreateParams(params) + }); + }; + var ZodDate = class _ZodDate extends ZodType { + _parse(input) { + if (this._def.coerce) { + input.data = new Date(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.date) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.date, + received: ctx2.parsedType + }); + return INVALID; + } + if (isNaN(input.data.getTime())) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_date + }); + return INVALID; + } + const status = new ParseStatus(); + let ctx = void 0; + for (const check of this._def.checks) { + if (check.kind === "min") { + if (input.data.getTime() < check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + message: check.message, + inclusive: true, + exact: false, + minimum: check.value, + type: "date" + }); + status.dirty(); + } + } else if (check.kind === "max") { + if (input.data.getTime() > check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + message: check.message, + inclusive: true, + exact: false, + maximum: check.value, + type: "date" + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { + status: status.value, + value: new Date(input.data.getTime()) + }; + } + _addCheck(check) { + return new _ZodDate({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + min(minDate, message2) { + return this._addCheck({ + kind: "min", + value: minDate.getTime(), + message: errorUtil.toString(message2) + }); + } + max(maxDate, message2) { + return this._addCheck({ + kind: "max", + value: maxDate.getTime(), + message: errorUtil.toString(message2) + }); + } + get minDate() { + let min = null; + for (const ch of this._def.checks) { + if (ch.kind === "min") { + if (min === null || ch.value > min) + min = ch.value; + } + } + return min != null ? new Date(min) : null; + } + get maxDate() { + let max = null; + for (const ch of this._def.checks) { + if (ch.kind === "max") { + if (max === null || ch.value < max) + max = ch.value; + } + } + return max != null ? new Date(max) : null; + } + }; + ZodDate.create = (params) => { + return new ZodDate({ + checks: [], + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + typeName: ZodFirstPartyTypeKind.ZodDate, + ...processCreateParams(params) + }); + }; + var ZodSymbol = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.symbol) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.symbol, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } + }; + ZodSymbol.create = (params) => { + return new ZodSymbol({ + typeName: ZodFirstPartyTypeKind.ZodSymbol, + ...processCreateParams(params) + }); + }; + var ZodUndefined = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.undefined, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } + }; + ZodUndefined.create = (params) => { + return new ZodUndefined({ + typeName: ZodFirstPartyTypeKind.ZodUndefined, + ...processCreateParams(params) + }); + }; + var ZodNull = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.null) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.null, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } + }; + ZodNull.create = (params) => { + return new ZodNull({ + typeName: ZodFirstPartyTypeKind.ZodNull, + ...processCreateParams(params) + }); + }; + var ZodAny = class extends ZodType { + constructor() { + super(...arguments); + this._any = true; + } + _parse(input) { + return OK(input.data); + } + }; + ZodAny.create = (params) => { + return new ZodAny({ + typeName: ZodFirstPartyTypeKind.ZodAny, + ...processCreateParams(params) + }); + }; + var ZodUnknown = class extends ZodType { + constructor() { + super(...arguments); + this._unknown = true; + } + _parse(input) { + return OK(input.data); + } + }; + ZodUnknown.create = (params) => { + return new ZodUnknown({ + typeName: ZodFirstPartyTypeKind.ZodUnknown, + ...processCreateParams(params) + }); + }; + var ZodNever = class extends ZodType { + _parse(input) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.never, + received: ctx.parsedType + }); + return INVALID; + } + }; + ZodNever.create = (params) => { + return new ZodNever({ + typeName: ZodFirstPartyTypeKind.ZodNever, + ...processCreateParams(params) + }); + }; + var ZodVoid = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.void, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } + }; + ZodVoid.create = (params) => { + return new ZodVoid({ + typeName: ZodFirstPartyTypeKind.ZodVoid, + ...processCreateParams(params) + }); + }; + var ZodArray = class _ZodArray extends ZodType { + _parse(input) { + const { ctx, status } = this._processInputParams(input); + const def = this._def; + if (ctx.parsedType !== ZodParsedType.array) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.array, + received: ctx.parsedType + }); + return INVALID; + } + if (def.exactLength !== null) { + const tooBig = ctx.data.length > def.exactLength.value; + const tooSmall = ctx.data.length < def.exactLength.value; + if (tooBig || tooSmall) { + addIssueToContext(ctx, { + code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small, + minimum: tooSmall ? def.exactLength.value : void 0, + maximum: tooBig ? def.exactLength.value : void 0, + type: "array", + inclusive: true, + exact: true, + message: def.exactLength.message + }); + status.dirty(); + } + } + if (def.minLength !== null) { + if (ctx.data.length < def.minLength.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: def.minLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.minLength.message + }); + status.dirty(); + } + } + if (def.maxLength !== null) { + if (ctx.data.length > def.maxLength.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: def.maxLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.maxLength.message + }); + status.dirty(); + } + } + if (ctx.common.async) { + return Promise.all([...ctx.data].map((item, i8) => { + return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i8)); + })).then((result2) => { + return ParseStatus.mergeArray(status, result2); + }); + } + const result = [...ctx.data].map((item, i8) => { + return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i8)); + }); + return ParseStatus.mergeArray(status, result); + } + get element() { + return this._def.type; + } + min(minLength, message2) { + return new _ZodArray({ + ...this._def, + minLength: { value: minLength, message: errorUtil.toString(message2) } + }); + } + max(maxLength, message2) { + return new _ZodArray({ + ...this._def, + maxLength: { value: maxLength, message: errorUtil.toString(message2) } + }); + } + length(len, message2) { + return new _ZodArray({ + ...this._def, + exactLength: { value: len, message: errorUtil.toString(message2) } + }); + } + nonempty(message2) { + return this.min(1, message2); + } + }; + ZodArray.create = (schema9, params) => { + return new ZodArray({ + type: schema9, + minLength: null, + maxLength: null, + exactLength: null, + typeName: ZodFirstPartyTypeKind.ZodArray, + ...processCreateParams(params) + }); + }; + var objectUtil; + (function(objectUtil2) { + objectUtil2.mergeShapes = (first, second) => { + return { + ...first, + ...second + // second overwrites first + }; + }; + })(objectUtil || (objectUtil = {})); + function deepPartialify(schema9) { + if (schema9 instanceof ZodObject) { + const newShape = {}; + for (const key in schema9.shape) { + const fieldSchema = schema9.shape[key]; + newShape[key] = ZodOptional.create(deepPartialify(fieldSchema)); + } + return new ZodObject({ + ...schema9._def, + shape: () => newShape + }); + } else if (schema9 instanceof ZodArray) { + return ZodArray.create(deepPartialify(schema9.element)); + } else if (schema9 instanceof ZodOptional) { + return ZodOptional.create(deepPartialify(schema9.unwrap())); + } else if (schema9 instanceof ZodNullable) { + return ZodNullable.create(deepPartialify(schema9.unwrap())); + } else if (schema9 instanceof ZodTuple) { + return ZodTuple.create(schema9.items.map((item) => deepPartialify(item))); + } else { + return schema9; + } + } + var ZodObject = class _ZodObject extends ZodType { + constructor() { + super(...arguments); + this._cached = null; + this.nonstrict = this.passthrough; + this.augment = this.extend; + } + _getCached() { + if (this._cached !== null) + return this._cached; + const shape = this._def.shape(); + const keys2 = util.objectKeys(shape); + return this._cached = { shape, keys: keys2 }; + } + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.object) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx2.parsedType + }); + return INVALID; + } + const { status, ctx } = this._processInputParams(input); + const { shape, keys: shapeKeys } = this._getCached(); + const extraKeys = []; + if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) { + for (const key in ctx.data) { + if (!shapeKeys.includes(key)) { + extraKeys.push(key); + } + } + } + const pairs = []; + for (const key of shapeKeys) { + const keyValidator = shape[key]; + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)), + alwaysSet: key in ctx.data + }); + } + if (this._def.catchall instanceof ZodNever) { + const unknownKeys = this._def.unknownKeys; + if (unknownKeys === "passthrough") { + for (const key of extraKeys) { + pairs.push({ + key: { status: "valid", value: key }, + value: { status: "valid", value: ctx.data[key] } + }); + } + } else if (unknownKeys === "strict") { + if (extraKeys.length > 0) { + addIssueToContext(ctx, { + code: ZodIssueCode.unrecognized_keys, + keys: extraKeys + }); + status.dirty(); + } + } else if (unknownKeys === "strip") + ; + else { + throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); + } + } else { + const catchall = this._def.catchall; + for (const key of extraKeys) { + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: catchall._parse( + new ParseInputLazyPath(ctx, value, ctx.path, key) + //, ctx.child(key), value, getParsedType(value) + ), + alwaysSet: key in ctx.data + }); + } + } + if (ctx.common.async) { + return Promise.resolve().then(async () => { + const syncPairs = []; + for (const pair of pairs) { + const key = await pair.key; + syncPairs.push({ + key, + value: await pair.value, + alwaysSet: pair.alwaysSet + }); + } + return syncPairs; + }).then((syncPairs) => { + return ParseStatus.mergeObjectSync(status, syncPairs); + }); + } else { + return ParseStatus.mergeObjectSync(status, pairs); + } + } + get shape() { + return this._def.shape(); + } + strict(message2) { + errorUtil.errToObj; + return new _ZodObject({ + ...this._def, + unknownKeys: "strict", + ...message2 !== void 0 ? { + errorMap: (issue4, ctx) => { + var _a2, _b, _c, _d; + const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue4, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + if (issue4.code === "unrecognized_keys") + return { + message: (_d = errorUtil.errToObj(message2).message) !== null && _d !== void 0 ? _d : defaultError + }; + return { + message: defaultError + }; + } + } : {} + }); + } + strip() { + return new _ZodObject({ + ...this._def, + unknownKeys: "strip" + }); + } + passthrough() { + return new _ZodObject({ + ...this._def, + unknownKeys: "passthrough" + }); + } + // const AugmentFactory = + // (def: Def) => + // ( + // augmentation: Augmentation + // ): ZodObject< + // extendShape, Augmentation>, + // Def["unknownKeys"], + // Def["catchall"] + // > => { + // return new ZodObject({ + // ...def, + // shape: () => ({ + // ...def.shape(), + // ...augmentation, + // }), + // }) as any; + // }; + extend(augmentation) { + return new _ZodObject({ + ...this._def, + shape: () => ({ + ...this._def.shape(), + ...augmentation + }) + }); + } + /** + * Prior to zod@1.0.12 there was a bug in the + * inferred type of merged objects. Please + * upgrade if you are experiencing issues. + */ + merge(merging) { + const merged = new _ZodObject({ + unknownKeys: merging._def.unknownKeys, + catchall: merging._def.catchall, + shape: () => objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + typeName: ZodFirstPartyTypeKind.ZodObject + }); + return merged; + } + // merge< + // Incoming extends AnyZodObject, + // Augmentation extends Incoming["shape"], + // NewOutput extends { + // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation + // ? Augmentation[k]["_output"] + // : k extends keyof Output + // ? Output[k] + // : never; + // }, + // NewInput extends { + // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation + // ? Augmentation[k]["_input"] + // : k extends keyof Input + // ? Input[k] + // : never; + // } + // >( + // merging: Incoming + // ): ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"], + // NewOutput, + // NewInput + // > { + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + setKey(key, schema9) { + return this.augment({ [key]: schema9 }); + } + // merge( + // merging: Incoming + // ): //ZodObject = (merging) => { + // ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"] + // > { + // // const mergedShape = objectUtil.mergeShapes( + // // this._def.shape(), + // // merging._def.shape() + // // ); + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + catchall(index2) { + return new _ZodObject({ + ...this._def, + catchall: index2 + }); + } + pick(mask2) { + const shape = {}; + util.objectKeys(mask2).forEach((key) => { + if (mask2[key] && this.shape[key]) { + shape[key] = this.shape[key]; + } + }); + return new _ZodObject({ + ...this._def, + shape: () => shape + }); + } + omit(mask2) { + const shape = {}; + util.objectKeys(this.shape).forEach((key) => { + if (!mask2[key]) { + shape[key] = this.shape[key]; + } + }); + return new _ZodObject({ + ...this._def, + shape: () => shape + }); + } + /** + * @deprecated + */ + deepPartial() { + return deepPartialify(this); + } + partial(mask2) { + const newShape = {}; + util.objectKeys(this.shape).forEach((key) => { + const fieldSchema = this.shape[key]; + if (mask2 && !mask2[key]) { + newShape[key] = fieldSchema; + } else { + newShape[key] = fieldSchema.optional(); + } + }); + return new _ZodObject({ + ...this._def, + shape: () => newShape + }); + } + required(mask2) { + const newShape = {}; + util.objectKeys(this.shape).forEach((key) => { + if (mask2 && !mask2[key]) { + newShape[key] = this.shape[key]; + } else { + const fieldSchema = this.shape[key]; + let newField = fieldSchema; + while (newField instanceof ZodOptional) { + newField = newField._def.innerType; + } + newShape[key] = newField; + } + }); + return new _ZodObject({ + ...this._def, + shape: () => newShape + }); + } + keyof() { + return createZodEnum(util.objectKeys(this.shape)); + } + }; + ZodObject.create = (shape, params) => { + return new ZodObject({ + shape: () => shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); + }; + ZodObject.strictCreate = (shape, params) => { + return new ZodObject({ + shape: () => shape, + unknownKeys: "strict", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); + }; + ZodObject.lazycreate = (shape, params) => { + return new ZodObject({ + shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); + }; + var ZodUnion = class extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const options = this._def.options; + function handleResults(results) { + for (const result of results) { + if (result.result.status === "valid") { + return result.result; + } + } + for (const result of results) { + if (result.result.status === "dirty") { + ctx.common.issues.push(...result.ctx.common.issues); + return result.result; + } + } + const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues)); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union, + unionErrors + }); + return INVALID; + } + if (ctx.common.async) { + return Promise.all(options.map(async (option) => { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + return { + result: await option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }), + ctx: childCtx + }; + })).then(handleResults); + } else { + let dirty = void 0; + const issues = []; + for (const option of options) { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + const result = option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }); + if (result.status === "valid") { + return result; + } else if (result.status === "dirty" && !dirty) { + dirty = { result, ctx: childCtx }; + } + if (childCtx.common.issues.length) { + issues.push(childCtx.common.issues); + } + } + if (dirty) { + ctx.common.issues.push(...dirty.ctx.common.issues); + return dirty.result; + } + const unionErrors = issues.map((issues2) => new ZodError(issues2)); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union, + unionErrors + }); + return INVALID; + } + } + get options() { + return this._def.options; + } + }; + ZodUnion.create = (types4, params) => { + return new ZodUnion({ + options: types4, + typeName: ZodFirstPartyTypeKind.ZodUnion, + ...processCreateParams(params) + }); + }; + var getDiscriminator = (type3) => { + if (type3 instanceof ZodLazy) { + return getDiscriminator(type3.schema); + } else if (type3 instanceof ZodEffects) { + return getDiscriminator(type3.innerType()); + } else if (type3 instanceof ZodLiteral) { + return [type3.value]; + } else if (type3 instanceof ZodEnum) { + return type3.options; + } else if (type3 instanceof ZodNativeEnum) { + return Object.keys(type3.enum); + } else if (type3 instanceof ZodDefault) { + return getDiscriminator(type3._def.innerType); + } else if (type3 instanceof ZodUndefined) { + return [void 0]; + } else if (type3 instanceof ZodNull) { + return [null]; + } else { + return null; + } + }; + var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx.parsedType + }); + return INVALID; + } + const discriminator = this.discriminator; + const discriminatorValue = ctx.data[discriminator]; + const option = this.optionsMap.get(discriminatorValue); + if (!option) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union_discriminator, + options: Array.from(this.optionsMap.keys()), + path: [discriminator] + }); + return INVALID; + } + if (ctx.common.async) { + return option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + } else { + return option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + } + } + get discriminator() { + return this._def.discriminator; + } + get options() { + return this._def.options; + } + get optionsMap() { + return this._def.optionsMap; + } + /** + * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. + * However, it only allows a union of objects, all of which need to share a discriminator property. This property must + * have a different value for each object in the union. + * @param discriminator the name of the discriminator property + * @param types an array of object schemas + * @param params + */ + static create(discriminator, options, params) { + const optionsMap = /* @__PURE__ */ new Map(); + for (const type3 of options) { + const discriminatorValues = getDiscriminator(type3.shape[discriminator]); + if (!discriminatorValues) { + throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); + } + for (const value of discriminatorValues) { + if (optionsMap.has(value)) { + throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); + } + optionsMap.set(value, type3); + } + } + return new _ZodDiscriminatedUnion({ + typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion, + discriminator, + options, + optionsMap, + ...processCreateParams(params) + }); + } + }; + function mergeValues(a8, b6) { + const aType = getParsedType(a8); + const bType = getParsedType(b6); + if (a8 === b6) { + return { valid: true, data: a8 }; + } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) { + const bKeys = util.objectKeys(b6); + const sharedKeys = util.objectKeys(a8).filter((key) => bKeys.indexOf(key) !== -1); + const newObj = { ...a8, ...b6 }; + for (const key of sharedKeys) { + const sharedValue = mergeValues(a8[key], b6[key]); + if (!sharedValue.valid) { + return { valid: false }; + } + newObj[key] = sharedValue.data; + } + return { valid: true, data: newObj }; + } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) { + if (a8.length !== b6.length) { + return { valid: false }; + } + const newArray = []; + for (let index2 = 0; index2 < a8.length; index2++) { + const itemA = a8[index2]; + const itemB = b6[index2]; + const sharedValue = mergeValues(itemA, itemB); + if (!sharedValue.valid) { + return { valid: false }; + } + newArray.push(sharedValue.data); + } + return { valid: true, data: newArray }; + } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a8 === +b6) { + return { valid: true, data: a8 }; + } else { + return { valid: false }; + } + } + var ZodIntersection = class extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const handleParsed = (parsedLeft, parsedRight) => { + if (isAborted(parsedLeft) || isAborted(parsedRight)) { + return INVALID; + } + const merged = mergeValues(parsedLeft.value, parsedRight.value); + if (!merged.valid) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_intersection_types + }); + return INVALID; + } + if (isDirty(parsedLeft) || isDirty(parsedRight)) { + status.dirty(); + } + return { status: status.value, value: merged.data }; + }; + if (ctx.common.async) { + return Promise.all([ + this._def.left._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), + this._def.right._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }) + ]).then(([left, right]) => handleParsed(left, right)); + } else { + return handleParsed(this._def.left._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), this._def.right._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + })); + } + } + }; + ZodIntersection.create = (left, right, params) => { + return new ZodIntersection({ + left, + right, + typeName: ZodFirstPartyTypeKind.ZodIntersection, + ...processCreateParams(params) + }); + }; + var ZodTuple = class _ZodTuple extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.array) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.array, + received: ctx.parsedType + }); + return INVALID; + } + if (ctx.data.length < this._def.items.length) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + return INVALID; + } + const rest = this._def.rest; + if (!rest && ctx.data.length > this._def.items.length) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + status.dirty(); + } + const items = [...ctx.data].map((item, itemIndex) => { + const schema9 = this._def.items[itemIndex] || this._def.rest; + if (!schema9) + return null; + return schema9._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)); + }).filter((x5) => !!x5); + if (ctx.common.async) { + return Promise.all(items).then((results) => { + return ParseStatus.mergeArray(status, results); + }); + } else { + return ParseStatus.mergeArray(status, items); + } + } + get items() { + return this._def.items; + } + rest(rest) { + return new _ZodTuple({ + ...this._def, + rest + }); + } + }; + ZodTuple.create = (schemas, params) => { + if (!Array.isArray(schemas)) { + throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); + } + return new ZodTuple({ + items: schemas, + typeName: ZodFirstPartyTypeKind.ZodTuple, + rest: null, + ...processCreateParams(params) + }); + }; + var ZodRecord = class _ZodRecord extends ZodType { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx.parsedType + }); + return INVALID; + } + const pairs = []; + const keyType = this._def.keyType; + const valueType = this._def.valueType; + for (const key in ctx.data) { + pairs.push({ + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)), + value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)) + }); + } + if (ctx.common.async) { + return ParseStatus.mergeObjectAsync(status, pairs); + } else { + return ParseStatus.mergeObjectSync(status, pairs); + } + } + get element() { + return this._def.valueType; + } + static create(first, second, third) { + if (second instanceof ZodType) { + return new _ZodRecord({ + keyType: first, + valueType: second, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(third) + }); + } + return new _ZodRecord({ + keyType: ZodString.create(), + valueType: first, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(second) + }); + } + }; + var ZodMap = class extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.map) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.map, + received: ctx.parsedType + }); + return INVALID; + } + const keyType = this._def.keyType; + const valueType = this._def.valueType; + const pairs = [...ctx.data.entries()].map(([key, value], index2) => { + return { + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index2, "key"])), + value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index2, "value"])) + }; + }); + if (ctx.common.async) { + const finalMap = /* @__PURE__ */ new Map(); + return Promise.resolve().then(async () => { + for (const pair of pairs) { + const key = await pair.key; + const value = await pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + }); + } else { + const finalMap = /* @__PURE__ */ new Map(); + for (const pair of pairs) { + const key = pair.key; + const value = pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + } + } + }; + ZodMap.create = (keyType, valueType, params) => { + return new ZodMap({ + valueType, + keyType, + typeName: ZodFirstPartyTypeKind.ZodMap, + ...processCreateParams(params) + }); + }; + var ZodSet = class _ZodSet extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.set) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.set, + received: ctx.parsedType + }); + return INVALID; + } + const def = this._def; + if (def.minSize !== null) { + if (ctx.data.size < def.minSize.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: def.minSize.value, + type: "set", + inclusive: true, + exact: false, + message: def.minSize.message + }); + status.dirty(); + } + } + if (def.maxSize !== null) { + if (ctx.data.size > def.maxSize.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: def.maxSize.value, + type: "set", + inclusive: true, + exact: false, + message: def.maxSize.message + }); + status.dirty(); + } + } + const valueType = this._def.valueType; + function finalizeSet(elements2) { + const parsedSet = /* @__PURE__ */ new Set(); + for (const element of elements2) { + if (element.status === "aborted") + return INVALID; + if (element.status === "dirty") + status.dirty(); + parsedSet.add(element.value); + } + return { status: status.value, value: parsedSet }; + } + const elements = [...ctx.data.values()].map((item, i8) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i8))); + if (ctx.common.async) { + return Promise.all(elements).then((elements2) => finalizeSet(elements2)); + } else { + return finalizeSet(elements); + } + } + min(minSize, message2) { + return new _ZodSet({ + ...this._def, + minSize: { value: minSize, message: errorUtil.toString(message2) } + }); + } + max(maxSize, message2) { + return new _ZodSet({ + ...this._def, + maxSize: { value: maxSize, message: errorUtil.toString(message2) } + }); + } + size(size4, message2) { + return this.min(size4, message2).max(size4, message2); + } + nonempty(message2) { + return this.min(1, message2); + } + }; + ZodSet.create = (valueType, params) => { + return new ZodSet({ + valueType, + minSize: null, + maxSize: null, + typeName: ZodFirstPartyTypeKind.ZodSet, + ...processCreateParams(params) + }); + }; + var ZodFunction = class _ZodFunction extends ZodType { + constructor() { + super(...arguments); + this.validate = this.implement; + } + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.function) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.function, + received: ctx.parsedType + }); + return INVALID; + } + function makeArgsIssue(args, error7) { + return makeIssue({ + data: args, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x5) => !!x5), + issueData: { + code: ZodIssueCode.invalid_arguments, + argumentsError: error7 + } + }); + } + function makeReturnsIssue(returns, error7) { + return makeIssue({ + data: returns, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x5) => !!x5), + issueData: { + code: ZodIssueCode.invalid_return_type, + returnTypeError: error7 + } + }); + } + const params = { errorMap: ctx.common.contextualErrorMap }; + const fn = ctx.data; + if (this._def.returns instanceof ZodPromise) { + return OK(async (...args) => { + const error7 = new ZodError([]); + const parsedArgs = await this._def.args.parseAsync(args, params).catch((e12) => { + error7.addIssue(makeArgsIssue(args, e12)); + throw error7; + }); + const result = await fn(...parsedArgs); + const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e12) => { + error7.addIssue(makeReturnsIssue(result, e12)); + throw error7; + }); + return parsedReturns; + }); + } else { + return OK((...args) => { + const parsedArgs = this._def.args.safeParse(args, params); + if (!parsedArgs.success) { + throw new ZodError([makeArgsIssue(args, parsedArgs.error)]); + } + const result = fn(...parsedArgs.data); + const parsedReturns = this._def.returns.safeParse(result, params); + if (!parsedReturns.success) { + throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]); + } + return parsedReturns.data; + }); + } + } + parameters() { + return this._def.args; + } + returnType() { + return this._def.returns; + } + args(...items) { + return new _ZodFunction({ + ...this._def, + args: ZodTuple.create(items).rest(ZodUnknown.create()) + }); + } + returns(returnType) { + return new _ZodFunction({ + ...this._def, + returns: returnType + }); + } + implement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + strictImplement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + static create(args, returns, params) { + return new _ZodFunction({ + args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()), + returns: returns || ZodUnknown.create(), + typeName: ZodFirstPartyTypeKind.ZodFunction, + ...processCreateParams(params) + }); + } + }; + var ZodLazy = class extends ZodType { + get schema() { + return this._def.getter(); + } + _parse(input) { + const { ctx } = this._processInputParams(input); + const lazySchema = this._def.getter(); + return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); + } + }; + ZodLazy.create = (getter, params) => { + return new ZodLazy({ + getter, + typeName: ZodFirstPartyTypeKind.ZodLazy, + ...processCreateParams(params) + }); + }; + var ZodLiteral = class extends ZodType { + _parse(input) { + if (input.data !== this._def.value) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_literal, + expected: this._def.value + }); + return INVALID; + } + return { status: "valid", value: input.data }; + } + get value() { + return this._def.value; + } + }; + ZodLiteral.create = (value, params) => { + return new ZodLiteral({ + value, + typeName: ZodFirstPartyTypeKind.ZodLiteral, + ...processCreateParams(params) + }); + }; + function createZodEnum(values2, params) { + return new ZodEnum({ + values: values2, + typeName: ZodFirstPartyTypeKind.ZodEnum, + ...processCreateParams(params) + }); + } + var ZodEnum = class _ZodEnum extends ZodType { + _parse(input) { + if (typeof input.data !== "string") { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type + }); + return INVALID; + } + if (this._def.values.indexOf(input.data) === -1) { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues + }); + return INVALID; + } + return OK(input.data); + } + get options() { + return this._def.values; + } + get enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Values() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + extract(values2) { + return _ZodEnum.create(values2); + } + exclude(values2) { + return _ZodEnum.create(this.options.filter((opt) => !values2.includes(opt))); + } + }; + ZodEnum.create = createZodEnum; + var ZodNativeEnum = class extends ZodType { + _parse(input) { + const nativeEnumValues = util.getValidEnumValues(this._def.values); + const ctx = this._getOrReturnCtx(input); + if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) { + const expectedValues = util.objectValues(nativeEnumValues); + addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type + }); + return INVALID; + } + if (nativeEnumValues.indexOf(input.data) === -1) { + const expectedValues = util.objectValues(nativeEnumValues); + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues + }); + return INVALID; + } + return OK(input.data); + } + get enum() { + return this._def.values; + } + }; + ZodNativeEnum.create = (values2, params) => { + return new ZodNativeEnum({ + values: values2, + typeName: ZodFirstPartyTypeKind.ZodNativeEnum, + ...processCreateParams(params) + }); + }; + var ZodPromise = class extends ZodType { + unwrap() { + return this._def.type; + } + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.promise, + received: ctx.parsedType + }); + return INVALID; + } + const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data); + return OK(promisified.then((data) => { + return this._def.type.parseAsync(data, { + path: ctx.path, + errorMap: ctx.common.contextualErrorMap + }); + })); + } + }; + ZodPromise.create = (schema9, params) => { + return new ZodPromise({ + type: schema9, + typeName: ZodFirstPartyTypeKind.ZodPromise, + ...processCreateParams(params) + }); + }; + var ZodEffects = class extends ZodType { + innerType() { + return this._def.schema; + } + sourceType() { + return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema; + } + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const effect2 = this._def.effect || null; + if (effect2.type === "preprocess") { + const processed = effect2.transform(ctx.data); + if (ctx.common.async) { + return Promise.resolve(processed).then((processed2) => { + return this._def.schema._parseAsync({ + data: processed2, + path: ctx.path, + parent: ctx + }); + }); + } else { + return this._def.schema._parseSync({ + data: processed, + path: ctx.path, + parent: ctx + }); + } + } + const checkCtx = { + addIssue: (arg) => { + addIssueToContext(ctx, arg); + if (arg.fatal) { + status.abort(); + } else { + status.dirty(); + } + }, + get path() { + return ctx.path; + } + }; + checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); + if (effect2.type === "refinement") { + const executeRefinement = (acc) => { + const result = effect2.refinement(acc, checkCtx); + if (ctx.common.async) { + return Promise.resolve(result); + } + if (result instanceof Promise) { + throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); + } + return acc; + }; + if (ctx.common.async === false) { + const inner = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inner.status === "aborted") + return INVALID; + if (inner.status === "dirty") + status.dirty(); + executeRefinement(inner.value); + return { status: status.value, value: inner.value }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { + if (inner.status === "aborted") + return INVALID; + if (inner.status === "dirty") + status.dirty(); + return executeRefinement(inner.value).then(() => { + return { status: status.value, value: inner.value }; + }); + }); + } + } + if (effect2.type === "transform") { + if (ctx.common.async === false) { + const base3 = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (!isValid(base3)) + return base3; + const result = effect2.transform(base3.value, checkCtx); + if (result instanceof Promise) { + throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); + } + return { status: status.value, value: result }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => { + if (!isValid(base3)) + return base3; + return Promise.resolve(effect2.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result })); + }); + } + } + util.assertNever(effect2); + } + }; + ZodEffects.create = (schema9, effect2, params) => { + return new ZodEffects({ + schema: schema9, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect: effect2, + ...processCreateParams(params) + }); + }; + ZodEffects.createWithPreprocess = (preprocess, schema9, params) => { + return new ZodEffects({ + schema: schema9, + effect: { type: "preprocess", transform: preprocess }, + typeName: ZodFirstPartyTypeKind.ZodEffects, + ...processCreateParams(params) + }); + }; + var ZodOptional = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType.undefined) { + return OK(void 0); + } + return this._def.innerType._parse(input); + } + unwrap() { + return this._def.innerType; + } + }; + ZodOptional.create = (type3, params) => { + return new ZodOptional({ + innerType: type3, + typeName: ZodFirstPartyTypeKind.ZodOptional, + ...processCreateParams(params) + }); + }; + var ZodNullable = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType.null) { + return OK(null); + } + return this._def.innerType._parse(input); + } + unwrap() { + return this._def.innerType; + } + }; + ZodNullable.create = (type3, params) => { + return new ZodNullable({ + innerType: type3, + typeName: ZodFirstPartyTypeKind.ZodNullable, + ...processCreateParams(params) + }); + }; + var ZodDefault = class extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + let data = ctx.data; + if (ctx.parsedType === ZodParsedType.undefined) { + data = this._def.defaultValue(); + } + return this._def.innerType._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + removeDefault() { + return this._def.innerType; + } + }; + ZodDefault.create = (type3, params) => { + return new ZodDefault({ + innerType: type3, + typeName: ZodFirstPartyTypeKind.ZodDefault, + defaultValue: typeof params.default === "function" ? params.default : () => params.default, + ...processCreateParams(params) + }); + }; + var ZodCatch = class extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const newCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + } + }; + const result = this._def.innerType._parse({ + data: newCtx.data, + path: newCtx.path, + parent: { + ...newCtx + } + }); + if (isAsync(result)) { + return result.then((result2) => { + return { + status: "valid", + value: result2.status === "valid" ? result2.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + } + }) + }; + }); + } else { + return { + status: "valid", + value: result.status === "valid" ? result.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + } + }) + }; + } + } + removeCatch() { + return this._def.innerType; + } + }; + ZodCatch.create = (type3, params) => { + return new ZodCatch({ + innerType: type3, + typeName: ZodFirstPartyTypeKind.ZodCatch, + catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, + ...processCreateParams(params) + }); + }; + var ZodNaN = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.nan) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.nan, + received: ctx.parsedType + }); + return INVALID; + } + return { status: "valid", value: input.data }; + } + }; + ZodNaN.create = (params) => { + return new ZodNaN({ + typeName: ZodFirstPartyTypeKind.ZodNaN, + ...processCreateParams(params) + }); + }; + var BRAND = Symbol("zod_brand"); + var ZodBranded = class extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const data = ctx.data; + return this._def.type._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + unwrap() { + return this._def.type; + } + }; + var ZodPipeline = class _ZodPipeline extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.common.async) { + const handleAsync = async () => { + const inResult = await this._def.in._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID; + if (inResult.status === "dirty") { + status.dirty(); + return DIRTY(inResult.value); + } else { + return this._def.out._parseAsync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + }; + return handleAsync(); + } else { + const inResult = this._def.in._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID; + if (inResult.status === "dirty") { + status.dirty(); + return { + status: "dirty", + value: inResult.value + }; + } else { + return this._def.out._parseSync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + } + } + static create(a8, b6) { + return new _ZodPipeline({ + in: a8, + out: b6, + typeName: ZodFirstPartyTypeKind.ZodPipeline + }); + } + }; + var custom = (check, params = {}, fatal) => { + if (check) + return ZodAny.create().superRefine((data, ctx) => { + var _a2, _b; + if (!check(data)) { + const p8 = typeof params === "function" ? params(data) : params; + const _fatal = (_b = (_a2 = p8.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true; + const p22 = typeof p8 === "string" ? { message: p8 } : p8; + ctx.addIssue({ code: "custom", ...p22, fatal: _fatal }); + } + }); + return ZodAny.create(); + }; + var late = { + object: ZodObject.lazycreate + }; + var ZodFirstPartyTypeKind; + (function(ZodFirstPartyTypeKind2) { + ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; + ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; + ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; + ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; + ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; + ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; + ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; + ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; + ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; + ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; + ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; + ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; + ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; + ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; + ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; + ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; + ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; + ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; + ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; + ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; + ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; + ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; + ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; + ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; + ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; + ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; + ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; + ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; + ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; + ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; + ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; + ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; + ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; + ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; + ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; + })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {})); + var instanceOfType = (cls, params = { + message: `Input not instance of ${cls.name}` + }) => custom((data) => data instanceof cls, params); + var stringType = ZodString.create; + var numberType = ZodNumber.create; + var nanType = ZodNaN.create; + var bigIntType = ZodBigInt.create; + var booleanType = ZodBoolean.create; + var dateType = ZodDate.create; + var symbolType = ZodSymbol.create; + var undefinedType = ZodUndefined.create; + var nullType = ZodNull.create; + var anyType = ZodAny.create; + var unknownType = ZodUnknown.create; + var neverType = ZodNever.create; + var voidType = ZodVoid.create; + var arrayType = ZodArray.create; + var objectType = ZodObject.create; + var strictObjectType = ZodObject.strictCreate; + var unionType = ZodUnion.create; + var discriminatedUnionType = ZodDiscriminatedUnion.create; + var intersectionType = ZodIntersection.create; + var tupleType = ZodTuple.create; + var recordType = ZodRecord.create; + var mapType = ZodMap.create; + var setType = ZodSet.create; + var functionType = ZodFunction.create; + var lazyType = ZodLazy.create; + var literalType = ZodLiteral.create; + var enumType = ZodEnum.create; + var nativeEnumType = ZodNativeEnum.create; + var promiseType = ZodPromise.create; + var effectsType = ZodEffects.create; + var optionalType = ZodOptional.create; + var nullableType = ZodNullable.create; + var preprocessType = ZodEffects.createWithPreprocess; + var pipelineType = ZodPipeline.create; + var ostring = () => stringType().optional(); + var onumber = () => numberType().optional(); + var oboolean = () => booleanType().optional(); + var coerce3 = { + string: (arg) => ZodString.create({ ...arg, coerce: true }), + number: (arg) => ZodNumber.create({ ...arg, coerce: true }), + boolean: (arg) => ZodBoolean.create({ + ...arg, + coerce: true + }), + bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }), + date: (arg) => ZodDate.create({ ...arg, coerce: true }) + }; + var NEVER = INVALID; + var z4 = /* @__PURE__ */ Object.freeze({ + __proto__: null, + defaultErrorMap: errorMap, + setErrorMap, + getErrorMap, + makeIssue, + EMPTY_PATH, + addIssueToContext, + ParseStatus, + INVALID, + DIRTY, + OK, + isAborted, + isDirty, + isValid, + isAsync, + get util() { + return util; + }, + ZodParsedType, + getParsedType, + ZodType, + ZodString, + ZodNumber, + ZodBigInt, + ZodBoolean, + ZodDate, + ZodSymbol, + ZodUndefined, + ZodNull, + ZodAny, + ZodUnknown, + ZodNever, + ZodVoid, + ZodArray, + get objectUtil() { + return objectUtil; + }, + ZodObject, + ZodUnion, + ZodDiscriminatedUnion, + ZodIntersection, + ZodTuple, + ZodRecord, + ZodMap, + ZodSet, + ZodFunction, + ZodLazy, + ZodLiteral, + ZodEnum, + ZodNativeEnum, + ZodPromise, + ZodEffects, + ZodTransformer: ZodEffects, + ZodOptional, + ZodNullable, + ZodDefault, + ZodCatch, + ZodNaN, + BRAND, + ZodBranded, + ZodPipeline, + custom, + Schema: ZodType, + ZodSchema: ZodType, + late, + get ZodFirstPartyTypeKind() { + return ZodFirstPartyTypeKind; + }, + coerce: coerce3, + any: anyType, + array: arrayType, + bigint: bigIntType, + boolean: booleanType, + date: dateType, + discriminatedUnion: discriminatedUnionType, + effect: effectsType, + "enum": enumType, + "function": functionType, + "instanceof": instanceOfType, + intersection: intersectionType, + lazy: lazyType, + literal: literalType, + map: mapType, + nan: nanType, + nativeEnum: nativeEnumType, + never: neverType, + "null": nullType, + nullable: nullableType, + number: numberType, + object: objectType, + oboolean, + onumber, + optional: optionalType, + ostring, + pipeline: pipelineType, + preprocess: preprocessType, + promise: promiseType, + record: recordType, + set: setType, + strictObject: strictObjectType, + string: stringType, + symbol: symbolType, + transformer: effectsType, + tuple: tupleType, + "undefined": undefinedType, + union: unionType, + unknown: unknownType, + "void": voidType, + NEVER, + ZodIssueCode, + quotelessJson, + ZodError + }); + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/awake/messages.js + var MessageType = z4.enum(["awake/init", "awake/res", "awake/msg"]); + var AwakeMessage = z4.object({ + awv: z4.literal("0.1.0"), + type: MessageType + }); + var PinChallengeMessage = z4.object({ + did: z4.string().startsWith("did:", { message: "should be a DID `did:key:z...`" }), + sig: z4.string() + }).strict(); + var AckMessage = z4.object({ + "awake/ack": z4.string().startsWith("did:", { message: "should be a DID `did:key:z...`" }) + }).strict(); + var InitResponse = AwakeMessage.extend({ + type: z4.literal("awake/init"), + did: z4.string().startsWith("did:", { message: "should be a DID `did:key:z...`" }), + caps: z4.array( + z4.object({ + with: z4.string(), + can: z4.string() + }) + ).nonempty() + }).strict(); + var DID2 = z4.string().startsWith("did:", { message: "should be a DID `did:key:z...`" }); + var ResResponse = AwakeMessage.extend({ + type: z4.literal("awake/res"), + iss: DID2, + aud: DID2, + msg: z4.string().min(1) + }).strict(); + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/awake/peer.js + var Peer = class { + /** + * @param {{ + * channel: import('./types').Channel + * agent: import('../agent').Agent + * }} opts + */ + constructor(opts) { + this.channel = opts.channel; + this.agent = opts.agent; + this.did = opts.agent.did(); + this.challenge = void 0; + this.nextdid = void 0; + this.audience = void 0; + this.pin = Math.floor(Math.random() * 1e6); + } + /** + * Bootstrap `awake/init`, receive `awake/res` and send challenge to Responder + * + * @param {import('@ipld/dag-ucan').Capabilities} caps + */ + async bootstrap(caps) { + this.channel.sendInit(caps); + const { ucan } = await this.channel.awaitRes(); + const challenge = findKey(ucan.facts, "awake/challenge"); + this.nextdid = parse2(findKey(ucan.facts, "awake/nextdid")); + if (challenge === "oob-pin") { + await this.sendPinSignature(); + return this.pin.toString(); + } + } + async awaitBootstrap() { + const msg = await this.channel.awaitInit(); + this.nextdid = msg.did; + const ucan = await issue({ + issuer: this.agent.issuer, + audience: this.nextdid, + capabilities: [{ with: "awake:", can: "*" }], + facts: [ + { "awake/challenge": "oob-pin" }, + // TODO: this should be rotated for the next step + { "awake/nextdid": this.channel.keypair.did } + ] + // TODO: proof for caps requested + }); + await this.channel.sendRes(this.nextdid, ucan); + const challengeMsg = await this.channel.awaitMsg(this.nextdid); + const { did: did3, sig } = PinChallengeMessage.parse(challengeMsg.msg); + this.audience = parse2(did3); + this.challenge = sig; + } + /** + * Acknowledgment for the PIN challenge + * + * @param {string} pin + */ + async ack(pin) { + if (!this.challenge || !this.nextdid || !this.audience) { + throw new Error("No challenge active."); + } + const sig = fromString5(this.challenge, "base64"); + const verifier = verifier_exports.parse(this.audience.did()); + const payload = fromString5(this.channel.keypair.did + pin); + const payloadHash = await sha256.encode(payload); + if (!await verifier.verify(payloadHash, decode14(sig))) { + throw new Error( + `Challenge failed: ${pin} is not valid for the current challenge.` + ); + } + await this.channel.sendMsg(this.nextdid, { + "awake/ack": this.did + }); + } + async awaitAck() { + if (!this.nextdid) { + throw new Error("No session is active. await ack"); + } + const awakeMsgAck = await this.channel.awaitMsg(this.nextdid); + const ack = AckMessage.parse(awakeMsgAck.msg); + this.audience = parse2(ack["awake/ack"]); + } + /** + * + * @param {{ + * caps: import('./types').LinkRequest['msg']['caps'] + * meta: import('./types').PeerMeta + * }} opts + */ + async link(opts) { + if (!this.nextdid || !this.audience) { + throw new Error("No session is active. request link"); + } + const msg = { + type: "link", + meta: opts.meta, + caps: opts.caps + }; + this.channel.sendMsg(this.nextdid, msg); + const capsRsp = await this.channel.awaitMsg(this.nextdid); + const delegations = stringToDelegations(capsRsp.msg.delegation); + await this.channel.sendFin(this.nextdid); + await this.agent.addProof(delegations[0]); + return { delegation: delegations[0], meta: capsRsp.msg.meta }; + } + async awaitLink() { + if (!this.nextdid || !this.audience) { + throw new Error("No challenge active."); + } + const reqCap = await this.channel.awaitMsg(this.nextdid); + const d7 = await this.agent.delegate({ + abilities: ["*"], + // TODO should be derived from reqCap + audience: this.audience, + expiration: Infinity, + audienceMeta: reqCap.msg.meta + }); + this.channel.subscribe("awake/msg", (msg) => { + this.channel.close(); + }); + this.channel.sendMsg(this.nextdid, { + meta: { + name: this.agent.did(), + type: "device" + }, + delegation: delegationsToString([d7]) + }); + } + /** + * Build pin signature and send it + * + * @private + */ + async sendPinSignature() { + if (!this.nextdid) { + throw new Error("No session is active."); + } + const bytes2 = fromString5(this.nextdid.did() + this.pin.toString()); + const signed = await this.agent.issuer.sign(await sha256.encode(bytes2)); + this.channel.sendMsg(this.nextdid, { + did: this.did, + sig: toString5(signed, "base64") + }); + } + }; + function findKey(arr, key) { + for (const i8 of arr) { + if (i8[key]) { + return i8[key]; + } + } + } + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/space.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/store.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+validator@8.0.0/node_modules/@ucanto/validator/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+validator@8.0.0/node_modules/@ucanto/validator/src/capability.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+validator@8.0.0/node_modules/@ucanto/validator/src/util.js + init_dirname(); + init_buffer2(); + init_process(); + var the = (value) => value; + var entries = (object) => ( + /** @type {any} */ + Object.entries(object) + ); + var combine = ([first, ...rest]) => { + const results = first.map((value) => [value]); + for (const values2 of rest) { + const tuples = results.splice(0); + for (const value of values2) { + for (const tuple3 of tuples) { + results.push([...tuple3, value]); + } + } + } + return results; + }; + var intersection2 = (left, right) => { + const [result, other] = left.length < right.length ? [new Set(left), new Set(right)] : [new Set(right), new Set(left)]; + for (const item of result) { + if (!other.has(item)) { + result.delete(item); + } + } + return [...result]; + }; + + // ../../node_modules/.pnpm/@ucanto+validator@8.0.0/node_modules/@ucanto/validator/src/error.js + init_dirname(); + init_buffer2(); + init_process(); + var EscalatedCapability = class extends Failure { + /** + * @param {API.ParsedCapability} claimed + * @param {object} delegated + * @param {API.Failure} cause + */ + constructor(claimed, delegated, cause) { + super(); + this.claimed = claimed; + this.delegated = delegated; + this.cause = cause; + this.name = the("EscalatedCapability"); + } + describe() { + return `Constraint violation: ${this.cause.message}`; + } + }; + var DelegationError = class extends Failure { + /** + * @param {(API.InvalidCapability | API.EscalatedDelegation | API.DelegationError)[]} causes + * @param {object} context + */ + constructor(causes, context2) { + super(); + this.name = the("InvalidClaim"); + this.causes = causes; + this.context = context2; + } + describe() { + return [ + `Can not derive ${this.context} from delegated capabilities:`, + ...this.causes.map((cause) => li2(cause.message)) + ].join("\n"); + } + /** + * @type {API.InvalidCapability | API.EscalatedDelegation | API.DelegationError} + */ + get cause() { + if (this.causes.length !== 1) { + return this; + } else { + const [cause] = this.causes; + const value = cause.name === "InvalidClaim" ? cause.cause : cause; + Object.defineProperties(this, { cause: { value } }); + return value; + } + } + }; + var MalformedCapability = class extends Failure { + /** + * @param {API.Capability} capability + * @param {API.Failure} cause + */ + constructor(capability3, cause) { + super(); + this.name = the("MalformedCapability"); + this.capability = capability3; + this.cause = cause; + } + describe() { + return [ + `Encountered malformed '${this.capability.can}' capability: ${format11( + this.capability + )}`, + li2(this.cause.message) + ].join("\n"); + } + }; + var UnknownCapability = class extends Failure { + /** + * @param {API.Capability} capability + */ + constructor(capability3) { + super(); + this.name = the("UnknownCapability"); + this.capability = capability3; + } + /* c8 ignore next 3 */ + describe() { + return `Encountered unknown capability: ${format11(this.capability)}`; + } + }; + var format11 = (capability3, space3) => JSON.stringify( + capability3, + (_key, value) => { + if (isLink(value)) { + return value.toString(); + } else { + return value; + } + }, + space3 + ); + var indent2 = (message2, indent5 = " ") => `${indent5}${message2.split("\n").join(` +${indent5}`)}`; + var li2 = (message2) => indent2(`- ${message2}`); + + // ../../node_modules/.pnpm/@ucanto+validator@8.0.0/node_modules/@ucanto/validator/src/capability.js + var capability = ({ + derives = defaultDerives, + nb = defaultNBSchema, + ...etc + }) => new Capability({ derives, nb, ...etc }); + var defaultNBSchema = ( + /** @type {Schema.MapRepresentation} */ + schema_exports3.struct({}) + ); + var or8 = (left, right) => new Or(left, right); + var and2 = (...selectors) => new And(selectors); + var derive2 = ({ from: from18, to, derives }) => new Derive(from18, to, derives); + var View2 = class { + /** + * @param {API.Source} source + * @returns {API.MatchResult} + */ + /* c8 ignore next 3 */ + match(source) { + return { error: new UnknownCapability(source.capability) }; + } + /** + * @param {API.Source[]} capabilities + * @returns {API.Select} + */ + select(capabilities) { + return select(this, capabilities); + } + /** + * @template {API.ParsedCapability} U + * @param {object} source + * @param {API.TheCapabilityParser>} source.to + * @param {API.Derives>} source.derives + * @returns {API.TheCapabilityParser>} + */ + derive({ derives, to }) { + return derive2({ derives, to, from: this }); + } + }; + var Unit = class extends View2 { + /** + * @template {API.Match} W + * @param {API.MatchSelector} other + * @returns {API.CapabilityParser} + */ + or(other) { + return or8(this, other); + } + /** + * @template {API.Match} W + * @param {API.CapabilityParser} other + * @returns {API.CapabilitiesParser<[M, W]>} + */ + and(other) { + return and2( + /** @type {API.CapabilityParser} */ + this, + other + ); + } + }; + var Capability = class extends Unit { + /** + * @param {Required>} descriptor + */ + constructor(descriptor) { + super(); + this.descriptor = descriptor; + this.schema = schema_exports3.struct({ + can: schema_exports3.literal(descriptor.can), + with: descriptor.with, + nb: descriptor.nb + }); + } + /** + * @param {API.InferCreateOptions} options + */ + create(options) { + const { descriptor, can } = this; + const decoders = descriptor.nb; + const data = ( + /** @type {C} */ + options.nb || {} + ); + const resource = descriptor.with.read(options.with); + if (resource.error) { + throw Object.assign( + new Error(`Invalid 'with' - ${resource.error.message}`), + { + cause: resource + } + ); + } + const nb = descriptor.nb.read(data); + if (nb.error) { + throw Object.assign(new Error(`Invalid 'nb' - ${nb.error.message}`), { + cause: nb + }); + } + return createCapability({ can, with: resource.ok, nb: nb.ok }); + } + /** + * @param {API.InferInvokeOptions} options + */ + invoke({ with: with_, nb, ...options }) { + return invoke({ + ...options, + capability: this.create( + /** @type {API.InferCreateOptions} */ + { with: with_, nb } + ) + }); + } + /** + * @param {API.InferDelegationOptions} options + * @returns {Promise>]>>} + */ + async delegate({ nb: input = {}, with: with_, ...options }) { + const { descriptor, can } = this; + const readers = descriptor.nb; + const resource = descriptor.with.read(with_); + if (resource.error) { + throw Object.assign( + new Error(`Invalid 'with' - ${resource.error.message}`), + { + cause: resource + } + ); + } + const nb = descriptor.nb.partial().read(input); + if (nb.error) { + throw Object.assign(new Error(`Invalid 'nb' - ${nb.error.message}`), { + cause: nb + }); + } + return delegate({ + capabilities: [createCapability({ can, with: resource.ok, nb: nb.ok })], + ...options + }); + } + get can() { + return this.descriptor.can; + } + /** + * @param {API.Source} source + * @returns {API.MatchResult>>} + */ + match(source) { + const result = parseCapability(this.descriptor, source); + return result.error ? result : { ok: new Match2(source, result.ok, this.descriptor) }; + } + toString() { + return JSON.stringify({ can: this.descriptor.can }); + } + }; + var createCapability = ({ can, with: with_, nb }) => ( + /** @type {API.InferCapability} */ + { + can, + with: with_, + ...isEmpty(nb) ? {} : { nb } + } + ); + var isEmpty = (object) => { + for (const _5 in object) { + return false; + } + return true; + }; + var Or = class extends Unit { + /** + * @param {API.Matcher} left + * @param {API.Matcher} right + */ + constructor(left, right) { + super(); + this.left = left; + this.right = right; + } + /** + * @param {API.Source} capability + * @return {API.MatchResult} + */ + match(capability3) { + const left = this.left.match(capability3); + if (left.error) { + const right = this.right.match(capability3); + if (right.error) { + return right.error.name === "MalformedCapability" ? ( + // + right + ) : ( + // + left + ); + } else { + return right; + } + } else { + return left; + } + } + toString() { + return `${this.left.toString()}|${this.right.toString()}`; + } + }; + var And = class _And extends View2 { + /** + * @param {Selectors} selectors + */ + constructor(selectors) { + super(); + this.selectors = selectors; + } + /** + * @param {API.Source} capability + * @returns {API.MatchResult>>} + */ + match(capability3) { + const group2 = []; + for (const selector of this.selectors) { + const result = selector.match(capability3); + if (result.error) { + return result; + } else { + group2.push(result.ok); + } + } + return { + ok: new AndMatch( + /** @type {API.InferMembers} */ + group2 + ) + }; + } + /** + * @param {API.Source[]} capabilities + */ + select(capabilities) { + return selectGroup(this, capabilities); + } + /** + * @template E + * @template {API.Match} X + * @param {API.MatchSelector>} other + * @returns {API.CapabilitiesParser<[...API.InferMembers, API.Match]>} + */ + and(other) { + return new _And([...this.selectors, other]); + } + toString() { + return `[${this.selectors.map(String).join(", ")}]`; + } + }; + var Derive = class extends Unit { + /** + * @param {API.MatchSelector} from + * @param {API.TheCapabilityParser>} to + * @param {API.Derives>} derives + */ + constructor(from18, to, derives) { + super(); + this.from = from18; + this.to = to; + this.derives = derives; + } + /** + * @type {typeof this.to['create']} + */ + create(options) { + return this.to.create(options); + } + /** + * @type {typeof this.to['invoke']} + */ + invoke(options) { + return this.to.invoke(options); + } + /** + * @type {typeof this.to['delegate']} + */ + delegate(options) { + return this.to.delegate(options); + } + get can() { + return this.to.can; + } + /** + * @param {API.Source} capability + * @returns {API.MatchResult>} + */ + match(capability3) { + const match10 = this.to.match(capability3); + if (match10.error) { + return match10; + } else { + return { ok: new DerivedMatch(match10.ok, this.from, this.derives) }; + } + } + toString() { + return this.to.toString(); + } + }; + var Match2 = class _Match { + /** + * @param {API.Source} source + * @param {API.ParsedCapability} value + * @param {Required>} descriptor + */ + constructor(source, value, descriptor) { + this.source = [source]; + this.value = value; + this.descriptor = descriptor; + } + get can() { + return this.value.can; + } + get proofs() { + const proofs3 = [this.source[0].delegation]; + Object.defineProperties(this, { + proofs: { value: proofs3 } + }); + return proofs3; + } + /** + * @param {API.CanIssue} context + * @returns {API.DirectMatch>|null} + */ + prune(context2) { + if (context2.canIssue(this.value, this.source[0].delegation.issuer.did())) { + return null; + } else { + return this; + } + } + /** + * @param {API.Source[]} capabilities + * @returns {API.Select>>} + */ + select(capabilities) { + const unknown3 = []; + const errors = []; + const matches = []; + for (const capability3 of capabilities) { + const result = resolveCapability(this.descriptor, this.value, capability3); + if (result.ok) { + const claim4 = this.descriptor.derives(this.value, result.ok); + if (claim4.error) { + errors.push( + new DelegationError( + [new EscalatedCapability(this.value, result.ok, claim4.error)], + this + ) + ); + } else { + matches.push(new _Match(capability3, result.ok, this.descriptor)); + } + } else { + switch (result.error.name) { + case "UnknownCapability": + unknown3.push(result.error.capability); + break; + case "MalformedCapability": + default: + errors.push(new DelegationError([result.error], this)); + } + } + } + return { matches, unknown: unknown3, errors }; + } + toString() { + const { nb } = this.value; + return JSON.stringify({ + can: this.descriptor.can, + with: this.value.with, + nb: nb && Object.keys(nb).length > 0 ? nb : void 0 + }); + } + }; + var DerivedMatch = class _DerivedMatch { + /** + * @param {API.DirectMatch} selected + * @param {API.MatchSelector} from + * @param {API.Derives>} derives + */ + constructor(selected, from18, derives) { + this.selected = selected; + this.from = from18; + this.derives = derives; + } + get can() { + return this.value.can; + } + get source() { + return this.selected.source; + } + get proofs() { + const proofs3 = []; + for (const { delegation } of this.selected.source) { + proofs3.push(delegation); + } + Object.defineProperties(this, { proofs: { value: proofs3 } }); + return proofs3; + } + get value() { + return this.selected.value; + } + /** + * @param {API.CanIssue} context + */ + prune(context2) { + const selected = ( + /** @type {API.DirectMatch|null} */ + this.selected.prune(context2) + ); + return selected ? new _DerivedMatch(selected, this.from, this.derives) : null; + } + /** + * @param {API.Source[]} capabilities + */ + select(capabilities) { + const { derives, selected, from: from18 } = this; + const { value } = selected; + const direct = selected.select(capabilities); + const derived = from18.select(capabilities); + const matches = []; + const errors = []; + for (const match10 of derived.matches) { + const result = derives(value, match10.value); + if (result.error) { + errors.push( + new DelegationError( + [new EscalatedCapability(value, match10.value, result.error)], + this + ) + ); + } else { + matches.push(match10); + } + } + return { + unknown: intersection2(direct.unknown, derived.unknown), + errors: [ + ...errors, + ...direct.errors, + ...derived.errors.map((error7) => new DelegationError([error7], this)) + ], + matches: [ + ...direct.matches.map((match10) => new _DerivedMatch(match10, from18, derives)), + ...matches + ] + }; + } + toString() { + return this.selected.toString(); + } + }; + var AndMatch = class _AndMatch { + /** + * @param {API.Match[]} matches + */ + constructor(matches) { + this.matches = matches; + } + get selectors() { + return this.matches; + } + /** + * @returns {API.Source[]} + */ + get source() { + const source = []; + for (const match10 of this.matches) { + source.push(...match10.source); + } + Object.defineProperties(this, { source: { value: source } }); + return source; + } + /** + * @param {API.CanIssue} context + */ + prune(context2) { + const matches = []; + for (const match10 of this.matches) { + const pruned = match10.prune(context2); + if (pruned) { + matches.push(pruned); + } + } + return matches.length === 0 ? null : new _AndMatch(matches); + } + get proofs() { + const proofs3 = []; + for (const { delegation } of this.source) { + proofs3.push(delegation); + } + Object.defineProperties(this, { proofs: { value: proofs3 } }); + return proofs3; + } + /** + * @type {API.InferValue>} + */ + get value() { + const value = []; + for (const match10 of this.matches) { + value.push(match10.value); + } + Object.defineProperties(this, { value: { value } }); + return ( + /** @type {any} */ + value + ); + } + /** + * @param {API.Source[]} capabilities + */ + select(capabilities) { + return selectGroup(this, capabilities); + } + toString() { + return `[${this.matches.map((match10) => match10.toString()).join(", ")}]`; + } + }; + var resolveAbility = (pattern, can, fallback) => { + switch (pattern) { + case can: + case "*": + return can; + default: + return pattern.endsWith("/*") && can.startsWith(pattern.slice(0, -1)) ? can : fallback; + } + }; + var resolveResource = (source, uri3, fallback) => { + switch (source) { + case uri3: + case "ucan:*": + return uri3; + default: + return fallback; + } + }; + var parseCapability = (descriptor, source) => { + const { delegation } = source; + const capability3 = ( + /** @type {API.Capability} */ + source.capability + ); + if (descriptor.can !== capability3.can) { + return { error: new UnknownCapability(capability3) }; + } + const uri3 = descriptor.with.read(capability3.with); + if (uri3.error) { + return { error: new MalformedCapability(capability3, uri3.error) }; + } + const nb = descriptor.nb.read(capability3.nb || {}); + if (nb.error) { + return { error: new MalformedCapability(capability3, nb.error) }; + } + return { ok: new CapabilityView(descriptor.can, uri3.ok, nb.ok, delegation) }; + }; + var resolveCapability = (descriptor, claimed, { capability: capability3, delegation }) => { + const can = resolveAbility(capability3.can, claimed.can, null); + if (can == null) { + return { error: new UnknownCapability(capability3) }; + } + const resource = resolveResource( + capability3.with, + claimed.with, + capability3.with + ); + const uri3 = descriptor.with.read(resource); + if (uri3.error) { + return { error: new MalformedCapability(capability3, uri3.error) }; + } + const nb = descriptor.nb.read({ + ...claimed.nb, + ...capability3.nb + }); + if (nb.error) { + return { error: new MalformedCapability(capability3, nb.error) }; + } + return { ok: new CapabilityView(can, uri3.ok, nb.ok, delegation) }; + }; + var CapabilityView = class { + /** + * @param {A} can + * @param {R} with_ + * @param {C} nb + * @param {API.Delegation} delegation + */ + constructor(can, with_, nb, delegation) { + this.can = can; + this.with = with_; + this.delegation = delegation; + this.nb = nb; + } + }; + var select = (matcher, capabilities) => { + const unknown3 = []; + const matches = []; + const errors = []; + for (const capability3 of capabilities) { + const result = matcher.match(capability3); + if (result.error) { + switch (result.error.name) { + case "UnknownCapability": + unknown3.push(result.error.capability); + break; + case "MalformedCapability": + default: + errors.push(new DelegationError([result.error], result.error.capability)); + } + } else { + matches.push(result.ok); + } + } + return { matches, errors, unknown: unknown3 }; + }; + var selectGroup = (self2, capabilities) => { + let unknown3; + const data = []; + const errors = []; + for (const selector of self2.selectors) { + const selected = selector.select(capabilities); + unknown3 = unknown3 ? intersection2(unknown3, selected.unknown) : selected.unknown; + for (const error7 of selected.errors) { + errors.push(new DelegationError([error7], self2)); + } + data.push(selected.matches); + } + const matches = combine(data).map((group2) => new AndMatch(group2)); + return { + unknown: ( + /* c8 ignore next */ + unknown3 || [] + ), + errors, + matches + }; + }; + var defaultDerives = (claimed, delegated) => { + if (delegated.with.endsWith("*")) { + if (!claimed.with.startsWith(delegated.with.slice(0, -1))) { + return schema_exports3.error( + `Resource ${claimed.with} does not match delegated ${delegated.with} ` + ); + } + } else if (delegated.with !== claimed.with) { + return schema_exports3.error( + `Resource ${claimed.with} is not contained by ${delegated.with}` + ); + } + const caveats = delegated.nb || {}; + const nb = claimed.nb || {}; + const kv = entries(caveats); + for (const [name15, value] of kv) { + if (nb[name15] != value) { + return schema_exports3.error(`${String(name15)}: ${nb[name15]} violates ${value}`); + } + } + return { ok: true }; + }; + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/utils.js + init_dirname(); + init_buffer2(); + init_process(); + function equalWith(child, parent) { + return child.with === parent.with ? ok({}) : fail2(`Can not derive ${child.can} with ${child.with} from ${parent.with}`); + } + function equal(child, parent, constraint) { + if (parent === void 0 || parent === "*") { + return ok({}); + } else if (String(child) === String(parent)) { + return ok({}); + } else { + return fail2( + `Constrain violation: ${child} violates imposed ${constraint} constraint ${parent}` + ); + } + } + var equalLink = (claimed, delegated) => { + if (claimed.with !== delegated.with) { + return fail2( + `Expected 'with: "${delegated.with}"' instead got '${claimed.with}'` + ); + } else if (delegated.nb.link && `${delegated.nb.link}` !== `${claimed.nb.link}`) { + return fail2( + `Link ${claimed.nb.link ? `${claimed.nb.link}` : ""} violates imposed ${delegated.nb.link} constraint.` + ); + } else { + return ok({}); + } + }; + var checkLink = (claimed, imposed, at2) => { + return equal( + String(claimed), + imposed === void 0 ? void 0 : String(imposed), + at2 + ); + }; + var and3 = (result) => result.error ? result : void 0; + function parseAbility(ability) { + const [namespace, ...segments] = ability.split("/"); + return { namespace, segments }; + } + function canDelegateAbility(parent, child) { + const parsedParent = parseAbility(parent); + const parsedChild = parseAbility(child); + if (parsedParent.namespace === "*" && parsedParent.segments.length === 0) { + return true; + } + if (parsedChild.namespace === "*" && parsedChild.segments.length === 0) { + return false; + } + if (parsedParent.namespace !== parsedChild.namespace) { + return false; + } + if (parsedParent.segments[0] === "*") { + return true; + } + if (parsedParent.segments.length !== parsedChild.segments.length) { + return false; + } + return parsedParent.segments.reduce( + (acc, v7, i8) => acc && parsedChild.segments[i8] === v7, + true + ); + } + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/store.js + var store = capability({ + can: "store/*", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + derives: equalWith + }); + var add = capability({ + can: "store/add", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * CID of the CAR file to be stored. Service will provision write target + * for this exact CAR file for agent to PUT or POST it. Attempt to write + * any other content will fail. + */ + link: link_exports2, + /** + * Size of the CAR file to be stored. Service will provision write target + * for this exact size. Attempt to write a larger CAR file will fail. + */ + size: schema_exports3.integer(), + /** + * Agent may optionally provide a link to a related CAR file using `origin` + * field. This is useful when storing large DAGs, agent could shard it + * across multiple CAR files and then link each shard with a previous one. + * + * Providing this relation tells service that given CAR is shard of the + * larger DAG as opposed to it being intentionally partial DAG. When DAG is + * not sharded, there will be only one `store/add` with `origin` left out. + */ + origin: link_exports2.optional() + }), + derives: (claim4, from18) => { + const result = equalLink(claim4, from18); + if (result.error) { + return result; + } else if (claim4.nb.size !== void 0 && from18.nb.size !== void 0) { + return claim4.nb.size > from18.nb.size ? fail2(`Size constraint violation: ${claim4.nb.size} > ${from18.nb.size}`) : ok({}); + } else { + return ok({}); + } + } + }); + var remove = capability({ + can: "store/remove", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * CID of the CAR file to be removed from the store. + */ + link: link_exports2 + }), + derives: equalLink + }); + var list = capability({ + can: "store/list", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * A pointer that can be moved back and forth on the list. + * It can be used to paginate a list for instance. + */ + cursor: schema_exports3.string().optional(), + /** + * Maximum number of items per page. + */ + size: schema_exports3.integer().optional(), + /** + * If true, return page of results preceding cursor. Defaults to false. + */ + pre: schema_exports3.boolean().optional() + }), + derives: (claimed, delegated) => { + if (claimed.with !== delegated.with) { + return fail2( + `Expected 'with: "${delegated.with}"' instead got '${claimed.with}'` + ); + } + return ok({}); + } + }); + var all = add.or(remove).or(list); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/upload.js + init_dirname(); + init_buffer2(); + init_process(); + var upload = capability({ + can: "upload/*", + /** + * did:key identifier of the (memory) space where upload is add to the + * upload list. + */ + with: uri_exports.match({ protocol: "did:" }), + derives: equalWith + }); + var CARLink = link_exports2.match({ code: car_exports.code, version: 1 }); + var add2 = capability({ + can: "upload/add", + /** + * did:key identifier of the (memory) space where uploaded is added. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * Root CID of the DAG to be added to the upload list. + */ + root: link_exports2, + /** + * CIDs to the CAR files that contain blocks of the DAG. + */ + shards: CARLink.array().optional() + }), + derives: (self2, from18) => { + return and3(equalWith(self2, from18)) || and3(equal(self2.nb.root, from18.nb.root, "root")) || and3(equal(self2.nb.shards, from18.nb.shards, "shards")) || ok({}); + } + }); + var remove2 = capability({ + can: "upload/remove", + /** + * did:key identifier of the (memory) space where uploaded is removed from. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * Root CID of the DAG to be removed from the upload list. + */ + root: link_exports2 + }), + derives: (self2, from18) => { + return and3(equalWith(self2, from18)) || and3(equal(self2.nb.root, from18.nb.root, "root")) || ok({}); + } + }); + var list2 = capability({ + can: "upload/list", + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * A pointer that can be moved back and forth on the list. + * It can be used to paginate a list for instance. + */ + cursor: schema_exports3.string().optional(), + /** + * Maximum number of items per page. + */ + size: schema_exports3.integer().optional(), + /** + * If true, return page of results preceding cursor. Defaults to false. + */ + pre: schema_exports3.boolean().optional() + }) + }); + var all2 = add2.or(remove2).or(list2); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/top.js + init_dirname(); + init_buffer2(); + init_process(); + var top = capability({ + can: "*", + with: uri_exports.match({ protocol: "did:" }), + derives: equalWith + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/space.js + var SpaceDID = schema_exports3.did({ method: "key" }); + var space = capability({ + can: "space/*", + with: SpaceDID, + derives: equalWith + }); + var info = add.or(list).or(remove).or(add2).or(list2).or(remove2).derive({ + to: capability({ + can: "space/info", + with: SpaceDID + }), + derives: equalWith + }); + var allocate = capability({ + can: "space/allocate", + with: SpaceDID, + nb: schema_exports3.struct({ + size: schema_exports3.integer() + }), + derives: (child, parent) => { + const result = equalWith(child, parent); + if (result.ok) { + return child.nb.size <= parent.nb.size ? ok({}) : fail2( + `Claimed size ${child.nb.size} escalates delegated size ${parent.nb.size}` + ); + } else { + return result; + } + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/access.js + var access_exports = {}; + __export(access_exports, { + Account: () => Account, + AuthorizationRequest: () => AuthorizationRequest, + CapabilityRequest: () => CapabilityRequest, + access: () => access, + authorize: () => authorize, + claim: () => claim, + confirm: () => confirm, + delegate: () => delegate3, + session: () => session, + top: () => top + }); + init_dirname(); + init_buffer2(); + init_process(); + var Account = did_exports2.match({ method: "mailto" }); + var CapabilityRequest = schema_exports3.struct({ + /** + * If set to `"*"` it corresponds to "sudo" access. + */ + can: schema_exports3.string() + }); + var AuthorizationRequest = schema_exports3.struct({ + /** + * DID of the Account authorization is requested from. + */ + iss: Account, + /** + * Capabilities agent wishes to be granted. + */ + att: CapabilityRequest.array() + }); + var access = capability({ + can: "access/*", + with: uri_exports.match({ protocol: "did:" }) + }); + var authorize = capability({ + can: "access/authorize", + with: did_exports2.match({ method: "key" }), + /** + * Authorization request describing set of desired capabilities + */ + nb: AuthorizationRequest, + derives: (child, parent) => { + return and3(equalWith(child, parent)) || and3(equal(child.nb.iss, parent.nb.iss, "iss")) || and3(subsetCapabilities(child.nb.att, parent.nb.att)) || ok({}); + } + }); + var confirm = capability({ + can: "access/confirm", + with: did_exports2, + nb: schema_exports3.struct({ + iss: Account, + aud: schema_exports3.did(), + att: CapabilityRequest.array() + }), + derives: (claim4, proof) => { + return and3(equalWith(claim4, proof)) || and3(equal(claim4.nb.iss, proof.nb.iss, "iss")) || and3(equal(claim4.nb.aud, proof.nb.aud, "aud")) || and3(subsetCapabilities(claim4.nb.att, proof.nb.att)) || ok({}); + } + }); + var session = capability({ + can: "ucan/attest", + // Should be web3.storage DID + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + // UCAN delegation that is being attested. + proof: link_exports2 + }) + }); + var claim = capability({ + can: "access/claim", + with: did_exports2.match({ method: "key" }).or(did_exports2.match({ method: "mailto" })) + }); + var delegate3 = capability({ + can: "access/delegate", + /** + * Field MUST be a space DID with a storage provider. Delegation will be stored just like any other DAG stored using store/add capability. + * + * @see https://github.com/web3-storage/specs/blob/main/w3-access.md#delegate-with + */ + with: did_exports2.match({ method: "key" }), + nb: schema_exports3.struct({ + // keys SHOULD be CIDs, but we won't require it in the schema + /** + * @type {Schema.Schema} + */ + delegations: schema_exports3.dictionary({ + value: schema_exports3.Link.match() + }) + }), + derives: (claim4, proof) => { + return and3(equalWith(claim4, proof)) || and3(subsetsNbDelegations(claim4, proof)) || ok({}); + } + }); + function subsetsNbDelegations(claim4, proof) { + const missingProofs = setDifference( + delegatedCids(claim4), + new Set(delegatedCids(proof)) + ); + if (missingProofs.size > 0) { + return fail2(`unauthorized nb.delegations ${[...missingProofs].join(", ")}`); + } + return ok({}); + } + var subsetCapabilities = (claim4, proof) => { + const allowed = new Set(proof.map((p8) => p8.can)); + if (allowed.has("*")) { + return ok({}); + } + const escalated = setDifference( + claim4.map((c8) => c8.can), + allowed + ); + if (escalated.size > 0) { + return fail2(`unauthorized nb.att.can ${[...escalated].join(", ")}`); + } + return ok({}); + }; + function* delegatedCids(delegate7) { + for (const d7 of Object.values(delegate7.nb.delegations || {})) { + yield d7.toString(); + } + } + function setDifference(minuend, subtrahend) { + const difference = /* @__PURE__ */ new Set(); + for (const e12 of minuend) { + if (!subtrahend.has(e12)) { + difference.add(e12); + } + } + return difference; + } + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/rsa.js + var rsa_exports = {}; + __export(rsa_exports, { + Verifier: () => RSAVerifier, + code: () => code8, + decode: () => decode33, + from: () => from11, + generate: () => generate2, + name: () => name8, + or: () => or9, + signatureAlgorithm: () => signatureAlgorithm3, + signatureCode: () => signatureCode3 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/one-webcrypto@1.0.3/node_modules/one-webcrypto/browser.mjs + init_dirname(); + init_buffer2(); + init_process(); + var _globalReference = globalThis || window || self; + var webcrypto2 = _globalReference.crypto; + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/rsa/type.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/multiformat.js + init_dirname(); + init_buffer2(); + init_process(); + var tagWith = (code15, bytes2) => { + const offset2 = varint_exports2.encodingLength(code15); + const multiformat = new Uint8Array(bytes2.byteLength + offset2); + varint_exports2.encodeTo(code15, multiformat, 0); + multiformat.set(bytes2, offset2); + return multiformat; + }; + var untagWith = (code15, source, byteOffset = 0) => { + const bytes2 = byteOffset !== 0 ? source.subarray(byteOffset) : source; + const [tag2, size4] = varint_exports2.decode(bytes2); + if (tag2 !== code15) { + throw new Error( + `Expected multiformat with 0x${code15.toString( + 16 + )} tag instead got 0x${tag2.toString(16)}` + ); + } else { + return new Uint8Array(bytes2.buffer, bytes2.byteOffset + size4); + } + }; + var encodingLength3 = varint_exports2.encodingLength; + var encodeTo3 = varint_exports2.encodeTo; + var decode29 = varint_exports2.decode; + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/rsa/spki.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/rsa/asn1.js + init_dirname(); + init_buffer2(); + init_process(); + var TAG_SIZE = 1; + var INT_TAG = 2; + var BITSTRING_TAG = 3; + var OCTET_STRING_TAG = 4; + var SEQUENCE_TAG = 48; + var UNUSED_BIT_PAD = 0; + var encodeDERLength = (length3) => { + if (length3 <= 127) { + return new Uint8Array([length3]); + } + const octets = []; + while (length3 !== 0) { + octets.push(length3 & 255); + length3 = length3 >>> 8; + } + octets.reverse(); + return new Uint8Array([128 | octets.length & 255, ...octets]); + }; + var readDERLength = (bytes2, offset2 = 0) => { + if ((bytes2[offset2] & 128) === 0) { + return { number: bytes2[offset2], consumed: 1 }; + } + const numberBytes = bytes2[offset2] & 127; + if (bytes2.length < numberBytes + 1) { + throw new Error( + `ASN parsing error: Too few bytes. Expected encoded length's length to be at least ${numberBytes}` + ); + } + let length3 = 0; + for (let i8 = 0; i8 < numberBytes; i8++) { + length3 = length3 << 8; + length3 = length3 | bytes2[offset2 + i8 + 1]; + } + return { number: length3, consumed: numberBytes + 1 }; + }; + var skip = (input, expectedTag, position) => { + const parsed = into(input, expectedTag, position); + return parsed.position + parsed.length; + }; + var into = (input, expectedTag, offset2) => { + const actualTag = input[offset2]; + if (actualTag !== expectedTag) { + throw new Error( + `ASN parsing error: Expected tag 0x${expectedTag.toString( + 16 + )} at position ${offset2}, but got 0x${actualTag.toString(16)}.` + ); + } + const length3 = readDERLength(input, offset2 + TAG_SIZE); + const position = offset2 + TAG_SIZE + length3.consumed; + return { position, length: length3.number }; + }; + var encodeBitString = (input) => { + const length3 = encodeDERLength(input.byteLength + 1); + const bytes2 = new Uint8Array( + TAG_SIZE + // ASN_BITSTRING_TAG + length3.byteLength + 1 + // amount of unused bits at the end of our bitstring + input.byteLength + ); + let byteOffset = 0; + bytes2[byteOffset] = BITSTRING_TAG; + byteOffset += TAG_SIZE; + bytes2.set(length3, byteOffset); + byteOffset += length3.byteLength; + bytes2[byteOffset] = UNUSED_BIT_PAD; + byteOffset += 1; + bytes2.set(input, byteOffset); + return bytes2; + }; + var encodeOctetString = (input) => { + const length3 = encodeDERLength(input.byteLength); + const bytes2 = new Uint8Array(TAG_SIZE + length3.byteLength + input.byteLength); + let byteOffset = 0; + bytes2[byteOffset] = OCTET_STRING_TAG; + byteOffset += TAG_SIZE; + bytes2.set(length3, byteOffset); + byteOffset += length3.byteLength; + bytes2.set(input, byteOffset); + return bytes2; + }; + var encodeSequence = (sequence) => { + let byteLength = 0; + for (const item of sequence) { + byteLength += item.byteLength; + } + const length3 = encodeDERLength(byteLength); + const bytes2 = new Uint8Array(TAG_SIZE + length3.byteLength + byteLength); + let byteOffset = 0; + bytes2[byteOffset] = SEQUENCE_TAG; + byteOffset += TAG_SIZE; + bytes2.set(length3, byteOffset); + byteOffset += length3.byteLength; + for (const item of sequence) { + bytes2.set(item, byteOffset); + byteOffset += item.byteLength; + } + return bytes2; + }; + var readSequence = (bytes2, offset2 = 0) => { + const { position, length: length3 } = into(bytes2, SEQUENCE_TAG, offset2); + return new Uint8Array(bytes2.buffer, bytes2.byteOffset + position, length3); + }; + var encodeInt = (input) => { + const extra = input.byteLength === 0 || input[0] & 128 ? 1 : 0; + const length3 = encodeDERLength(input.byteLength + extra); + const bytes2 = new Uint8Array( + TAG_SIZE + // INT_TAG + length3.byteLength + input.byteLength + extra + ); + let byteOffset = 0; + bytes2[byteOffset] = INT_TAG; + byteOffset += TAG_SIZE; + bytes2.set(length3, byteOffset); + byteOffset += length3.byteLength; + if (extra > 0) { + bytes2[byteOffset] = UNUSED_BIT_PAD; + byteOffset += extra; + } + bytes2.set(input, byteOffset); + return bytes2; + }; + var enterSequence = (bytes2, offset2 = 0) => into(bytes2, SEQUENCE_TAG, offset2).position; + var skipSequence = (bytes2, offset2 = 0) => skip(bytes2, SEQUENCE_TAG, offset2); + var skipInt = (bytes2, offset2 = 0) => skip(bytes2, INT_TAG, offset2); + var readBitString = (bytes2, offset2 = 0) => { + const { position, length: length3 } = into(bytes2, BITSTRING_TAG, offset2); + const tag2 = bytes2[position]; + if (tag2 !== UNUSED_BIT_PAD) { + throw new Error( + `Can not read bitstring, expected length to be multiple of 8, but got ${tag2} unused bits in last byte.` + ); + } + return new Uint8Array( + bytes2.buffer, + bytes2.byteOffset + position + 1, + length3 - 1 + ); + }; + var readInt2 = (bytes2, byteOffset = 0) => { + const { position, length: length3 } = into(bytes2, INT_TAG, byteOffset); + let delta = 0; + while (bytes2[position + delta] === 0) { + delta++; + } + return new Uint8Array( + bytes2.buffer, + bytes2.byteOffset + position + delta, + length3 - delta + ); + }; + var readOctetString = (bytes2, offset2 = 0) => { + const { position, length: length3 } = into(bytes2, OCTET_STRING_TAG, offset2); + return new Uint8Array(bytes2.buffer, bytes2.byteOffset + position, length3); + }; + var readSequenceWith = (readers, source, byteOffset = 0) => { + const results = []; + const sequence = readSequence(source, byteOffset); + let offset2 = 0; + for (const read13 of readers) { + const chunk = read13(sequence, offset2); + results.push(chunk); + offset2 = chunk.byteOffset + chunk.byteLength - sequence.byteOffset; + } + return results; + }; + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/rsa/spki.js + var SPKI_PARAMS_ENCODED = new Uint8Array([ + 48, + 13, + 6, + 9, + 42, + 134, + 72, + 134, + 247, + 13, + 1, + 1, + 1, + 5, + 0 + ]); + var encode24 = (key) => encodeSequence([SPKI_PARAMS_ENCODED, encodeBitString(key)]); + var decode30 = (info3) => { + const offset2 = enterSequence(info3, 0); + const keyOffset = skipSequence(info3, offset2); + return readBitString(info3, keyOffset); + }; + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/rsa/pkcs8.js + init_dirname(); + init_buffer2(); + init_process(); + var PKSC8_HEADER = new Uint8Array([ + // version + 2, + 1, + 0, + // privateKeyAlgorithm + 48, + 13, + 6, + 9, + 42, + 134, + 72, + 134, + 247, + 13, + 1, + 1, + 1, + 5, + 0 + ]); + var decode31 = (info3) => { + let offset2 = 0; + offset2 = enterSequence(info3, offset2); + offset2 = skipInt(info3, offset2); + offset2 = skipSequence(info3, offset2); + return readOctetString(info3, offset2); + }; + var encode25 = (key) => encodeSequence([PKSC8_HEADER, encodeOctetString(key)]); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/rsa/private-key.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/rsa/public-key.js + init_dirname(); + init_buffer2(); + init_process(); + var encode26 = ({ n: n9, e: e12 }) => encodeSequence([encodeInt(n9), encodeInt(e12)]); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/rsa/private-key.js + var VERSION2 = new Uint8Array(); + var decode32 = (source, byteOffset = 0) => { + const [v7, n9, e12, d7, p8, q4, dp, dq, qi] = readSequenceWith( + [ + readInt2, + readInt2, + readInt2, + readInt2, + readInt2, + readInt2, + readInt2, + readInt2, + readInt2 + ], + source, + byteOffset + ); + return { v: v7, n: n9, e: e12, d: d7, p: p8, q: q4, dp, dq, qi }; + }; + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/rsa.js + var name8 = "RSA"; + var code8 = 4869; + var verifierCode = 4613; + var signatureCode3 = RS256; + var signatureAlgorithm3 = "RS256"; + var ALG = "RSASSA-PKCS1-v1_5"; + var HASH_ALG = "SHA-256"; + var KEY_SIZE2 = 2048; + var SALT_LENGTH = 128; + var IMPORT_PARAMS = { + name: ALG, + hash: { name: HASH_ALG } + }; + var generate2 = async ({ + size: size4 = KEY_SIZE2, + extractable = false + } = {}) => { + const { publicKey, privateKey } = await webcrypto2.subtle.generateKey( + { + name: ALG, + modulusLength: size4, + publicExponent: new Uint8Array([1, 0, 1]), + hash: { name: HASH_ALG } + }, + extractable, + ["sign", "verify"] + ); + const spki = await webcrypto2.subtle.exportKey("spki", publicKey); + const publicBytes = tagWith(verifierCode, decode30(new Uint8Array(spki))); + const verifier = new RSAVerifier({ bytes: publicBytes, publicKey }); + if (!extractable) { + return new UnextractableRSASigner({ + privateKey, + verifier + }); + } else { + const pkcs8 = await webcrypto2.subtle.exportKey("pkcs8", privateKey); + const bytes2 = tagWith(code8, decode31(new Uint8Array(pkcs8))); + return new ExtractableRSASigner({ + privateKey, + bytes: bytes2, + verifier + }); + } + }; + var from11 = ({ id, keys: keys2 }) => { + if (id.startsWith("did:key:")) { + const did3 = ( + /** @type {API.DIDKey} */ + id + ); + const key = keys2[did3]; + if (key instanceof Uint8Array) { + return decode33(key); + } else { + return new UnextractableRSASigner({ + privateKey: key, + verifier: RSAVerifier.parse(did3) + }); + } + } else { + throw new TypeError( + `RSA can not import from ${id} archive, try generic Signer instead` + ); + } + }; + var or9 = (other) => or6({ from: from11 }, other); + var decode33 = (bytes2) => { + const rsa = decode32(untagWith(code8, bytes2)); + const publicBytes = tagWith(verifierCode, encode26(rsa)); + return new ExtractableRSASigner({ + bytes: bytes2, + privateKey: webcrypto2.subtle.importKey( + "pkcs8", + encode25(untagWith(code8, bytes2)), + IMPORT_PARAMS, + true, + ["sign"] + ), + verifier: RSAVerifier.decode(publicBytes) + }); + }; + var RSAVerifier = class _RSAVerifier { + /** + * @param {object} options + * @param {API.Await} options.publicKey + * @param {API.ByteView} options.bytes + */ + constructor({ publicKey, bytes: bytes2 }) { + this.publicKey = publicKey; + this.bytes = bytes2; + } + /** + * @template {API.DID} ID + * @param {ID} id + * @returns {API.Verifier} + */ + withDID(id) { + return withDID(this, id); + } + toDIDKey() { + return this.did(); + } + /** + * @param {API.ByteView} bytes + * @returns {API.RSAVerifier} + */ + static decode(bytes2) { + return new this({ + bytes: bytes2, + publicKey: webcrypto2.subtle.importKey( + "spki", + encode24(untagWith(verifierCode, bytes2)), + IMPORT_PARAMS, + true, + ["verify"] + ) + }); + } + /** + * @param {API.DIDKey} did + * @returns {API.RSAVerifier} + */ + static parse(did3) { + return _RSAVerifier.decode( + /** @type {Uint8Array} */ + parse2(did3) + ); + } + /** + * @param {API.PrincipalParser} other + */ + static or(other) { + return or4(this, other); + } + /** @type {typeof verifierCode} */ + get code() { + return verifierCode; + } + /** + * @type {typeof signatureCode} + */ + get signatureCode() { + return signatureCode3; + } + /** + * @type {typeof signatureAlgorithm} + */ + get signatureAlgorithm() { + return signatureAlgorithm3; + } + /** + * DID of the Principal in `did:key` format. + * @returns {API.DID<"key">} + */ + did() { + return `did:key:${base58btc2.encode(this.bytes)}`; + } + /** + * @template T + * @param {API.ByteView} payload + * @param {API.Signature} signature + * @returns {Promise} + */ + async verify(payload, signature) { + if (signature.code !== signatureCode3) { + return false; + } + return webcrypto2.subtle.verify( + { name: ALG, hash: { name: HASH_ALG } }, + await this.publicKey, + signature.raw, + payload + ); + } + }; + var RSASigner = class { + /** + * @param {object} options + * @param {API.Await} options.privateKey + * @param {API.RSAVerifier} options.verifier + */ + constructor({ privateKey, verifier }) { + this.verifier = verifier; + this.privateKey = privateKey; + } + get signer() { + return this; + } + /** + * @type {typeof code} + */ + get code() { + return code8; + } + /** + * @type {typeof signatureCode} + */ + get signatureCode() { + return signatureCode3; + } + /** + * @type {typeof signatureAlgorithm} + */ + get signatureAlgorithm() { + return signatureAlgorithm3; + } + did() { + return this.verifier.did(); + } + toDIDKey() { + return this.verifier.toDIDKey(); + } + /** + * @template T + * @param {API.ByteView} payload + * @param {API.Signature} signature + */ + verify(payload, signature) { + return this.verifier.verify(payload, signature); + } + /** + * @template T + * @param {API.ByteView} payload + * @returns {Promise>} + */ + async sign(payload) { + const buffer4 = await webcrypto2.subtle.sign( + { name: ALG, saltLength: SALT_LENGTH }, + await this.privateKey, + payload + ); + return create4(signatureCode3, new Uint8Array(buffer4)); + } + }; + var ExtractableRSASigner = class extends RSASigner { + /** + * @param {object} options + * @param {API.Await} options.privateKey + * @param {EncodedSigner} options.bytes + * @param {API.RSAVerifier} options.verifier + */ + constructor(options) { + super(options); + this.bytes = options.bytes; + } + /** + * @template {API.DID} ID + * @param {ID} id + * @returns {API.Signer} + */ + withDID(id) { + return withDID2(this, id); + } + toArchive() { + const id = this.did(); + return { + id, + keys: { [id]: this.bytes } + }; + } + }; + var UnextractableRSASigner = class extends RSASigner { + /** + * @param {object} options + * @param {CryptoKey} options.privateKey + * @param {API.RSAVerifier} options.verifier + */ + constructor(options) { + super(options); + this.privateKey = options.privateKey; + } + /** + * @template {API.DID} ID + * @param {ID} id + * @returns {API.Signer} + */ + withDID(id) { + return withDID2(this, id); + } + toArchive() { + const id = this.did(); + return { + id, + keys: { [id]: this.privateKey } + }; + } + }; + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/absentee.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+principal@8.0.0/node_modules/@ucanto/principal/src/lib.js + var Verifier = verifier_exports.or(RSAVerifier); + var Signer = or7(rsa_exports); + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/delegations.js + init_dirname(); + init_buffer2(); + init_process(); + function isExpired(delegation) { + if (delegation.expiration === void 0 || delegation.expiration <= Math.floor(Date.now() / 1e3)) { + return true; + } + return false; + } + function isTooEarly(delegation) { + if (!delegation.notBefore) { + return false; + } + return delegation.notBefore > Math.floor(Date.now() / 1e3); + } + function validate(delegation, opts) { + const { + checkAudience, + checkIsExpired = true, + checkIsTooEarly = true + } = opts ?? {}; + if (checkAudience && delegation.audience.did() !== checkAudience.did()) { + throw new Error( + `Delegation audience ${delegation.audience.did()} does not match required DID ${checkAudience.did()}` + ); + } + if (checkIsExpired && isExpired(delegation)) { + throw new Error(`Delegation expired.`); + } + if (checkIsTooEarly && isTooEarly(delegation)) { + throw new Error(`Delegation is not active yet (too early).`); + } + } + function canDelegateCapability(delegation, child) { + const allowsCapabilities = delegation_exports.allows(delegation); + if (allowsCapabilities[child.with]) { + const cans = ( + /** @type {import('@ucanto/interface').Ability[]} */ + Object.keys(allowsCapabilities[child.with]) + ); + for (const can of cans) { + if (canDelegateAbility(can, child.can)) { + return true; + } + } + } + return false; + } + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/agent-data.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/provider.js + var provider_exports = {}; + __export(provider_exports, { + AccountDID: () => AccountDID, + Provider: () => Provider, + add: () => add3 + }); + init_dirname(); + init_buffer2(); + init_process(); + var Provider = did_exports2.match({ method: "web" }); + var AccountDID = did_exports2.match({ method: "mailto" }); + var add3 = capability({ + can: "provider/add", + with: AccountDID, + nb: struct({ + provider: Provider, + consumer: did_exports2.match({ method: "key" }) + }), + derives: (child, parent) => { + return and3(equalWith(child, parent)) || and3(equal(child.nb.provider, parent.nb.provider, "provider")) || and3(equal(child.nb.consumer, parent.nb.consumer, "consumer")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/consumer.js + init_dirname(); + init_buffer2(); + init_process(); + var ProviderDID = did_exports2.match({ method: "web" }); + var SpaceDID2 = did_exports2.match({ method: "key" }); + var has = capability({ + can: "consumer/has", + with: ProviderDID, + nb: struct({ + consumer: SpaceDID2 + }), + derives: (child, parent) => { + return and3(equalWith(child, parent)) || and3(equal(child.nb.consumer, parent.nb.consumer, "consumer")) || ok({}); + } + }); + var get2 = capability({ + can: "consumer/get", + with: ProviderDID, + nb: struct({ + consumer: SpaceDID2 + }), + derives: (child, parent) => { + return and3(equalWith(child, parent)) || and3(equal(child.nb.consumer, parent.nb.consumer, "consumer")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/customer.js + init_dirname(); + init_buffer2(); + init_process(); + var ProviderDID2 = did_exports2.match({ method: "web" }); + var AccountDID2 = did_exports2.match({ method: "mailto" }); + var get3 = capability({ + can: "customer/get", + with: ProviderDID2, + nb: struct({ + customer: AccountDID2 + }), + derives: (child, parent) => { + return and3(equalWith(child, parent)) || and3(equal(child.nb.customer, parent.nb.customer, "customer")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/console.js + init_dirname(); + init_buffer2(); + init_process(); + var log2 = capability({ + can: "console/log", + with: schema_exports3.did(), + nb: schema_exports3.struct({ + value: schema_exports3.unknown() + }), + derives: equalWith + }); + var error3 = capability({ + can: "console/error", + with: schema_exports3.did(), + nb: schema_exports3.struct({ + error: schema_exports3.unknown() + }), + derives: equalWith + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/rate-limit.js + init_dirname(); + init_buffer2(); + init_process(); + var Provider2 = did_exports2; + var add4 = capability({ + can: "rate-limit/add", + with: Provider2, + nb: struct({ + subject: schema_exports3.string(), + rate: schema_exports3.number() + }), + derives: (child, parent) => { + return and3(equalWith(child, parent)) || and3(equal(child.nb.subject, parent.nb.subject, "subject")) || and3(equal(child.nb.rate, parent.nb.rate, "rate")) || ok({}); + } + }); + var remove3 = capability({ + can: "rate-limit/remove", + with: Provider2, + nb: struct({ + id: schema_exports3.string() + }), + derives: (child, parent) => { + return and3(equalWith(child, parent)) || and3(equal(child.nb.id, parent.nb.id, "id")) || ok({}); + } + }); + var list3 = capability({ + can: "rate-limit/list", + with: Provider2, + nb: struct({ + subject: schema_exports3.string() + }), + derives: (child, parent) => { + return and3(equalWith(child, parent)) || and3(equal(child.nb.subject, parent.nb.subject, "subject")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/subscription.js + init_dirname(); + init_buffer2(); + init_process(); + var ProviderDID3 = did_exports2.match({ method: "web" }); + var get4 = capability({ + can: "subscription/get", + with: ProviderDID3, + nb: struct({ + subscription: schema_exports3.string() + }), + derives: (child, parent) => { + return and3(equalWith(child, parent)) || and3(equal(child.nb.subscription, parent.nb.subscription, "consumer")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/filecoin.js + init_dirname(); + init_buffer2(); + init_process(); + var FR32_SHA2_256_TRUNC254_PADDED_BINARY_TREE = 4113; + var RAW_CODE = 85; + var PIECE_LINK = schema_exports3.link({ + code: RAW_CODE, + version: 1, + multihash: { + code: FR32_SHA2_256_TRUNC254_PADDED_BINARY_TREE + } + }); + var filecoinAdd = capability({ + can: "filecoin/add", + /** + * did:key identifier of the broker authority where offer is made available. + */ + with: schema_exports3.did(), + nb: schema_exports3.struct({ + /** + * CID of the content that resulted in Filecoin piece. + */ + content: schema_exports3.link(), + /** + * CID of the piece. + * + * @see https://github.com/filecoin-project/FIPs/pull/758/files + */ + piece: ( + /** @type {import('./types').PieceLinkSchema} */ + PIECE_LINK + ) + }), + derives: (claim4, from18) => { + return and3(equalWith(claim4, from18)) || and3(checkLink(claim4.nb.content, from18.nb.content, "nb.content")) || and3(checkLink(claim4.nb.piece, from18.nb.piece, "nb.piece")) || ok({}); + } + }); + var aggregateAdd = capability({ + can: "aggregate/add", + /** + * did:key identifier of the broker authority where offer is made available. + */ + with: schema_exports3.did(), + nb: schema_exports3.struct({ + /** + * CID of the piece. + * + * @see https://github.com/filecoin-project/FIPs/pull/758/files + */ + piece: ( + /** @type {import('./types').PieceLinkSchema} */ + PIECE_LINK + ), + /** + * Storefront requestin piece to be aggregated + */ + storefront: schema_exports3.text(), + /** + * Grouping for the piece to be aggregated + */ + group: schema_exports3.text() + }), + derives: (claim4, from18) => { + return and3(equalWith(claim4, from18)) || and3(checkLink(claim4.nb.piece, from18.nb.piece, "nb.piece")) || and3(equal(claim4.nb.storefront, from18.nb.storefront, "nb.storefront")) || and3(equal(claim4.nb.group, from18.nb.group, "nb.group")) || ok({}); + } + }); + var dealAdd = capability({ + can: "deal/add", + /** + * did:key identifier of the broker authority where offer is made available. + */ + with: schema_exports3.did(), + nb: schema_exports3.struct({ + /** + * CID of the DAG-CBOR encoded block with offer details. + * Service will queue given offer to be validated and handled. + */ + pieces: schema_exports3.link(), + /** + * Commitment proof for the aggregate being offered. + * + * @see https://github.com/filecoin-project/go-state-types/blob/1e6cf0d47cdda75383ef036fc2725d1cf51dbde8/abi/piece.go#L47-L50 + * @see https://github.com/filecoin-project/FIPs/pull/758/files + */ + aggregate: ( + /** @type {import('./types').PieceLinkSchema} */ + PIECE_LINK + ), + /** + * Storefront requesting deal + */ + storefront: schema_exports3.text(), + /** + * arbitrary label to be added to the deal on chain + */ + label: schema_exports3.text().optional() + }), + derives: (claim4, from18) => { + return and3(equalWith(claim4, from18)) || and3(checkLink(claim4.nb.aggregate, from18.nb.aggregate, "nb.aggregate")) || and3(checkLink(claim4.nb.pieces, from18.nb.pieces, "nb.pieces")) || and3(equal(claim4.nb.storefront, from18.nb.storefront, "nb.storefront")) || and3(equal(claim4.nb.label, from18.nb.label, "nb.label")) || ok({}); + } + }); + var chainTrackerInfo = capability({ + can: "chain-tracker/info", + /** + * did:key identifier of the broker authority where offer is made available. + */ + with: schema_exports3.did(), + nb: schema_exports3.struct({ + /** + * CID of the piece. + * + * @see https://github.com/filecoin-project/FIPs/pull/758/files + */ + piece: ( + /** @type {import('./types').PieceLinkSchema} */ + PIECE_LINK + ) + }), + derives: (claim4, from18) => { + return and3(equalWith(claim4, from18)) || and3(checkLink(claim4.nb.piece, from18.nb.piece, "nb.piece")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@9.2.0/node_modules/@web3-storage/capabilities/src/index.js + var abilitiesAsStrings = [ + top.can, + add3.can, + space.can, + info.can, + upload.can, + add2.can, + remove2.can, + list2.can, + store.can, + add.can, + remove.can, + list.can, + access.can, + authorize.can, + session.can, + get3.can, + has.can, + get2.can, + get4.can, + add4.can, + remove3.can, + list3.can, + filecoinAdd.can, + aggregateAdd.can, + dealAdd.can, + chainTrackerInfo.can + ]; + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/agent-data.js + var _save; + var _AgentData = class _AgentData { + /** + * @param {import('./types').AgentDataModel} data + * @param {import('./types').AgentDataOptions} [options] + */ + constructor(data, options = {}) { + /** @type {(data: import('./types').AgentDataExport) => Promise | void} */ + __privateAdd(this, _save, void 0); + this.meta = data.meta; + this.principal = data.principal; + this.spaces = data.spaces; + this.delegations = data.delegations; + this.currentSpace = data.currentSpace; + __privateSet(this, _save, (data2) => options.store ? options.store.save(data2) : void 0); + } + /** + * Create a new AgentData instance from the passed initialization data. + * + * @param {Partial} [init] + * @param {import('./types').AgentDataOptions} [options] + */ + static async create(init3 = {}, options = {}) { + const agentData = new _AgentData( + { + meta: { name: "agent", type: "device", ...init3.meta }, + principal: init3.principal ?? await signer_exports.generate(), + spaces: init3.spaces ?? /* @__PURE__ */ new Map(), + delegations: init3.delegations ?? /* @__PURE__ */ new Map(), + currentSpace: init3.currentSpace + }, + options + ); + if (options.store) { + await options.store.save(agentData.export()); + } + return agentData; + } + /** + * Instantiate AgentData from previously exported data. + * + * @param {import('./types').AgentDataExport} raw + * @param {import('./types').AgentDataOptions} [options] + */ + static fromExport(raw, options) { + const dels = /* @__PURE__ */ new Map(); + for (const [key, value] of raw.delegations) { + dels.set(key, { + delegation: importDAG( + value.delegation.map((d7) => ({ + cid: CID2.parse(d7.cid), + bytes: d7.bytes + })) + ), + meta: value.meta + }); + } + return new _AgentData( + { + meta: raw.meta, + // @ts-expect-error for some reason TS thinks this is a EdSigner + principal: Signer.from(raw.principal), + currentSpace: raw.currentSpace, + spaces: raw.spaces, + delegations: dels + }, + options + ); + } + /** + * Export data in a format safe to pass to `structuredClone()`. + */ + export() { + const raw = { + meta: this.meta, + principal: this.principal.toArchive(), + currentSpace: this.currentSpace, + spaces: this.spaces, + delegations: /* @__PURE__ */ new Map() + }; + for (const [key, value] of this.delegations) { + raw.delegations.set(key, { + meta: value.meta, + delegation: [...value.delegation.export()].map((b6) => ({ + cid: b6.cid.toString(), + bytes: b6.bytes + })) + }); + } + return raw; + } + /** + * @deprecated + * @param {import('@ucanto/interface').DID} did + * @param {import('./types').SpaceMeta} meta + * @param {import('@ucanto/interface').Delegation} [proof] + */ + async addSpace(did3, meta, proof) { + this.spaces.set(did3, meta); + await (proof ? this.addDelegation(proof) : __privateGet(this, _save).call(this, this.export())); + } + /** + * @deprecated + * @param {import('@ucanto/interface').DID<'key'>} did + */ + async setCurrentSpace(did3) { + this.currentSpace = did3; + await __privateGet(this, _save).call(this, this.export()); + } + /** + * @param {import('@ucanto/interface').Delegation} delegation + * @param {import('./types').DelegationMeta} [meta] + */ + async addDelegation(delegation, meta) { + this.delegations.set(delegation.cid.toString(), { + delegation, + meta: meta ?? {} + }); + await __privateGet(this, _save).call(this, this.export()); + } + /** + * @param {import('@ucanto/interface').UCANLink} cid + */ + async removeDelegation(cid) { + this.delegations.delete(cid.toString()); + await __privateGet(this, _save).call(this, this.export()); + } + }; + _save = new WeakMap(); + var AgentData = _AgentData; + var isSessionCapability = (cap) => cap.can === access_exports.session.can; + var isSessionProof = (delegation) => delegation.capabilities.some((cap) => isSessionCapability(cap)); + function getSessionProofs(data) { + const proofs3 = {}; + for (const { delegation } of data.delegations.values()) { + if (isSessionProof(delegation)) { + const cap = delegation.capabilities[0]; + if (cap && !isExpired(delegation)) { + const proof = cap.nb.proof; + if (proof) { + proofs3[proof.toString()] = delegation; + } + } + } + } + return proofs3; + } + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/agent-use-cases.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/utils/ws.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/isomorphic-ws@5.0.0_ws@8.13.0/node_modules/isomorphic-ws/browser.js + init_dirname(); + init_buffer2(); + init_process(); + var ws = null; + if (typeof WebSocket !== "undefined") { + ws = WebSocket; + } else if (typeof MozWebSocket !== "undefined") { + ws = MozWebSocket; + } else if (typeof global !== "undefined") { + ws = global.WebSocket || global.MozWebSocket; + } else if (typeof window !== "undefined") { + ws = window.WebSocket || window.MozWebSocket; + } else if (typeof self !== "undefined") { + ws = self.WebSocket || self.MozWebSocket; + } + + // ../../node_modules/.pnpm/p-wait-for@5.0.0/node_modules/p-wait-for/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/p-timeout@6.1.1/node_modules/p-timeout/index.js + init_dirname(); + init_buffer2(); + init_process(); + var TimeoutError = class extends Error { + constructor(message2) { + super(message2); + this.name = "TimeoutError"; + } + }; + var AbortError = class extends Error { + constructor(message2) { + super(); + this.name = "AbortError"; + this.message = message2; + } + }; + var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new AbortError(errorMessage) : new DOMException(errorMessage); + var getAbortedReason = (signal) => { + const reason = signal.reason === void 0 ? getDOMException("This operation was aborted.") : signal.reason; + return reason instanceof Error ? reason : getDOMException(reason); + }; + function pTimeout(promise, options) { + const { + milliseconds, + fallback, + message: message2, + customTimers = { setTimeout, clearTimeout } + } = options; + let timer; + const cancelablePromise = new Promise((resolve7, reject) => { + if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) { + throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``); + } + if (milliseconds === Number.POSITIVE_INFINITY) { + resolve7(promise); + return; + } + if (options.signal) { + const { signal } = options; + if (signal.aborted) { + reject(getAbortedReason(signal)); + } + signal.addEventListener("abort", () => { + reject(getAbortedReason(signal)); + }); + } + const timeoutError = new TimeoutError(); + timer = customTimers.setTimeout.call(void 0, () => { + if (fallback) { + try { + resolve7(fallback()); + } catch (error7) { + reject(error7); + } + return; + } + if (typeof promise.cancel === "function") { + promise.cancel(); + } + if (message2 === false) { + resolve7(); + } else if (message2 instanceof Error) { + reject(message2); + } else { + timeoutError.message = message2 ?? `Promise timed out after ${milliseconds} milliseconds`; + reject(timeoutError); + } + }, milliseconds); + (async () => { + try { + resolve7(await promise); + } catch (error7) { + reject(error7); + } finally { + customTimers.clearTimeout.call(void 0, timer); + } + })(); + }); + cancelablePromise.clear = () => { + customTimers.clearTimeout.call(void 0, timer); + timer = void 0; + }; + return cancelablePromise; + } + + // ../../node_modules/.pnpm/p-wait-for@5.0.0/node_modules/p-wait-for/index.js + var resolveValue = Symbol("resolveValue"); + async function pWaitFor(condition, options = {}) { + const { + interval = 20, + timeout = Number.POSITIVE_INFINITY, + before = true + } = options; + let retryTimeout; + const promise = new Promise((resolve7, reject) => { + const check = async () => { + try { + const value = await condition(); + if (typeof value === "object" && value[resolveValue]) { + resolve7(value[resolveValue]); + } else if (typeof value !== "boolean") { + throw new TypeError("Expected condition to return a boolean"); + } else if (value === true) { + resolve7(); + } else { + retryTimeout = setTimeout(check, interval); + } + } catch (error7) { + reject(error7); + } + }; + if (before) { + check(); + } else { + retryTimeout = setTimeout(check, interval); + } + }); + if (timeout === Number.POSITIVE_INFINITY) { + return promise; + } + try { + return await pTimeout(promise, typeof timeout === "number" ? { milliseconds: timeout } : timeout); + } finally { + clearTimeout(retryTimeout); + } + } + pWaitFor.resolveWith = (value) => ({ [resolveValue]: value }); + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/utils/ws.js + var AbortError2 = class _AbortError extends Error { + /** + * @param {string} message + * @param {ErrorOptions} [opts] + */ + constructor(message2, opts) { + super(message2, opts); + this.name = "AbortError"; + this.message = message2; + this.code = _AbortError.code; + } + }; + AbortError2.code = "ERR_AWAIT_MSG_CANCEL"; + + // ../../node_modules/.pnpm/@web3-storage+did-mailto@2.0.0/node_modules/@web3-storage/did-mailto/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + function fromEmail(email2) { + const { domain, local } = parseEmail(email2); + const did3 = ( + /** @type {const} */ + `did:mailto:${encodeURIComponent(domain)}:${encodeURIComponent(local)}` + ); + return did3; + } + function email(input) { + const { domain, local } = parseEmail(input); + const emailAddress = `${local}@${domain}`; + return emailAddress; + } + function parseEmail(email2) { + const atParts = email2.split("@"); + if (atParts.length < 2) { + throw new TypeError( + `expected at least 2 @-delimtied segments, but got ${atParts.length}` + ); + } + const domain = atParts.at(-1) ?? ""; + const local = atParts.slice(0, -1).join("@"); + return { domain, local }; + } + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/agent-use-cases.js + async function requestAccess(access5, account, capabilities) { + const res = await access5.invokeAndExecute(authorize, { + audience: access5.connection.id, + with: access5.issuer.did(), + nb: { + iss: account.did(), + att: [...capabilities] + } + }); + if (res?.out.error) { + throw res.out.error; + } + } + async function claimAccess(access5, audienceOfClaimedDelegations = access5.connection.id.did(), { addProofs = false } = {}) { + const res = await access5.invokeAndExecute(claim, { + audience: access5.connection.id, + with: audienceOfClaimedDelegations + }); + if (res.out.error) { + throw res.out.error; + } + const delegations = Object.values(res.out.ok.delegations).flatMap( + (bytes2) => bytesToDelegations(bytes2) + ); + if (addProofs) { + for (const d7 of delegations) { + await access5.addProof(d7); + } + await addSpacesFromDelegations(access5, delegations); + } + return delegations; + } + async function addProvider({ access: access5, space: space3, account, provider }) { + const result = await access5.invokeAndExecute(provider_exports.add, { + audience: access5.connection.id, + with: account.did(), + nb: { + provider, + consumer: space3 + } + }); + if (result.out.error) { + throw result.out.error; + } + } + function delegationsIncludeSessionProof(delegations) { + return delegations.some((d7) => isSessionProof(d7)); + } + async function pollAccessClaimUntil(delegationsMatch, access5, delegee, opts) { + const interval = opts?.interval || 250; + while (true) { + if (opts?.signal?.aborted) + throw opts.signal.reason ?? new Error("operation aborted"); + const res = await access5.invokeAndExecute(access_exports.claim, { + with: delegee + }); + if (res.out.error) + throw res.out.error; + const claims = Object.values(res.out.ok.delegations).flatMap( + (d7) => bytesToDelegations(d7) + ); + if (delegationsMatch(claims)) + return claims; + await new Promise((resolve7) => setTimeout(resolve7, interval)); + } + } + async function waitForAuthorizationByPolling(access5, opts = {}) { + const claimed = await pollAccessClaimUntil( + delegationsIncludeSessionProof, + access5, + access5.issuer.did(), + { + signal: opts?.signal, + interval: opts?.interval + } + ); + return [...claimed]; + } + async function authorizeAndWait(access5, email2, opts = {}) { + const expectAuthorization = opts.expectAuthorization || waitForAuthorizationByPolling; + const account = { did: () => fromEmail(email2) }; + await requestAccess( + access5, + account, + opts?.capabilities || [ + { can: "space/*" }, + { can: "store/*" }, + { can: "provider/add" }, + { can: "upload/*" } + ] + ); + const sessionDelegations = [...await expectAuthorization(access5, opts)]; + if (!opts?.dontAddProofs) { + await Promise.all(sessionDelegations.map(async (d7) => access5.addProof(d7))); + } + } + async function authorizeWaitAndClaim(accessAgent, email2, opts) { + await authorizeAndWait(accessAgent, email2, opts); + await claimAccess(accessAgent, accessAgent.issuer.did(), { + addProofs: opts?.addProofs ?? true + }); + } + async function addProviderAndDelegateToAccount(access5, agentData, email2, opts) { + const space3 = opts?.space || access5.currentSpace(); + const spaceMeta = space3 ? agentData.spaces.get(space3) : void 0; + const provider = opts?.provider || (() => { + const service = access5.connection.id.did(); + if (did_exports2.match({ method: "web" }).is(service)) { + return service; + } + throw new Error( + `unable to determine provider to use to addProviderAndDelegateToAccount using access.connection.id did ${service}. expected a did:web:` + ); + })(); + if (!space3 || !spaceMeta) { + throw new Error("No space selected"); + } + if (spaceMeta && spaceMeta.isRegistered) { + throw new Error("Space already registered with web3.storage."); + } + const account = { did: () => fromEmail(email(email2)) }; + await addProvider({ access: access5, space: space3, account, provider }); + const delegateSpaceAccessResult = await delegateSpaceAccessToAccount( + access5, + space3, + account + ); + if (delegateSpaceAccessResult.out.error) { + throw delegateSpaceAccessResult.out.error; + } + spaceMeta.isRegistered = true; + await agentData.addSpace(space3, spaceMeta); + } + async function delegateSpaceAccessToAccount(access5, space3, account) { + const issuerSaysAccountCanAdminSpace = await createIssuerSaysAccountCanAdminSpace( + access5.issuer, + space3, + account, + void 0, + access5.proofs([{ with: space3, can: "*" }]), + // we want to sign over control of this space forever + Infinity + ); + return access5.invokeAndExecute(delegate3, { + audience: access5.connection.id, + with: space3, + expiration: Infinity, + nb: { + delegations: { + [issuerSaysAccountCanAdminSpace.cid.toString()]: issuerSaysAccountCanAdminSpace.cid + } + }, + proofs: [ + // must be embedded here because it's referenced by cid in .nb.delegations + issuerSaysAccountCanAdminSpace + ] + }); + } + async function createIssuerSaysAccountCanAdminSpace(issuer, space3, account, capabilities = [ + { + can: "*", + with: space3 + } + ], proofs3 = [], expiration) { + return delegate({ + issuer, + audience: account, + capabilities, + proofs: proofs3, + expiration + }); + } + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/agent.js + var HOST = "https://up.web3.storage"; + var PRINCIPAL = did_exports.parse("did:web:web3.storage"); + var agentToData = /* @__PURE__ */ new WeakMap(); + function connection(options = {}) { + return connect({ + id: options.principal ?? PRINCIPAL, + codec: outbound2, + channel: options.channel ?? open({ + url: options.url ?? new URL(HOST), + method: "POST", + fetch: options.fetch ?? globalThis.fetch.bind(globalThis) + }) + }); + } + var _data, _delegations, delegations_fn; + var _Agent = class _Agent { + /** + * @param {import('./agent-data').AgentData} data - Agent data + * @param {import('./types').AgentOptions} [options] + */ + constructor(data, options = {}) { + /** + * Query the delegations store for all the delegations matching the capabilities provided. + * + * @param {import('@ucanto/interface').Capability[]} [caps] + */ + __privateAdd(this, _delegations); + /** @type {import('./agent-data').AgentData} */ + __privateAdd(this, _data, void 0); + const channel = options.connection?.channel; + this.url = options.url ?? channel?.url ?? new URL(HOST); + this.connection = options.connection ?? connection({ + principal: options.servicePrincipal, + url: this.url + }); + __privateSet(this, _data, data); + agentToData.set(this, __privateGet(this, _data)); + } + /** + * Create a new Agent instance, optionally with the passed initialization data. + * + * @param {Partial} [init] + * @param {import('./types').AgentOptions & import('./types').AgentDataOptions} [options] + */ + static async create(init3, options = {}) { + const data = await AgentData.create(init3, options); + return new _Agent(data, options); + } + /** + * Instantiate an Agent from pre-exported agent data. + * + * @param {import('./types').AgentDataExport} raw + * @param {import('./types').AgentOptions & import('./types').AgentDataOptions} [options] + */ + static from(raw, options = {}) { + const data = AgentData.fromExport(raw, options); + return new _Agent(data, options); + } + get issuer() { + return __privateGet(this, _data).principal; + } + get meta() { + return __privateGet(this, _data).meta; + } + get spaces() { + return __privateGet(this, _data).spaces; + } + did() { + return __privateGet(this, _data).principal.did(); + } + /** + * Add a proof to the agent store + * + * A proof is a delegation with an audience matching agent DID + * + * @param {Ucanto.Delegation} delegation + */ + async addProof(delegation) { + validate(delegation, { + checkAudience: this.issuer, + checkIsExpired: true + }); + await __privateGet(this, _data).addDelegation(delegation, { audience: this.meta }); + await this.removeExpiredDelegations(); + } + /** + * Clean up any expired delegations. + */ + async removeExpiredDelegations() { + for (const [, value] of __privateGet(this, _data).delegations) { + if (isExpired(value.delegation)) { + await __privateGet(this, _data).removeDelegation(value.delegation.cid); + } + } + } + /** + * Get all the proofs matching the capabilities. + * + * Proofs are delegations with an audience matching agent DID, or with an + * audience matching the session DID. + * + * Proof of session will also be included in the returned proofs if any + * proofs matching the passed capabilities require it. + * + * @param {import('@ucanto/interface').Capability[]} [caps] - Capabilities to filter by. Empty or undefined caps with return all the proofs. + */ + proofs(caps) { + const arr = []; + for (const { delegation } of __privateMethod(this, _delegations, delegations_fn).call(this, caps)) { + if (delegation.audience.did() === this.issuer.did()) { + arr.push(delegation); + } + } + const sessions = getSessionProofs(__privateGet(this, _data)); + for (const proof of arr) { + const session3 = sessions[proof.asCID.toString()]; + if (session3) { + arr.push(session3); + } + } + return arr; + } + /** + * Get delegations created by the agent for others. + * + * @param {import('@ucanto/interface').Capability[]} [caps] - Capabilities to filter by. Empty or undefined caps with return all the delegations. + */ + delegations(caps) { + const arr = []; + for (const { delegation } of this.delegationsWithMeta(caps)) { + arr.push(delegation); + } + return arr; + } + /** + * Get delegations created by the agent for others and their metadata. + * + * @param {import('@ucanto/interface').Capability[]} [caps] - Capabilities to filter by. Empty or undefined caps with return all the delegations. + */ + delegationsWithMeta(caps) { + const arr = []; + for (const value of __privateMethod(this, _delegations, delegations_fn).call(this, caps)) { + const { delegation } = value; + const isSession = delegation.capabilities.some( + (c8) => c8.can === session.can + ); + if (!isSession && delegation.audience.did() !== this.issuer.did()) { + arr.push(value); + } + } + return arr; + } + /** + * Creates a space signer and a delegation to the agent + * + * @param {string} [name] + */ + async createSpace(name15, delegations = []) { + const signer = await signer_exports.generate(); + delegations = [{ + // issuer: signer, + audience: this.issuer + // with: signer.did(), + // expiration: Infinity, + }, ...delegations]; + const proofs3 = await Promise.all(delegations.map(async (d7) => { + d7.issuer = signer; + d7.with = signer.did(); + d7.expiration = Infinity; + return await top.delegate(d7); + })); + const meta = { isRegistered: false }; + if (name15 != void 0) { + if (typeof name15 !== "string") { + throw new TypeError("invalid name"); + } + meta.name = name15; + } + await __privateGet(this, _data).addSpace(signer.did(), meta, proofs3[0]); + await __privateGet(this, _data).addDelegation(proofs3[1]); + return { + did: signer.did(), + meta, + proof: proofs3[0] + }; + } + /** + * Import a space from a delegation. + * + * @param {Ucanto.Delegation} delegation + */ + async importSpaceFromDelegation(delegation) { + const meta = ( + /** @type {import('./types').SpaceMeta} */ + delegation.facts[0]?.space ?? { isRegistered: false } + ); + const did3 = Verifier.parse(delegation.capabilities[0].with).did(); + __privateGet(this, _data).spaces.set(did3, meta); + await this.addProof(delegation); + return { + did: did3, + meta, + proof: delegation + }; + } + /** + * Sets the current selected space + * + * Other methods will default to use the current space if no resource is defined + * + * @param {Ucanto.DID<'key'>} space + */ + async setCurrentSpace(space3) { + if (!__privateGet(this, _data).spaces.has(space3)) { + throw new Error(`Agent has no proofs for ${space3}.`); + } + await __privateGet(this, _data).setCurrentSpace(space3); + return space3; + } + /** + * Get current space DID + */ + currentSpace() { + return __privateGet(this, _data).currentSpace; + } + /** + * Get current space DID, proofs and abilities + */ + currentSpaceWithMeta() { + if (!__privateGet(this, _data).currentSpace) { + return; + } + const proofs3 = this.proofs([ + { + can: "space/info", + with: __privateGet(this, _data).currentSpace + } + ]); + const caps = /* @__PURE__ */ new Set(); + for (const p8 of proofs3) { + for (const cap of p8.capabilities) { + caps.add(cap.can); + } + } + return { + did: __privateGet(this, _data).currentSpace, + proofs: proofs3, + capabilities: [...caps], + meta: __privateGet(this, _data).spaces.get(__privateGet(this, _data).currentSpace) + }; + } + /** + * Requests a subscription from a provider and attaches it to a space. + * + * It also adds a full space delegation to the service that can later + * be claimed by the currently authorized account to restore access to the space. + * + * @param {string} email + * @param {object} [opts] + * @param {AbortSignal} [opts.signal] + * @param {Ucanto.DID<'key'>} [opts.space] - space to register + * @param {Ucanto.DID<'web'>} [opts.provider] - provider to register - defaults to this.connection.id + */ + async registerSpace(email2, opts = {}) { + return await addProviderAndDelegateToAccount(this, __privateGet(this, _data), email2, opts); + } + /** + * + * @param {import('./types').DelegationOptions} options + */ + async delegate(options) { + const space3 = this.currentSpaceWithMeta(); + if (!space3) { + throw new Error("no space selected."); + } + const caps = ( + /** @type {Ucanto.Capabilities} */ + options.abilities.map((a8) => { + return { + with: space3.did, + can: a8 + }; + }) + ); + for (const cap of caps) { + if (!this.proofs([cap]).length) { + throw new Error( + `cannot delegate capability ${cap.can} with ${cap.with}` + ); + } + } + const delegation = await delegate({ + issuer: this.issuer, + capabilities: caps, + proofs: this.proofs(caps), + facts: [{ space: space3.meta ?? {} }], + ...options + }); + await __privateGet(this, _data).addDelegation(delegation, { + audience: options.audienceMeta + }); + await this.removeExpiredDelegations(); + return delegation; + } + /** + * Invoke and execute the given capability on the Access service connection + * + * ```js + * + * await agent.invokeAndExecute(Space.recover, { + * nb: { + * identity: 'mailto: email@gmail.com', + * }, + * }) + * + * // sugar for + * const recoverInvocation = await agent.invoke(Space.recover, { + * nb: { + * identity: 'mailto: email@gmail.com', + * }, + * }) + * + * await recoverInvocation.execute(agent.connection) + * ``` + * + * @template {Ucanto.Ability} A + * @template {Ucanto.URI} R + * @template {Ucanto.Caveats} C + * @param {Ucanto.TheCapabilityParser>} cap + * @param {import('./types').InvokeOptions>>} options + * @returns {Promise, import('./types').Service>>} + */ + async invokeAndExecute(cap, options) { + const inv = await this.invoke(cap, options); + const out = inv.execute( + /** @type {*} */ + this.connection + ); + return ( + /** @type {*} */ + out + ); + } + /** + * Execute invocations on the agent's connection + * + * @example + * ```js + * const i1 = await agent.invoke(Space.info, {}) + * const i2 = await agent.invoke(Space.recover, { + * nb: { + * identity: 'mailto:hello@web3.storage', + * }, + * }) + * + * const results = await agent.execute2(i1, i2) + * + * ``` + * @template {Ucanto.Capability} C + * @template {Ucanto.Tuple>} I + * @param {I} invocations + */ + execute(...invocations) { + return this.connection.execute(...invocations); + } + /** + * Creates an invocation for the given capability with Agent's proofs, service, issuer and space. + * + * @example + * ```js + * const recoverInvocation = await agent.invoke(Space.recover, { + * nb: { + * identity: 'mailto: email@gmail.com', + * }, + * }) + * + * await recoverInvocation.execute(agent.connection) + * // or + * await agent.execute(recoverInvocation) + * ``` + * + * @template {Ucanto.Ability} A + * @template {Ucanto.URI} R + * @template {Ucanto.TheCapabilityParser>} CAP + * @template {Ucanto.Caveats} [C={}] + * @param {CAP} cap + * @param {import('./types').InvokeOptions} options + */ + async invoke(cap, options) { + const space3 = options.with || this.currentSpace(); + if (!space3) { + throw new Error( + "No space or resource selected, you need pass a resource." + ); + } + const proofs3 = [ + ...options.proofs || [], + ...this.proofs([ + { + with: space3, + can: cap.can + } + ]) + ]; + if (proofs3.length === 0 && options.with !== this.did()) { + throw new Error( + `no proofs available for resource ${space3} and ability ${cap.can}` + ); + } + const inv = invoke({ + ...options, + audience: options.audience || this.connection.id, + // @ts-ignore + capability: cap.create({ + with: space3, + nb: options.nb + }), + issuer: this.issuer, + proofs: [...proofs3] + }); + return ( + /** @type {Ucanto.IssuedInvocationView>} */ + inv + ); + } + /** + * + * @param {import('../src/awake/types').Channel} channel + */ + peer(channel) { + return new Peer({ agent: this, channel }); + } + /** + * Get Space information from Access service + * + * @param {Ucanto.URI<"did:">} [space] + */ + async getSpaceInfo(space3) { + const _space = space3 || this.currentSpace(); + if (!_space) { + throw new Error("No space selected, you need pass a resource."); + } + const inv = await this.invokeAndExecute(info, { + with: _space + }); + if (inv.out.error) { + throw inv.out.error; + } + return inv.out.ok; + } + }; + _data = new WeakMap(); + _delegations = new WeakSet(); + delegations_fn = function(caps) { + const _caps = new Set(caps); + const values2 = []; + for (const [, value] of __privateGet(this, _data).delegations) { + if (!isExpired(value.delegation) && // check if delegation can be used + !isTooEarly(value.delegation)) { + if (Array.isArray(caps) && caps.length > 0) { + for (const cap of _caps) { + if (canDelegateCapability(value.delegation, cap)) { + _caps.delete(cap); + values2.push(value); + } + } + } else { + values2.push(value); + } + } + } + return values2; + }; + var Agent = _Agent; + async function addSpacesFromDelegations(access5, delegations) { + const data = agentToData.get(access5); + if (!data) { + throw Object.assign(new Error(`cannot determine AgentData for Agent`), { + agent: access5 + }); + } + if (delegations.length > 0) { + const allows3 = delegation_exports.allows( + delegations[0], + ...delegations.slice(1) + ); + for (const [did3, value] of Object.entries(allows3)) { + if (did3.startsWith("did:key") && value["space/*"]) { + data.addSpace( + /** @type {Ucanto.DID} */ + did3, + { + isRegistered: true + } + ); + } + } + } + } + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/stores/store-indexeddb.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/drivers/indexeddb.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/p-defer@4.0.0/node_modules/p-defer/index.js + init_dirname(); + init_buffer2(); + init_process(); + function pDefer() { + const deferred = {}; + deferred.promise = new Promise((resolve7, reject) => { + deferred.resolve = resolve7; + deferred.reject = reject; + }); + return deferred; + } + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/drivers/indexeddb.js + var STORE_NAME = "AccessStore"; + var DATA_ID = 1; + var _dbName, _dbVersion, _dbStoreName, _db, _autoOpen, _getOpenDB, getOpenDB_fn; + var IndexedDBDriver = class { + /** + * @param {string} dbName + * @param {object} [options] + * @param {number} [options.dbVersion] + * @param {string} [options.dbStoreName] + * @param {boolean} [options.autoOpen] + */ + constructor(dbName, options = {}) { + /** @returns {Promise} */ + __privateAdd(this, _getOpenDB); + /** @type {string} */ + __privateAdd(this, _dbName, void 0); + /** @type {number|undefined} */ + __privateAdd(this, _dbVersion, void 0); + /** @type {string} */ + __privateAdd(this, _dbStoreName, void 0); + /** @type {IDBDatabase|undefined} */ + __privateAdd(this, _db, void 0); + /** @type {boolean} */ + __privateAdd(this, _autoOpen, void 0); + __privateSet(this, _dbName, dbName); + __privateSet(this, _dbVersion, options.dbVersion); + __privateSet(this, _dbStoreName, options.dbStoreName ?? STORE_NAME); + __privateSet(this, _autoOpen, options.autoOpen ?? true); + } + async open() { + const db = __privateGet(this, _db); + if (db) + return; + const { resolve: resolve7, reject, promise } = pDefer(); + const openReq = indexedDB.open(__privateGet(this, _dbName), __privateGet(this, _dbVersion)); + openReq.addEventListener("upgradeneeded", () => { + const db2 = openReq.result; + db2.createObjectStore(__privateGet(this, _dbStoreName), { keyPath: "id" }); + }); + openReq.addEventListener("success", () => { + __privateSet(this, _db, openReq.result); + resolve7(); + }); + openReq.addEventListener("error", () => reject(openReq.error)); + return promise; + } + async close() { + const db = __privateGet(this, _db); + if (!db) + throw new Error("Store is not open"); + db.close(); + __privateSet(this, _db, void 0); + } + /** @param {T} data */ + async save(data) { + const db = await __privateMethod(this, _getOpenDB, getOpenDB_fn).call(this); + const putData = withObjectStore( + db, + "readwrite", + __privateGet(this, _dbStoreName), + async (store4) => { + const { resolve: resolve7, reject, promise } = pDefer(); + const putReq = store4.put({ id: DATA_ID, ...data }); + putReq.addEventListener("success", () => resolve7()); + putReq.addEventListener( + "error", + () => reject(new Error("failed to query DB", { cause: putReq.error })) + ); + return promise; + } + ); + return await putData(); + } + async load() { + const db = await __privateMethod(this, _getOpenDB, getOpenDB_fn).call(this); + const getData = withObjectStore( + db, + "readonly", + __privateGet(this, _dbStoreName), + async (store4) => { + const { resolve: resolve7, reject, promise } = pDefer(); + const getReq = store4.get(DATA_ID); + getReq.addEventListener("success", () => resolve7(getReq.result)); + getReq.addEventListener( + "error", + () => reject(new Error("failed to query DB", { cause: getReq.error })) + ); + return promise; + } + ); + return await getData(); + } + async reset() { + const db = await __privateMethod(this, _getOpenDB, getOpenDB_fn).call(this); + withObjectStore(db, "readwrite", __privateGet(this, _dbStoreName), (s7) => { + const { resolve: resolve7, reject, promise } = pDefer(); + const req = s7.clear(); + req.addEventListener("success", () => { + resolve7(); + }); + req.addEventListener( + "error", + () => reject(new Error("failed to query DB", { cause: req.error })) + ); + return promise; + }); + } + }; + _dbName = new WeakMap(); + _dbVersion = new WeakMap(); + _dbStoreName = new WeakMap(); + _db = new WeakMap(); + _autoOpen = new WeakMap(); + _getOpenDB = new WeakSet(); + getOpenDB_fn = async function() { + if (!__privateGet(this, _db)) { + if (!__privateGet(this, _autoOpen)) + throw new Error("Store is not open"); + await this.open(); + } + return __privateGet(this, _db); + }; + function withObjectStore(db, txnMode, storeName, fn) { + return async () => { + const tx = db.transaction(storeName, txnMode); + const { resolve: resolve7, reject, promise } = pDefer(); + let result; + tx.addEventListener("complete", () => resolve7(result)); + tx.addEventListener( + "abort", + () => reject(tx.error || new Error("transaction aborted")) + ); + tx.addEventListener( + "error", + () => reject(new Error("transaction error", { cause: tx.error })) + ); + try { + result = await fn(tx.objectStore(storeName)); + tx.commit(); + } catch (error7) { + reject(error7); + tx.abort(); + } + return promise; + }; + } + + // ../../node_modules/.pnpm/@web3-storage+access@15.1.1/node_modules/@web3-storage/access/src/stores/store-indexeddb.js + var StoreIndexedDB = class extends IndexedDBDriver { + }; + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/client.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/store.js + var store_exports2 = {}; + __export(store_exports2, { + add: () => add6, + list: () => list5, + remove: () => remove5 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/utf8.js + init_dirname(); + init_buffer2(); + init_process(); + var encoder2 = new TextEncoder(); + var decoder2 = new TextDecoder(); + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/legacy.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/legacy/response.js + var response_exports2 = {}; + __export(response_exports2, { + contentType: () => contentType6, + encode: () => encode27 + }); + init_dirname(); + init_buffer2(); + init_process(); + var contentType6 = "application/cbor"; + var HEADERS3 = Object.freeze({ + "content-type": contentType6 + }); + var encode27 = (message2, options) => { + const legacyResults = []; + for (const receipt of message2.receipts.values()) { + const result = receipt.out; + if (result.ok) { + legacyResults.push(result.ok); + } else { + legacyResults.push({ + ...result.error, + error: true + }); + } + } + const body = encode16(legacyResults); + return ( + /** @type {API.HTTPResponse} */ + { + headers: HEADERS3, + body + } + ); + }; + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/legacy/request.js + var request_exports2 = {}; + __export(request_exports2, { + contentType: () => contentType7, + decode: () => decode34 + }); + init_dirname(); + init_buffer2(); + init_process(); + var contentType7 = "application/car"; + var decode34 = async ({ body }) => { + const { roots, blocks } = decode21( + /** @type {Uint8Array} */ + body + ); + const run = []; + for (const { cid } of roots) { + const invocation = invocation_exports.view({ + root: ( + /** @type {API.Link} */ + cid + ), + blocks + }); + run.push(invocation); + } + const message2 = await message_exports.build({ + invocations: ( + /** @type {API.Tuple} */ + run + ) + }); + return ( + /** @type {Message} */ + message2 + ); + }; + + // ../../node_modules/.pnpm/@ucanto+transport@8.0.0/node_modules/@ucanto/transport/src/legacy.js + var { contentType: contentType8 } = request_exports2; + var inbound3 = inbound({ + decoders: { + [contentType8]: request_exports2, + [contentType5]: request_exports + }, + encoders: { + // Here we configure encoders such that if accept header is `*/*` (which is + // the default if omitted) we will encode the response in CBOR. If + // `application/vnd.ipld.car` is set we will encode the response in current + // format. + // Here we exploit the fact that legacy clients do not send an accept header + // and therefore will get response in legacy format. New clients on the other + // hand will send `application/vnd.ipld.car` and consequently get response + // in current format. + "*/*;q=0.1": response_exports2, + [contentType5]: response_exports + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@6.0.1/node_modules/@web3-storage/capabilities/src/store.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@6.0.1/node_modules/@web3-storage/capabilities/src/utils.js + init_dirname(); + init_buffer2(); + init_process(); + function equalWith2(child, parent) { + return child.with === parent.with ? ok({}) : fail2(`Can not derive ${child.can} with ${child.with} from ${parent.with}`); + } + function equal2(child, parent, constraint) { + if (parent === void 0 || parent === "*") { + return ok({}); + } else if (String(child) === String(parent)) { + return ok({}); + } else { + return fail2( + `Constrain violation: ${child} violates imposed ${constraint} constraint ${parent}` + ); + } + } + var equalLink2 = (claimed, delegated) => { + if (claimed.with !== delegated.with) { + return fail2( + `Expected 'with: "${delegated.with}"' instead got '${claimed.with}'` + ); + } else if (delegated.nb.link && `${delegated.nb.link}` !== `${claimed.nb.link}`) { + return fail2( + `Link ${claimed.nb.link ? `${claimed.nb.link}` : ""} violates imposed ${delegated.nb.link} constraint.` + ); + } else { + return ok({}); + } + }; + var and4 = (result) => result.error ? result : void 0; + + // ../../node_modules/.pnpm/@web3-storage+capabilities@6.0.1/node_modules/@web3-storage/capabilities/src/store.js + var store2 = capability({ + can: "store/*", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + derives: equalWith2 + }); + var add5 = capability({ + can: "store/add", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * CID of the CAR file to be stored. Service will provision write target + * for this exact CAR file for agent to PUT or POST it. Attempt to write + * any other content will fail. + */ + link: link_exports2, + /** + * Size of the CAR file to be stored. Service will provision write target + * for this exact size. Attempt to write a larger CAR file will fail. + */ + size: schema_exports3.integer(), + /** + * Agent may optionally provide a link to a related CAR file using `origin` + * field. This is useful when storing large DAGs, agent could shard it + * across multiple CAR files and then link each shard with a previous one. + * + * Providing this relation tells service that given CAR is shard of the + * larger DAG as opposed to it being intentionally partial DAG. When DAG is + * not sharded, there will be only one `store/add` with `origin` left out. + */ + origin: link_exports2.optional() + }), + derives: (claim4, from18) => { + const result = equalLink2(claim4, from18); + if (result.error) { + return result; + } else if (claim4.nb.size !== void 0 && from18.nb.size !== void 0) { + return claim4.nb.size > from18.nb.size ? fail2(`Size constraint violation: ${claim4.nb.size} > ${from18.nb.size}`) : ok({}); + } else { + return ok({}); + } + } + }); + var remove4 = capability({ + can: "store/remove", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * CID of the CAR file to be removed from the store. + */ + link: link_exports2 + }), + derives: equalLink2 + }); + var list4 = capability({ + can: "store/list", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * A pointer that can be moved back and forth on the list. + * It can be used to paginate a list for instance. + */ + cursor: schema_exports3.string().optional(), + /** + * Maximum number of items per page. + */ + size: schema_exports3.integer().optional(), + /** + * If true, return page of results preceding cursor. Defaults to false. + */ + pre: schema_exports3.boolean().optional() + }), + derives: (claimed, delegated) => { + if (claimed.with !== delegated.with) { + return fail2( + `Expected 'with: "${delegated.with}"' instead got '${claimed.with}'` + ); + } + return ok({}); + } + }); + var all3 = add5.or(remove4).or(list4); + + // ../../node_modules/.pnpm/p-retry@5.1.2/node_modules/p-retry/index.js + init_dirname(); + init_buffer2(); + init_process(); + var import_retry = __toESM(require_retry2(), 1); + var networkErrorMsgs = /* @__PURE__ */ new Set([ + "Failed to fetch", + // Chrome + "NetworkError when attempting to fetch resource.", + // Firefox + "The Internet connection appears to be offline.", + // Safari + "Network request failed", + // `cross-fetch` + "fetch failed" + // Undici (Node.js) + ]); + var AbortError3 = class extends Error { + constructor(message2) { + super(); + if (message2 instanceof Error) { + this.originalError = message2; + ({ message: message2 } = message2); + } else { + this.originalError = new Error(message2); + this.originalError.stack = this.stack; + } + this.name = "AbortError"; + this.message = message2; + } + }; + var decorateErrorWithCounts = (error7, attemptNumber, options) => { + const retriesLeft = options.retries - (attemptNumber - 1); + error7.attemptNumber = attemptNumber; + error7.retriesLeft = retriesLeft; + return error7; + }; + var isNetworkError = (errorMessage) => networkErrorMsgs.has(errorMessage); + var getDOMException2 = (errorMessage) => globalThis.DOMException === void 0 ? new Error(errorMessage) : new DOMException(errorMessage); + async function pRetry(input, options) { + return new Promise((resolve7, reject) => { + options = { + onFailedAttempt() { + }, + retries: 10, + ...options + }; + const operation = import_retry.default.operation(options); + operation.attempt(async (attemptNumber) => { + try { + resolve7(await input(attemptNumber)); + } catch (error7) { + if (!(error7 instanceof Error)) { + reject(new TypeError(`Non-error was thrown: "${error7}". You should only throw errors.`)); + return; + } + if (error7 instanceof AbortError3) { + operation.stop(); + reject(error7.originalError); + } else if (error7 instanceof TypeError && !isNetworkError(error7.message)) { + operation.stop(); + reject(error7); + } else { + decorateErrorWithCounts(error7, attemptNumber, options); + try { + await options.onFailedAttempt(error7); + } catch (error8) { + reject(error8); + return; + } + if (!operation.retry(error7)) { + reject(operation.mainError()); + } + } + } + }); + if (options.signal && !options.signal.aborted) { + options.signal.addEventListener("abort", () => { + operation.stop(); + const reason = options.signal.reason === void 0 ? getDOMException2("The operation was aborted.") : options.signal.reason; + reject(reason instanceof Error ? reason : getDOMException2(reason)); + }, { + once: true + }); + } + }); + } + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/service.js + init_dirname(); + init_buffer2(); + init_process(); + var serviceURL = new URL("https://up.web3.storage"); + var servicePrincipal = parse2("did:web:web3.storage"); + var connection2 = connect({ + id: servicePrincipal, + codec: car_exports2.outbound, + channel: http_exports.open({ + url: serviceURL, + method: "POST" + }) + }); + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/constants.js + init_dirname(); + init_buffer2(); + init_process(); + var REQUEST_RETRIES = 3; + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/store.js + var import_fetch = __toESM(require_fetch_browser2(), 1); + var { fetch: fetch3 } = import_fetch.default; + function createUploadProgressHandler(url, handler) { + function onUploadProgress({ total, loaded, lengthComputable }) { + return handler({ total, loaded, lengthComputable, url }); + } + return onUploadProgress; + } + async function add6({ issuer, with: resource, proofs: proofs3, audience }, car, options = {}) { + const bytes2 = new Uint8Array(await car.arrayBuffer()); + const link10 = await car_exports2.codec.link(bytes2); + const conn = options.connection ?? connection2; + const result = await pRetry( + async () => { + return await add5.invoke({ + issuer, + /* c8 ignore next */ + audience: audience ?? servicePrincipal, + with: resource, + nb: { link: link10, size: car.size }, + proofs: proofs3 + }).execute(conn); + }, + { + onFailedAttempt: console.warn, + retries: options.retries ?? REQUEST_RETRIES + } + ); + if (!result.out.ok) { + throw new Error(`failed ${add5.can} invocation`, { + cause: result.out.error + }); + } + if (result.out.ok.status === "done") { + return link10; + } + const responseAddUpload = result.out.ok; + const fetchWithUploadProgress = ( + /** @type {(url: string, init?: import('./types').FetchOptions) => Promise} */ + fetch3 + ); + const res = await pRetry( + async () => { + try { + const res2 = await fetchWithUploadProgress(responseAddUpload.url, { + method: "PUT", + mode: "cors", + body: car, + headers: responseAddUpload.headers, + signal: options.signal, + onUploadProgress: options.onUploadProgress ? createUploadProgressHandler( + responseAddUpload.url, + options.onUploadProgress + ) : void 0, + // @ts-expect-error - this is needed by recent versions of node - see https://github.com/bluesky-social/atproto/pull/470 for more info + duplex: "half" + }); + if (res2.status >= 400 && res2.status < 500) { + throw new AbortError3(`upload failed: ${res2.status}`); + } + return res2; + } catch (err) { + if (options.signal?.aborted === true) { + throw new AbortError3("upload aborted"); + } + throw err; + } + }, + { + onFailedAttempt: console.warn, + retries: options.retries ?? REQUEST_RETRIES + } + ); + if (!res.ok) { + throw new Error(`upload failed: ${res.status}`); + } + return link10; + } + async function list5({ issuer, with: resource, proofs: proofs3, audience }, options = {}) { + const conn = options.connection ?? connection2; + const result = await list4.invoke({ + issuer, + /* c8 ignore next */ + audience: audience ?? servicePrincipal, + with: resource, + proofs: proofs3, + nb: { + cursor: options.cursor, + size: options.size, + pre: options.pre + } + }).execute(conn); + if (!result.out.ok) { + throw new Error(`failed ${list4.can} invocation`, { + cause: result.out.error + }); + } + return result.out.ok; + } + async function remove5({ issuer, with: resource, proofs: proofs3, audience }, link10, options = {}) { + const conn = options.connection ?? connection2; + const result = await remove4.invoke({ + issuer, + /* c8 ignore next */ + audience: audience ?? servicePrincipal, + with: resource, + nb: { link: link10 }, + proofs: proofs3 + }).execute(conn); + if (!result.out.ok) { + throw new Error(`failed ${remove4.can} invocation`, { + cause: result.out.error + }); + } + } + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/upload.js + var upload_exports2 = {}; + __export(upload_exports2, { + add: () => add8, + list: () => list7, + remove: () => remove7 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@6.0.1/node_modules/@web3-storage/capabilities/src/upload.js + init_dirname(); + init_buffer2(); + init_process(); + var upload2 = capability({ + can: "upload/*", + /** + * did:key identifier of the (memory) space where upload is add to the + * upload list. + */ + with: uri_exports.match({ protocol: "did:" }), + derives: equalWith2 + }); + var CARLink2 = link_exports2.match({ code: car_exports.code, version: 1 }); + var add7 = capability({ + can: "upload/add", + /** + * did:key identifier of the (memory) space where uploaded is added. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * Root CID of the DAG to be added to the upload list. + */ + root: link_exports2, + /** + * CIDs to the CAR files that contain blocks of the DAG. + */ + shards: CARLink2.array().optional() + }), + derives: (self2, from18) => { + return and4(equalWith2(self2, from18)) || and4(equal2(self2.nb.root, from18.nb.root, "root")) || and4(equal2(self2.nb.shards, from18.nb.shards, "shards")) || ok({}); + } + }); + var remove6 = capability({ + can: "upload/remove", + /** + * did:key identifier of the (memory) space where uploaded is removed from. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * Root CID of the DAG to be removed from the upload list. + */ + root: link_exports2 + }), + derives: (self2, from18) => { + return and4(equalWith2(self2, from18)) || and4(equal2(self2.nb.root, from18.nb.root, "root")) || ok({}); + } + }); + var list6 = capability({ + can: "upload/list", + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * A pointer that can be moved back and forth on the list. + * It can be used to paginate a list for instance. + */ + cursor: schema_exports3.string().optional(), + /** + * Maximum number of items per page. + */ + size: schema_exports3.integer().optional(), + /** + * If true, return page of results preceding cursor. Defaults to false. + */ + pre: schema_exports3.boolean().optional() + }) + }); + var all4 = add7.or(remove6).or(list6); + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/upload.js + async function add8({ issuer, with: resource, proofs: proofs3, audience }, root3, shards, options = {}) { + const conn = options.connection ?? connection2; + const result = await pRetry( + async () => { + return await add7.invoke({ + issuer, + /* c8 ignore next */ + audience: audience ?? servicePrincipal, + with: resource, + nb: { root: root3, shards }, + proofs: proofs3 + }).execute(conn); + }, + { + onFailedAttempt: console.warn, + retries: options.retries ?? REQUEST_RETRIES + } + ); + if (!result.out.ok) { + throw new Error(`failed ${add7.can} invocation`, { + cause: result.out.error + }); + } + return result.out.ok; + } + async function list7({ issuer, with: resource, proofs: proofs3, audience }, options = {}) { + const conn = options.connection ?? connection2; + const result = await list6.invoke({ + issuer, + /* c8 ignore next */ + audience: audience ?? servicePrincipal, + with: resource, + proofs: proofs3, + nb: { + cursor: options.cursor, + size: options.size, + pre: options.pre + } + }).execute(conn); + if (!result.out.ok) { + throw new Error(`failed ${list6.can} invocation`, { + cause: result.out.error + }); + } + return result.out.ok; + } + async function remove7({ issuer, with: resource, proofs: proofs3, audience }, root3, options = {}) { + const conn = options.connection ?? connection2; + const result = await remove6.invoke({ + issuer, + /* c8 ignore next */ + audience: audience ?? servicePrincipal, + with: resource, + nb: { root: root3 }, + proofs: proofs3 + }).execute(conn); + if (!result.out.ok) { + throw new Error(`failed ${remove6.can} invocation`, { + cause: result.out.error + }); + } + return result.out.ok; + } + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/unixfs.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/api.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/api.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/codec.js + var codec_exports2 = {}; + __export(codec_exports2, { + DEFAULT_DIRECTORY_MODE: () => DEFAULT_DIRECTORY_MODE, + DEFAULT_FILE_MODE: () => DEFAULT_FILE_MODE, + NodeType: () => NodeType, + code: () => code10, + createAdvancedFile: () => createAdvancedFile, + createComplexFile: () => createComplexFile, + createDirectoryShard: () => createDirectoryShard, + createEmptyFile: () => createEmptyFile, + createFileChunk: () => createFileChunk, + createFileShard: () => createFileShard, + createFlatDirectory: () => createFlatDirectory, + createRaw: () => createRaw, + createShardedDirectory: () => createShardedDirectory, + createSimpleFile: () => createSimpleFile, + createSymlink: () => createSymlink, + cumulativeContentByteLength: () => cumulativeContentByteLength, + cumulativeDagByteLength: () => cumulativeDagByteLength, + decode: () => decode36, + decodeMetadata: () => decodeMetadata, + encode: () => encode29, + encodeAdvancedFile: () => encodeAdvancedFile, + encodeComplexFile: () => encodeComplexFile, + encodeDirectory: () => encodeDirectory, + encodeDirectoryMetadata: () => encodeDirectoryMetadata, + encodeFile: () => encodeFile, + encodeFileChunk: () => encodeFileChunk, + encodeFileShard: () => encodeFileShard, + encodeHAMTShard: () => encodeHAMTShard, + encodeLink: () => encodeLink2, + encodeMetadata: () => encodeMetadata, + encodeMode: () => encodeMode, + encodeRaw: () => encodeRaw, + encodeSimpleFile: () => encodeSimpleFile, + encodeSymlink: () => encodeSymlink, + filesize: () => filesize, + matchFile: () => matchFile, + name: () => name9 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+dag-pb@4.0.2/node_modules/@ipld/dag-pb/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+dag-pb@4.0.2/node_modules/@ipld/dag-pb/src/pb-decode.js + init_dirname(); + init_buffer2(); + init_process(); + var textDecoder4 = new TextDecoder(); + function decodeVarint2(bytes2, offset2) { + let v7 = 0; + for (let shift = 0; ; shift += 7) { + if (shift >= 64) { + throw new Error("protobuf: varint overflow"); + } + if (offset2 >= bytes2.length) { + throw new Error("protobuf: unexpected end of data"); + } + const b6 = bytes2[offset2++]; + v7 += shift < 28 ? (b6 & 127) << shift : (b6 & 127) * 2 ** shift; + if (b6 < 128) { + break; + } + } + return [v7, offset2]; + } + function decodeBytes(bytes2, offset2) { + let byteLen; + [byteLen, offset2] = decodeVarint2(bytes2, offset2); + const postOffset = offset2 + byteLen; + if (byteLen < 0 || postOffset < 0) { + throw new Error("protobuf: invalid length"); + } + if (postOffset > bytes2.length) { + throw new Error("protobuf: unexpected end of data"); + } + return [bytes2.subarray(offset2, postOffset), postOffset]; + } + function decodeKey(bytes2, index2) { + let wire; + [wire, index2] = decodeVarint2(bytes2, index2); + return [wire & 7, wire >> 3, index2]; + } + function decodeLink(bytes2) { + const link10 = {}; + const l8 = bytes2.length; + let index2 = 0; + while (index2 < l8) { + let wireType, fieldNum; + [wireType, fieldNum, index2] = decodeKey(bytes2, index2); + if (fieldNum === 1) { + if (link10.Hash) { + throw new Error("protobuf: (PBLink) duplicate Hash section"); + } + if (wireType !== 2) { + throw new Error(`protobuf: (PBLink) wrong wireType (${wireType}) for Hash`); + } + if (link10.Name !== void 0) { + throw new Error("protobuf: (PBLink) invalid order, found Name before Hash"); + } + if (link10.Tsize !== void 0) { + throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash"); + } + [link10.Hash, index2] = decodeBytes(bytes2, index2); + } else if (fieldNum === 2) { + if (link10.Name !== void 0) { + throw new Error("protobuf: (PBLink) duplicate Name section"); + } + if (wireType !== 2) { + throw new Error(`protobuf: (PBLink) wrong wireType (${wireType}) for Name`); + } + if (link10.Tsize !== void 0) { + throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name"); + } + let byts; + [byts, index2] = decodeBytes(bytes2, index2); + link10.Name = textDecoder4.decode(byts); + } else if (fieldNum === 3) { + if (link10.Tsize !== void 0) { + throw new Error("protobuf: (PBLink) duplicate Tsize section"); + } + if (wireType !== 0) { + throw new Error(`protobuf: (PBLink) wrong wireType (${wireType}) for Tsize`); + } + [link10.Tsize, index2] = decodeVarint2(bytes2, index2); + } else { + throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${fieldNum}`); + } + } + if (index2 > l8) { + throw new Error("protobuf: (PBLink) unexpected end of data"); + } + return link10; + } + function decodeNode(bytes2) { + const l8 = bytes2.length; + let index2 = 0; + let links4; + let linksBeforeData = false; + let data; + while (index2 < l8) { + let wireType, fieldNum; + [wireType, fieldNum, index2] = decodeKey(bytes2, index2); + if (wireType !== 2) { + throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${wireType}`); + } + if (fieldNum === 1) { + if (data) { + throw new Error("protobuf: (PBNode) duplicate Data section"); + } + [data, index2] = decodeBytes(bytes2, index2); + if (links4) { + linksBeforeData = true; + } + } else if (fieldNum === 2) { + if (linksBeforeData) { + throw new Error("protobuf: (PBNode) duplicate Links section"); + } else if (!links4) { + links4 = []; + } + let byts; + [byts, index2] = decodeBytes(bytes2, index2); + links4.push(decodeLink(byts)); + } else { + throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${fieldNum}`); + } + } + if (index2 > l8) { + throw new Error("protobuf: (PBNode) unexpected end of data"); + } + const node = {}; + if (data) { + node.Data = data; + } + node.Links = links4 || []; + return node; + } + + // ../../node_modules/.pnpm/@ipld+dag-pb@4.0.2/node_modules/@ipld/dag-pb/src/pb-encode.js + init_dirname(); + init_buffer2(); + init_process(); + var textEncoder4 = new TextEncoder(); + var maxInt32 = 2 ** 32; + var maxUInt32 = 2 ** 31; + function encodeLink(link10, bytes2) { + let i8 = bytes2.length; + if (typeof link10.Tsize === "number") { + if (link10.Tsize < 0) { + throw new Error("Tsize cannot be negative"); + } + if (!Number.isSafeInteger(link10.Tsize)) { + throw new Error("Tsize too large for encoding"); + } + i8 = encodeVarint(bytes2, i8, link10.Tsize) - 1; + bytes2[i8] = 24; + } + if (typeof link10.Name === "string") { + const nameBytes = textEncoder4.encode(link10.Name); + i8 -= nameBytes.length; + bytes2.set(nameBytes, i8); + i8 = encodeVarint(bytes2, i8, nameBytes.length) - 1; + bytes2[i8] = 18; + } + if (link10.Hash) { + i8 -= link10.Hash.length; + bytes2.set(link10.Hash, i8); + i8 = encodeVarint(bytes2, i8, link10.Hash.length) - 1; + bytes2[i8] = 10; + } + return bytes2.length - i8; + } + function encodeNode(node) { + const size4 = sizeNode(node); + const bytes2 = new Uint8Array(size4); + let i8 = size4; + if (node.Data) { + i8 -= node.Data.length; + bytes2.set(node.Data, i8); + i8 = encodeVarint(bytes2, i8, node.Data.length) - 1; + bytes2[i8] = 10; + } + if (node.Links) { + for (let index2 = node.Links.length - 1; index2 >= 0; index2--) { + const size5 = encodeLink(node.Links[index2], bytes2.subarray(0, i8)); + i8 -= size5; + i8 = encodeVarint(bytes2, i8, size5) - 1; + bytes2[i8] = 18; + } + } + return bytes2; + } + function sizeLink(link10) { + let n9 = 0; + if (link10.Hash) { + const l8 = link10.Hash.length; + n9 += 1 + l8 + sov(l8); + } + if (typeof link10.Name === "string") { + const l8 = textEncoder4.encode(link10.Name).length; + n9 += 1 + l8 + sov(l8); + } + if (typeof link10.Tsize === "number") { + n9 += 1 + sov(link10.Tsize); + } + return n9; + } + function sizeNode(node) { + let n9 = 0; + if (node.Data) { + const l8 = node.Data.length; + n9 += 1 + l8 + sov(l8); + } + if (node.Links) { + for (const link10 of node.Links) { + const l8 = sizeLink(link10); + n9 += 1 + l8 + sov(l8); + } + } + return n9; + } + function encodeVarint(bytes2, offset2, v7) { + offset2 -= sov(v7); + const base3 = offset2; + while (v7 >= maxUInt32) { + bytes2[offset2++] = v7 & 127 | 128; + v7 /= 128; + } + while (v7 >= 128) { + bytes2[offset2++] = v7 & 127 | 128; + v7 >>>= 7; + } + bytes2[offset2] = v7; + return base3; + } + function sov(x5) { + if (x5 % 2 === 0) { + x5++; + } + return Math.floor((len64(x5) + 6) / 7); + } + function len64(x5) { + let n9 = 0; + if (x5 >= maxInt32) { + x5 = Math.floor(x5 / maxInt32); + n9 = 32; + } + if (x5 >= 1 << 16) { + x5 >>>= 16; + n9 += 16; + } + if (x5 >= 1 << 8) { + x5 >>>= 8; + n9 += 8; + } + return n9 + len8tab[x5]; + } + var len8tab = [ + 0, + 1, + 2, + 2, + 3, + 3, + 3, + 3, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 6, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8 + ]; + + // ../../node_modules/.pnpm/@ipld+dag-pb@4.0.2/node_modules/@ipld/dag-pb/src/util.js + init_dirname(); + init_buffer2(); + init_process(); + var pbNodeProperties = ["Data", "Links"]; + var pbLinkProperties = ["Hash", "Name", "Tsize"]; + var textEncoder5 = new TextEncoder(); + function linkComparator(a8, b6) { + if (a8 === b6) { + return 0; + } + const abuf = a8.Name ? textEncoder5.encode(a8.Name) : []; + const bbuf = b6.Name ? textEncoder5.encode(b6.Name) : []; + let x5 = abuf.length; + let y7 = bbuf.length; + for (let i8 = 0, len = Math.min(x5, y7); i8 < len; ++i8) { + if (abuf[i8] !== bbuf[i8]) { + x5 = abuf[i8]; + y7 = bbuf[i8]; + break; + } + } + return x5 < y7 ? -1 : y7 < x5 ? 1 : 0; + } + function hasOnlyProperties(node, properties) { + return !Object.keys(node).some((p8) => !properties.includes(p8)); + } + function asLink(link10) { + if (typeof link10.asCID === "object") { + const Hash2 = CID2.asCID(link10); + if (!Hash2) { + throw new TypeError("Invalid DAG-PB form"); + } + return { Hash: Hash2 }; + } + if (typeof link10 !== "object" || Array.isArray(link10)) { + throw new TypeError("Invalid DAG-PB form"); + } + const pbl = {}; + if (link10.Hash) { + let cid = CID2.asCID(link10.Hash); + try { + if (!cid) { + if (typeof link10.Hash === "string") { + cid = CID2.parse(link10.Hash); + } else if (link10.Hash instanceof Uint8Array) { + cid = CID2.decode(link10.Hash); + } + } + } catch (e12) { + throw new TypeError(`Invalid DAG-PB form: ${e12.message}`); + } + if (cid) { + pbl.Hash = cid; + } + } + if (!pbl.Hash) { + throw new TypeError("Invalid DAG-PB form"); + } + if (typeof link10.Name === "string") { + pbl.Name = link10.Name; + } + if (typeof link10.Tsize === "number") { + pbl.Tsize = link10.Tsize; + } + return pbl; + } + function prepare2(node) { + if (node instanceof Uint8Array || typeof node === "string") { + node = { Data: node }; + } + if (typeof node !== "object" || Array.isArray(node)) { + throw new TypeError("Invalid DAG-PB form"); + } + const pbn = {}; + if (node.Data !== void 0) { + if (typeof node.Data === "string") { + pbn.Data = textEncoder5.encode(node.Data); + } else if (node.Data instanceof Uint8Array) { + pbn.Data = node.Data; + } else { + throw new TypeError("Invalid DAG-PB form"); + } + } + if (node.Links !== void 0) { + if (Array.isArray(node.Links)) { + pbn.Links = node.Links.map(asLink); + pbn.Links.sort(linkComparator); + } else { + throw new TypeError("Invalid DAG-PB form"); + } + } else { + pbn.Links = []; + } + return pbn; + } + function validate2(node) { + if (!node || typeof node !== "object" || Array.isArray(node) || node instanceof Uint8Array || node["/"] && node["/"] === node.bytes) { + throw new TypeError("Invalid DAG-PB form"); + } + if (!hasOnlyProperties(node, pbNodeProperties)) { + throw new TypeError("Invalid DAG-PB form (extraneous properties)"); + } + if (node.Data !== void 0 && !(node.Data instanceof Uint8Array)) { + throw new TypeError("Invalid DAG-PB form (Data must be bytes)"); + } + if (!Array.isArray(node.Links)) { + throw new TypeError("Invalid DAG-PB form (Links must be a list)"); + } + for (let i8 = 0; i8 < node.Links.length; i8++) { + const link10 = node.Links[i8]; + if (!link10 || typeof link10 !== "object" || Array.isArray(link10) || link10 instanceof Uint8Array || link10["/"] && link10["/"] === link10.bytes) { + throw new TypeError("Invalid DAG-PB form (bad link)"); + } + if (!hasOnlyProperties(link10, pbLinkProperties)) { + throw new TypeError("Invalid DAG-PB form (extraneous properties on link)"); + } + if (link10.Hash === void 0) { + throw new TypeError("Invalid DAG-PB form (link must have a Hash)"); + } + if (link10.Hash == null || !link10.Hash["/"] || link10.Hash["/"] !== link10.Hash.bytes) { + throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)"); + } + if (link10.Name !== void 0 && typeof link10.Name !== "string") { + throw new TypeError("Invalid DAG-PB form (link Name must be a string)"); + } + if (link10.Tsize !== void 0) { + if (typeof link10.Tsize !== "number" || link10.Tsize % 1 !== 0) { + throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)"); + } + if (link10.Tsize < 0) { + throw new TypeError("Invalid DAG-PB form (link Tsize cannot be negative)"); + } + } + if (i8 > 0 && linkComparator(link10, node.Links[i8 - 1]) === -1) { + throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)"); + } + } + } + + // ../../node_modules/.pnpm/@ipld+dag-pb@4.0.2/node_modules/@ipld/dag-pb/src/index.js + var code9 = 112; + function encode28(node) { + validate2(node); + const pbn = {}; + if (node.Links) { + pbn.Links = node.Links.map((l8) => { + const link10 = {}; + if (l8.Hash) { + link10.Hash = l8.Hash.bytes; + } + if (l8.Name !== void 0) { + link10.Name = l8.Name; + } + if (l8.Tsize !== void 0) { + link10.Tsize = l8.Tsize; + } + return link10; + }); + } + if (node.Data) { + pbn.Data = node.Data; + } + return encodeNode(pbn); + } + function decode35(bytes2) { + const pbn = decodeNode(bytes2); + const node = {}; + if (pbn.Data) { + node.Data = pbn.Data; + } + if (pbn.Links) { + node.Links = pbn.Links.map((l8) => { + const link10 = {}; + try { + link10.Hash = CID2.decode(l8.Hash); + } catch (e12) { + } + if (!link10.Hash) { + throw new Error("Invalid Hash field found in link, expected CID"); + } + if (l8.Name !== void 0) { + link10.Name = l8.Name; + } + if (l8.Tsize !== void 0) { + link10.Tsize = l8.Tsize; + } + return link10; + }); + } + return node; + } + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/unixfs.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/gen/unixfs.js + init_dirname(); + init_buffer2(); + init_process(); + var import_minimal = __toESM(require_minimal2(), 1); + var $Reader = import_minimal.default.Reader; + var $Writer = import_minimal.default.Writer; + var $util = import_minimal.default.util; + var $root = import_minimal.default.roots.unixfs || (import_minimal.default.roots.unixfs = {}); + var Data = $root.Data = (() => { + function Data3(p8) { + this.blocksizes = []; + if (p8) { + for (var ks = Object.keys(p8), i8 = 0; i8 < ks.length; ++i8) + if (p8[ks[i8]] != null) + this[ks[i8]] = p8[ks[i8]]; + } + } + Data3.prototype.Type = 0; + Data3.prototype.Data = $util.newBuffer([]); + Data3.prototype.filesize = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Data3.prototype.blocksizes = $util.emptyArray; + Data3.prototype.hashType = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Data3.prototype.fanout = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Data3.prototype.mode = 0; + Data3.prototype.mtime = null; + Data3.encode = function encode41(m7, w5) { + if (!w5) + w5 = $Writer.create(); + w5.uint32(8).int32(m7.Type); + if (m7.Data != null && Object.hasOwnProperty.call(m7, "Data")) + w5.uint32(18).bytes(m7.Data); + if (m7.filesize != null && Object.hasOwnProperty.call(m7, "filesize")) + w5.uint32(24).uint64(m7.filesize); + if (m7.blocksizes != null && m7.blocksizes.length) { + for (var i8 = 0; i8 < m7.blocksizes.length; ++i8) + w5.uint32(32).uint64(m7.blocksizes[i8]); + } + if (m7.hashType != null && Object.hasOwnProperty.call(m7, "hashType")) + w5.uint32(40).uint64(m7.hashType); + if (m7.fanout != null && Object.hasOwnProperty.call(m7, "fanout")) + w5.uint32(48).uint64(m7.fanout); + if (m7.mode != null && Object.hasOwnProperty.call(m7, "mode")) + w5.uint32(56).uint32(m7.mode); + if (m7.mtime != null && Object.hasOwnProperty.call(m7, "mtime")) + $root.UnixTime.encode(m7.mtime, w5.uint32(66).fork()).ldelim(); + return w5; + }; + Data3.decode = function decode46(r10, l8) { + if (!(r10 instanceof $Reader)) + r10 = $Reader.create(r10); + var c8 = l8 === void 0 ? r10.len : r10.pos + l8, m7 = new $root.Data(); + while (r10.pos < c8) { + var t9 = r10.uint32(); + switch (t9 >>> 3) { + case 1: + m7.Type = r10.int32(); + break; + case 2: + m7.Data = r10.bytes(); + break; + case 3: + m7.filesize = r10.uint64(); + break; + case 4: + if (!(m7.blocksizes && m7.blocksizes.length)) + m7.blocksizes = []; + if ((t9 & 7) === 2) { + var c22 = r10.uint32() + r10.pos; + while (r10.pos < c22) + m7.blocksizes.push(r10.uint64()); + } else + m7.blocksizes.push(r10.uint64()); + break; + case 5: + m7.hashType = r10.uint64(); + break; + case 6: + m7.fanout = r10.uint64(); + break; + case 7: + m7.mode = r10.uint32(); + break; + case 8: + m7.mtime = $root.UnixTime.decode(r10, r10.uint32()); + break; + default: + r10.skipType(t9 & 7); + break; + } + } + if (!m7.hasOwnProperty("Type")) + throw $util.ProtocolError("missing required 'Type'", { instance: m7 }); + return m7; + }; + Data3.fromObject = function fromObject(d7) { + if (d7 instanceof $root.Data) + return d7; + var m7 = new $root.Data(); + switch (d7.Type) { + case "Raw": + case 0: + m7.Type = 0; + break; + case "Directory": + case 1: + m7.Type = 1; + break; + case "File": + case 2: + m7.Type = 2; + break; + case "Metadata": + case 3: + m7.Type = 3; + break; + case "Symlink": + case 4: + m7.Type = 4; + break; + case "HAMTShard": + case 5: + m7.Type = 5; + break; + } + if (d7.Data != null) { + if (typeof d7.Data === "string") + $util.base64.decode(d7.Data, m7.Data = $util.newBuffer($util.base64.length(d7.Data)), 0); + else if (d7.Data.length) + m7.Data = d7.Data; + } + if (d7.filesize != null) { + if ($util.Long) + (m7.filesize = $util.Long.fromValue(d7.filesize)).unsigned = true; + else if (typeof d7.filesize === "string") + m7.filesize = parseInt(d7.filesize, 10); + else if (typeof d7.filesize === "number") + m7.filesize = d7.filesize; + else if (typeof d7.filesize === "object") + m7.filesize = new $util.LongBits(d7.filesize.low >>> 0, d7.filesize.high >>> 0).toNumber(true); + } + if (d7.blocksizes) { + if (!Array.isArray(d7.blocksizes)) + throw TypeError(".Data.blocksizes: array expected"); + m7.blocksizes = []; + for (var i8 = 0; i8 < d7.blocksizes.length; ++i8) { + if ($util.Long) + (m7.blocksizes[i8] = $util.Long.fromValue(d7.blocksizes[i8])).unsigned = true; + else if (typeof d7.blocksizes[i8] === "string") + m7.blocksizes[i8] = parseInt(d7.blocksizes[i8], 10); + else if (typeof d7.blocksizes[i8] === "number") + m7.blocksizes[i8] = d7.blocksizes[i8]; + else if (typeof d7.blocksizes[i8] === "object") + m7.blocksizes[i8] = new $util.LongBits(d7.blocksizes[i8].low >>> 0, d7.blocksizes[i8].high >>> 0).toNumber(true); + } + } + if (d7.hashType != null) { + if ($util.Long) + (m7.hashType = $util.Long.fromValue(d7.hashType)).unsigned = true; + else if (typeof d7.hashType === "string") + m7.hashType = parseInt(d7.hashType, 10); + else if (typeof d7.hashType === "number") + m7.hashType = d7.hashType; + else if (typeof d7.hashType === "object") + m7.hashType = new $util.LongBits(d7.hashType.low >>> 0, d7.hashType.high >>> 0).toNumber(true); + } + if (d7.fanout != null) { + if ($util.Long) + (m7.fanout = $util.Long.fromValue(d7.fanout)).unsigned = true; + else if (typeof d7.fanout === "string") + m7.fanout = parseInt(d7.fanout, 10); + else if (typeof d7.fanout === "number") + m7.fanout = d7.fanout; + else if (typeof d7.fanout === "object") + m7.fanout = new $util.LongBits(d7.fanout.low >>> 0, d7.fanout.high >>> 0).toNumber(true); + } + if (d7.mode != null) { + m7.mode = d7.mode >>> 0; + } + if (d7.mtime != null) { + if (typeof d7.mtime !== "object") + throw TypeError(".Data.mtime: object expected"); + m7.mtime = $root.UnixTime.fromObject(d7.mtime); + } + return m7; + }; + Data3.toObject = function toObject(m7, o9) { + if (!o9) + o9 = {}; + var d7 = {}; + if (o9.arrays || o9.defaults) { + d7.blocksizes = []; + } + if (o9.defaults) { + d7.Type = o9.enums === String ? "Raw" : 0; + if (o9.bytes === String) + d7.Data = ""; + else { + d7.Data = []; + if (o9.bytes !== Array) + d7.Data = $util.newBuffer(d7.Data); + } + if ($util.Long) { + var n9 = new $util.Long(0, 0, true); + d7.filesize = o9.longs === String ? n9.toString() : o9.longs === Number ? n9.toNumber() : n9; + } else + d7.filesize = o9.longs === String ? "0" : 0; + if ($util.Long) { + var n9 = new $util.Long(0, 0, true); + d7.hashType = o9.longs === String ? n9.toString() : o9.longs === Number ? n9.toNumber() : n9; + } else + d7.hashType = o9.longs === String ? "0" : 0; + if ($util.Long) { + var n9 = new $util.Long(0, 0, true); + d7.fanout = o9.longs === String ? n9.toString() : o9.longs === Number ? n9.toNumber() : n9; + } else + d7.fanout = o9.longs === String ? "0" : 0; + d7.mode = 0; + d7.mtime = null; + } + if (m7.Type != null && m7.hasOwnProperty("Type")) { + d7.Type = o9.enums === String ? $root.Data.DataType[m7.Type] : m7.Type; + } + if (m7.Data != null && m7.hasOwnProperty("Data")) { + d7.Data = o9.bytes === String ? $util.base64.encode(m7.Data, 0, m7.Data.length) : o9.bytes === Array ? Array.prototype.slice.call(m7.Data) : m7.Data; + } + if (m7.filesize != null && m7.hasOwnProperty("filesize")) { + if (typeof m7.filesize === "number") + d7.filesize = o9.longs === String ? String(m7.filesize) : m7.filesize; + else + d7.filesize = o9.longs === String ? $util.Long.prototype.toString.call(m7.filesize) : o9.longs === Number ? new $util.LongBits(m7.filesize.low >>> 0, m7.filesize.high >>> 0).toNumber(true) : m7.filesize; + } + if (m7.blocksizes && m7.blocksizes.length) { + d7.blocksizes = []; + for (var j5 = 0; j5 < m7.blocksizes.length; ++j5) { + if (typeof m7.blocksizes[j5] === "number") + d7.blocksizes[j5] = o9.longs === String ? String(m7.blocksizes[j5]) : m7.blocksizes[j5]; + else + d7.blocksizes[j5] = o9.longs === String ? $util.Long.prototype.toString.call(m7.blocksizes[j5]) : o9.longs === Number ? new $util.LongBits(m7.blocksizes[j5].low >>> 0, m7.blocksizes[j5].high >>> 0).toNumber(true) : m7.blocksizes[j5]; + } + } + if (m7.hashType != null && m7.hasOwnProperty("hashType")) { + if (typeof m7.hashType === "number") + d7.hashType = o9.longs === String ? String(m7.hashType) : m7.hashType; + else + d7.hashType = o9.longs === String ? $util.Long.prototype.toString.call(m7.hashType) : o9.longs === Number ? new $util.LongBits(m7.hashType.low >>> 0, m7.hashType.high >>> 0).toNumber(true) : m7.hashType; + } + if (m7.fanout != null && m7.hasOwnProperty("fanout")) { + if (typeof m7.fanout === "number") + d7.fanout = o9.longs === String ? String(m7.fanout) : m7.fanout; + else + d7.fanout = o9.longs === String ? $util.Long.prototype.toString.call(m7.fanout) : o9.longs === Number ? new $util.LongBits(m7.fanout.low >>> 0, m7.fanout.high >>> 0).toNumber(true) : m7.fanout; + } + if (m7.mode != null && m7.hasOwnProperty("mode")) { + d7.mode = m7.mode; + } + if (m7.mtime != null && m7.hasOwnProperty("mtime")) { + d7.mtime = $root.UnixTime.toObject(m7.mtime, o9); + } + return d7; + }; + Data3.prototype.toJSON = function toJSON4() { + return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions); + }; + Data3.DataType = function() { + const valuesById = {}, values2 = Object.create(valuesById); + values2[valuesById[0] = "Raw"] = 0; + values2[valuesById[1] = "Directory"] = 1; + values2[valuesById[2] = "File"] = 2; + values2[valuesById[3] = "Metadata"] = 3; + values2[valuesById[4] = "Symlink"] = 4; + values2[valuesById[5] = "HAMTShard"] = 5; + return values2; + }(); + return Data3; + })(); + var UnixTime = $root.UnixTime = (() => { + function UnixTime3(p8) { + if (p8) { + for (var ks = Object.keys(p8), i8 = 0; i8 < ks.length; ++i8) + if (p8[ks[i8]] != null) + this[ks[i8]] = p8[ks[i8]]; + } + } + UnixTime3.prototype.Seconds = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + UnixTime3.prototype.FractionalNanoseconds = 0; + UnixTime3.encode = function encode41(m7, w5) { + if (!w5) + w5 = $Writer.create(); + w5.uint32(8).int64(m7.Seconds); + if (m7.FractionalNanoseconds != null && Object.hasOwnProperty.call(m7, "FractionalNanoseconds")) + w5.uint32(21).fixed32(m7.FractionalNanoseconds); + return w5; + }; + UnixTime3.decode = function decode46(r10, l8) { + if (!(r10 instanceof $Reader)) + r10 = $Reader.create(r10); + var c8 = l8 === void 0 ? r10.len : r10.pos + l8, m7 = new $root.UnixTime(); + while (r10.pos < c8) { + var t9 = r10.uint32(); + switch (t9 >>> 3) { + case 1: + m7.Seconds = r10.int64(); + break; + case 2: + m7.FractionalNanoseconds = r10.fixed32(); + break; + default: + r10.skipType(t9 & 7); + break; + } + } + if (!m7.hasOwnProperty("Seconds")) + throw $util.ProtocolError("missing required 'Seconds'", { instance: m7 }); + return m7; + }; + UnixTime3.fromObject = function fromObject(d7) { + if (d7 instanceof $root.UnixTime) + return d7; + var m7 = new $root.UnixTime(); + if (d7.Seconds != null) { + if ($util.Long) + (m7.Seconds = $util.Long.fromValue(d7.Seconds)).unsigned = false; + else if (typeof d7.Seconds === "string") + m7.Seconds = parseInt(d7.Seconds, 10); + else if (typeof d7.Seconds === "number") + m7.Seconds = d7.Seconds; + else if (typeof d7.Seconds === "object") + m7.Seconds = new $util.LongBits(d7.Seconds.low >>> 0, d7.Seconds.high >>> 0).toNumber(); + } + if (d7.FractionalNanoseconds != null) { + m7.FractionalNanoseconds = d7.FractionalNanoseconds >>> 0; + } + return m7; + }; + UnixTime3.toObject = function toObject(m7, o9) { + if (!o9) + o9 = {}; + var d7 = {}; + if (o9.defaults) { + if ($util.Long) { + var n9 = new $util.Long(0, 0, false); + d7.Seconds = o9.longs === String ? n9.toString() : o9.longs === Number ? n9.toNumber() : n9; + } else + d7.Seconds = o9.longs === String ? "0" : 0; + d7.FractionalNanoseconds = 0; + } + if (m7.Seconds != null && m7.hasOwnProperty("Seconds")) { + if (typeof m7.Seconds === "number") + d7.Seconds = o9.longs === String ? String(m7.Seconds) : m7.Seconds; + else + d7.Seconds = o9.longs === String ? $util.Long.prototype.toString.call(m7.Seconds) : o9.longs === Number ? new $util.LongBits(m7.Seconds.low >>> 0, m7.Seconds.high >>> 0).toNumber() : m7.Seconds; + } + if (m7.FractionalNanoseconds != null && m7.hasOwnProperty("FractionalNanoseconds")) { + d7.FractionalNanoseconds = m7.FractionalNanoseconds; + } + return d7; + }; + UnixTime3.prototype.toJSON = function toJSON4() { + return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions); + }; + return UnixTime3; + })(); + var Metadata = $root.Metadata = (() => { + function Metadata3(p8) { + if (p8) { + for (var ks = Object.keys(p8), i8 = 0; i8 < ks.length; ++i8) + if (p8[ks[i8]] != null) + this[ks[i8]] = p8[ks[i8]]; + } + } + Metadata3.prototype.MimeType = ""; + Metadata3.encode = function encode41(m7, w5) { + if (!w5) + w5 = $Writer.create(); + if (m7.MimeType != null && Object.hasOwnProperty.call(m7, "MimeType")) + w5.uint32(10).string(m7.MimeType); + return w5; + }; + Metadata3.decode = function decode46(r10, l8) { + if (!(r10 instanceof $Reader)) + r10 = $Reader.create(r10); + var c8 = l8 === void 0 ? r10.len : r10.pos + l8, m7 = new $root.Metadata(); + while (r10.pos < c8) { + var t9 = r10.uint32(); + switch (t9 >>> 3) { + case 1: + m7.MimeType = r10.string(); + break; + default: + r10.skipType(t9 & 7); + break; + } + } + return m7; + }; + Metadata3.fromObject = function fromObject(d7) { + if (d7 instanceof $root.Metadata) + return d7; + var m7 = new $root.Metadata(); + if (d7.MimeType != null) { + m7.MimeType = String(d7.MimeType); + } + return m7; + }; + Metadata3.toObject = function toObject(m7, o9) { + if (!o9) + o9 = {}; + var d7 = {}; + if (o9.defaults) { + d7.MimeType = ""; + } + if (m7.MimeType != null && m7.hasOwnProperty("MimeType")) { + d7.MimeType = m7.MimeType; + } + return d7; + }; + Metadata3.prototype.toJSON = function toJSON4() { + return this.constructor.toObject(this, import_minimal.default.util.toJSONOptions); + }; + return Metadata3; + })(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/unixfs.js + var NodeType = Data.DataType; + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/codec.js + var EMPTY = Object.freeze([]); + var EMPTY_BUFFER = new Uint8Array(0); + var BLANK = Object.freeze({}); + var DEFAULT_FILE_MODE = parseInt("0644", 8); + var DEFAULT_DIRECTORY_MODE = parseInt("0755", 8); + var code10 = code9; + var name9 = "UnixFS"; + var encodePB = (data, links4) => { + Object(globalThis).debug && console.log({ data, links: links4 }); + return encode28( + // We run through prepare as links need to be sorted by name which it will + // do. + prepare2({ + Data: Data.encode(data).finish(), + // We can cast to mutable array as we know no mutation occurs there + Links: ( + /** @type {PB.PBLink[]} */ + links4 + ) + }) + ); + }; + var createRaw = (content) => ({ + type: NodeType.Raw, + content + }); + var createEmptyFile = (metadata) => createSimpleFile(EMPTY_BUFFER, metadata); + var createSimpleFile = (content, metadata) => ({ + type: NodeType.File, + layout: "simple", + content, + metadata: decodeMetadata(metadata) + }); + var createFileChunk = (content) => ({ + type: NodeType.File, + layout: "simple", + content + }); + var createAdvancedFile = (parts, metadata) => ({ + type: NodeType.File, + layout: "advanced", + parts, + metadata: decodeMetadata(metadata) + }); + var createFileShard = (parts) => ({ + type: NodeType.File, + layout: "advanced", + parts + }); + var createComplexFile = (content, parts, metadata) => ({ + type: NodeType.File, + layout: "complex", + content, + parts, + metadata: decodeMetadata(metadata) + }); + var createFlatDirectory = (entries6, metadata) => ({ + type: NodeType.Directory, + metadata: decodeMetadata(metadata), + entries: entries6 + }); + var createShardedDirectory = (entries6, bitfield, fanout, hashType, metadata = BLANK) => ({ + type: NodeType.HAMTShard, + bitfield, + fanout: readFanout(fanout), + hashType: readInt3(hashType), + entries: entries6, + metadata: decodeMetadata(metadata) + }); + var createDirectoryShard = (entries6, bitfield, fanout, hashType) => ({ + type: NodeType.HAMTShard, + bitfield, + fanout: readFanout(fanout), + hashType: readInt3(hashType), + entries: entries6 + }); + var encodeRaw = (content) => encodePB( + { + Type: NodeType.Raw, + // TODO: + Data: content.byteLength > 0 ? content : void 0, + filesize: content.byteLength, + // @ts-ignore + blocksizes: EMPTY + }, + [] + ); + var encodeFile = (node, ignoreMetadata = false) => { + const metadata = ignoreMetadata ? BLANK : Object(node).metadata; + switch (node.layout) { + case "simple": + return encodeSimpleFile(node.content, metadata); + case "advanced": + return encodeAdvancedFile(node.parts, metadata); + case "complex": + return encodeComplexFile(node.content, node.parts, metadata); + default: + throw new TypeError( + `File with unknown layout "${Object(node).layout}" was passed` + ); + } + }; + var encodeFileChunk = (content) => encodeSimpleFile(content, BLANK); + var encodeFileShard = (parts) => encodePB( + { + Type: NodeType.File, + blocksizes: parts.map(contentByteLength), + filesize: cumulativeContentByteLength(parts) + }, + parts.map(encodeLink2) + ); + var encodeAdvancedFile = (parts, metadata = BLANK) => encodePB( + { + Type: NodeType.File, + blocksizes: parts.map(contentByteLength), + filesize: cumulativeContentByteLength(parts), + ...encodeMetadata(metadata) + }, + parts.map(encodeLink2) + ); + var encodeLink2 = (dag) => ({ + Name: "", + Tsize: dag.dagByteLength, + // @ts-ignore - @see https://github.com/multiformats/js-multiformats/pull/161 + Hash: dag.cid + }); + var encodeSimpleFile = (content, metadata = BLANK) => encodePB( + { + Type: NodeType.File, + // adding empty file to both go-ipfs and js-ipfs produces block in + // which `Data` is omitted but filesize and blocksizes are present. + // For the sake of hash consistency we do the same. + Data: content.byteLength > 0 ? content : void 0, + filesize: content.byteLength, + blocksizes: [], + ...encodeMetadata(metadata) + }, + [] + ); + var encodeComplexFile = (content, parts, metadata = BLANK) => encodePB( + { + Type: NodeType.File, + Data: content, + filesize: content.byteLength + cumulativeContentByteLength(parts), + blocksizes: parts.map(contentByteLength) + }, + parts.map(encodeLink2) + ); + var encodeDirectory = (node) => encodePB( + { + Type: node.type, + ...encodeDirectoryMetadata(node.metadata || BLANK) + }, + node.entries.map(encodeNamedLink) + ); + var encodeHAMTShard = ({ + bitfield, + fanout, + hashType, + entries: entries6, + metadata = BLANK + }) => encodePB( + { + Type: NodeType.HAMTShard, + Data: bitfield.byteLength > 0 ? bitfield : void 0, + fanout: readFanout(fanout), + hashType: readInt3(hashType), + ...encodeDirectoryMetadata(metadata) + }, + entries6.map(encodeNamedLink) + ); + var readFanout = (n9) => { + if (Math.log2(n9) % 1 === 0) { + return n9; + } else { + throw new TypeError( + `Expected hamt size to be a power of two instead got ${n9}` + ); + } + }; + var readInt3 = (n9) => { + if (Number.isInteger(n9)) { + return n9; + } else { + throw new TypeError(`Expected an integer value instead got ${n9}`); + } + }; + var createSymlink = (path2, metadata = BLANK) => ({ + type: NodeType.Symlink, + content: path2, + metadata: decodeMetadata(metadata) + }); + var encodeSymlink = (node, ignoreMetadata = false) => { + const metadata = ignoreMetadata ? BLANK : Object(node).metadata; + return encodePB( + { + Type: NodeType.Symlink, + Data: node.content, + ...encodeMetadata(metadata || BLANK) + }, + [] + ); + }; + var encode29 = (node, root3 = true) => { + switch (node.type) { + case NodeType.Raw: + return encodeRaw(node.content); + case NodeType.File: + return encodeFile(node); + case NodeType.Directory: + return encodeDirectory(node); + case NodeType.HAMTShard: + return encodeHAMTShard(node); + case NodeType.Symlink: + return encodeSymlink(node); + default: + throw new Error(`Unknown node type ${Object(node).type}`); + } + }; + var decode36 = (bytes2) => { + const pb = decode35(bytes2); + const message2 = Data.decode( + /** @type {Uint8Array} */ + pb.Data + ); + const { + Type: type3, + Data: data, + mtime, + mode, + blocksizes, + ...rest + } = Data.toObject(message2, { + defaults: false, + arrays: true, + longs: Number, + objects: false + }); + const metadata = { + ...mode && { mode }, + ...decodeMtime(mtime) + }; + const links4 = pb.Links; + switch (message2.Type) { + case NodeType.Raw: + return createRaw(data); + case NodeType.File: + if (links4.length === 0) { + return new SimpleFileView(data, metadata); + } else if (data.byteLength === 0) { + return new AdvancedFileView( + decodeFileLinks(rest.blocksizes, links4), + metadata + ); + } else { + return new ComplexFileView( + data, + decodeFileLinks(rest.blocksizes, links4), + metadata + ); + } + case NodeType.Directory: + return createFlatDirectory(decodeDirectoryLinks(links4), metadata); + case NodeType.HAMTShard: + return createShardedDirectory( + decodeDirectoryLinks(links4), + data || EMPTY_BUFFER, + rest.fanout, + rest.hashType, + metadata + ); + case NodeType.Symlink: + return createSymlink(data, metadata); + default: + throw new TypeError(`Unsupported node type ${message2.Type}`); + } + }; + var decodeMtime = (mtime) => mtime == null ? void 0 : { + mtime: { secs: mtime.Seconds, nsecs: mtime.FractionalNanoseconds || 0 } + }; + var decodeFileLinks = (blocksizes, links4) => { + const parts = []; + const length3 = blocksizes.length; + let n9 = 0; + while (n9 < length3) { + parts.push( + /** @type {UnixFS.FileLink} */ + { + cid: links4[n9].Hash, + dagByteLength: links4[n9].Tsize || 0, + contentByteLength: blocksizes[n9] + } + ); + } + return parts; + }; + var decodeDirectoryLinks = (links4) => links4.map( + (link10) => ( + /** @type {UnixFS.DirectoryEntryLink} */ + { + cid: link10.Hash, + name: link10.Name || "", + dagByteLength: link10.Tsize || 0 + } + ) + ); + var cumulativeContentByteLength = (links4) => links4.reduce((size4, link10) => size4 + link10.contentByteLength, 0); + var cumulativeDagByteLength = (root3, links4) => links4.reduce((size4, link10) => size4 + link10.dagByteLength, root3.byteLength); + var contentByteLength = (link10) => link10.contentByteLength; + var encodeNamedLink = ({ name: name15, dagByteLength, cid }) => ({ + Name: name15, + Tsize: dagByteLength, + Hash: cid + }); + var encodeDirectoryMetadata = (metadata) => encodeMetadata(metadata, DEFAULT_DIRECTORY_MODE); + var encodeMetadata = ({ mode, mtime }, defaultMode = DEFAULT_FILE_MODE) => ({ + mode: mode != null ? encodeMode(mode, defaultMode) : void 0, + mtime: mtime != null ? encodeMTime(mtime) : void 0 + }); + var decodeMetadata = (data) => data == null ? BLANK : { + ...data.mode == null ? void 0 : { mode: decodeMode(data.mode) }, + ...data.mtime == null ? void 0 : { mtime: data.mtime } + }; + var encodeMTime = (mtime) => { + return mtime == null ? void 0 : mtime.nsecs !== 0 ? { Seconds: mtime.secs, FractionalNanoseconds: mtime.nsecs } : { Seconds: mtime.secs }; + }; + var encodeMode = (specifiedMode, defaultMode) => { + const mode = specifiedMode == null ? void 0 : decodeMode(specifiedMode); + return mode === defaultMode || mode == null ? void 0 : mode; + }; + var decodeMode = (mode) => mode & 4095 | mode & 4294963200; + var matchFile = ({ + content = EMPTY_BUFFER, + parts = EMPTY, + metadata = BLANK, + ...rest + }) => { + if (parts.length === 0) { + return new SimpleFileView(content, metadata); + } else if (content.byteLength === 0) { + return new AdvancedFileView(parts, metadata); + } else { + return new ComplexFileView(content, parts, metadata); + } + }; + var SimpleFileView = class { + /** + * @param {Uint8Array} content + * @param {UnixFS.Metadata} metadata + */ + constructor(content, metadata) { + this.content = content; + this.metadata = metadata; + this.layout = "simple"; + this.type = NodeType.File; + } + get filesize() { + return this.content.byteLength; + } + encode() { + return encodeSimpleFile(this.content, this.metadata); + } + }; + var AdvancedFileView = class { + /** + * @param {ReadonlyArray} parts + * @param {UnixFS.Metadata} metadata + */ + constructor(parts, metadata) { + this.parts = parts; + this.metadata = metadata; + } + /** @type {"advanced"} */ + get layout() { + return "advanced"; + } + /** + * @returns {NodeType.File} + */ + get type() { + return NodeType.File; + } + get fileSize() { + return cumulativeContentByteLength(this.parts); + } + get blockSizes() { + return this.parts.map(contentByteLength); + } + encode() { + return encodeAdvancedFile(this.parts, this.metadata); + } + }; + var ComplexFileView = class { + /** + * @param {Uint8Array} content + * @param {ReadonlyArray} parts + * @param {UnixFS.Metadata} metadata + */ + constructor(content, parts, metadata) { + this.content = content; + this.parts = parts; + this.metadata = metadata; + } + /** @type {"complex"} */ + get layout() { + return "complex"; + } + /** + * @returns {NodeType.File} + */ + get type() { + return NodeType.File; + } + get fileSize() { + return this.content.byteLength + cumulativeContentByteLength(this.parts); + } + get blockSizes() { + return this.parts.map(contentByteLength); + } + encode() { + return encodeComplexFile(this.content, this.parts, this.metadata); + } + }; + var filesize = (node) => { + switch (node.type) { + case NodeType.Raw: + case NodeType.Symlink: + return node.content.byteLength; + case NodeType.File: + switch (node.layout) { + case "simple": + return node.content.byteLength; + case "advanced": + return cumulativeContentByteLength(node.parts); + case "complex": + return node.content.byteLength + cumulativeContentByteLength(node.parts); + } + default: + return 0; + } + }; + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/writer.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/actor@2.3.1/node_modules/actor/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/actor@2.3.1/node_modules/actor/src/task.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/actor@2.3.1/node_modules/actor/src/lib.js + var effect = function* (task) { + const message2 = yield* task; + yield* send(message2); + }; + function* current() { + return ( + /** @type {Task.Controller} */ + yield CURRENT + ); + } + var suspend = function* () { + yield SUSPEND; + }; + var wait = function* (input) { + const task = yield* current(); + if (isAsync2(input)) { + let failed = false; + let output = void 0; + input.then( + (value) => { + failed = false; + output = value; + enqueue(task); + }, + (error7) => { + failed = true; + output = error7; + enqueue(task); + } + ); + yield* suspend(); + if (failed) { + throw output; + } else { + return ( + /** @type {T} */ + output + ); + } + } else { + main(wake(task)); + yield* suspend(); + return input; + } + }; + function* wake(task) { + enqueue(task); + } + var isAsync2 = (node) => node != null && typeof /** @type {{then?:unknown}} */ + node.then === "function"; + var send = function* (message2) { + yield ( + /** @type {Task.Message} */ + message2 + ); + }; + var listen = function* (source) { + const forks = []; + for (const entry of Object.entries(source)) { + const [name15, effect2] = ( + /** @type {[Tag, Task.Effect]} */ + entry + ); + if (effect2 !== NONE) { + forks.push(yield* fork(tag(effect2, name15))); + } + } + yield* group(forks); + }; + var effects = (tasks) => tasks.length > 0 ? batch(tasks.map(effect)) : NONE; + function* batch(effects2) { + const forks = []; + for (const effect2 of effects2) { + forks.push(yield* fork(effect2)); + } + yield* group(forks); + } + var tag = (effect2, tag2) => ( + // @ts-ignore + effect2 === NONE ? NONE : effect2 instanceof Tagger ? new Tagger([...effect2.tags, tag2], effect2.source) : new Tagger([tag2], effect2) + ); + var Tagger = class { + /** + * @param {Task.Task} source + * @param {string[]} tags + */ + constructor(tags, source) { + this.tags = tags; + this.source = source; + this.controller; + } + /* c8 ignore next 3 */ + [Symbol.iterator]() { + if (!this.controller) { + this.controller = this.source[Symbol.iterator](); + } + return this; + } + /** + * @param {Task.TaskState} state + * @returns {Task.TaskState>} + */ + box(state) { + if (state.done) { + return state; + } else { + switch (state.value) { + case SUSPEND: + case CURRENT: + return ( + /** @type {Task.TaskState>} */ + state + ); + default: { + const tagged = ( + /** @type {{ done: false, value: any }} */ + state + ); + let { value } = tagged; + for (const tag2 of this.tags) { + value = withTag(tag2, value); + } + tagged.value = value; + return tagged; + } + } + } + } + /** + * + * @param {Task.Instruction} instruction + */ + next(instruction) { + return this.box(this.controller.next(instruction)); + } + /** + * + * @param {Failure} error + */ + throw(error7) { + return this.box(this.controller.throw(error7)); + } + /** + * @param {Success} value + */ + return(value) { + return this.box(this.controller.return(value)); + } + get [Symbol.toStringTag]() { + return "TaggedEffect"; + } + }; + var none = () => NONE; + var withTag = (tag2, value) => ( + /** @type {Tagged} */ + { type: tag2, [tag2]: value } + ); + var CURRENT = Symbol("current"); + var SUSPEND = Symbol("suspend"); + var Group = class _Group { + /** + * @template T, X, M + * @param {Task.Controller|Task.Fork} member + * @returns {Task.Group} + */ + static of(member) { + return ( + /** @type {{group?:Task.TaskGroup}} */ + member.group || MAIN + ); + } + /** + * @template T, X, M + * @param {(Task.Controller|Task.Fork) & {group?:Task.TaskGroup}} member + * @param {Task.TaskGroup} group + */ + static enqueue(member, group2) { + member.group = group2; + group2.stack.active.push(member); + } + /** + * @param {Task.Controller} driver + * @param {Task.Controller[]} [active] + * @param {Set>} [idle] + * @param {Task.Stack} [stack] + */ + constructor(driver, active = [], idle = /* @__PURE__ */ new Set(), stack = new Stack(active, idle)) { + this.driver = driver; + this.parent = _Group.of(driver); + this.stack = stack; + this.id = ++ID; + } + }; + var Main = class { + constructor() { + this.status = IDLE; + this.stack = new Stack(); + this.id = /** @type {0} */ + 0; + } + }; + var Stack = class { + /** + * @param {Task.Controller[]} [active] + * @param {Set>} [idle] + */ + constructor(active = [], idle = /* @__PURE__ */ new Set()) { + this.active = active; + this.idle = idle; + } + /** + * + * @param {Task.Stack} stack + * @returns + */ + static size({ active, idle }) { + return active.length + idle.size; + } + }; + var main = (task) => enqueue(task[Symbol.iterator]()); + var enqueue = (task) => { + let group2 = Group.of(task); + group2.stack.active.push(task); + group2.stack.idle.delete(task); + while (group2.parent) { + const { idle, active } = group2.parent.stack; + if (idle.has(group2.driver)) { + idle.delete(group2.driver); + active.push(group2.driver); + } else { + break; + } + group2 = group2.parent; + } + if (MAIN.status === IDLE) { + MAIN.status = ACTIVE; + while (true) { + try { + for (const _message of step(MAIN)) { + } + MAIN.status = IDLE; + break; + } catch (_error) { + MAIN.stack.active.shift(); + } + } + } + }; + var resume = (task) => enqueue(task); + var step = function* (group2) { + const { active } = group2.stack; + let task = active[0]; + group2.stack.idle.delete(task); + while (task) { + let state = INIT; + loop: + while (!state.done && task === active[0]) { + const instruction = state.value; + switch (instruction) { + case SUSPEND: + group2.stack.idle.add(task); + break loop; + case CURRENT: + state = task.next(task); + break; + default: + state = task.next( + yield ( + /** @type {M & Task.Message}*/ + instruction + ) + ); + break; + } + } + active.shift(); + task = active[0]; + group2.stack.idle.delete(task); + } + }; + var fork = (task, options) => new Fork(task, options); + var exit = (handle, value) => conclude(handle, { ok: true, value }); + var abort = (handle, error7) => conclude(handle, { ok: false, error: error7 }); + function* conclude(handle, result) { + try { + const task = handle; + const state = result.ok ? task.return(result.value) : task.throw(result.error); + if (!state.done) { + if (state.value === SUSPEND) { + const { idle } = Group.of(task).stack; + idle.add(task); + } else { + enqueue(task); + } + } + } catch (error7) { + } + } + function* group(forks) { + if (forks.length === 0) + return; + const self2 = yield* current(); + const group2 = new Group(self2); + let failure = null; + for (const fork5 of forks) { + const { result } = fork5; + if (result) { + if (!result.ok && !failure) { + failure = result; + } + continue; + } + move(fork5, group2); + } + try { + if (failure) { + throw failure.error; + } + while (true) { + yield* step(group2); + if (Stack.size(group2.stack) > 0) { + yield* suspend(); + } else { + break; + } + } + } catch (error7) { + for (const task of group2.stack.active) { + yield* abort(task, error7); + } + for (const task of group2.stack.idle) { + yield* abort(task, error7); + enqueue(task); + } + throw error7; + } + } + var move = (fork5, group2) => { + const from18 = Group.of(fork5); + if (from18 !== group2) { + const { active, idle } = from18.stack; + const target = group2.stack; + fork5.group = group2; + if (idle.has(fork5)) { + idle.delete(fork5); + target.idle.add(fork5); + } else { + const index2 = active.indexOf(fork5); + if (index2 >= 0) { + active.splice(index2, 1); + target.active.push(fork5); + } + } + } + }; + function* join(fork5) { + if (fork5.status === IDLE) { + yield* fork5; + } + if (!fork5.result) { + yield* group([fork5]); + } + const result = ( + /** @type {Task.Result} */ + fork5.result + ); + if (result.ok) { + return result.value; + } else { + throw result.error; + } + } + var Future = class { + /** + * @param {Task.StateHandler} handler + */ + constructor(handler) { + this.handler = handler; + this.result; + } + /** + * @type {Promise} + */ + get promise() { + const { result } = this; + const promise = result == null ? new Promise((succeed, fail5) => { + this.handler.onsuccess = succeed; + this.handler.onfailure = fail5; + }) : result.ok ? Promise.resolve(result.value) : Promise.reject(result.error); + Object.defineProperty(this, "promise", { value: promise }); + return promise; + } + /** + * @template U, [E=never] + * @param {((value:T) => U | PromiseLike)|undefined|null} [onresolve] + * @param {((error:X) => E|PromiseLike)|undefined|null} [onreject] + * @returns {Promise} + */ + then(onresolve, onreject) { + return this.activate().promise.then(onresolve, onreject); + } + /** + * @template [U=never] + * @param {(error:X) => U} onreject + */ + catch(onreject) { + return ( + /** @type {Task.Future} */ + this.activate().promise.catch(onreject) + ); + } + /** + * @param {() => void} onfinally + * @returns {Task.Future} + */ + finally(onfinally) { + return ( + /** @type {Task.Future} */ + this.activate().promise.finally(onfinally) + ); + } + /** + * @abstract + */ + /* c8 ignore next 3 */ + activate() { + return this; + } + }; + var Fork = class extends Future { + /** + * @param {Task.Task} task + * @param {Task.ForkOptions} [options] + * @param {Task.StateHandler} [handler] + * @param {Task.TaskState} [state] + */ + constructor(task, options = BLANK2, handler = {}, state = INIT) { + super(handler); + this.id = ++ID; + this.name = options.name || ""; + this.task = task; + this.state = state; + this.status = IDLE; + this.result; + this.handler = handler; + this.controller; + } + *resume() { + resume(this); + } + /** + * @returns {Task.Task} + */ + join() { + return join(this); + } + /** + * @param {X} error + */ + abort(error7) { + return abort(this, error7); + } + /** + * @param {T} value + */ + exit(value) { + return exit(this, value); + } + get [Symbol.toStringTag]() { + return "Fork"; + } + /** + * @returns {Task.Controller, never, never>} + */ + *[Symbol.iterator]() { + return this.activate(); + } + activate() { + this.controller = this.task[Symbol.iterator](); + this.status = ACTIVE; + enqueue(this); + return this; + } + /** + * @private + * @param {any} error + * @returns {never} + */ + panic(error7) { + this.result = { ok: false, error: error7 }; + this.status = FINISHED; + const { handler } = this; + if (handler.onfailure) { + handler.onfailure(error7); + } + throw error7; + } + /** + * @private + * @param {Task.TaskState} state + */ + step(state) { + this.state = state; + if (state.done) { + this.result = { ok: true, value: state.value }; + this.status = FINISHED; + const { handler } = this; + if (handler.onsuccess) { + handler.onsuccess(state.value); + } + } + return state; + } + /** + * @param {unknown} value + */ + next(value) { + try { + return this.step(this.controller.next(value)); + } catch (error7) { + return this.panic(error7); + } + } + /** + * @param {T} value + */ + return(value) { + try { + return this.step(this.controller.return(value)); + } catch (error7) { + return this.panic(error7); + } + } + /** + * @param {X} error + */ + throw(error7) { + try { + return this.step(this.controller.throw(error7)); + } catch (error8) { + return this.panic(error8); + } + } + }; + var loop = function* (init3, next) { + const controller = yield* current(); + const group2 = new Group(controller); + Group.enqueue(init3[Symbol.iterator](), group2); + while (true) { + for (const message2 of step(group2)) { + Group.enqueue(next(message2)[Symbol.iterator](), group2); + } + if (Stack.size(group2.stack) > 0) { + yield* suspend(); + } else { + break; + } + } + }; + var ID = 0; + var IDLE = "idle"; + var ACTIVE = "active"; + var FINISHED = "finished"; + var INIT = { done: false, value: CURRENT }; + var BLANK2 = {}; + var NONE = /* @__PURE__ */ function* none2() { + }(); + var MAIN = new Main(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/layout/api.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/chunker.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/chunker/buffer.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/chunker/indexed.js + init_dirname(); + init_buffer2(); + init_process(); + function Indexed() { + } + Object.defineProperties(Indexed, { + prototype: { + value: new Proxy(Object.prototype, { + /** + * @param {object} target + * @param {PropertyKey} property + * @param {{get(key:PropertyKey): any}} receiver + */ + get(target, property, receiver) { + return typeof property === "symbol" ? Reflect.get(target, property, receiver) : receiver.get(property); + } + }) + } + }); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/chunker/buffer.js + var empty3 = () => new BufferView(); + var slice3 = (buffer4, startOffset = 0, endOffset = buffer4.byteLength) => { + const segments = []; + const start = startOffset < 0 ? buffer4.byteLength - startOffset : startOffset; + const end = endOffset < 0 ? buffer4.byteLength - endOffset : endOffset; + if (start === 0 && end >= buffer4.byteLength) { + return buffer4; + } + if (start > end || start > buffer4.byteLength || end <= 0) { + return empty3(); + } + let byteLength = 0; + let offset2 = 0; + for (const segment of buffer4.segments) { + const nextOffset = offset2 + segment.byteLength; + if (byteLength === 0) { + if (end <= nextOffset) { + const range = segment.subarray(start - offset2, end - offset2); + segments.push(range); + byteLength = range.byteLength; + break; + } else if (start < nextOffset) { + const range = start === offset2 ? segment : segment.subarray(start - offset2); + segments.push(range); + byteLength = range.byteLength; + } + } else if (end <= nextOffset) { + const range = end === nextOffset ? segment : segment.subarray(0, end - offset2); + segments.push(range); + byteLength += range.byteLength; + break; + } else { + segments.push(segment); + byteLength += segment.byteLength; + } + offset2 = nextOffset; + } + return new BufferView(segments, buffer4.byteOffset + start, byteLength); + }; + var push = (buffer4, part) => { + if (part.byteLength > 0) { + buffer4.segments.push(part); + return new BufferView( + buffer4.segments, + buffer4.byteOffset, + buffer4.byteLength + part.byteLength + ); + } else { + return buffer4; + } + }; + var get5 = (buffer4, n9) => { + if (n9 < buffer4.byteLength) { + let offset2 = 0; + for (const segment of buffer4.segments) { + if (n9 < offset2 + segment.byteLength) { + return segment[n9 - offset2]; + } else { + offset2 += segment.byteLength; + } + } + } + return void 0; + }; + var copyTo = (buffer4, target, byteOffset) => { + let offset2 = byteOffset; + for (const segment of buffer4.segments) { + target.set(segment, offset2); + offset2 += segment.byteLength; + } + return target; + }; + function* iterate2(buffer4) { + for (const part of buffer4.segments) { + yield* part; + } + } + var BufferView = class extends Indexed { + /** + * @param {Uint8Array[]} segments + * @param {number} byteOffset + * @param {number} byteLength + */ + constructor(segments = [], byteOffset = 0, byteLength = 0) { + super(); + this.segments = segments; + this.byteLength = byteLength; + this.length = byteLength; + this.byteOffset = byteOffset; + } + [Symbol.iterator]() { + return iterate2(this); + } + /** + * @param {number} [start] + * @param {number} [end] + */ + slice(start, end) { + return ( + /** @type {BufferView} */ + slice3(this, start, end) + ); + } + /** + * @param {number} [start] + * @param {number} [end] + */ + subarray(start, end) { + return ( + /** @type {BufferView} */ + slice3(this, start, end) + ); + } + /** + * + * @param {Uint8Array} bytes + */ + push(bytes2) { + return ( + /** @type {BufferView} */ + push(this, bytes2) + ); + } + /** + * @param {number} n + */ + get(n9) { + return get5(this, n9); + } + /** + * + * @param {Uint8Array} target + * @param {number} offset + */ + copyTo(target, offset2) { + return copyTo(this, target, offset2); + } + }; + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/chunker/api.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/writer/util.js + init_dirname(); + init_buffer2(); + init_process(); + var panic2 = (reason) => { + throw new Error(reason); + }; + var unreachable = (template, subject, ...substitutions) => panic2(String.raw(template, JSON.stringify(subject), ...substitutions)); + var EMPTY_BUFFER2 = new Uint8Array(0); + var EMPTY2 = []; + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/chunker.js + var open2 = (config2) => ({ + config: config2, + buffer: empty3() + }); + var write4 = (state, bytes2) => bytes2.byteLength > 0 ? split(state.config, state.buffer.push(bytes2), false) : { ...state, chunks: EMPTY2 }; + var close2 = (state) => split(state.config, state.buffer, true); + var split = (config2, buffer4, end) => { + const chunker2 = config2.chunker; + const chunks = []; + let offset2 = 0; + for (const size4 of chunker2.cut(chunker2.context, buffer4, end)) { + if (size4 > 0) { + const chunk = buffer4.subarray(offset2, offset2 + size4); + chunks.push(chunk); + offset2 += size4; + } + } + return { config: config2, chunks, buffer: buffer4.subarray(offset2) }; + }; + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/layout/queue.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/layout/queue/api.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/layout/queue.js + var mutable = () => ({ + mutable: true, + needs: {}, + nodes: {}, + links: {}, + linked: EMPTY3 + }); + var addNodes = (newNodes, input) => { + let queue = patch(input, {}); + for (const node of newNodes) { + const { ready, has: has4, wants } = collect(node.children, queue.links); + if (wants.length === 0) { + queue = patch(queue, { + links: assign(void 0, has4), + linked: [{ id: node.id, links: ready }] + }); + } else { + queue = patch(queue, { + needs: assign(node.id, wants), + nodes: { + [node.id]: { + children: node.children, + count: wants.length + } + } + }); + } + } + return queue; + }; + var addLink = (id, link10, queue) => { + const nodeID = queue.needs[id]; + const node = queue.nodes[nodeID]; + if (node != null) { + if (node.count === 1) { + const { ready, has: has4 } = collect(node.children, { + ...queue.links, + [id]: link10 + }); + return patch(queue, { + needs: { [id]: void 0 }, + links: assign(void 0, has4), + nodes: { [nodeID]: void 0 }, + linked: [{ id: nodeID, links: ready }] + }); + } else { + return patch(queue, { + needs: { [id]: void 0 }, + links: { [id]: link10 }, + nodes: { + [nodeID]: { + ...node, + count: node.count - 1 + } + } + }); + } + } else { + return patch(queue, { + links: { [id]: link10 } + }); + } + }; + var patch = (queue, { needs, nodes, links: links4, linked }) => { + const result = queue.mutable ? queue : { ...queue }; + const original = queue.mutable ? BLANK3 : void 0; + if (needs) { + result.needs = patchDict(queue.needs, needs, original); + } + if (nodes) { + result.nodes = patchDict(queue.nodes, nodes, original); + } + if (links4) { + result.links = patchDict(queue.links, links4, original); + } + result.linked = linked ? append(queue.linked || EMPTY3, linked, EMPTY3) : queue.linked || []; + return ( + /** @type {Queue.Result} */ + result + ); + }; + var assign = (value, keys2) => { + const delta = ( + /** @type {Record} */ + {} + ); + for (const key of keys2) { + delta[key] = value; + } + return delta; + }; + var patchDict = (target, delta, original = target) => { + const result = target === original ? { ...target } : target; + for (const entry of Object.entries(delta)) { + const [id, value] = ( + /** @type {[K, V|void]} */ + entry + ); + if (value == null) { + delete result[id]; + } else { + result[id] = value; + } + } + return result; + }; + var append = (target, items, original = target) => { + if (target === original) { + return [...target, ...items]; + } else { + for (const item of items) { + target.push(item); + } + return target; + } + }; + var collect = (children, source) => { + const has4 = []; + const wants = []; + const ready = []; + for (const child of children) { + const link10 = source[child]; + if (link10) { + has4.push(child); + ready.push(link10); + } else { + wants.push(child); + } + } + return { has: has4, wants, ready }; + }; + var EMPTY3 = ( + /** @type {never[]} */ + Object.freeze([]) + ); + var BLANK3 = ( + /** @type {Record} */ + Object.freeze({}) + ); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/writer.js + var update = (message2, state) => { + switch (message2.type) { + case "write": + return write5(state, message2.bytes); + case "link": + return link4(state, message2.link); + case "block": + return { state, effect: none() }; + case "close": + return close3(state); + case "end": + return { state, effect: none() }; + default: + return unreachable`File Writer got unknown message ${message2}`; + } + }; + var init = (writer2, metadata, config2) => { + return { + status: "open", + metadata, + config: config2, + writer: writer2, + chunker: open2({ chunker: config2.chunker }), + layout: config2.fileLayout.open(), + // Note: Writing in large slices e.g. 1GiB at a time creates large queues + // with around `16353` items. Immutable version ends up copying it every + // time state of the queue changes, which introduces significant overhead. + // To avoid this overhead we use mutable implementation which is API + // compatible but makes in place updates. + // TODO: We should consider using Persistent bit-partitioned vector tries + // instead of arrays which would provide immutable interface with neglegable + // overhead. + // @see https://github.com/Gozala/vectrie + nodeQueue: mutable() + }; + }; + var write5 = (state, bytes2) => { + if (state.status === "open") { + const { chunks, ...chunker2 } = write4(state.chunker, bytes2); + const { nodes, leaves, layout } = state.config.fileLayout.write( + state.layout, + chunks + ); + const { linked, ...nodeQueue } = addNodes(nodes, state.nodeQueue); + const tasks = [ + ...encodeLeaves(leaves, state.config), + ...encodeBranches(linked, state.config) + ]; + return { + state: { + ...state, + chunker: chunker2, + layout, + nodeQueue + }, + effect: listen({ + link: effects(tasks) + }) + }; + } else { + return panic2("Unable to perform write on closed file"); + } + }; + var link4 = (state, { id, link: link10, block }) => { + let { linked, ...nodeQueue } = addLink(id, link10, state.nodeQueue); + const tasks = encodeBranches(linked, state.config); + const newState = state.status === "closed" && id === state.rootID ? { + ...state, + status: "linked", + link: link10, + nodeQueue + } : { ...state, nodeQueue }; + const end = state.status === "closed" && id === state.rootID && state.end ? state.end.resume() : none(); + return { + state: newState, + effect: listen({ + link: effects(tasks), + block: writeBlock(state.writer, block), + end + }) + }; + }; + var close3 = (state) => { + if (state.status === "open") { + const { chunks } = close2(state.chunker); + const { layout, ...write11 } = state.config.fileLayout.write( + state.layout, + chunks + ); + const { root: root3, ...close10 } = state.config.fileLayout.close( + layout, + state.metadata + ); + const [nodes, leaves] = isLeafNode(root3) ? [ + [...write11.nodes, ...close10.nodes], + [...write11.leaves, ...close10.leaves, root3] + ] : [ + [...write11.nodes, ...close10.nodes, root3], + [...write11.leaves, ...close10.leaves] + ]; + const { linked, ...nodeQueue } = addNodes(nodes, state.nodeQueue); + const tasks = [ + ...encodeLeaves(leaves, state.config), + ...encodeBranches(linked, state.config) + ]; + const fork5 = fork(suspend()); + return { + state: { + ...state, + chunker: null, + layout: null, + rootID: root3.id, + status: "closed", + end: fork5, + nodeQueue + }, + effect: listen({ + link: effects(tasks), + end: join(fork5) + }) + }; + } else { + return { state, effect: none() }; + } + }; + var encodeLeaves = (leaves, config2) => leaves.map((leaf) => encodeLeaf(config2, leaf, config2.fileChunkEncoder)); + var encodeLeaf = function* ({ hasher, linker }, { id, content }, encoder4) { + const bytes2 = encoder4.encode(content ? asUint8Array2(content) : EMPTY_BUFFER2); + const hash = yield* wait(hasher.digest(bytes2)); + const cid = linker.createLink(encoder4.code, hash); + const block = { cid, bytes: bytes2 }; + const link10 = ( + /** @type {UnixFS.FileLink} */ + { + cid, + contentByteLength: content ? content.byteLength : 0, + dagByteLength: bytes2.byteLength + } + ); + return { id, block, link: link10 }; + }; + var encodeBranches = (nodes, config2) => nodes.map((node) => encodeBranch(config2, node)); + var encodeBranch = function* (config2, { id, links: links4 }, metadata) { + const bytes2 = config2.fileEncoder.encode({ + type: NodeType.File, + layout: "advanced", + parts: links4, + metadata + }); + const hash = yield* wait(Promise.resolve(config2.hasher.digest(bytes2))); + const cid = config2.linker.createLink(config2.fileEncoder.code, hash); + const block = { bytes: bytes2, cid }; + const link10 = ( + /** @type {UnixFS.FileLink} */ + { + cid, + contentByteLength: cumulativeContentByteLength(links4), + dagByteLength: cumulativeDagByteLength(bytes2, links4) + } + ); + return { id, block, link: link10 }; + }; + var writeBlock = function* (writer2, block) { + if ((writer2.desiredSize || 0) <= 0) { + yield* wait(writer2.ready); + } + writer2.write(block); + }; + var asUint8Array2 = (buffer4) => buffer4 instanceof Uint8Array ? buffer4 : buffer4.copyTo(new Uint8Array(buffer4.byteLength), 0); + var isLeafNode = (node) => node.children == null; + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/chunker/fixed.js + var fixed_exports = {}; + __export(fixed_exports, { + context: () => context, + cut: () => cut, + name: () => name10, + type: () => type, + withMaxChunkSize: () => withMaxChunkSize + }); + init_dirname(); + init_buffer2(); + init_process(); + var name10 = "fixed"; + var context = { + maxChunkSize: 262144 + }; + var type = "Stateless"; + var withMaxChunkSize = (maxChunkSize) => ({ + type: "Stateless", + context: { maxChunkSize }, + name: name10, + cut + }); + var cut = ({ maxChunkSize }, { byteLength }, end) => { + const n9 = byteLength / maxChunkSize | 0; + const chunks = new Array(n9).fill(maxChunkSize); + const lastChunkSize = end ? byteLength - n9 * maxChunkSize : 0; + if (lastChunkSize > 0) { + chunks.push(lastChunkSize); + } + return chunks; + }; + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file/layout/balanced.js + init_dirname(); + init_buffer2(); + init_process(); + var Node = class { + /** + * + * @param {number} id + * @param {number[]} children + * @param {Layout.Metadata} [metadata] + */ + constructor(id, children, metadata) { + this.id = id; + this.children = children; + this.metadata = metadata; + } + }; + var withWidth = (width) => ({ + open: () => open3({ width }), + write: write6, + close: close4 + }); + var defaults = { width: 174 }; + var open3 = ({ width } = defaults) => ({ + width, + head: null, + leafIndex: [], + nodeIndex: [], + lastID: 0 + }); + var write6 = (layout, chunks) => { + if (chunks.length === 0) { + return { layout, nodes: EMPTY4, leaves: EMPTY4 }; + } else { + let { lastID } = layout; + const [head2, slices] = layout.head ? ( + // If we had a head we have more then two chunks (we already checked + // chunks weren't empty) so we process head along with other chunks. + [null, (chunks.unshift(layout.head), chunks)] + ) : ( + // If we have no head no leaves and got only one chunk we have to save it + // until we can decide what to do with it. + chunks.length === 1 && layout.leafIndex.length === 0 ? [chunks[0], EMPTY4] : ( + // Otherwise we have no head but got enough chunks to know we'll have a + // node. + [null, chunks] + ) + ); + if (slices.length === 0) { + return { layout: { ...layout, head: head2 }, nodes: EMPTY4, leaves: EMPTY4 }; + } else { + const leafIndex = [...layout.leafIndex]; + const leaves = []; + for (const chunk of slices) { + const leaf = { id: ++lastID, content: chunk }; + leaves.push(leaf); + leafIndex.push(leaf.id); + } + if (leafIndex.length >= layout.width) { + return flush({ ...layout, leafIndex, head: head2, lastID }, leaves); + } else { + return { + layout: { ...layout, head: head2, leafIndex, lastID }, + leaves, + nodes: EMPTY4 + }; + } + } + } + }; + var flush = (state, leaves = EMPTY4, nodes = [], close10 = false) => { + let { lastID } = state; + const nodeIndex = state.nodeIndex.map((row) => [...row]); + const leafIndex = [...state.leafIndex]; + const { width } = state; + while (leafIndex.length >= width || leafIndex.length > 0 && close10) { + grow(nodeIndex, 1); + const node = new Node(++lastID, leafIndex.splice(0, width)); + nodeIndex[0].push(node.id); + nodes.push(node); + } + let depth = 0; + while (depth < nodeIndex.length) { + const row = nodeIndex[depth]; + depth++; + while (row.length >= width || row.length > 0 && close10 && depth < nodeIndex.length) { + const node = new Node(++lastID, row.splice(0, width)); + grow(nodeIndex, depth + 1); + nodeIndex[depth].push(node.id); + nodes.push(node); + } + } + return { layout: { ...state, lastID, leafIndex, nodeIndex }, leaves, nodes }; + }; + var close4 = (layout, metadata) => { + const state = layout; + if (layout.head) { + return { + root: { id: 1, content: layout.head, metadata }, + leaves: EMPTY4, + nodes: EMPTY4 + }; + } else if (layout.leafIndex.length === 0) { + return { + root: { id: 1, metadata }, + leaves: EMPTY4, + nodes: EMPTY4 + }; + } else { + const { nodes, layout: layout2 } = flush(state, EMPTY4, [], true); + const { nodeIndex } = layout2; + const height = nodeIndex.length - 1; + const top3 = nodeIndex[height]; + if (top3.length === 1) { + const root3 = nodes[nodes.length - 1]; + nodes.length = nodes.length - 1; + return { root: root3, nodes, leaves: EMPTY4 }; + } else { + const root3 = new Node(layout2.lastID + 1, top3, metadata); + return { root: root3, nodes, leaves: EMPTY4 }; + } + } + }; + var grow = (index2, length3) => { + while (index2.length < length3) { + index2.push([]); + } + return index2; + }; + var EMPTY4 = []; + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/file.js + var defaults2 = () => ({ + chunker: fixed_exports, + fileChunkEncoder: UnixFSLeaf, + smallFileEncoder: UnixFSLeaf, + fileEncoder: codec_exports2, + fileLayout: withWidth(174), + hasher: sha256, + linker: { createLink: CID2.createV1 } + }); + var configure = (config2) => ({ + ...defaults2(), + ...config2 + }); + var UnixFSLeaf = { + code: code10, + name: name9, + encode: encodeFileChunk + }; + var create8 = ({ writer: writer2, metadata = {}, settings: settings3 = defaults2() }) => new FileWriterView(init(writer2, metadata, configure(settings3))); + var write7 = async (view10, bytes2) => { + await perform(view10, send({ type: "write", bytes: bytes2 })); + return view10; + }; + var close5 = async (view10, { releaseLock = false, closeWriter = false } = {}) => { + await perform(view10, send({ type: "close" })); + const { state } = view10; + if (state.status === "linked") { + if (closeWriter) { + await view10.state.writer.close(); + } else if (releaseLock) { + view10.state.writer.releaseLock(); + } + return state.link; + } else { + panic2( + `Expected writer to be in 'linked' state after close, but it is in "${state.status}" instead` + ); + } + }; + var perform = (view10, effect2) => fork( + loop(effect2, (message2) => { + const { state, effect: effect3 } = update(message2, view10.state); + view10.state = state; + return effect3; + }) + ); + var FileWriterView = class { + /** + * @param {Writer.State} state + */ + constructor(state) { + this.state = state; + } + get writer() { + return this.state.writer; + } + get settings() { + return this.state.config; + } + /** + * @param {Uint8Array} bytes + * @returns {Promise>} + */ + write(bytes2) { + return write7(this, bytes2); + } + /** + * @param {API.CloseOptions} [options] + * @returns {Promise} + */ + close(options) { + return close5(this, options); + } + }; + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/directory.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/directory/api.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/directory.js + var defaults3 = defaults2; + var create9 = ({ writer: writer2, settings: settings3 = defaults3(), metadata = {} }) => new DirectoryWriter({ + writer: writer2, + metadata, + settings: settings3, + entries: /* @__PURE__ */ new Map(), + closed: false + }); + var set = (view10, name15, link10, { overwrite = false } = {}) => { + const writable = asWritable(view10.state); + if (name15.includes("/")) { + throw new Error( + `Directory entry name "${name15}" contains forbidden "/" character` + ); + } + if (!overwrite && writable.entries.has(name15)) { + throw new Error(`Directory already contains entry with name "${name15}"`); + } else { + writable.entries.set(name15, link10); + return view10; + } + }; + var remove8 = (view10, name15) => { + const writer2 = asWritable(view10.state); + writer2.entries.delete(name15); + return view10; + }; + var asWritable = (writer2) => { + if (!writer2.closed) { + return writer2; + } else { + throw new Error( + `Can not change written directory, but you can .fork() and make changes to it` + ); + } + }; + var close6 = async (view10, { closeWriter = false, releaseLock = false } = {}) => { + const { writer: writer2, settings: settings3, metadata } = asWritable(view10.state); + view10.state.closed = true; + const entries6 = [...links(view10)]; + const node = createFlatDirectory(entries6, metadata); + const bytes2 = encodeDirectory(node); + const digest3 = await settings3.hasher.digest(bytes2); + const cid = settings3.linker.createLink(code10, digest3); + if ((writer2.desiredSize || 0) <= 0) { + await writer2.ready; + } + writer2.write({ cid, bytes: bytes2 }); + if (closeWriter) { + await writer2.close(); + } else if (releaseLock) { + writer2.releaseLock(); + } + return { + cid, + dagByteLength: cumulativeDagByteLength(bytes2, entries6) + }; + }; + var links = function* ({ state }) { + for (const [name15, { dagByteLength, cid }] of state.entries) { + yield ( + /** @type {UnixFS.DirectoryEntryLink} */ + { + name: name15, + dagByteLength, + cid + } + ); + } + }; + var fork2 = ({ state }, { + writer: writer2 = state.writer, + metadata = state.metadata, + settings: settings3 = state.settings + } = {}) => new DirectoryWriter({ + writer: writer2, + metadata, + settings: settings3, + entries: new Map(state.entries.entries()), + closed: false + }); + var DirectoryWriter = class { + /** + * @param {API.State} state + */ + constructor(state) { + this.state = state; + } + get writer() { + return this.state.writer; + } + get settings() { + return this.state.settings; + } + links() { + return links(this); + } + /** + * @param {string} name + * @param {UnixFS.FileLink | UnixFS.DirectoryLink} link + * @param {API.WriteOptions} [options] + */ + set(name15, link10, options) { + return set(this, name15, link10, options); + } + /** + * @param {string} name + */ + remove(name15) { + return remove8(this, name15); + } + /** + * @template L + * @param {Partial>} [options] + * @returns {API.View} + */ + fork(options) { + return fork2(this, options); + } + /** + * @param {API.CloseOptions} [options] + * @returns {Promise} + */ + close(options) { + return close6(this, options); + } + entries() { + return this.state.entries.entries(); + } + /** + * @param {string} name + */ + has(name15) { + return this.state.entries.has(name15); + } + get size() { + return this.state.entries.size; + } + }; + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/sharded-directory.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/api.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/node.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/bitfield/Uint32.js + var Uint32_exports = {}; + __export(Uint32_exports, { + API: () => api_exports6, + and: () => and5, + bitCount: () => bitCount, + empty: () => empty4, + from: () => from12, + fromBytes: () => fromBytes2, + get: () => get6, + or: () => or10, + popcount: () => popcount, + set: () => set2, + size: () => size2, + toBytes: () => toBytes, + unset: () => unset + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/bitfield/api.js + var api_exports6 = {}; + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/bitfield/Uint32.js + var empty4 = (size4 = 32) => { + if (size4 !== 32) { + throw new Error(`Uint32 BitField does not support size: ${size4}`); + } + return 0; + }; + var from12 = (bits, size4) => { + let bitfield = empty4(size4); + for (const bit of bits) { + bitfield = set2(bitfield, bit); + } + return bitfield; + }; + var size2 = (_bitField) => 32; + var mask = (bitField2, index2) => bitField2 >>> index2 & 31; + var offset = (bitField2, index2) => 1 << mask(bitField2, index2); + var popcount = (bitField2, index2 = 31) => bitCount(bitField2 & offset(index2, 0) - 1); + var set2 = (bitField2, index2) => bitField2 | 1 << index2; + var unset = (bitField2, index2) => bitField2 & (255 ^ 1 << index2); + var get6 = (bitField2, index2) => (bitField2 >> index2 & 1) !== 0; + var bitCount = (bitField2) => { + const n1 = bitField2 - (bitField2 >> 1 & 1431655765); + const n22 = (n1 & 858993459) + (n1 >> 2 & 858993459); + const n32 = (n22 + (n22 >> 4) & 252645135) * 16843009; + return n32 >> 24; + }; + var and5 = (left, right) => left & right; + var or10 = (left, right) => left | right; + var toBytes = (bitField2) => Uint8Array.of( + bitField2 >> 24 & 255, + bitField2 >> 16 & 255, + bitField2 >> 8 & 255, + bitField2 & 255 + ); + var fromBytes2 = (bytes2) => { + if (bytes2.length !== 4) { + throw new Error(`Expected 4 bytes instead got ${bytes2.length}`); + } + return (bytes2[0] << 24) + (bytes2[1] << 16) + (bytes2[2] << 8) + bytes2[3]; + }; + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/path/Uint32.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/path/api.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/path/Uint32.js + var import_murmurhash3js_revisited = __toESM(require_murmurhash3js_revisited(), 1); + var utf8 = new TextEncoder(); + var hash32 = import_murmurhash3js_revisited.default.x64.hash126; + var configure2 = ({ bitWidth: bitWidth2 = 5, hash = hash32 }) => { + const hashSize = 4; + if (bitWidth2 > hashSize * 8) { + throw new RangeError( + `Can not use bitWidth ${bitWidth2} which exceeds the hashSize ${hashSize}` + ); + } + if (hashSize * 8 > 32) { + throw new RangeError( + `Can not use hashSize ${hashSize} as it can not be encoded in Uint32` + ); + } + const mask2 = 4294967295 >>> 32 - bitWidth2; + const at2 = (path2, depth) => path2 >>> depth * bitWidth2 & mask2; + const from18 = (key) => hash(utf8.encode(key)); + return { at: at2, from: from18, size: Math.ceil(hashSize * 8 / bitWidth2) }; + }; + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/node.js + var BitmapIndexedNode = class { + /** + * @param {API.Edit|null} edit + * @param {ReturnType} datamap + * @param {ReturnType} nodemap + * @param {API.Children} children + * @param {C} config + */ + constructor(edit, datamap, nodemap, children, config2) { + this.edit = edit; + this.config = config2; + this.datamap = datamap; + this.nodemap = nodemap; + this.children = children; + } + get nodeArity() { + return this.config.BitField.popcount(this.nodemap); + } + get dataArity() { + return this.config.BitField.popcount(this.datamap); + } + /** + * @returns {API.BitmapIndexedNode} + */ + /* c8 ignore next 3 */ + empty() { + return create10(this.config); + } + /** + * @template X + * @param {API.Uint32} depth + * @param {ReturnType} path + * @param {K} key + * @param {X} notFound + * @returns {T|X} + */ + lookup(depth, path2, key, notFound3) { + return lookup(this, depth, path2, key, notFound3); + } + /** + * @template {string} R + * @param {API.Edit|null} edit + * @param {API.Uint32} depth + * @param {ReturnType} path + * @param {K|R} key + * @param {T} value + * @param {{value:boolean}} addedLeaf + * @returns {API.BitmapIndexedNode} + */ + associate(edit, depth, path2, key, value, addedLeaf) { + return associate(this, edit, depth, path2, key, value, addedLeaf); + } + /** + * @param {API.Edit|null} edit + * @param {API.Uint32} depth + * @param {ReturnType} path + * @param {K} key + * @param {{value:boolean}} removedLeaf + * @returns {API.BitmapIndexedNode} + */ + dissociate(edit, depth, path2, key, removedLeaf) { + return dissociate(this, edit, depth, path2, key, removedLeaf); + } + /** + * @param {API.Edit|null} edit + * @returns {API.BitmapIndexedNode} + */ + fork(edit = null) { + return fork3(this, edit); + } + /** + * @returns {IterableIterator<[K, T]>} + */ + entries() { + return entries2(this); + } + /** + * @returns {IterableIterator} + */ + keys() { + return keys(this); + } + /** + * @returns {IterableIterator} + */ + values() { + return values(this); + } + }; + var HashCollisionNode = class { + /** + * @param {API.Edit|null} edit + * @param {number} count + * @param {API.CollisionEntries} children + * @param {C} config + */ + /* c8 ignore next 12 */ + constructor(edit, count, children, config2) { + this.edit = edit; + this.count = count; + this.children = children; + this.config = config2; + } + get nodeArity() { + return ( + /** @type {0} */ + 0 + ); + } + get dataArity() { + return this.count; + } + /** + * @template X + * @param {API.Uint32} _shift + * @param {unknown} _path + * @param {K} key + * @param {X} notFound + * @returns {T|X} + */ + /* c8 ignore next 3 */ + lookup(_shift, _path, key, notFound3) { + return lookupCollision(this, key, notFound3); + } + /** + * @template {string} R + * @param {API.Edit|null} edit + * @param {API.Uint32} _shift + * @param {ReturnType} path + * @param {K|R} key + * @param {T} value + * @param {{value:boolean}} addedLeaf + * @returns {API.HashCollisionNode} + */ + /* c8 ignore next 3 */ + associate(edit, _shift, path2, key, value, addedLeaf) { + return associateCollision(this, edit, path2, key, value, addedLeaf); + } + /** + * @param {API.Edit|null} edit + * @param {API.Uint32} _shift + * @param {ReturnType} path + * @param {K} key + * @param {{value:boolean}} removedLeaf + * @returns {API.Node} + */ + /* c8 ignore next 3 */ + dissociate(edit, _shift, path2, key, removedLeaf) { + return dissociateCollision(this, edit, path2, key, removedLeaf); + } + /** + * @param {API.Edit|null} edit + * @returns {this} + */ + /* c8 ignore next 3 */ + fork(edit = null) { + return ( + /** @type {this} */ + forkCollision(this, edit) + ); + } + /** + * @returns {IterableIterator<[K, T]>} + */ + /* c8 ignore next 3 */ + entries() { + return entries2(this); + } + /** + * @returns {IterableIterator} + */ + /* c8 ignore next 3 */ + keys() { + return keys(this); + } + /** + * @returns {IterableIterator} + */ + /* c8 ignore next 3 */ + values() { + return values(this); + } + }; + var lookupCollision = (node, name15, notFound3) => { + const { children: entries6, count } = node; + const n9 = findHashCollisionNodeIndex(entries6, count, name15); + return entries6[n9] === name15 ? ( + /** @type {T} */ + entries6[n9 + 1] + ) : notFound3; + }; + var associateCollision = (node, edit, key, name15, value, addedLeaf) => { + const { children, count } = node; + const index2 = findHashCollisionNodeIndex(children, count, name15); + if (children[index2] !== name15) { + const newNode = node.fork(edit); + addedLeaf.value = true; + newNode.count += 1; + newNode.children.splice(index2, key, value); + return newNode; + } else if (children[index2 + 1] !== value) { + const newNode = node.fork(edit); + newNode.children[index2 + 1] = value; + return newNode; + } else { + return node; + } + }; + var dissociateCollision = (node, edit, hash, name15, removedLeaf) => { + const { children: entries6, count, config: config2 } = node; + const index2 = findHashCollisionNodeIndex(entries6, count, name15); + if (entries6[index2] !== name15) { + return node; + } else { + removedLeaf.value = true; + if (count === 2) { + const offset2 = index2 === 0 ? 2 : 0; + return ( + /** @type {API.BitmapIndexedNode} */ + associate( + create10(config2), + edit, + 0, + hash, + /** @type {K} */ + entries6[offset2], + /** @type {T} */ + entries6[offset2 + 1], + removedLeaf + ) + ); + } else { + const newNode = node.fork(edit); + newNode.children.splice(index2, 2); + newNode.count -= 1; + return newNode; + } + } + }; + var forkCollision = (node, edit = null) => { + if (canEdit(node.edit, edit)) { + return node; + } else { + return new HashCollisionNode( + edit, + node.count, + /** @type {API.CollisionEntries} */ + node.children.slice(), + node.config + ); + } + }; + var findHashCollisionNodeIndex = (entries6, count, key) => { + let index2 = 0; + while (index2 < count && entries6[index2] > key) { + index2 += 2; + } + return index2; + }; + var create10 = (config2, edit = null) => new BitmapIndexedNode( + edit, + config2.BitField.empty(Math.pow(2, config2.bitWidth)), + config2.BitField.empty(Math.pow(2, config2.bitWidth)), + /** @type {API.Children} */ + [], + config2 + ); + var get7 = (node, key, notFound3) => lookup(node, 0, node.config.Path.from(key), key, notFound3); + var lookup = (node, depth, path2, key, notFound3) => { + const { datamap, nodemap, config: config2 } = node; + const { Path, BitField } = config2; + const offset2 = Path.at(path2, depth); + if (BitField.get(datamap, offset2)) { + const index2 = BitField.popcount(datamap, offset2); + if (keyAt(node, index2) === key) { + return valueAt(node, index2); + } else { + return notFound3; + } + } else if (BitField.get(nodemap, offset2)) { + const child = resolveNode(node, offset2); + return child.lookup(depth + 1, path2, key, notFound3); + } else { + return notFound3; + } + }; + var set3 = (node, edit, key, value, addedLeaf) => associate(node, edit, 0, node.config.Path.from(key), key, value, addedLeaf); + var associate = (node, edit, depth, path2, key, value, addedLeaf) => { + const { datamap, nodemap, config: config2 } = node; + const { Path, BitField } = config2; + const offset2 = Path.at(path2, depth); + if (BitField.get(datamap, offset2)) { + const index2 = BitField.popcount(datamap, offset2); + const found = keyAt(node, index2); + if (key === found) { + return valueAt(node, index2) === value ? node : forkAndSet(node, edit, index2, value); + } else { + const branch = mergeTwoLeaves( + config2, + edit, + depth + 1, + Path.from(found), + found, + valueAt(node, index2), + path2, + key, + value + ); + addedLeaf.value = true; + return migrateLeafToBranch(node, edit, offset2, branch); + } + } else if (BitField.get(nodemap, offset2)) { + const child = resolveNode(node, offset2); + const newChild = child.associate( + edit, + depth + 1, + path2, + key, + value, + addedLeaf + ); + if (child === newChild) { + return node; + } else { + return copyAndSetChild(node, edit, offset2, newChild); + } + } else { + const index2 = BitField.popcount(datamap, offset2); + addedLeaf.value = true; + const newNode = node.fork(edit); + newNode.datamap = BitField.set(datamap, offset2); + newNode.children.splice(keyPosition(index2), 0, key, value); + return newNode; + } + }; + var remove9 = (node, edit, key, removedLeaf) => dissociate(node, edit, 0, node.config.Path.from(key), key, removedLeaf); + var dissociate = (source, edit, depth, path2, key, removedLeaf) => { + const { datamap, nodemap, config: config2 } = source; + const { BitField, Path } = config2; + const offset2 = Path.at(path2, depth); + if (BitField.get(datamap, offset2)) { + const index2 = BitField.popcount(datamap, offset2); + if (key === keyAt(source, index2)) { + removedLeaf.value = true; + const node = fork3(source, edit); + node.datamap = BitField.unset(source.datamap, offset2); + node.children.splice(keyPosition(index2), 2); + return node; + } else { + return source; + } + } else if (BitField.get(nodemap, offset2)) { + const node = resolveNode(source, offset2); + const child = node.dissociate(edit, depth + 1, path2, key, removedLeaf); + if (hasSingleLeaf(child)) { + return hasSingleNode(source) ? child : inlineChild(source, edit, offset2, child); + } else if (node === child) { + return source; + } else { + return copyAndSetChild(source, edit, offset2, child); + } + } else { + return source; + } + }; + var entries2 = function* ({ children }) { + let offset2 = 0; + const count = children.length; + while (offset2 < count) { + const key = children[offset2]; + if (typeof key === "string") { + offset2 += 1; + const value = children[offset2]; + yield ( + /** @type {[K, T]} */ + [key, value] + ); + offset2 += 1; + } else { + break; + } + } + while (offset2 < count) { + const node = ( + /** @type {API.BitmapIndexedNode} */ + children[offset2] + ); + yield* node.entries(); + offset2 += 1; + } + }; + var fork3 = (node, edit) => { + if (canEdit(node.edit, edit)) { + return node; + } else { + const newNode = new BitmapIndexedNode( + edit, + node.datamap, + node.nodemap, + node.children.slice(), + node.config + ); + return newNode; + } + }; + var keys = function* ({ children }) { + let offset2 = 0; + const count = children.length; + while (offset2 < count) { + const key = children[offset2]; + if (typeof key === "string") { + yield ( + /** @type {K} */ + key + ); + offset2 += 2; + } else { + break; + } + } + while (offset2 < count) { + const node = ( + /** @type {API.BitmapIndexedNode} */ + children[offset2] + ); + yield* node.keys(); + offset2 += 1; + } + }; + var values = function* ({ children }) { + let offset2 = 0; + const count = children.length; + while (offset2 < count) { + const key = children[offset2]; + if (typeof key === "string") { + offset2 += 1; + yield ( + /** @type {T} */ + children[offset2] + ); + offset2 += 1; + } else { + break; + } + } + while (offset2 < count) { + const node = ( + /** @type {API.BitmapIndexedNode} */ + children[offset2] + ); + yield* node.values(); + offset2 += 1; + } + }; + var forkAndSet = (node, edit, offset2, value) => { + const newNode = node.fork(edit); + newNode.children[valuePosition(offset2)] = value; + return newNode; + }; + var inlineChild = (source, edit, offset2, child) => { + const { datamap, nodemap, config: config2 } = source; + const { BitField } = config2; + const node = fork3(source, edit); + node.children.splice(nodePosition(source, offset2), 1); + node.children.splice( + keyPosition(BitField.popcount(datamap, offset2)), + 0, + child.children[0], + child.children[1] + ); + node.datamap = BitField.set(datamap, offset2); + node.nodemap = BitField.unset(nodemap, offset2); + return node; + }; + var copyAndSetChild = (node, edit, offset2, child) => { + const newNode = fork3(node, edit); + newNode.children[nodePosition(node, offset2)] = child; + return newNode; + }; + var migrateLeafToBranch = (source, edit, offset2, branch) => { + const { nodemap, datamap, config: config2 } = source; + const { BitField } = config2; + const index2 = BitField.popcount(datamap, offset2); + const oldId = keyPosition(index2); + const newId = nodePosition(source, offset2); + const node = fork3(source, edit); + node.datamap = BitField.unset(datamap, offset2); + node.children.splice(oldId, 2); + node.nodemap = BitField.set(nodemap, offset2); + node.children.splice(newId - 1, 0, branch); + return node; + }; + var mergeTwoLeaves = (config2, edit, depth, oldPath, oldKey, oldValue, newPath, newKey, newValue) => { + const { BitField, Path } = config2; + if (Path.size < depth) { + return new HashCollisionNode( + edit, + 2, + [oldKey, oldValue, newKey, newValue], + config2 + ); + } else { + const oldOffset = Path.at(oldPath, depth); + const newOffset = Path.at(newPath, depth); + if (oldOffset === newOffset) { + return new BitmapIndexedNode( + edit, + BitField.empty(Math.pow(2, config2.bitWidth)), + BitField.from([oldOffset], Math.pow(2, config2.bitWidth)), + [ + mergeTwoLeaves( + config2, + edit, + depth + 1, + oldPath, + oldKey, + oldValue, + newPath, + newKey, + newValue + ) + ], + config2 + ); + } else { + return new BitmapIndexedNode( + edit, + BitField.from([oldOffset, newOffset], Math.pow(2, config2.bitWidth)), + BitField.empty(Math.pow(2, config2.bitWidth)), + /** @type {API.Children} */ + // We insert child with a lower index first so that we can derive it's + // index on access via popcount + oldOffset < newOffset ? [oldKey, oldValue, newKey, newValue] : [newKey, newValue, oldKey, oldValue], + config2 + ); + } + } + }; + var keyAt = ({ children }, index2) => ( + /** @type {K} */ + children[keyPosition(index2)] + ); + var keyPosition = (index2) => index2 * 2; + var valueAt = ({ children }, index2) => ( + /** @type {T} */ + children[valuePosition(index2)] + ); + var valuePosition = (index2) => index2 * 2 + 1; + var resolveNode = (node, offset2) => ( + /** @type {API.BitmapIndexedNode|API.HashCollisionNode} */ + node.children[nodePosition(node, offset2)] + ); + var nodePosition = ({ children, nodemap, config: config2 }, offset2) => children.length - 1 - config2.BitField.popcount(nodemap, offset2); + var canEdit = (owner, editor) => owner != null && owner === editor; + var hasSingleLeaf = (node) => node.nodeArity === 0 && node.dataArity === 1; + var hasSingleNode = ({ config: { BitField }, datamap, nodemap }) => BitField.popcount(datamap) === 0 && BitField.popcount(nodemap) === 1; + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/path/Uint8Array.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@multiformats+murmur3@2.1.5/node_modules/@multiformats/murmur3/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + init_src(); + init_hasher(); + var import_murmurhash3js_revisited2 = __toESM(require_murmurhash3js_revisited(), 1); + function fromNumberTo32BitBuf(number3) { + const bytes2 = new Array(4); + for (let i8 = 0; i8 < 4; i8++) { + bytes2[i8] = number3 & 255; + number3 = number3 >> 8; + } + return new Uint8Array(bytes2); + } + var murmur332 = from5({ + name: "murmur3-32", + code: 35, + encode: (input) => fromNumberTo32BitBuf(import_murmurhash3js_revisited2.default.x86.hash32(input)) + }); + var murmur3128 = from5({ + name: "murmur3-128", + code: 34, + encode: (input) => bytes_exports2.fromHex(import_murmurhash3js_revisited2.default.x64.hash128(input)) + }); + var murmur364 = from5({ + name: "murmur3-x64-64", + code: 34, + encode: (input) => bytes_exports2.fromHex(import_murmurhash3js_revisited2.default.x64.hash128(input)).subarray(0, 8) + }); + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/path/Uint8Array.js + var utf82 = new TextEncoder(); + var hash64 = (bytes2) => ( + /** @type {Uint8Array} */ + murmur364.encode(bytes2) + ); + var configure3 = ({ bitWidth: bitWidth2 = 8, hash = hash64 } = {}) => { + const hashSize = hash(new Uint8Array()).byteLength; + const at2 = (path2, depth) => { + const offset2 = depth * bitWidth2; + if (offset2 > hashSize) { + throw new RangeError(`Out of bounds`); + } + return toInt(path2, offset2, bitWidth2); + }; + const from18 = (key) => hash(utf82.encode(key)); + return { from: from18, at: at2, size: Math.ceil(hashSize * 8 / bitWidth2) }; + }; + var toInt = (bytes2, offset2, count) => { + let byteOffset = offset2 / 8 | 0; + let bitOffset = offset2 % 8; + let desired = count; + let bits = 0; + while (desired > 0 && byteOffset < bytes2.byteLength) { + const byte = bytes2[byteOffset]; + const available = 8 - bitOffset; + const taking = available < desired ? available : desired; + const bitsLeft = 8 - bitOffset - taking; + const mask2 = 255 >> bitOffset; + const value = (mask2 & byte) >> bitsLeft; + bits = (bits << taking) + value; + desired -= taking; + byteOffset++; + bitOffset = 0; + } + return bits; + }; + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/bitfield/Uint8Array.js + var Uint8Array_exports = {}; + __export(Uint8Array_exports, { + API: () => api_exports6, + and: () => and6, + empty: () => empty5, + from: () => from13, + fromBytes: () => fromBytes3, + get: () => get8, + or: () => or11, + popcount: () => popcount2, + set: () => set4, + size: () => size3, + toBytes: () => toBytes2, + unset: () => unset2 + }); + init_dirname(); + init_buffer2(); + init_process(); + var empty5 = (size4 = 256) => { + if (size4 % 8 !== 0) { + throw new Error(`Must be multiple of 8`); + } + return new Uint8Array(size4 / 8); + }; + var from13 = (bits, size4) => { + let bitfield = empty5(size4); + for (const index2 of bits) { + const { byte, byteOffset, bitOffset } = at(bitfield, index2); + bitfield[byteOffset] = byte | 1 << bitOffset; + } + return bitfield; + }; + var size3 = (bitfield) => bitfield.byteLength * 8; + var at = (bitfield, index2) => { + const byteOffset = bitfield.byteLength - 1 - (index2 / 8 | 0); + const bitOffset = index2 % 8; + const byte = bitfield[byteOffset]; + return { byte, byteOffset, bitOffset }; + }; + var setByte = (bytes2, index2, byte) => { + if (bytes2[index2] !== byte) { + const result = bytes2.slice(0); + result[index2] = byte; + return result; + } + return bytes2; + }; + var set4 = (bitfield, index2) => { + const { byte, byteOffset, bitOffset } = at(bitfield, index2); + return setByte(bitfield, byteOffset, byte | 1 << bitOffset); + }; + var unset2 = (bitfield, index2) => { + const { byte, byteOffset, bitOffset } = at(bitfield, index2); + return setByte(bitfield, byteOffset, byte & (255 ^ 1 << bitOffset)); + }; + var get8 = (bitfield, index2) => { + var { byte, bitOffset } = at(bitfield, index2); + return (byte >> bitOffset & 1) !== 0; + }; + var toBytes2 = (bitfield) => bitfield; + var fromBytes3 = (bytes2) => bytes2; + var popcount2 = (bitfield, index2 = bitfield.byteLength * 8) => { + const { byteOffset, bitOffset, byte } = at(bitfield, index2); + let count = popcount(byte, bitOffset); + let offset2 = bitfield.byteLength - 1; + while (offset2 > byteOffset) { + const byte2 = bitfield[offset2]; + count += bitCount(byte2); + offset2--; + } + return count; + }; + var or11 = (left, right) => { + const result = left.slice(); + let offset2 = 0; + while (offset2 < left.length) { + result[offset2] |= right[offset2]; + offset2++; + } + return result; + }; + var and6 = (left, right) => { + const result = left.slice(); + let offset2 = 0; + while (offset2 < left.length) { + result[offset2] &= right[offset2]; + offset2++; + } + return result; + }; + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/lib.js + var NOT_FOUND = new RangeError("Not Found"); + var configure4 = ({ + bitWidth: bitWidth2 = 5, + /* c8 ignore next 4 */ + BitField = bitWidth2 === 5 ? Uint32_exports : Uint8Array_exports, + Path = bitWidth2 === 5 ? configure2({ bitWidth: bitWidth2 }) : configure3({ bitWidth: bitWidth2 }) + } = {}) => ( + /** @type {C} */ + { bitWidth: bitWidth2, BitField, Path } + ); + var from14 = (entries6, options) => { + const node = ( + /** @type {API.HashMapBuilder} */ + builder(options) + ); + for (const [key, value] of entries6) { + node.set(key, value); + } + return node.build(); + }; + var has2 = (hamt, key) => get7(hamt.root, key, NOT_FOUND) !== NOT_FOUND; + var get9 = (hamt, key, notFound3 = ( + /** @type {U} */ + void 0 + )) => get7(hamt.root, key, notFound3); + var builder = (options) => { + const edit = {}; + const config2 = configure4(options); + return new HashMapBuilder( + edit, + 0, + create10(config2, edit), + config2 + ); + }; + var PersistentHashMap = class _PersistentHashMap { + /** + * + * @param {number} count + * @param {API.BitmapIndexedNode} root + * @param {C} config + */ + constructor(count = 0, root3, config2) { + this.count = count; + this.root = root3; + this.config = config2; + } + get size() { + return this.count; + } + clone() { + return new _PersistentHashMap(this.count, this.root, this.config); + } + /** + * @returns {API.PersistentHashMap} + */ + empty() { + return new _PersistentHashMap( + 0, + create10(this.config, null), + this.config + ); + } + /** + * @param {K} key + * @returns {boolean} + */ + has(key) { + return has2(this, key); + } + /** + * @param {K} key + * @returns {T|undefined} + */ + get(key) { + return get7(this.root, key, void 0); + } + /** + * @template {string} R + * @param {R} key + * @param {T} value + * @returns {PersistentHashMap} + */ + set(key, value) { + const addedLeaf = { value: false }; + const root3 = set3(this.root, null, key, value, addedLeaf); + if (root3 === this.root) { + return this; + } else { + return new _PersistentHashMap( + addedLeaf.value ? this.count + 1 : this.count, + root3, + this.config + ); + } + } + /** + * @param {K} key + */ + delete(key) { + const root3 = remove9(this.root, null, key, { value: false }); + if (root3 === this.root) { + return this; + } else { + return new _PersistentHashMap(this.count - 1, root3, this.config); + } + } + /* c8 ignore next 3 */ + get bitField() { + return this.config.BitField.or(this.root.datamap, this.root.nodemap); + } + [Symbol.iterator]() { + return this.entries(); + } + entries() { + return this.root.entries(); + } + keys() { + return this.root.keys(); + } + values() { + return this.root.values(); + } + /** + * @returns {API.HashMapBuilder} + */ + createBuilder() { + return new HashMapBuilder({}, this.count, this.root, this.config); + } + }; + var HashMapBuilder = class { + /** + * @param {API.Edit} edit + * @param {number} count + * @param {API.BitmapIndexedNode} root + * @param {C} config + */ + constructor(edit, count, root3, config2) { + this.edit = edit; + this.count = count; + this.root = root3; + this.config = config2; + } + get size() { + if (this.edit) { + return this.count; + } else { + throw new Error(`.size was accessed on the finalized builder`); + } + } + /** + * @template {string} R + * @param {R} key + * @param {T} value + * @returns {HashMapBuilder} + */ + set(key, value) { + if (this.edit) { + const addedLeaf = { value: false }; + const root3 = set3(this.root, this.edit, key, value, addedLeaf); + if (this.root !== root3) { + this.root = /** @type {API.BitmapIndexedNode} */ + root3; + } + if (addedLeaf.value) { + this.count += 1; + } + return this; + } else { + throw new Error(`.set was called on the finalized builder`); + } + } + /** + * @param {K} key + */ + delete(key) { + if (this.edit) { + if (this.count === 0) { + return this; + } + const removedLeaf = { value: false }; + const root3 = remove9(this.root, this.edit, key, removedLeaf); + if (root3 !== this.root) { + this.root = root3; + } + if (removedLeaf.value) { + this.count -= 1; + } + return this; + } else { + throw new Error(`.delete was called on the finalized builder`); + } + } + build() { + if (this.edit) { + this.edit = null; + return new PersistentHashMap(this.count, this.root, this.config); + } else { + throw new Error(`.build was called on the finalized builder`); + } + } + }; + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/unixfs.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/path/InfiniteUint8Array.js + init_dirname(); + init_buffer2(); + init_process(); + var utf83 = new TextEncoder(); + var hash642 = (bytes2) => ( + /** @type {Uint8Array} */ + murmur364.encode(bytes2) + ); + var configure5 = ({ bitWidth: bitWidth2 = 8, hash = hash642 }) => { + const hashSize = hash(new Uint8Array()).byteLength; + const options = { bitWidth: bitWidth2, hash, hashSize }; + const at2 = (path2, depth) => read7(path2, depth, options); + const from18 = (key) => utf83.encode(key); + return { at: at2, from: from18, size: Infinity }; + }; + var read7 = (key, depth = 0, { bitWidth: bitWidth2 = 8, hash, hashSize }) => { + const frameBitSize = hashSize * 8; + let digest3 = 0; + let bitCount2 = bitWidth2; + let bitOffset = bitWidth2 * depth; + while (bitCount2 > 0) { + const frameOffset = bitOffset / frameBitSize >> 0; + const frame = frameOffset === 0 ? hash(key) : hash(appendByte(key, frameOffset)); + const offset2 = frameBitSize <= bitOffset ? bitOffset % frameBitSize : bitOffset; + const maxBits = frameBitSize - offset2; + const count = maxBits < bitCount2 ? maxBits : bitCount2; + digest3 = (digest3 << count) + toInt(frame, offset2, count); + bitCount2 -= count; + bitOffset += count; + } + return digest3; + }; + var appendByte = (source, byte) => { + const bytes2 = new Uint8Array(source.byteLength + 1).fill( + byte, + source.byteLength + ); + bytes2.set(source); + return bytes2; + }; + + // ../../node_modules/.pnpm/@perma+map@1.0.3/node_modules/@perma/map/src/unixfs.js + var bitWidth = 8; + var config = { + bitWidth, + Path: configure5({ bitWidth }) + }; + var tableSize = (hamt) => Math.pow(2, hamt.config.bitWidth); + var builder2 = (options = ( + /** @type {C} */ + config + )) => builder(options); + var from15 = (entries6, options = ( + /** @type {C} */ + config + )) => from14(entries6, options); + var bitField = ({ datamap, nodemap, config: { BitField } }) => withoutLeadingZeros(BitField.toBytes(BitField.or(datamap, nodemap))); + var withoutLeadingZeros = (bytes2) => { + let offset2 = 0; + while (offset2 < bytes2.byteLength) { + if (bytes2[offset2] !== 0) { + return bytes2.subarray(offset2); + } + offset2 += 1; + } + return bytes2.subarray(offset2); + }; + var iterate3 = function* (root3) { + const { config: config2, datamap, nodemap } = root3; + const { BitField: bitfield } = config2; + const size4 = bitfield.size(datamap); + let bitOffset = 0; + let dataCount = 0; + while (bitOffset < size4) { + const prefix = bitOffset.toString(16).toUpperCase().padStart(2, "0"); + if (bitfield.get(datamap, bitOffset)) { + const key = keyAt(root3, dataCount); + yield { + prefix, + key, + value: valueAt(root3, dataCount) + }; + dataCount++; + } else if (bitfield.get(nodemap, bitOffset)) { + yield { + prefix, + // UnixFS never contains hash collision nodes because it uses + // inifinite hashes + node: ( + /** @type {HAMT.BitmapIndexedNode} */ + resolveNode(root3, bitOffset) + ) + }; + } + bitOffset++; + } + }; + + // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/block.js + init_dirname(); + init_buffer2(); + init_process(); + function readonly({ enumerable = true, configurable = false } = {}) { + return { enumerable, configurable, writable: false }; + } + function* linksWithin(path2, value) { + if (value != null && typeof value === "object") { + if (Array.isArray(value)) { + for (const [index2, element] of value.entries()) { + const elementPath = [...path2, index2]; + const cid = CID2.asCID(element); + if (cid) { + yield [elementPath.join("/"), cid]; + } else if (typeof element === "object") { + yield* links2(element, elementPath); + } + } + } else { + const cid = CID2.asCID(value); + if (cid) { + yield [path2.join("/"), cid]; + } else { + yield* links2(value, path2); + } + } + } + } + function* links2(source, base3) { + if (source == null || source instanceof Uint8Array) { + return; + } + const cid = CID2.asCID(source); + if (cid) { + yield [base3.join("/"), cid]; + } + for (const [key, value] of Object.entries(source)) { + const path2 = ( + /** @type {[string|number, string]} */ + [...base3, key] + ); + yield* linksWithin(path2, value); + } + } + function* treeWithin(path2, value) { + if (Array.isArray(value)) { + for (const [index2, element] of value.entries()) { + const elementPath = [...path2, index2]; + yield elementPath.join("/"); + if (typeof element === "object" && !CID2.asCID(element)) { + yield* tree(element, elementPath); + } + } + } else { + yield* tree(value, path2); + } + } + function* tree(source, base3) { + if (source == null || typeof source !== "object") { + return; + } + for (const [key, value] of Object.entries(source)) { + const path2 = ( + /** @type {[string|number, string]} */ + [...base3, key] + ); + yield path2.join("/"); + if (value != null && !(value instanceof Uint8Array) && typeof value === "object" && !CID2.asCID(value)) { + yield* treeWithin(path2, value); + } + } + } + function get10(source, path2) { + let node = ( + /** @type {Record} */ + source + ); + for (const [index2, key] of path2.entries()) { + node = node[key]; + if (node == null) { + throw new Error(`Object has no property at ${path2.slice(0, index2 + 1).map((part) => `[${JSON.stringify(part)}]`).join("")}`); + } + const cid = CID2.asCID(node); + if (cid) { + return { value: cid, remaining: path2.slice(index2 + 1).join("/") }; + } + } + return { value: node }; + } + var Block = class { + /** + * @param {object} options + * @param {CID} options.cid + * @param {API.ByteView} options.bytes + * @param {T} options.value + */ + constructor({ cid, bytes: bytes2, value }) { + if (!cid || !bytes2 || typeof value === "undefined") { + throw new Error("Missing required argument"); + } + this.cid = cid; + this.bytes = bytes2; + this.value = value; + this.asBlock = this; + Object.defineProperties(this, { + cid: readonly(), + bytes: readonly(), + value: readonly(), + asBlock: readonly() + }); + } + links() { + return links2(this.value, []); + } + tree() { + return tree(this.value, []); + } + /** + * + * @param {string} [path] + * @returns {API.BlockCursorView} + */ + get(path2 = "/") { + return get10(this.value, path2.split("/").filter(Boolean)); + } + }; + async function encode30({ value, codec, hasher }) { + if (typeof value === "undefined") + throw new Error('Missing required argument "value"'); + if (!codec || !hasher) + throw new Error("Missing required argument: codec or hasher"); + const bytes2 = codec.encode(value); + const hash = await hasher.digest(bytes2); + const cid = CID2.create( + 1, + codec.code, + hash + ); + return new Block({ value, bytes: bytes2, cid }); + } + async function decode37({ bytes: bytes2, codec, hasher }) { + if (!bytes2) + throw new Error('Missing required argument "bytes"'); + if (!codec || !hasher) + throw new Error("Missing required argument: codec or hasher"); + const value = codec.decode(bytes2); + const hash = await hasher.digest(bytes2); + const cid = CID2.create(1, codec.code, hash); + return new Block({ value, bytes: bytes2, cid }); + } + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/sharded-directory.js + var defaults4 = defaults2; + var create11 = ({ writer: writer2, settings: settings3 = defaults4(), metadata = {} }) => new HAMTDirectoryWriter({ + writer: writer2, + metadata, + settings: settings3, + entries: new HashMap(), + closed: false + }); + var asWritable2 = (writer2) => { + if (!writer2.closed) { + return writer2; + } else { + throw new Error("Can not change written HAMT directory, but you can .fork() and make changes to it"); + } + }; + var close7 = async (view10, { closeWriter = false, releaseLock = false } = {}) => { + const { writer: writer2, settings: settings3, metadata } = asWritable2(view10.state); + view10.state.closed = true; + const { entries: entries6 } = view10.state; + if (!(entries6 instanceof HashMap)) { + throw new Error(`not a HAMT: ${entries6}`); + } + const hamt = entries6.builder.build(); + const blocks = iterateBlocks(hamt, hamt.root, settings3); + let root3 = null; + for await (const block of blocks) { + root3 = block; + if ((writer2.desiredSize || 0) <= 0) { + await writer2.ready; + } + writer2.write(block); + } + if (root3 == null) + throw new Error("no root block yielded"); + if (closeWriter) { + await writer2.close(); + } else if (releaseLock) { + writer2.releaseLock(); + } + return { + cid: root3.cid, + dagByteLength: cumulativeDagByteLength(root3.bytes, root3.value.entries) + }; + }; + var iterateBlocks = async function* (hamt, node, settings3) { + const entries6 = []; + for (const ent of iterate3(node)) { + if ("key" in ent) { + entries6.push( + /** @type {UnixFS.DirectoryEntryLink} */ + { + name: `${ent.prefix ?? ""}${ent.key ?? ""}`, + dagByteLength: ent.value.dagByteLength, + cid: ent.value.cid + } + ); + } else { + let root3 = null; + for await (const block of iterateBlocks(hamt, ent.node, settings3)) { + yield block; + root3 = block; + } + if (root3 == null) + throw new Error("no root block yielded"); + entries6.push( + /** @type {UnixFS.ShardedDirectoryLink} */ + { + name: ent.prefix, + dagByteLength: cumulativeDagByteLength(root3.bytes, root3.value.entries), + cid: root3.cid + } + ); + } + } + const shard = createDirectoryShard( + entries6, + bitField(node), + tableSize(hamt), + murmur364.code + ); + yield await encodeHAMTShardBlock(shard, settings3); + }; + async function encodeHAMTShardBlock(shard, settings3) { + const bytes2 = encodeHAMTShard(shard); + const hash = await settings3.hasher.digest(bytes2); + const cid = settings3.linker.createLink(code9, hash); + return new Block({ cid, bytes: bytes2, value: shard }); + } + var fork4 = ({ state }, { + writer: writer2 = state.writer, + metadata = state.metadata, + settings: settings3 = state.settings + } = {}) => new HAMTDirectoryWriter({ + writer: writer2, + metadata, + settings: settings3, + entries: new HashMap(from15(state.entries.entries()).createBuilder()), + closed: false + }); + var HAMTDirectoryWriter = class { + /** + * @param {API.State} state + */ + constructor(state) { + this.state = state; + } + get writer() { + return this.state.writer; + } + get settings() { + return this.state.settings; + } + /** + * @param {string} name + * @param {UnixFS.FileLink | UnixFS.DirectoryLink} link + * @param {API.WriteOptions} [options] + */ + set(name15, link10, options) { + return set(this, name15, link10, options); + } + /** + * @param {string} name + */ + remove(name15) { + return remove8(this, name15); + } + /** + * @template L + * @param {Partial>} [options] + * @returns {API.View} + */ + fork(options) { + return fork4(this, options); + } + /** + * @param {API.CloseOptions} [options] + * @returns {Promise} + */ + close(options) { + return close7(this, options); + } + entries() { + return this.state.entries.entries(); + } + /** + * @param {string} name + */ + has(name15) { + return this.state.entries.has(name15); + } + get size() { + return this.state.entries.size; + } + }; + var HashMap = class extends Map { + /** + * @param {UnixFSPermaMap.HashMapBuilder} [builder] + */ + constructor(builder3 = builder2()) { + super(); + this.builder = builder3; + } + clear() { + this.builder = builder2(); + } + /** + * @param {string} key + */ + delete(key) { + const { root: root3 } = this.builder; + this.builder.delete(key); + return this.builder.root !== root3; + } + /** + * @param {(value: API.EntryLink, key: string, map: Map) => void} callbackfn + * @param {any} [thisArg] + */ + forEach(callbackfn, thisArg = this) { + for (const [k5, v7] of this.builder.root.entries()) { + callbackfn.call(thisArg, v7, k5, this); + } + } + /** + * @param {string} key + */ + get(key) { + return get9(this.builder, key); + } + /** + * @param {string} key + */ + has(key) { + return has2(this.builder, key); + } + /** + * @param {string} key + * @param {API.EntryLink} value + */ + set(key, value) { + this.builder.set(key, value); + return this; + } + get size() { + return this.builder.size; + } + [Symbol.iterator]() { + return this.builder.root.entries(); + } + entries() { + return this.builder.root.entries(); + } + keys() { + return this.builder.root.keys(); + } + values() { + return this.builder.root.values(); + } + }; + + // ../../node_modules/.pnpm/@ipld+unixfs@2.1.1/node_modules/@ipld/unixfs/src/lib.js + var createWriter3 = ({ writable, settings: settings3 = defaults2() }) => new FileSystemWriter({ + writer: writable.getWriter(), + settings: settings3 + }); + var close8 = async (view10, { releaseLock = true, closeWriter = true } = {}) => { + if (closeWriter) { + await view10.writer.close(); + } else if (releaseLock) { + view10.writer.releaseLock(); + } + return view10; + }; + var FileSystemWriter = class { + /** + * @param {object} options + * @param {API.BlockWriter} options.writer + * @param {Partial>} options.settings + */ + constructor({ writer: writer2, settings: settings3 }) { + this.writer = writer2; + this.settings = configure(settings3); + } + /** + * @template [L=unknown] + * @param {API.WriterOptions} config + */ + createFileWriter({ settings: settings3 = this.settings, metadata } = {}) { + return create8({ + writer: this.writer, + settings: settings3, + metadata + }); + } + /** + * @template [L=unknown] + * @param {API.WriterOptions} config + */ + createDirectoryWriter({ settings: settings3 = this.settings, metadata } = {}) { + return create9({ + writer: this.writer, + settings: settings3, + metadata + }); + } + /** + * @param {API.CloseOptions} [options] + */ + close(options) { + return close8(this, options); + } + }; + var BLOCK_SIZE_LIMIT = 1048576; + var defaultCapacity = BLOCK_SIZE_LIMIT * 100; + var withCapacity = (byteLength = defaultCapacity) => ({ + highWaterMark: byteLength, + size: (block) => block.bytes.length + }); + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/unixfs.js + var SHARD_THRESHOLD = 1e3; + var queuingStrategy = withCapacity(); + var settings = configure({ + fileChunkEncoder: raw_exports, + smallFileEncoder: raw_exports, + chunker: withMaxChunkSize(1024 * 1024), + fileLayout: withWidth(1024) + }); + function createFileEncoderStream(blob) { + const { readable, writable } = new TransformStream({}, queuingStrategy); + const unixfsWriter = createWriter3({ writable, settings }); + const fileBuilder = new UnixFSFileBuilder("", blob); + void (async () => { + await fileBuilder.finalize(unixfsWriter); + await unixfsWriter.close(); + })(); + return readable; + } + var _file; + var UnixFSFileBuilder = class { + /** + * @param {string} name + * @param {import('./types').BlobLike} file + */ + constructor(name15, file) { + __privateAdd(this, _file, void 0); + this.name = name15; + __privateSet(this, _file, file); + } + /** @param {import('@ipld/unixfs').View} writer */ + async finalize(writer2) { + const unixfsFileWriter = create8(writer2); + await __privateGet(this, _file).stream().pipeTo( + new WritableStream({ + async write(chunk) { + await unixfsFileWriter.write(chunk); + } + }) + ); + return await unixfsFileWriter.close(); + } + }; + _file = new WeakMap(); + var _options; + var UnixFSDirectoryBuilder = class { + /** + * @param {string} name + * @param {import('./types').UnixFSDirectoryEncoderOptions} [options] + */ + constructor(name15, options) { + __privateAdd(this, _options, void 0); + /** @type {Map} */ + __publicField(this, "entries", /* @__PURE__ */ new Map()); + this.name = name15; + __privateSet(this, _options, options); + } + /** @param {import('@ipld/unixfs').View} writer */ + async finalize(writer2) { + const dirWriter = this.entries.size <= SHARD_THRESHOLD ? create9(writer2) : create11(writer2); + for (const [name15, entry] of this.entries) { + const link10 = await entry.finalize(writer2); + if (__privateGet(this, _options)?.onDirectoryEntryLink) { + __privateGet(this, _options).onDirectoryEntryLink({ name: entry.name, ...link10 }); + } + dirWriter.set(name15, link10); + } + return await dirWriter.close(); + } + }; + _options = new WeakMap(); + function createDirectoryEncoderStream(files, options) { + const rootDir = new UnixFSDirectoryBuilder("", options); + for (const file of files) { + const path2 = file.name.split("/"); + if (path2[0] === "" || path2[0] === ".") { + path2.shift(); + } + let dir = rootDir; + for (const [i8, name15] of path2.entries()) { + if (i8 === path2.length - 1) { + dir.entries.set(name15, new UnixFSFileBuilder(path2.join("/"), file)); + break; + } + let dirBuilder = dir.entries.get(name15); + if (dirBuilder == null) { + const dirName = dir === rootDir ? name15 : `${dir.name}/${name15}`; + dirBuilder = new UnixFSDirectoryBuilder(dirName, options); + dir.entries.set(name15, dirBuilder); + } + if (!(dirBuilder instanceof UnixFSDirectoryBuilder)) { + throw new Error(`"${file.name}" cannot be a file and a directory`); + } + dir = dirBuilder; + } + } + const { readable, writable } = new TransformStream({}, queuingStrategy); + const unixfsWriter = createWriter3({ writable, settings }); + void (async () => { + const link10 = await rootDir.finalize(unixfsWriter); + if (options?.onDirectoryEntryLink) { + options.onDirectoryEntryLink({ name: "", ...link10 }); + } + await unixfsWriter.close(); + })(); + return readable; + } + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/car.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/reader-browser.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/decoder.js + init_dirname(); + init_buffer2(); + init_process(); + async function readHeader2(reader2, strictVersion) { + const length3 = decodeVarint(await reader2.upTo(8), reader2); + if (length3 === 0) { + throw new Error("Invalid CAR header (zero length)"); + } + const header = await reader2.exactly(length3, true); + const block = decode6(header); + if (!CarHeader(block)) { + throw new Error("Invalid CAR header format"); + } + if (block.version !== 1 && block.version !== 2 || strictVersion !== void 0 && block.version !== strictVersion) { + throw new Error(`Invalid CAR version: ${block.version}${strictVersion !== void 0 ? ` (expected ${strictVersion})` : ""}`); + } + const hasRoots = Array.isArray(block.roots); + if (block.version === 1 && !hasRoots || block.version === 2 && hasRoots) { + throw new Error("Invalid CAR header format"); + } + if (block.version === 1) { + return block; + } + const v2Header = decodeV2Header(await reader2.exactly(V2_HEADER_LENGTH, true)); + reader2.seek(v2Header.dataOffset - reader2.pos); + const v1Header = await readHeader2(reader2, 1); + return Object.assign(v1Header, v2Header); + } + async function readCid2(reader2) { + const first = await reader2.exactly(2, false); + if (first[0] === CIDV0_BYTES.SHA2_256 && first[1] === CIDV0_BYTES.LENGTH) { + const bytes3 = await reader2.exactly(34, true); + const multihash2 = decode10(bytes3); + return CID2.create(0, CIDV0_BYTES.DAG_PB, multihash2); + } + const version3 = decodeVarint(await reader2.upTo(8), reader2); + if (version3 !== 1) { + throw new Error(`Unexpected CID version (${version3})`); + } + const codec = decodeVarint(await reader2.upTo(8), reader2); + const bytes2 = await reader2.exactly(getMultihashLength(await reader2.upTo(8)), true); + const multihash = decode10(bytes2); + return CID2.create(version3, codec, multihash); + } + async function readBlockHead2(reader2) { + const start = reader2.pos; + let length3 = decodeVarint(await reader2.upTo(8), reader2); + if (length3 === 0) { + throw new Error("Invalid CAR section (zero length)"); + } + length3 += reader2.pos - start; + const cid = await readCid2(reader2); + const blockLength2 = length3 - Number(reader2.pos - start); + return { cid, length: length3, blockLength: blockLength2 }; + } + async function readBlock(reader2) { + const { cid, blockLength: blockLength2 } = await readBlockHead2(reader2); + const bytes2 = await reader2.exactly(blockLength2, true); + return { bytes: bytes2, cid }; + } + async function readBlockIndex(reader2) { + const offset2 = reader2.pos; + const { cid, length: length3, blockLength: blockLength2 } = await readBlockHead2(reader2); + const index2 = { cid, length: length3, blockLength: blockLength2, offset: offset2, blockOffset: reader2.pos }; + reader2.seek(index2.blockLength); + return index2; + } + function createDecoder(reader2) { + const headerPromise = (async () => { + const header = await readHeader2(reader2); + if (header.version === 2) { + const v1length = reader2.pos - header.dataOffset; + reader2 = limitReader2(reader2, header.dataSize - v1length); + } + return header; + })(); + return { + header: () => headerPromise, + async *blocks() { + await headerPromise; + while ((await reader2.upTo(8)).length > 0) { + yield await readBlock(reader2); + } + }, + async *blocksIndex() { + await headerPromise; + while ((await reader2.upTo(8)).length > 0) { + yield await readBlockIndex(reader2); + } + } + }; + } + function bytesReader2(bytes2) { + let pos = 0; + return { + async upTo(length3) { + const out = bytes2.subarray(pos, pos + Math.min(length3, bytes2.length - pos)); + return out; + }, + async exactly(length3, seek = false) { + if (length3 > bytes2.length - pos) { + throw new Error("Unexpected end of data"); + } + const out = bytes2.subarray(pos, pos + length3); + if (seek) { + pos += length3; + } + return out; + }, + seek(length3) { + pos += length3; + }, + get pos() { + return pos; + } + }; + } + function chunkReader(readChunk) { + let pos = 0; + let have = 0; + let offset2 = 0; + let currentChunk = new Uint8Array(0); + const read13 = async (length3) => { + have = currentChunk.length - offset2; + const bufa = [currentChunk.subarray(offset2)]; + while (have < length3) { + const chunk = await readChunk(); + if (chunk == null) { + break; + } + if (have < 0) { + if (chunk.length > have) { + bufa.push(chunk.subarray(-have)); + } + } else { + bufa.push(chunk); + } + have += chunk.length; + } + currentChunk = new Uint8Array(bufa.reduce((p8, c8) => p8 + c8.length, 0)); + let off = 0; + for (const b6 of bufa) { + currentChunk.set(b6, off); + off += b6.length; + } + offset2 = 0; + }; + return { + async upTo(length3) { + if (currentChunk.length - offset2 < length3) { + await read13(length3); + } + return currentChunk.subarray(offset2, offset2 + Math.min(currentChunk.length - offset2, length3)); + }, + async exactly(length3, seek = false) { + if (currentChunk.length - offset2 < length3) { + await read13(length3); + } + if (currentChunk.length - offset2 < length3) { + throw new Error("Unexpected end of data"); + } + const out = currentChunk.subarray(offset2, offset2 + length3); + if (seek) { + pos += length3; + offset2 += length3; + } + return out; + }, + seek(length3) { + pos += length3; + offset2 += length3; + }, + get pos() { + return pos; + } + }; + } + function asyncIterableReader(asyncIterable) { + const iterator = asyncIterable[Symbol.asyncIterator](); + async function readChunk() { + const next = await iterator.next(); + if (next.done) { + return null; + } + return next.value; + } + return chunkReader(readChunk); + } + function limitReader2(reader2, byteLimit) { + let bytesRead = 0; + return { + async upTo(length3) { + let bytes2 = await reader2.upTo(length3); + if (bytes2.length + bytesRead > byteLimit) { + bytes2 = bytes2.subarray(0, byteLimit - bytesRead); + } + return bytes2; + }, + async exactly(length3, seek = false) { + const bytes2 = await reader2.exactly(length3, seek); + if (bytes2.length + bytesRead > byteLimit) { + throw new Error("Unexpected end of data"); + } + if (seek) { + bytesRead += length3; + } + return bytes2; + }, + seek(length3) { + bytesRead += length3; + reader2.seek(length3); + }, + get pos() { + return reader2.pos; + } + }; + } + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/reader-browser.js + var CarReader = class { + /** + * @constructs CarReader + * @param {CarHeader|CarV2Header} header + * @param {Block[]} blocks + */ + constructor(header, blocks) { + this._header = header; + this._blocks = blocks; + this._keys = blocks.map((b6) => b6.cid.toString()); + } + /** + * @property + * @memberof CarReader + * @instance + */ + get version() { + return this._header.version; + } + /** + * Get the list of roots defined by the CAR referenced by this reader. May be + * zero or more `CID`s. + * + * @function + * @memberof CarReader + * @instance + * @async + * @returns {Promise} + */ + async getRoots() { + return this._header.roots; + } + /** + * Check whether a given `CID` exists within the CAR referenced by this + * reader. + * + * @function + * @memberof CarReader + * @instance + * @async + * @param {CID} key + * @returns {Promise} + */ + async has(key) { + return this._keys.indexOf(key.toString()) > -1; + } + /** + * Fetch a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) from the CAR + * referenced by this reader matching the provided `CID`. In the case where + * the provided `CID` doesn't exist within the CAR, `undefined` will be + * returned. + * + * @function + * @memberof CarReader + * @instance + * @async + * @param {CID} key + * @returns {Promise} + */ + async get(key) { + const index2 = this._keys.indexOf(key.toString()); + return index2 > -1 ? this._blocks[index2] : void 0; + } + /** + * Returns a `BlockIterator` (`AsyncIterable`) that iterates over all + * of the `Block`s (`{ cid:CID, bytes:Uint8Array }` pairs) contained within + * the CAR referenced by this reader. + * + * @function + * @memberof CarReader + * @instance + * @async + * @generator + * @returns {AsyncGenerator} + */ + async *blocks() { + for (const block of this._blocks) { + yield block; + } + } + /** + * Returns a `CIDIterator` (`AsyncIterable`) that iterates over all of + * the `CID`s contained within the CAR referenced by this reader. + * + * @function + * @memberof CarReader + * @instance + * @async + * @generator + * @returns {AsyncGenerator} + */ + async *cids() { + for (const block of this._blocks) { + yield block.cid; + } + } + /** + * Instantiate a {@link CarReader} from a `Uint8Array` blob. This performs a + * decode fully in memory and maintains the decoded state in memory for full + * access to the data via the `CarReader` API. + * + * @async + * @static + * @memberof CarReader + * @param {Uint8Array} bytes + * @returns {Promise} + */ + static async fromBytes(bytes2) { + if (!(bytes2 instanceof Uint8Array)) { + throw new TypeError("fromBytes() requires a Uint8Array"); + } + return decodeReaderComplete(bytesReader2(bytes2)); + } + /** + * Instantiate a {@link CarReader} from a `AsyncIterable`, such as + * a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators). + * This performs a decode fully in memory and maintains the decoded state in + * memory for full access to the data via the `CarReader` API. + * + * Care should be taken for large archives; this API may not be appropriate + * where memory is a concern or the archive is potentially larger than the + * amount of memory that the runtime can handle. + * + * @async + * @static + * @memberof CarReader + * @param {AsyncIterable} asyncIterable + * @returns {Promise} + */ + static async fromIterable(asyncIterable) { + if (!asyncIterable || !(typeof asyncIterable[Symbol.asyncIterator] === "function")) { + throw new TypeError("fromIterable() requires an async iterable"); + } + return decodeReaderComplete(asyncIterableReader(asyncIterable)); + } + }; + async function decodeReaderComplete(reader2) { + const decoder4 = createDecoder(reader2); + const header = await decoder4.header(); + const blocks = []; + for await (const block of decoder4.blocks()) { + blocks.push(block); + } + return new CarReader(header, blocks); + } + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/indexer.js + init_dirname(); + init_buffer2(); + init_process(); + var CarIndexer = class { + /** + * @param {number} version + * @param {CID[]} roots + * @param {AsyncGenerator} iterator + */ + constructor(version3, roots, iterator) { + this._version = version3; + this._roots = roots; + this._iterator = iterator; + } + get version() { + return this._version; + } + /** + * Get the list of roots defined by the CAR referenced by this indexer. May be + * zero or more `CID`s. + * + * @function + * @memberof CarIndexer + * @instance + * @async + * @returns {Promise} + */ + async getRoots() { + return this._roots; + } + /** + * @returns {AsyncIterator} + */ + [Symbol.asyncIterator]() { + return this._iterator; + } + /** + * Instantiate a {@link CarIndexer} from a `Uint8Array` blob. Only the header + * is decoded initially, the remainder is processed and emitted via the + * iterator as it is consumed. + * + * @async + * @static + * @memberof CarIndexer + * @param {Uint8Array} bytes + * @returns {Promise} + */ + static async fromBytes(bytes2) { + if (!(bytes2 instanceof Uint8Array)) { + throw new TypeError("fromBytes() requires a Uint8Array"); + } + return decodeIndexerComplete(bytesReader2(bytes2)); + } + /** + * Instantiate a {@link CarIndexer} from a `AsyncIterable`, + * such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators). + * is decoded initially, the remainder is processed and emitted via the + * iterator as it is consumed. + * + * @async + * @static + * @memberof CarIndexer + * @param {AsyncIterable} asyncIterable + * @returns {Promise} + */ + static async fromIterable(asyncIterable) { + if (!asyncIterable || !(typeof asyncIterable[Symbol.asyncIterator] === "function")) { + throw new TypeError("fromIterable() requires an async iterable"); + } + return decodeIndexerComplete(asyncIterableReader(asyncIterable)); + } + }; + async function decodeIndexerComplete(reader2) { + const decoder4 = createDecoder(reader2); + const { version: version3, roots } = await decoder4.header(); + return new CarIndexer(version3, roots, decoder4.blocksIndex()); + } + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/iterator.js + init_dirname(); + init_buffer2(); + init_process(); + var CarIteratorBase = class { + /** + * @param {number} version + * @param {CID[]} roots + * @param {AsyncIterable|void} iterable + */ + constructor(version3, roots, iterable) { + this._version = version3; + this._roots = roots; + this._iterable = iterable; + this._decoded = false; + } + get version() { + return this._version; + } + /** + * @returns {Promise} + */ + async getRoots() { + return this._roots; + } + }; + var CarBlockIterator = class _CarBlockIterator extends CarIteratorBase { + // inherited method + /** + * Get the list of roots defined by the CAR referenced by this iterator. May be + * zero or more `CID`s. + * + * @function getRoots + * @memberof CarBlockIterator + * @instance + * @async + * @returns {Promise} + */ + /** + * @returns {AsyncIterator} + */ + [Symbol.asyncIterator]() { + if (this._decoded) { + throw new Error("Cannot decode more than once"); + } + if (!this._iterable) { + throw new Error("Block iterable not found"); + } + this._decoded = true; + return this._iterable[Symbol.asyncIterator](); + } + /** + * Instantiate a {@link CarBlockIterator} from a `Uint8Array` blob. Rather + * than decoding the entire byte array prior to returning the iterator, as in + * {@link CarReader.fromBytes}, only the header is decoded and the remainder + * of the CAR is parsed as the `Block`s as yielded. + * + * @async + * @static + * @memberof CarBlockIterator + * @param {Uint8Array} bytes + * @returns {Promise} + */ + static async fromBytes(bytes2) { + const { version: version3, roots, iterator } = await fromBytes4(bytes2); + return new _CarBlockIterator(version3, roots, iterator); + } + /** + * Instantiate a {@link CarBlockIterator} from a `AsyncIterable`, + * such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators). + * Rather than decoding the entire byte array prior to returning the iterator, + * as in {@link CarReader.fromIterable}, only the header is decoded and the + * remainder of the CAR is parsed as the `Block`s as yielded. + * + * @async + * @static + * @param {AsyncIterable} asyncIterable + * @returns {Promise} + */ + static async fromIterable(asyncIterable) { + const { version: version3, roots, iterator } = await fromIterable(asyncIterable); + return new _CarBlockIterator(version3, roots, iterator); + } + }; + var CarCIDIterator = class _CarCIDIterator extends CarIteratorBase { + // inherited method + /** + * Get the list of roots defined by the CAR referenced by this iterator. May be + * zero or more `CID`s. + * + * @function getRoots + * @memberof CarCIDIterator + * @instance + * @async + * @returns {Promise} + */ + /** + * @returns {AsyncIterator} + */ + [Symbol.asyncIterator]() { + if (this._decoded) { + throw new Error("Cannot decode more than once"); + } + if (!this._iterable) { + throw new Error("Block iterable not found"); + } + this._decoded = true; + const iterable = this._iterable[Symbol.asyncIterator](); + return { + async next() { + const next = await iterable.next(); + if (next.done) { + return next; + } + return { done: false, value: next.value.cid }; + } + }; + } + /** + * Instantiate a {@link CarCIDIterator} from a `Uint8Array` blob. Rather + * than decoding the entire byte array prior to returning the iterator, as in + * {@link CarReader.fromBytes}, only the header is decoded and the remainder + * of the CAR is parsed as the `CID`s as yielded. + * + * @async + * @static + * @memberof CarCIDIterator + * @param {Uint8Array} bytes + * @returns {Promise} + */ + static async fromBytes(bytes2) { + const { version: version3, roots, iterator } = await fromBytes4(bytes2); + return new _CarCIDIterator(version3, roots, iterator); + } + /** + * Instantiate a {@link CarCIDIterator} from a `AsyncIterable`, + * such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators). + * Rather than decoding the entire byte array prior to returning the iterator, + * as in {@link CarReader.fromIterable}, only the header is decoded and the + * remainder of the CAR is parsed as the `CID`s as yielded. + * + * @async + * @static + * @memberof CarCIDIterator + * @param {AsyncIterable} asyncIterable + * @returns {Promise} + */ + static async fromIterable(asyncIterable) { + const { version: version3, roots, iterator } = await fromIterable(asyncIterable); + return new _CarCIDIterator(version3, roots, iterator); + } + }; + async function fromBytes4(bytes2) { + if (!(bytes2 instanceof Uint8Array)) { + throw new TypeError("fromBytes() requires a Uint8Array"); + } + return decodeIterator(bytesReader2(bytes2)); + } + async function fromIterable(asyncIterable) { + if (!asyncIterable || !(typeof asyncIterable[Symbol.asyncIterator] === "function")) { + throw new TypeError("fromIterable() requires an async iterable"); + } + return decodeIterator(asyncIterableReader(asyncIterable)); + } + async function decodeIterator(reader2) { + const decoder4 = createDecoder(reader2); + const { version: version3, roots } = await decoder4.header(); + return { version: version3, roots, iterator: decoder4.blocks() }; + } + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/writer-browser.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/encoder.js + init_dirname(); + init_buffer2(); + init_process(); + var import_varint5 = __toESM(require_varint(), 1); + function createHeader(roots) { + const headerBytes = encode4({ version: 1, roots }); + const varintBytes = import_varint5.default.encode(headerBytes.length); + const header = new Uint8Array(varintBytes.length + headerBytes.length); + header.set(varintBytes, 0); + header.set(headerBytes, varintBytes.length); + return header; + } + function createEncoder(writer2) { + return { + /** + * @param {CID[]} roots + * @returns {Promise} + */ + async setRoots(roots) { + const bytes2 = createHeader(roots); + await writer2.write(bytes2); + }, + /** + * @param {Block} block + * @returns {Promise} + */ + async writeBlock(block) { + const { cid, bytes: bytes2 } = block; + await writer2.write(new Uint8Array(import_varint5.default.encode(cid.bytes.length + bytes2.length))); + await writer2.write(cid.bytes); + if (bytes2.length) { + await writer2.write(bytes2); + } + }, + /** + * @returns {Promise} + */ + async close() { + await writer2.end(); + } + }; + } + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/iterator-channel.js + init_dirname(); + init_buffer2(); + init_process(); + function noop() { + } + function create12() { + const chunkQueue = []; + let drainer = null; + let drainerResolver = noop; + let ended = false; + let outWait = null; + let outWaitResolver = noop; + const makeDrainer = () => { + if (!drainer) { + drainer = new Promise((resolve7) => { + drainerResolver = () => { + drainer = null; + drainerResolver = noop; + resolve7(); + }; + }); + } + return drainer; + }; + const writer2 = { + /** + * @param {T} chunk + * @returns {Promise} + */ + write(chunk) { + chunkQueue.push(chunk); + const drainer2 = makeDrainer(); + outWaitResolver(); + return drainer2; + }, + async end() { + ended = true; + const drainer2 = makeDrainer(); + outWaitResolver(); + await drainer2; + } + }; + const iterator = { + /** @returns {Promise>} */ + async next() { + const chunk = chunkQueue.shift(); + if (chunk) { + if (chunkQueue.length === 0) { + drainerResolver(); + } + return { done: false, value: chunk }; + } + if (ended) { + drainerResolver(); + return { done: true, value: void 0 }; + } + if (!outWait) { + outWait = new Promise((resolve7) => { + outWaitResolver = () => { + outWait = null; + outWaitResolver = noop; + return resolve7(iterator.next()); + }; + }); + } + return outWait; + } + }; + return { writer: writer2, iterator }; + } + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/writer-browser.js + var CarWriter = class _CarWriter { + /** + * @param {CID[]} roots + * @param {CarEncoder} encoder + */ + constructor(roots, encoder4) { + this._encoder = encoder4; + this._mutex = encoder4.setRoots(roots); + this._ended = false; + } + /** + * Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive. + * + * @function + * @memberof CarWriter + * @instance + * @async + * @param {Block} block - A `{ cid:CID, bytes:Uint8Array }` pair. + * @returns {Promise} The returned promise will only resolve once the + * bytes this block generates are written to the `out` iterable. + */ + async put(block) { + if (!(block.bytes instanceof Uint8Array) || !block.cid) { + throw new TypeError("Can only write {cid, bytes} objects"); + } + if (this._ended) { + throw new Error("Already closed"); + } + const cid = CID2.asCID(block.cid); + if (!cid) { + throw new TypeError("Can only write {cid, bytes} objects"); + } + this._mutex = this._mutex.then(() => this._encoder.writeBlock({ cid, bytes: block.bytes })); + return this._mutex; + } + /** + * Finalise the CAR archive and signal that the `out` iterable should end once + * any remaining bytes are written. + * + * @function + * @memberof CarWriter + * @instance + * @async + * @returns {Promise} + */ + async close() { + if (this._ended) { + throw new Error("Already closed"); + } + await this._mutex; + this._ended = true; + return this._encoder.close(); + } + /** + * Create a new CAR writer "channel" which consists of a + * `{ writer:CarWriter, out:AsyncIterable }` pair. + * + * @async + * @static + * @memberof CarWriter + * @param {CID[] | CID | void} roots + * @returns {WriterChannel} The channel takes the form of + * `{ writer:CarWriter, out:AsyncIterable }`. + */ + static create(roots) { + roots = toRoots(roots); + const { encoder: encoder4, iterator } = encodeWriter(); + const writer2 = new _CarWriter(roots, encoder4); + const out = new CarWriterOut(iterator); + return { writer: writer2, out }; + } + /** + * Create a new CAR appender "channel" which consists of a + * `{ writer:CarWriter, out:AsyncIterable }` pair. + * This appender does not consider roots and does not produce a CAR header. + * It is designed to append blocks to an _existing_ CAR archive. It is + * expected that `out` will be concatenated onto the end of an existing + * archive that already has a properly formatted header. + * + * @async + * @static + * @memberof CarWriter + * @returns {WriterChannel} The channel takes the form of + * `{ writer:CarWriter, out:AsyncIterable }`. + */ + static createAppender() { + const { encoder: encoder4, iterator } = encodeWriter(); + encoder4.setRoots = () => Promise.resolve(); + const writer2 = new _CarWriter([], encoder4); + const out = new CarWriterOut(iterator); + return { writer: writer2, out }; + } + /** + * Update the list of roots in the header of an existing CAR as represented + * in a Uint8Array. + * + * This operation is an _overwrite_, the total length of the CAR will not be + * modified. A rejection will occur if the new header will not be the same + * length as the existing header, in which case the CAR will not be modified. + * It is the responsibility of the user to ensure that the roots being + * replaced encode as the same length as the new roots. + * + * The byte array passed in an argument will be modified and also returned + * upon successful modification. + * + * @async + * @static + * @memberof CarWriter + * @param {Uint8Array} bytes + * @param {CID[]} roots - A new list of roots to replace the existing list in + * the CAR header. The new header must take up the same number of bytes as the + * existing header, so the roots should collectively be the same byte length + * as the existing roots. + * @returns {Promise} + */ + static async updateRootsInBytes(bytes2, roots) { + const reader2 = bytesReader2(bytes2); + await readHeader2(reader2); + const newHeader = createHeader(roots); + if (Number(reader2.pos) !== newHeader.length) { + throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${reader2.pos} bytes, new header is ${newHeader.length} bytes)`); + } + bytes2.set(newHeader, 0); + return bytes2; + } + }; + var CarWriterOut = class { + /** + * @param {AsyncIterator} iterator + */ + constructor(iterator) { + this._iterator = iterator; + } + [Symbol.asyncIterator]() { + if (this._iterating) { + throw new Error("Multiple iterator not supported"); + } + this._iterating = true; + return this._iterator; + } + }; + function encodeWriter() { + const iw = create12(); + const { writer: writer2, iterator } = iw; + const encoder4 = createEncoder(writer2); + return { encoder: encoder4, iterator }; + } + function toRoots(roots) { + if (roots === void 0) { + return []; + } + if (!Array.isArray(roots)) { + const cid = CID2.asCID(roots); + if (!cid) { + throw new TypeError("roots must be a single CID or an array of CIDs"); + } + return [cid]; + } + const _roots = []; + for (const root3 of roots) { + const _root = CID2.asCID(root3); + if (!_root) { + throw new TypeError("roots must be a single CID or an array of CIDs"); + } + _roots.push(_root); + } + return _roots; + } + + // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/indexed-reader.js + init_dirname(); + init_buffer2(); + init_process(); + init_fs(); + init_stream(); + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/car.js + async function encode31(blocks, root3) { + const { writer: writer2, out } = CarWriter.create(root3); + let error7; + void (async () => { + try { + for await (const block of blocks) { + await writer2.put(block); + } + } catch (err) { + error7 = err; + } finally { + await writer2.close(); + } + })(); + const chunks = []; + for await (const chunk of out) + chunks.push(chunk); + if (error7 != null) + throw error7; + const roots = root3 != null ? [root3] : []; + return Object.assign(new Blob(chunks), { version: 1, roots }); + } + var BlockStream = class extends ReadableStream { + /** @param {import('./types').BlobLike} car */ + constructor(car) { + let blocksPromise = null; + const getBlocksIterable = () => { + if (blocksPromise) + return blocksPromise; + blocksPromise = CarBlockIterator.fromIterable(toIterable(car.stream())); + return blocksPromise; + }; + let iterator = null; + super({ + async start() { + const blocks = await getBlocksIterable(); + iterator = /** @type {AsyncIterator} */ + blocks[Symbol.asyncIterator](); + }, + async pull(controller) { + if (!iterator) + throw new Error("missing blocks iterator"); + const { value, done } = await iterator.next(); + if (done) + return controller.close(); + controller.enqueue(value); + } + }); + this.getRoots = async () => { + const blocks = await getBlocksIterable(); + return await blocks.getRoots(); + }; + } + }; + function toIterable(stream2) { + return Symbol.asyncIterator in stream2 ? stream2 : ( + /* c8 ignore next 12 */ + async function* () { + const reader2 = stream2.getReader(); + try { + while (true) { + const { done, value } = await reader2.read(); + if (done) + return; + yield value; + } + } finally { + reader2.releaseLock(); + } + }() + ); + } + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/sharding.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/p-queue@7.3.4/node_modules/p-queue/dist/index.js + init_dirname(); + init_buffer2(); + init_process(); + var import_eventemitter3 = __toESM(require_eventemitter3(), 1); + + // ../../node_modules/.pnpm/p-timeout@5.1.0/node_modules/p-timeout/index.js + init_dirname(); + init_buffer2(); + init_process(); + var TimeoutError2 = class extends Error { + constructor(message2) { + super(message2); + this.name = "TimeoutError"; + } + }; + var AbortError4 = class extends Error { + constructor(message2) { + super(); + this.name = "AbortError"; + this.message = message2; + } + }; + var getDOMException3 = (errorMessage) => globalThis.DOMException === void 0 ? new AbortError4(errorMessage) : new DOMException(errorMessage); + var getAbortedReason2 = (signal) => { + const reason = signal.reason === void 0 ? getDOMException3("This operation was aborted.") : signal.reason; + return reason instanceof Error ? reason : getDOMException3(reason); + }; + function pTimeout2(promise, milliseconds, fallback, options) { + let timer; + const cancelablePromise = new Promise((resolve7, reject) => { + if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) { + throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``); + } + if (milliseconds === Number.POSITIVE_INFINITY) { + resolve7(promise); + return; + } + options = { + customTimers: { setTimeout, clearTimeout }, + ...options + }; + if (options.signal) { + const { signal } = options; + if (signal.aborted) { + reject(getAbortedReason2(signal)); + } + signal.addEventListener("abort", () => { + reject(getAbortedReason2(signal)); + }); + } + timer = options.customTimers.setTimeout.call(void 0, () => { + if (typeof fallback === "function") { + try { + resolve7(fallback()); + } catch (error7) { + reject(error7); + } + return; + } + const message2 = typeof fallback === "string" ? fallback : `Promise timed out after ${milliseconds} milliseconds`; + const timeoutError = fallback instanceof Error ? fallback : new TimeoutError2(message2); + if (typeof promise.cancel === "function") { + promise.cancel(); + } + reject(timeoutError); + }, milliseconds); + (async () => { + try { + resolve7(await promise); + } catch (error7) { + reject(error7); + } finally { + options.customTimers.clearTimeout.call(void 0, timer); + } + })(); + }); + cancelablePromise.clear = () => { + clearTimeout(timer); + timer = void 0; + }; + return cancelablePromise; + } + + // ../../node_modules/.pnpm/p-queue@7.3.4/node_modules/p-queue/dist/priority-queue.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/p-queue@7.3.4/node_modules/p-queue/dist/lower-bound.js + init_dirname(); + init_buffer2(); + init_process(); + function lowerBound(array3, value, comparator) { + let first = 0; + let count = array3.length; + while (count > 0) { + const step2 = Math.trunc(count / 2); + let it4 = first + step2; + if (comparator(array3[it4], value) <= 0) { + first = ++it4; + count -= step2 + 1; + } else { + count = step2; + } + } + return first; + } + + // ../../node_modules/.pnpm/p-queue@7.3.4/node_modules/p-queue/dist/priority-queue.js + var __classPrivateFieldGet = function(receiver, state, kind, f9) { + if (kind === "a" && !f9) + throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f9 : !state.has(receiver)) + throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f9 : kind === "a" ? f9.call(receiver) : f9 ? f9.value : state.get(receiver); + }; + var _PriorityQueue_queue; + var PriorityQueue = class { + constructor() { + _PriorityQueue_queue.set(this, []); + } + enqueue(run, options) { + options = { + priority: 0, + ...options + }; + const element = { + priority: options.priority, + run + }; + if (this.size && __classPrivateFieldGet(this, _PriorityQueue_queue, "f")[this.size - 1].priority >= options.priority) { + __classPrivateFieldGet(this, _PriorityQueue_queue, "f").push(element); + return; + } + const index2 = lowerBound(__classPrivateFieldGet(this, _PriorityQueue_queue, "f"), element, (a8, b6) => b6.priority - a8.priority); + __classPrivateFieldGet(this, _PriorityQueue_queue, "f").splice(index2, 0, element); + } + dequeue() { + const item = __classPrivateFieldGet(this, _PriorityQueue_queue, "f").shift(); + return item === null || item === void 0 ? void 0 : item.run; + } + filter(options) { + return __classPrivateFieldGet(this, _PriorityQueue_queue, "f").filter((element) => element.priority === options.priority).map((element) => element.run); + } + get size() { + return __classPrivateFieldGet(this, _PriorityQueue_queue, "f").length; + } + }; + _PriorityQueue_queue = /* @__PURE__ */ new WeakMap(); + + // ../../node_modules/.pnpm/p-queue@7.3.4/node_modules/p-queue/dist/index.js + var __classPrivateFieldSet = function(receiver, state, value, kind, f9) { + if (kind === "m") + throw new TypeError("Private method is not writable"); + if (kind === "a" && !f9) + throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f9 : !state.has(receiver)) + throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return kind === "a" ? f9.call(receiver, value) : f9 ? f9.value = value : state.set(receiver, value), value; + }; + var __classPrivateFieldGet2 = function(receiver, state, kind, f9) { + if (kind === "a" && !f9) + throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f9 : !state.has(receiver)) + throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f9 : kind === "a" ? f9.call(receiver) : f9 ? f9.value : state.get(receiver); + }; + var _PQueue_instances; + var _PQueue_carryoverConcurrencyCount; + var _PQueue_isIntervalIgnored; + var _PQueue_intervalCount; + var _PQueue_intervalCap; + var _PQueue_interval; + var _PQueue_intervalEnd; + var _PQueue_intervalId; + var _PQueue_timeoutId; + var _PQueue_queue; + var _PQueue_queueClass; + var _PQueue_pending; + var _PQueue_concurrency; + var _PQueue_isPaused; + var _PQueue_throwOnTimeout; + var _PQueue_doesIntervalAllowAnother_get; + var _PQueue_doesConcurrentAllowAnother_get; + var _PQueue_next; + var _PQueue_onResumeInterval; + var _PQueue_isIntervalPaused_get; + var _PQueue_tryToStartAnother; + var _PQueue_initializeIntervalIfNeeded; + var _PQueue_onInterval; + var _PQueue_processQueue; + var _PQueue_throwOnAbort; + var _PQueue_onEvent; + var AbortError5 = class extends Error { + }; + var PQueue = class extends import_eventemitter3.default { + // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()` + constructor(options) { + var _a2, _b, _c, _d; + super(); + _PQueue_instances.add(this); + _PQueue_carryoverConcurrencyCount.set(this, void 0); + _PQueue_isIntervalIgnored.set(this, void 0); + _PQueue_intervalCount.set(this, 0); + _PQueue_intervalCap.set(this, void 0); + _PQueue_interval.set(this, void 0); + _PQueue_intervalEnd.set(this, 0); + _PQueue_intervalId.set(this, void 0); + _PQueue_timeoutId.set(this, void 0); + _PQueue_queue.set(this, void 0); + _PQueue_queueClass.set(this, void 0); + _PQueue_pending.set(this, 0); + _PQueue_concurrency.set(this, void 0); + _PQueue_isPaused.set(this, void 0); + _PQueue_throwOnTimeout.set(this, void 0); + Object.defineProperty(this, "timeout", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + options = { + carryoverConcurrencyCount: false, + intervalCap: Number.POSITIVE_INFINITY, + interval: 0, + concurrency: Number.POSITIVE_INFINITY, + autoStart: true, + queueClass: PriorityQueue, + ...options + }; + if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) { + throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(_b = (_a2 = options.intervalCap) === null || _a2 === void 0 ? void 0 : _a2.toString()) !== null && _b !== void 0 ? _b : ""}\` (${typeof options.intervalCap})`); + } + if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) { + throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(_d = (_c = options.interval) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : ""}\` (${typeof options.interval})`); + } + __classPrivateFieldSet(this, _PQueue_carryoverConcurrencyCount, options.carryoverConcurrencyCount, "f"); + __classPrivateFieldSet(this, _PQueue_isIntervalIgnored, options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0, "f"); + __classPrivateFieldSet(this, _PQueue_intervalCap, options.intervalCap, "f"); + __classPrivateFieldSet(this, _PQueue_interval, options.interval, "f"); + __classPrivateFieldSet(this, _PQueue_queue, new options.queueClass(), "f"); + __classPrivateFieldSet(this, _PQueue_queueClass, options.queueClass, "f"); + this.concurrency = options.concurrency; + this.timeout = options.timeout; + __classPrivateFieldSet(this, _PQueue_throwOnTimeout, options.throwOnTimeout === true, "f"); + __classPrivateFieldSet(this, _PQueue_isPaused, options.autoStart === false, "f"); + } + get concurrency() { + return __classPrivateFieldGet2(this, _PQueue_concurrency, "f"); + } + set concurrency(newConcurrency) { + if (!(typeof newConcurrency === "number" && newConcurrency >= 1)) { + throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${newConcurrency}\` (${typeof newConcurrency})`); + } + __classPrivateFieldSet(this, _PQueue_concurrency, newConcurrency, "f"); + __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_processQueue).call(this); + } + async add(function_, options = {}) { + options = { + timeout: this.timeout, + throwOnTimeout: __classPrivateFieldGet2(this, _PQueue_throwOnTimeout, "f"), + ...options + }; + return new Promise((resolve7, reject) => { + __classPrivateFieldGet2(this, _PQueue_queue, "f").enqueue(async () => { + var _a2; + var _b, _c; + __classPrivateFieldSet(this, _PQueue_pending, (_b = __classPrivateFieldGet2(this, _PQueue_pending, "f"), _b++, _b), "f"); + __classPrivateFieldSet(this, _PQueue_intervalCount, (_c = __classPrivateFieldGet2(this, _PQueue_intervalCount, "f"), _c++, _c), "f"); + try { + if ((_a2 = options.signal) === null || _a2 === void 0 ? void 0 : _a2.aborted) { + throw new AbortError5("The task was aborted."); + } + let operation = function_({ signal: options.signal }); + if (options.timeout) { + operation = pTimeout2(Promise.resolve(operation), options.timeout); + } + if (options.signal) { + operation = Promise.race([operation, __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_throwOnAbort).call(this, options.signal)]); + } + const result = await operation; + resolve7(result); + this.emit("completed", result); + } catch (error7) { + if (error7 instanceof TimeoutError2 && !options.throwOnTimeout) { + resolve7(); + return; + } + reject(error7); + this.emit("error", error7); + } finally { + __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_next).call(this); + } + }, options); + this.emit("add"); + __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_tryToStartAnother).call(this); + }); + } + async addAll(functions, options) { + return Promise.all(functions.map(async (function_) => this.add(function_, options))); + } + /** + Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.) + */ + start() { + if (!__classPrivateFieldGet2(this, _PQueue_isPaused, "f")) { + return this; + } + __classPrivateFieldSet(this, _PQueue_isPaused, false, "f"); + __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_processQueue).call(this); + return this; + } + /** + Put queue execution on hold. + */ + pause() { + __classPrivateFieldSet(this, _PQueue_isPaused, true, "f"); + } + /** + Clear the queue. + */ + clear() { + __classPrivateFieldSet(this, _PQueue_queue, new (__classPrivateFieldGet2(this, _PQueue_queueClass, "f"))(), "f"); + } + /** + Can be called multiple times. Useful if you for example add additional items at a later time. + + @returns A promise that settles when the queue becomes empty. + */ + async onEmpty() { + if (__classPrivateFieldGet2(this, _PQueue_queue, "f").size === 0) { + return; + } + await __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onEvent).call(this, "empty"); + } + /** + @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`. + + If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item. + + Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation. + */ + async onSizeLessThan(limit) { + if (__classPrivateFieldGet2(this, _PQueue_queue, "f").size < limit) { + return; + } + await __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onEvent).call(this, "next", () => __classPrivateFieldGet2(this, _PQueue_queue, "f").size < limit); + } + /** + The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet. + + @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`. + */ + async onIdle() { + if (__classPrivateFieldGet2(this, _PQueue_pending, "f") === 0 && __classPrivateFieldGet2(this, _PQueue_queue, "f").size === 0) { + return; + } + await __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onEvent).call(this, "idle"); + } + /** + Size of the queue, the number of queued items waiting to run. + */ + get size() { + return __classPrivateFieldGet2(this, _PQueue_queue, "f").size; + } + /** + Size of the queue, filtered by the given options. + + For example, this can be used to find the number of items remaining in the queue with a specific priority level. + */ + sizeBy(options) { + return __classPrivateFieldGet2(this, _PQueue_queue, "f").filter(options).length; + } + /** + Number of running items (no longer in the queue). + */ + get pending() { + return __classPrivateFieldGet2(this, _PQueue_pending, "f"); + } + /** + Whether the queue is currently paused. + */ + get isPaused() { + return __classPrivateFieldGet2(this, _PQueue_isPaused, "f"); + } + }; + _PQueue_carryoverConcurrencyCount = /* @__PURE__ */ new WeakMap(), _PQueue_isIntervalIgnored = /* @__PURE__ */ new WeakMap(), _PQueue_intervalCount = /* @__PURE__ */ new WeakMap(), _PQueue_intervalCap = /* @__PURE__ */ new WeakMap(), _PQueue_interval = /* @__PURE__ */ new WeakMap(), _PQueue_intervalEnd = /* @__PURE__ */ new WeakMap(), _PQueue_intervalId = /* @__PURE__ */ new WeakMap(), _PQueue_timeoutId = /* @__PURE__ */ new WeakMap(), _PQueue_queue = /* @__PURE__ */ new WeakMap(), _PQueue_queueClass = /* @__PURE__ */ new WeakMap(), _PQueue_pending = /* @__PURE__ */ new WeakMap(), _PQueue_concurrency = /* @__PURE__ */ new WeakMap(), _PQueue_isPaused = /* @__PURE__ */ new WeakMap(), _PQueue_throwOnTimeout = /* @__PURE__ */ new WeakMap(), _PQueue_instances = /* @__PURE__ */ new WeakSet(), _PQueue_doesIntervalAllowAnother_get = function _PQueue_doesIntervalAllowAnother_get2() { + return __classPrivateFieldGet2(this, _PQueue_isIntervalIgnored, "f") || __classPrivateFieldGet2(this, _PQueue_intervalCount, "f") < __classPrivateFieldGet2(this, _PQueue_intervalCap, "f"); + }, _PQueue_doesConcurrentAllowAnother_get = function _PQueue_doesConcurrentAllowAnother_get2() { + return __classPrivateFieldGet2(this, _PQueue_pending, "f") < __classPrivateFieldGet2(this, _PQueue_concurrency, "f"); + }, _PQueue_next = function _PQueue_next2() { + var _a2; + __classPrivateFieldSet(this, _PQueue_pending, (_a2 = __classPrivateFieldGet2(this, _PQueue_pending, "f"), _a2--, _a2), "f"); + __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_tryToStartAnother).call(this); + this.emit("next"); + }, _PQueue_onResumeInterval = function _PQueue_onResumeInterval2() { + __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onInterval).call(this); + __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_initializeIntervalIfNeeded).call(this); + __classPrivateFieldSet(this, _PQueue_timeoutId, void 0, "f"); + }, _PQueue_isIntervalPaused_get = function _PQueue_isIntervalPaused_get2() { + const now2 = Date.now(); + if (__classPrivateFieldGet2(this, _PQueue_intervalId, "f") === void 0) { + const delay = __classPrivateFieldGet2(this, _PQueue_intervalEnd, "f") - now2; + if (delay < 0) { + __classPrivateFieldSet(this, _PQueue_intervalCount, __classPrivateFieldGet2(this, _PQueue_carryoverConcurrencyCount, "f") ? __classPrivateFieldGet2(this, _PQueue_pending, "f") : 0, "f"); + } else { + if (__classPrivateFieldGet2(this, _PQueue_timeoutId, "f") === void 0) { + __classPrivateFieldSet(this, _PQueue_timeoutId, setTimeout(() => { + __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onResumeInterval).call(this); + }, delay), "f"); + } + return true; + } + } + return false; + }, _PQueue_tryToStartAnother = function _PQueue_tryToStartAnother2() { + if (__classPrivateFieldGet2(this, _PQueue_queue, "f").size === 0) { + if (__classPrivateFieldGet2(this, _PQueue_intervalId, "f")) { + clearInterval(__classPrivateFieldGet2(this, _PQueue_intervalId, "f")); + } + __classPrivateFieldSet(this, _PQueue_intervalId, void 0, "f"); + this.emit("empty"); + if (__classPrivateFieldGet2(this, _PQueue_pending, "f") === 0) { + this.emit("idle"); + } + return false; + } + if (!__classPrivateFieldGet2(this, _PQueue_isPaused, "f")) { + const canInitializeInterval = !__classPrivateFieldGet2(this, _PQueue_instances, "a", _PQueue_isIntervalPaused_get); + if (__classPrivateFieldGet2(this, _PQueue_instances, "a", _PQueue_doesIntervalAllowAnother_get) && __classPrivateFieldGet2(this, _PQueue_instances, "a", _PQueue_doesConcurrentAllowAnother_get)) { + const job = __classPrivateFieldGet2(this, _PQueue_queue, "f").dequeue(); + if (!job) { + return false; + } + this.emit("active"); + job(); + if (canInitializeInterval) { + __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_initializeIntervalIfNeeded).call(this); + } + return true; + } + } + return false; + }, _PQueue_initializeIntervalIfNeeded = function _PQueue_initializeIntervalIfNeeded2() { + if (__classPrivateFieldGet2(this, _PQueue_isIntervalIgnored, "f") || __classPrivateFieldGet2(this, _PQueue_intervalId, "f") !== void 0) { + return; + } + __classPrivateFieldSet(this, _PQueue_intervalId, setInterval(() => { + __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_onInterval).call(this); + }, __classPrivateFieldGet2(this, _PQueue_interval, "f")), "f"); + __classPrivateFieldSet(this, _PQueue_intervalEnd, Date.now() + __classPrivateFieldGet2(this, _PQueue_interval, "f"), "f"); + }, _PQueue_onInterval = function _PQueue_onInterval2() { + if (__classPrivateFieldGet2(this, _PQueue_intervalCount, "f") === 0 && __classPrivateFieldGet2(this, _PQueue_pending, "f") === 0 && __classPrivateFieldGet2(this, _PQueue_intervalId, "f")) { + clearInterval(__classPrivateFieldGet2(this, _PQueue_intervalId, "f")); + __classPrivateFieldSet(this, _PQueue_intervalId, void 0, "f"); + } + __classPrivateFieldSet(this, _PQueue_intervalCount, __classPrivateFieldGet2(this, _PQueue_carryoverConcurrencyCount, "f") ? __classPrivateFieldGet2(this, _PQueue_pending, "f") : 0, "f"); + __classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_processQueue).call(this); + }, _PQueue_processQueue = function _PQueue_processQueue2() { + while (__classPrivateFieldGet2(this, _PQueue_instances, "m", _PQueue_tryToStartAnother).call(this)) { + } + }, _PQueue_throwOnAbort = async function _PQueue_throwOnAbort2(signal) { + return new Promise((_resolve, reject) => { + signal.addEventListener("abort", () => { + reject(new AbortError5("The task was aborted.")); + }, { once: true }); + }); + }, _PQueue_onEvent = async function _PQueue_onEvent2(event, filter2) { + return new Promise((resolve7) => { + const listener = () => { + if (filter2 && !filter2()) { + return; + } + this.off(event, listener); + resolve7(); + }; + this.on(event, listener); + }); + }; + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/sharding.js + var SHARD_SIZE = 1024 * 1024 * 100; + var CONCURRENT_UPLOADS = 3; + var ShardingStream = class extends TransformStream { + /** + * @param {import('./types').ShardingOptions} [options] + */ + constructor(options = {}) { + const shardSize = options.shardSize ?? SHARD_SIZE; + let shard = []; + let readyShard = null; + let size4 = 0; + super({ + async transform(block, controller) { + if (readyShard != null) { + controller.enqueue(await encode31(readyShard)); + readyShard = null; + } + if (shard.length && size4 + block.bytes.length > shardSize) { + readyShard = shard; + shard = []; + size4 = 0; + } + shard.push(block); + size4 += block.bytes.length; + }, + async flush(controller) { + if (readyShard != null) { + controller.enqueue(await encode31(readyShard)); + } + const rootBlock = shard.at(-1); + if (rootBlock != null) { + controller.enqueue( + await encode31(shard, options.rootCID ?? rootBlock.cid) + ); + } + } + }); + } + }; + var ShardStoringStream = class extends TransformStream { + /** + * @param {import('./types').InvocationConfig} conf Configuration + * for the UCAN invocation. An object with `issuer`, `with` and `proofs`. + * + * The `issuer` is the signing authority that is issuing the UCAN + * invocation(s). It is typically the user _agent_. + * + * The `with` is the resource the invocation applies to. It is typically the + * DID of a space. + * + * The `proofs` are a set of capability delegations that prove the issuer + * has the capability to perform the action. + * + * The issuer needs the `store/add` delegated capability. + * @param {import('./types').ShardStoringOptions} [options] + */ + constructor(conf, options = {}) { + const queue = new PQueue({ + concurrency: options.concurrentRequests ?? CONCURRENT_UPLOADS + }); + const abortController = new AbortController(); + super({ + async transform(car, controller) { + void queue.add( + async () => { + try { + const opts = { ...options, signal: abortController.signal }; + const cid = await add6(conf, car, opts); + const { version: version3, roots, size: size4 } = car; + controller.enqueue({ version: version3, roots, cid, size: size4 }); + } catch (err) { + controller.error(err); + abortController.abort(err); + } + }, + { signal: abortController.signal } + ).catch((err) => console.error(err)); + await queue.onSizeLessThan(1); + }, + async flush() { + await queue.onIdle(); + } + }); + } + }; + + // ../../node_modules/.pnpm/@web3-storage+upload-client@9.1.0/node_modules/@web3-storage/upload-client/src/index.js + async function uploadFile(conf, file, options = {}) { + return await uploadBlockStream( + conf, + createFileEncoderStream(file), + options + ); + } + async function uploadDirectory(conf, files, options = {}) { + return await uploadBlockStream( + conf, + createDirectoryEncoderStream(files, options), + options + ); + } + async function uploadCAR(conf, car, options = {}) { + const blocks = new BlockStream(car); + options.rootCID = options.rootCID ?? (await blocks.getRoots())[0]; + return await uploadBlockStream(conf, blocks, options); + } + async function uploadBlockStream(conf, blocks, options = {}) { + const shards = []; + let root3 = null; + await blocks.pipeThrough(new ShardingStream(options)).pipeThrough(new ShardStoringStream(conf, options)).pipeTo( + new WritableStream({ + write(meta) { + root3 = root3 || meta.roots[0]; + shards.push(meta.cid); + if (options.onShardStored) + options.onShardStored(meta); + } + }) + ); + if (!root3) + throw new Error("missing root CID"); + await add8(conf, root3, shards, options); + return root3; + } + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/provider.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/utils.js + init_dirname(); + init_buffer2(); + init_process(); + function canDelegateURI(child, parent) { + if (parent === void 0) { + return ok({}); + } + if (child !== void 0 && parent.endsWith("*")) { + return child.startsWith(parent.slice(0, -1)) ? ok({}) : fail2(`${child} does not match ${parent}`); + } + return child === parent ? ok({}) : fail2(`${child} is different from ${parent}`); + } + function equalWith3(child, parent) { + return child.with === parent.with ? ok({}) : fail2(`Can not derive ${child.can} with ${child.with} from ${parent.with}`); + } + function equal4(child, parent, constraint) { + if (parent === void 0 || parent === "*") { + return ok({}); + } else if (String(child) === String(parent)) { + return ok({}); + } else { + return fail2( + `Constrain violation: ${child} violates imposed ${constraint} constraint ${parent}` + ); + } + } + var equalLink3 = (claimed, delegated) => { + if (claimed.with !== delegated.with) { + return fail2( + `Expected 'with: "${delegated.with}"' instead got '${claimed.with}'` + ); + } else if (delegated.nb.link && `${delegated.nb.link}` !== `${claimed.nb.link}`) { + return fail2( + `Link ${claimed.nb.link ? `${claimed.nb.link}` : ""} violates imposed ${delegated.nb.link} constraint.` + ); + } else { + return ok({}); + } + }; + var checkLink2 = (claimed, imposed, at2) => { + return equal4( + String(claimed), + imposed === void 0 ? void 0 : String(imposed), + at2 + ); + }; + var and7 = (result) => result.error ? result : void 0; + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/provider.js + var Provider3 = did_exports2.match({ method: "web" }); + var AccountDID3 = did_exports2.match({ method: "mailto" }); + var add9 = capability({ + can: "provider/add", + with: AccountDID3, + nb: struct({ + provider: Provider3, + consumer: did_exports2.match({ method: "key" }) + }), + derives: (child, parent) => { + return and7(equalWith3(child, parent)) || and7(equal4(child.nb.provider, parent.nb.provider, "provider")) || and7(equal4(child.nb.consumer, parent.nb.consumer, "consumer")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/space.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/store.js + var store_exports4 = {}; + __export(store_exports4, { + Link: () => link_exports2, + Schema: () => schema_exports3, + add: () => add10, + all: () => all5, + list: () => list8, + remove: () => remove10, + store: () => store3 + }); + init_dirname(); + init_buffer2(); + init_process(); + var store3 = capability({ + can: "store/*", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + derives: equalWith3 + }); + var add10 = capability({ + can: "store/add", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * CID of the CAR file to be stored. Service will provision write target + * for this exact CAR file for agent to PUT or POST it. Attempt to write + * any other content will fail. + */ + link: link_exports2, + /** + * Size of the CAR file to be stored. Service will provision write target + * for this exact size. Attempt to write a larger CAR file will fail. + */ + size: schema_exports3.integer(), + /** + * Agent may optionally provide a link to a related CAR file using `origin` + * field. This is useful when storing large DAGs, agent could shard it + * across multiple CAR files and then link each shard with a previous one. + * + * Providing this relation tells service that given CAR is shard of the + * larger DAG as opposed to it being intentionally partial DAG. When DAG is + * not sharded, there will be only one `store/add` with `origin` left out. + */ + origin: link_exports2.optional() + }), + derives: (claim4, from18) => { + const result = equalLink3(claim4, from18); + if (result.error) { + return result; + } else if (claim4.nb.size !== void 0 && from18.nb.size !== void 0) { + return claim4.nb.size > from18.nb.size ? fail2(`Size constraint violation: ${claim4.nb.size} > ${from18.nb.size}`) : ok({}); + } else { + return ok({}); + } + } + }); + var remove10 = capability({ + can: "store/remove", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * CID of the CAR file to be removed from the store. + */ + link: link_exports2 + }), + derives: equalLink3 + }); + var list8 = capability({ + can: "store/list", + /** + * did:key identifier of the (memory) space where CAR is intended to + * be stored. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * A pointer that can be moved back and forth on the list. + * It can be used to paginate a list for instance. + */ + cursor: schema_exports3.string().optional(), + /** + * Maximum number of items per page. + */ + size: schema_exports3.integer().optional(), + /** + * If true, return page of results preceding cursor. Defaults to false. + */ + pre: schema_exports3.boolean().optional() + }), + derives: (claimed, delegated) => { + if (claimed.with !== delegated.with) { + return fail2( + `Expected 'with: "${delegated.with}"' instead got '${claimed.with}'` + ); + } + return ok({}); + } + }); + var all5 = add10.or(remove10).or(list8); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/upload.js + var upload_exports4 = {}; + __export(upload_exports4, { + Link: () => link_exports2, + Schema: () => schema_exports3, + add: () => add11, + all: () => all6, + list: () => list9, + remove: () => remove11, + upload: () => upload3 + }); + init_dirname(); + init_buffer2(); + init_process(); + var upload3 = capability({ + can: "upload/*", + /** + * did:key identifier of the (memory) space where upload is add to the + * upload list. + */ + with: uri_exports.match({ protocol: "did:" }), + derives: equalWith3 + }); + var CARLink3 = link_exports2.match({ code: car_exports.code, version: 1 }); + var add11 = capability({ + can: "upload/add", + /** + * did:key identifier of the (memory) space where uploaded is added. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * Root CID of the DAG to be added to the upload list. + */ + root: link_exports2, + /** + * CIDs to the CAR files that contain blocks of the DAG. + */ + shards: CARLink3.array().optional() + }), + derives: (self2, from18) => { + return and7(equalWith3(self2, from18)) || and7(equal4(self2.nb.root, from18.nb.root, "root")) || and7(equal4(self2.nb.shards, from18.nb.shards, "shards")) || ok({}); + } + }); + var remove11 = capability({ + can: "upload/remove", + /** + * did:key identifier of the (memory) space where uploaded is removed from. + */ + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * Root CID of the DAG to be removed from the upload list. + */ + root: link_exports2 + }), + derives: (self2, from18) => { + return and7(equalWith3(self2, from18)) || and7(equal4(self2.nb.root, from18.nb.root, "root")) || ok({}); + } + }); + var list9 = capability({ + can: "upload/list", + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * A pointer that can be moved back and forth on the list. + * It can be used to paginate a list for instance. + */ + cursor: schema_exports3.string().optional(), + /** + * Maximum number of items per page. + */ + size: schema_exports3.integer().optional(), + /** + * If true, return page of results preceding cursor. Defaults to false. + */ + pre: schema_exports3.boolean().optional() + }) + }); + var all6 = add11.or(remove11).or(list9); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/top.js + init_dirname(); + init_buffer2(); + init_process(); + var top2 = capability({ + can: "*", + with: uri_exports.match({ protocol: "did:" }), + derives: equalWith3 + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/space.js + var SpaceDID3 = schema_exports3.did({ method: "key" }); + var space2 = capability({ + can: "space/*", + with: SpaceDID3, + derives: equalWith3 + }); + var info2 = add10.or(list8).or(remove10).or(add11).or(list9).or(remove11).derive({ + to: capability({ + can: "space/info", + with: SpaceDID3 + }), + derives: equalWith3 + }); + var recoverValidation = capability({ + can: "space/recover-validation", + with: SpaceDID3, + nb: schema_exports3.struct({ + identity: uri_exports.match({ protocol: "mailto:" }) + }) + }); + var recover = capability({ + can: "space/recover", + with: schema_exports3.did(), + nb: schema_exports3.struct({ + identity: uri_exports.match({ protocol: "mailto:" }) + }), + derives: (child, parent) => { + return and7(equalWith3(child, parent)) || and7(canDelegateURI(child.nb.identity, parent.nb.identity)) || ok({}); + } + }); + var allocate2 = capability({ + can: "space/allocate", + with: SpaceDID3, + nb: schema_exports3.struct({ + size: schema_exports3.integer() + }), + derives: (child, parent) => { + const result = equalWith3(child, parent); + if (result.ok) { + return child.nb.size <= parent.nb.size ? ok({}) : fail2( + `Claimed size ${child.nb.size} escalates delegated size ${parent.nb.size}` + ); + } else { + return result; + } + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/voucher.js + init_dirname(); + init_buffer2(); + init_process(); + var SpaceDID4 = did_exports2.match({ method: "key" }); + var Product = uri_exports.uri(); + var Identity = uri_exports.match({ protocol: "mailto:" }); + var Service = did_exports2.match({}); + var voucher = capability({ + can: "voucher/*", + with: uri_exports.match({ protocol: "did:" }), + derives: equalWith3 + }); + var claim2 = capability({ + can: "voucher/claim", + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * URI of the product agent is requesting a voucher of. + */ + product: Product, + /** + * Verifiable identity on who's behalf behalf claim is made. + */ + identity: Identity, + /** + * Optional service DID who's voucher is been requested. + */ + service: Service.optional() + }), + derives: (child, parent) => { + return and7(equalWith3(child, parent)) || and7(equal4(child.nb.product, parent.nb.product, "product")) || and7(equal4(child.nb.identity, parent.nb.identity, "identity")) || and7(equal4(child.nb.service, parent.nb.service, "service")) || ok({}); + } + }); + var redeem = capability({ + can: "voucher/redeem", + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + /** + * Link of the product voucher is for. Must be the same as `nb.product` + * of `voucher/claim` that requested this. + */ + product: Product, + /** + * Verifiable identity to whom voucher is issued. It is a `mailto:` URL + * where this delegation is typically sent. + */ + identity: Identity, + /** + * Space identifier where voucher can be redeemed. When service delegates + * `voucher/redeem` to the user agent it may omit this field to allow + * agent to choose space. + */ + space: uri_exports.match({ protocol: "did:" }) + }), + derives: (child, parent) => { + return and7(equalWith3(child, parent)) || and7(equal4(child.nb.product, parent.nb.product, "product")) || and7(equal4(child.nb.identity, parent.nb.identity, "identity")) || and7(equal4(child.nb.space, parent.nb.space, "account")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/access.js + init_dirname(); + init_buffer2(); + init_process(); + var Account2 = did_exports2.match({ method: "mailto" }); + var CapabilityRequest2 = schema_exports3.struct({ + /** + * If set to `"*"` it corresponds to "sudo" access. + */ + can: schema_exports3.string() + }); + var AuthorizationRequest2 = schema_exports3.struct({ + /** + * DID of the Account authorization is requested from. + */ + iss: Account2, + /** + * Capabilities agent wishes to be granted. + */ + att: CapabilityRequest2.array() + }); + var access3 = capability({ + can: "access/*", + with: uri_exports.match({ protocol: "did:" }) + }); + var authorize2 = capability({ + can: "access/authorize", + with: did_exports2.match({ method: "key" }), + /** + * Authorization request describing set of desired capabilities + */ + nb: AuthorizationRequest2, + derives: (child, parent) => { + return and7(equalWith3(child, parent)) || and7(equal4(child.nb.iss, parent.nb.iss, "iss")) || and7(subsetCapabilities2(child.nb.att, parent.nb.att)) || ok({}); + } + }); + var confirm2 = capability({ + can: "access/confirm", + with: did_exports2, + nb: schema_exports3.struct({ + iss: Account2, + aud: schema_exports3.did(), + att: CapabilityRequest2.array() + }), + derives: (claim4, proof) => { + return and7(equalWith3(claim4, proof)) || and7(equal4(claim4.nb.iss, proof.nb.iss, "iss")) || and7(equal4(claim4.nb.aud, proof.nb.aud, "aud")) || and7(subsetCapabilities2(claim4.nb.att, proof.nb.att)) || ok({}); + } + }); + var session2 = capability({ + can: "ucan/attest", + // Should be web3.storage DID + with: uri_exports.match({ protocol: "did:" }), + nb: schema_exports3.struct({ + // UCAN delegation that is being attested. + proof: link_exports2 + }) + }); + var claim3 = capability({ + can: "access/claim", + with: did_exports2.match({ method: "key" }).or(did_exports2.match({ method: "mailto" })) + }); + var delegate4 = capability({ + can: "access/delegate", + /** + * Field MUST be a space DID with a storage provider. Delegation will be stored just like any other DAG stored using store/add capability. + * + * @see https://github.com/web3-storage/specs/blob/main/w3-access.md#delegate-with + */ + with: did_exports2.match({ method: "key" }), + nb: schema_exports3.struct({ + // keys SHOULD be CIDs, but we won't require it in the schema + /** + * @type {Schema.Schema} + */ + delegations: schema_exports3.dictionary({ + value: schema_exports3.Link.match() + }) + }), + derives: (claim4, proof) => { + return and7(equalWith3(claim4, proof)) || and7(subsetsNbDelegations2(claim4, proof)) || ok({}); + } + }); + function subsetsNbDelegations2(claim4, proof) { + const missingProofs = setDifference2( + delegatedCids2(claim4), + new Set(delegatedCids2(proof)) + ); + if (missingProofs.size > 0) { + return fail2(`unauthorized nb.delegations ${[...missingProofs].join(", ")}`); + } + return ok({}); + } + var subsetCapabilities2 = (claim4, proof) => { + const allowed = new Set(proof.map((p8) => p8.can)); + if (allowed.has("*")) { + return ok({}); + } + const escalated = setDifference2( + claim4.map((c8) => c8.can), + allowed + ); + if (escalated.size > 0) { + return fail2(`unauthorized nb.att.can ${[...escalated].join(", ")}`); + } + return ok({}); + }; + function* delegatedCids2(delegate7) { + for (const d7 of Object.values(delegate7.nb.delegations || {})) { + yield d7.toString(); + } + } + function setDifference2(minuend, subtrahend) { + const difference = /* @__PURE__ */ new Set(); + for (const e12 of minuend) { + if (!subtrahend.has(e12)) { + difference.add(e12); + } + } + return difference; + } + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/consumer.js + init_dirname(); + init_buffer2(); + init_process(); + var ProviderDID4 = did_exports2.match({ method: "web" }); + var SpaceDID5 = did_exports2.match({ method: "key" }); + var has3 = capability({ + can: "consumer/has", + with: ProviderDID4, + nb: struct({ + consumer: SpaceDID5 + }), + derives: (child, parent) => { + return and7(equalWith3(child, parent)) || and7(equal4(child.nb.consumer, parent.nb.consumer, "consumer")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/customer.js + init_dirname(); + init_buffer2(); + init_process(); + var ProviderDID5 = did_exports2.match({ method: "web" }); + var AccountDID4 = did_exports2.match({ method: "mailto" }); + var get11 = capability({ + can: "customer/get", + with: ProviderDID5, + nb: struct({ + customer: AccountDID4 + }), + derives: (child, parent) => { + return and7(equalWith3(child, parent)) || and7(equal4(child.nb.customer, parent.nb.customer, "customer")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/console.js + init_dirname(); + init_buffer2(); + init_process(); + var log4 = capability({ + can: "console/log", + with: schema_exports3.did(), + nb: schema_exports3.struct({ + value: schema_exports3.unknown() + }), + derives: equalWith3 + }); + var error4 = capability({ + can: "console/error", + with: schema_exports3.did(), + nb: schema_exports3.struct({ + error: schema_exports3.unknown() + }), + derives: equalWith3 + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/offer.js + init_dirname(); + init_buffer2(); + init_process(); + var arrange = capability({ + can: "offer/arrange", + with: schema_exports3.did(), + nb: schema_exports3.struct({ + /** + * Commitment proof for the aggregate being requested. + */ + pieceLink: schema_exports3.link() + }), + derives: (claim4, from18) => { + return and7(equalWith3(claim4, from18)) || and7(checkLink2(claim4.nb.pieceLink, from18.nb.pieceLink, "nb.pieceLink")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/aggregate.js + init_dirname(); + init_buffer2(); + init_process(); + var SHA2_256_TRUNC254_PADDED = 4114; + var FilCommitmentUnsealed = 61697; + var offer = capability({ + can: "aggregate/offer", + /** + * did:key identifier of the broker authority where offer is made available. + */ + with: schema_exports3.did(), + nb: schema_exports3.struct({ + /** + * CID of the DAG-CBOR encoded block with offer details. + * Service will queue given offer to be validated and handled. + */ + offer: schema_exports3.link(), + /** + * Commitment proof for the aggregate being offered. + * https://github.com/filecoin-project/go-state-types/blob/1e6cf0d47cdda75383ef036fc2725d1cf51dbde8/abi/piece.go#L47-L50 + */ + piece: schema_exports3.struct({ + /** + * CID of the aggregate piece. + */ + link: schema_exports3.link({ + code: FilCommitmentUnsealed, + version: 1, + multihash: { + code: SHA2_256_TRUNC254_PADDED + } + }), + /** + * Size in nodes. For BLS12-381 (capacity 254 bits), must be >= 16. (16 * 8 = 128) + */ + size: schema_exports3.integer() + }) + }), + derives: (claim4, from18) => { + return and7(equalWith3(claim4, from18)) || and7(checkLink2(claim4.nb.offer, from18.nb.offer, "nb.offer")) || and7( + checkLink2(claim4.nb.piece.link, from18.nb.piece.link, "nb.piece.link") + ) || and7(equal4(claim4.nb.piece.size, from18.nb.piece.size, "nb.piece.size")) || ok({}); + } + }); + var get12 = capability({ + can: "aggregate/get", + with: schema_exports3.did(), + nb: schema_exports3.struct({ + /** + * Commitment proof for the aggregate being requested. + */ + subject: schema_exports3.link() + }), + derives: (claim4, from18) => { + return and7(equalWith3(claim4, from18)) || and7(checkLink2(claim4.nb.subject, from18.nb.subject, "nb.subject")) || ok({}); + } + }); + + // ../../node_modules/.pnpm/@web3-storage+capabilities@7.0.0/node_modules/@web3-storage/capabilities/src/index.js + var abilitiesAsStrings2 = [ + top2.can, + add9.can, + space2.can, + info2.can, + recover.can, + recoverValidation.can, + upload3.can, + add11.can, + remove11.can, + list9.can, + store3.can, + add10.can, + remove10.can, + list8.can, + claim2.can, + redeem.can, + access3.can, + authorize2.can, + session2.can, + offer.can, + get12.can, + arrange.can + ]; + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/base.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/service.js + init_dirname(); + init_buffer2(); + init_process(); + var accessServiceURL = new URL("https://up.web3.storage"); + var accessServicePrincipal = parse2("did:web:web3.storage"); + var accessServiceConnection = connect({ + id: accessServicePrincipal, + codec: car_exports2.outbound, + channel: http_exports.open({ + url: accessServiceURL, + method: "POST" + }) + }); + var uploadServiceURL = new URL("https://up.web3.storage"); + var uploadServicePrincipal = parse2("did:web:web3.storage"); + var uploadServiceConnection = connect({ + id: uploadServicePrincipal, + codec: car_exports2.outbound, + channel: http_exports.open({ + url: uploadServiceURL, + method: "POST" + }) + }); + var serviceConf = { + access: accessServiceConnection, + upload: uploadServiceConnection + }; + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/base.js + var Base = class { + /** + * @param {import('@web3-storage/access').AgentData} agentData + * @param {object} [options] + * @param {import('./types').ServiceConf} [options.serviceConf] + */ + constructor(agentData, options = {}) { + /** + * @type {Agent} + * @protected + */ + __publicField(this, "_agent"); + /** + * @type {import('./types').ServiceConf} + * @protected + */ + __publicField(this, "_serviceConf"); + this._serviceConf = options.serviceConf ?? serviceConf; + this._agent = new Agent(agentData, { + servicePrincipal: this._serviceConf.access.id, + // @ts-expect-error I know but it will be HTTP for the forseeable. + url: this._serviceConf.access.channel.url, + connection: this._serviceConf.access + }); + } + /** + * @protected + * @param {import('./types').Ability[]} abilities + */ + async _invocationConfig(abilities) { + const resource = this._agent.currentSpace(); + if (!resource) { + throw new Error( + "missing current space: use createSpace() or setCurrentSpace()" + ); + } + const issuer = this._agent.issuer; + const proofs3 = await this._agent.proofs( + abilities.map((can) => ({ can, with: resource })) + ); + const audience = this._serviceConf.upload.id; + return { issuer, with: resource, proofs: proofs3, audience }; + } + }; + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/space.js + init_dirname(); + init_buffer2(); + init_process(); + var _did, _meta; + var Space = class { + /** + * @param {import('./types').DID} did + * @param {Record} meta + */ + constructor(did3, meta = {}) { + /** @type {import('./types').DID} */ + __privateAdd(this, _did, void 0); + /** @type {Record} */ + __privateAdd(this, _meta, void 0); + __privateSet(this, _did, did3); + __privateSet(this, _meta, meta); + } + /** + * The given space name. + */ + name() { + return __privateGet(this, _meta).name; + } + /** + * The DID of the space. + */ + did() { + return __privateGet(this, _did); + } + /** + * Whether the space has been registered with the service. + */ + registered() { + return Boolean(__privateGet(this, _meta).isRegistered); + } + /** + * User defined space metadata. + */ + meta() { + return __privateGet(this, _meta); + } + }; + _did = new WeakMap(); + _meta = new WeakMap(); + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/delegation.js + init_dirname(); + init_buffer2(); + init_process(); + var _meta2; + var Delegation2 = class extends Delegation { + /** + * @param {import('./types').UCANBlock} root + * @param {Map} [blocks] + * @param {Record} [meta] + */ + constructor(root3, blocks, meta = {}) { + super(root3, blocks); + /** @type {Record} */ + __privateAdd(this, _meta2, void 0); + __privateSet(this, _meta2, meta); + } + /** + * User defined delegation metadata. + */ + meta() { + return __privateGet(this, _meta2); + } + }; + _meta2 = new WeakMap(); + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/capability/store.js + init_dirname(); + init_buffer2(); + init_process(); + var StoreClient = class extends Base { + /** + * Store a DAG encoded as a CAR file. + * + * @param {Blob} car - CAR file data. + * @param {import('../types').RequestOptions} [options] + */ + async add(car, options = {}) { + const conf = await this._invocationConfig([store_exports4.add.can]); + options.connection = this._serviceConf.upload; + return store_exports2.add(conf, car, options); + } + /** + * List CAR files stored to the resource. + * + * @param {import('../types').ListRequestOptions} [options] + */ + async list(options = {}) { + const conf = await this._invocationConfig([store_exports4.add.can]); + options.connection = this._serviceConf.upload; + return store_exports2.list(conf, options); + } + /** + * Remove a stored CAR file by CAR CID. + * + * @param {import('../types').CARLink} link - CID of CAR file to remove. + * @param {import('../types').RequestOptions} [options] + */ + async remove(link10, options = {}) { + const conf = await this._invocationConfig([store_exports4.remove.can]); + options.connection = this._serviceConf.upload; + return store_exports2.remove(conf, link10, options); + } + }; + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/capability/upload.js + init_dirname(); + init_buffer2(); + init_process(); + var UploadClient = class extends Base { + /** + * Register an "upload" to the resource. + * + * @param {import('../types').UnknownLink} root - Root data CID for the DAG that was stored. + * @param {import('../types').CARLink[]} shards - CIDs of CAR files that contain the DAG. + * @param {import('../types').RequestOptions} [options] + */ + async add(root3, shards, options = {}) { + const conf = await this._invocationConfig([upload_exports4.add.can]); + options.connection = this._serviceConf.upload; + return upload_exports2.add(conf, root3, shards, options); + } + /** + * List uploads registered to the resource. + * + * @param {import('../types').ListRequestOptions} [options] + */ + async list(options = {}) { + const conf = await this._invocationConfig([upload_exports4.list.can]); + options.connection = this._serviceConf.upload; + return upload_exports2.list(conf, options); + } + /** + * Remove an upload by root data CID. + * + * @param {import('../types').UnknownLink} root - Root data CID to remove. + * @param {import('../types').RequestOptions} [options] + */ + async remove(root3, options = {}) { + const conf = await this._invocationConfig([upload_exports4.remove.can]); + options.connection = this._serviceConf.upload; + return upload_exports2.remove(conf, root3, options); + } + }; + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/capability/space.js + init_dirname(); + init_buffer2(); + init_process(); + var SpaceClient = class extends Base { + /** + * Get information about a space. + * + * @param {import('../types').DID} space - DID of the space to retrieve info about. + */ + async info(space3) { + return await this._agent.getSpaceInfo(space3); + } + }; + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/capability/access.js + init_dirname(); + init_buffer2(); + init_process(); + var AccessClient = class extends Base { + /* c8 ignore start - testing websocket code is hard */ + /** + * Authorize the current agent to use capabilities granted to the passed + * email account. + * + * @param {`${string}@${string}`} email + * @param {object} [options] + * @param {AbortSignal} [options.signal] + * @param {Iterable<{ can: import('../types').Ability }>} [options.capabilities] + */ + async authorize(email2, options) { + return authorizeWaitAndClaim(this._agent, email2, options); + } + /* c8 ignore stop */ + /** + * Claim delegations granted to the account associated with this agent. + */ + async claim() { + return claimAccess(this._agent, this._agent.issuer.did(), { + addProofs: true + }); + } + }; + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/client.js + var Client = class extends Base { + /** + * @param {import('@web3-storage/access').AgentData} agentData + * @param {object} [options] + * @param {import('./types').ServiceConf} [options.serviceConf] + */ + constructor(agentData, options) { + super(agentData, options); + this.capability = { + access: new AccessClient(agentData, options), + store: new StoreClient(agentData, options), + upload: new UploadClient(agentData, options), + space: new SpaceClient(agentData, options) + }; + } + /* c8 ignore start - testing websockets is hard */ + /** + * Authorize the current agent to use capabilities granted to the passed + * email account. + * + * @param {`${string}@${string}`} email + * @param {object} [options] + * @param {AbortSignal} [options.signal] + * @param {Iterable<{ can: import('./types').Ability }>} [options.capabilities] + */ + async authorize(email2, options) { + await this.capability.access.authorize(email2, options); + } + /* c8 ignore stop */ + /** + * Uploads a file to the service and returns the root data CID for the + * generated DAG. + * + * @param {import('./types').BlobLike} file - File data. + * @param {import('./types').UploadOptions} [options] + */ + async uploadFile(file, options = {}) { + const conf = await this._invocationConfig([ + store_exports4.add.can, + upload_exports4.add.can + ]); + options.connection = this._serviceConf.upload; + return uploadFile(conf, file, options); + } + /** + * Uploads a directory of files to the service and returns the root data CID + * for the generated DAG. All files are added to a container directory, with + * paths in file names preserved. + * + * @param {import('./types').FileLike[]} files - File data. + * @param {import('./types').UploadDirectoryOptions} [options] + */ + async uploadDirectory(files, options = {}) { + const conf = await this._invocationConfig([ + store_exports4.add.can, + upload_exports4.add.can + ]); + options.connection = this._serviceConf.upload; + return uploadDirectory(conf, files, options); + } + /** + * Uploads a CAR file to the service. + * + * The difference between this function and `capability.store.add` is that the + * CAR file is automatically sharded and an "upload" is registered, linking + * the individual shards (see `capability.upload.add`). + * + * Use the `onShardStored` callback to obtain the CIDs of the CAR file shards. + * + * @param {import('./types').BlobLike} car - CAR file. + * @param {import('./types').UploadOptions} [options] + */ + async uploadCAR(car, options = {}) { + const conf = await this._invocationConfig([ + store_exports4.add.can, + upload_exports4.add.can + ]); + options.connection = this._serviceConf.upload; + return uploadCAR(conf, car, options); + } + /** + * Return the default provider. + */ + defaultProvider() { + return this._agent.connection.id.did(); + } + /** + * The current user agent (this device). + */ + agent() { + return this._agent.issuer; + } + /** + * The current space. + */ + currentSpace() { + const did3 = this._agent.currentSpace(); + return did3 ? new Space(did3, this._agent.spaces.get(did3)) : void 0; + } + /** + * Use a specific space. + * + * @param {import('./types').DID} did + */ + async setCurrentSpace(did3) { + await this._agent.setCurrentSpace( + /** @type {`did:key:${string}`} */ + did3 + ); + } + /** + * Spaces available to this agent. + */ + spaces() { + return [...this._agent.spaces].map(([did3, meta]) => { + return new Space(did3, meta); + }); + } + /** + * Create a new space with an optional name. + * + * @param {string} [name] + * * @param {any[]} [ds] + */ + async createSpace(name15, ds = []) { + const { did: did3, meta } = await this._agent.createSpace(name15, ds); + return new Space(did3, meta); + } + /* c8 ignore start - hard to test this without authorize tests which require websockets */ + /** + * Register the _current_ space with the service. + * + * @param {string} email + * @param {object} [options] + * @param {import('./types').DID<'web'>} [options.provider] + * @param {AbortSignal} [options.signal] + */ + async registerSpace(email2, options = {}) { + options.provider = options.provider ?? /** @type {import('./types').DID<'web'>} */ + this.defaultProvider(); + await this._agent.registerSpace(email2, options); + } + /* c8 ignore stop */ + /** + * Add a space from a received proof. + * + * @param {import('./types').Delegation} proof + */ + async addSpace(proof) { + const { did: did3, meta } = await this._agent.importSpaceFromDelegation(proof); + return new Space(did3, meta); + } + /** + * Get all the proofs matching the capabilities. + * + * Proofs are delegations with an _audience_ matching the agent DID. + * + * @param {import('./types').Capability[]} [caps] - Capabilities to + * filter by. Empty or undefined caps with return all the proofs. + */ + proofs(caps) { + return this._agent.proofs(caps); + } + /** + * Add a proof to the agent. Proofs are delegations with an _audience_ + * matching the agent DID. + * + * @param {import('./types').Delegation} proof + */ + async addProof(proof) { + await this._agent.addProof(proof); + } + /** + * Get delegations created by the agent for others. + * + * @param {import('./types').Capability[]} [caps] - Capabilities to + * filter by. Empty or undefined caps with return all the delegations. + */ + delegations(caps) { + const delegations = []; + for (const { delegation, meta } of this._agent.delegationsWithMeta(caps)) { + delegations.push( + new Delegation2(delegation.root, delegation.blocks, meta) + ); + } + return delegations; + } + /** + * Create a delegation to the passed audience for the given abilities with + * the _current_ space as the resource. + * + * @param {import('./types').Principal} audience + * @param {import('./types').Abilities[]} abilities + * @param {Omit & { audienceMeta?: import('./types').AgentMeta }} [options] + */ + async createDelegation(audience, abilities, options = {}) { + const audienceMeta = options.audienceMeta ?? { + name: "agent", + type: "device" + }; + const { root: root3, blocks } = await this._agent.delegate({ + ...options, + abilities, + audience, + audienceMeta + }); + return new Delegation2(root3, blocks, { audience: audienceMeta }); + } + }; + + // ../../node_modules/.pnpm/@web3-storage+w3up-client@8.0.1/node_modules/@web3-storage/w3up-client/src/index.js + async function create13(options = {}) { + const store4 = options.store ?? new StoreIndexedDB("w3up-client"); + const raw = await store4.load(); + if (raw) { + const data2 = AgentData.fromExport(raw, { store: store4 }); + if (options.principal && data2.principal.did() !== options.principal.did()) { + throw new Error( + `store cannot be used with ${options.principal.did()}, stored principal and passed principal must match` + ); + } + return new Client(data2, options); + } + const principal = options.principal ?? await generate2(); + const data = await AgentData.create({ principal }, { store: store4 }); + return new Client(data, options); + } + + // ../../node_modules/.pnpm/@web3-storage+clock@0.3.0/node_modules/@web3-storage/clock/src/client/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+client@7.0.1/node_modules/@ucanto/client/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+client@7.0.1/node_modules/@ucanto/client/src/connection.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+interface@7.1.0/node_modules/@ucanto/interface/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/delegation.js + var delegation_exports2 = {}; + __export(delegation_exports2, { + Delegation: () => Delegation3, + View: () => Delegation3, + allows: () => allows2, + create: () => create14, + delegate: () => delegate5, + exportDAG: () => exportDAG2, + importDAG: () => importDAG2, + isDelegation: () => isDelegation2, + isLink: () => isLink3, + view: () => view6 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/link.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/dag.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/cbor.js + var cbor_exports3 = {}; + __export(cbor_exports3, { + code: () => code, + contentType: () => contentType9, + decode: () => decode6, + encode: () => encode32, + link: () => link6, + name: () => name2, + write: () => write9 + }); + init_dirname(); + init_buffer2(); + init_process(); + var contentType9 = "application/vnd.ipld.dag-cbor"; + var prepare3 = (data, seen) => { + if (seen.has(data)) { + throw new TypeError("Can not encode circular structure"); + } + if (data === void 0 && seen.size === 0) { + return null; + } + if (data === null) { + return null; + } + if (typeof data === "symbol" && seen.size === 0) { + return null; + } + if (isLink(data)) { + return data; + } + if (ArrayBuffer.isView(data)) { + return data; + } + if (Array.isArray(data)) { + seen.add(data); + const items = []; + for (const item of data) { + items.push( + item === void 0 || typeof item === "symbol" ? null : prepare3(item, seen) + ); + } + return items; + } + if (typeof /** @type {{toJSON?:unknown}} */ + data.toJSON === "function") { + seen.add(data); + const json = ( + /** @type {{toJSON():unknown}} */ + data.toJSON() + ); + return prepare3(json, seen); + } + if (typeof data === "object") { + seen.add(data); + const object = {}; + for (const [key, value] of Object.entries(data)) { + if (value !== void 0 && typeof value !== "symbol") { + object[key] = prepare3(value, seen); + } + } + return object; + } + return data; + }; + var encode32 = (data) => ( + /** @type {CBOR.ByteView} */ + encode4(prepare3(data, /* @__PURE__ */ new Set())) + ); + var link6 = async (bytes2, { hasher = sha256 } = {}) => { + return ( + /** @type {API.Link} */ + create3(code, await hasher.digest(bytes2)) + ); + }; + var write9 = async (data, options) => { + const bytes2 = encode32(data); + const cid = await link6(bytes2, options); + return { cid, bytes: bytes2 }; + }; + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/dag.js + var iterate4 = function* (value) { + if (value && typeof value === "object" && "iterateIPLDBlocks" in value && typeof value.iterateIPLDBlocks === "function") { + yield* value.iterateIPLDBlocks(); + } + }; + var createStore2 = (blocks = []) => { + const store4 = /* @__PURE__ */ new Map(); + addEveryInto2(blocks, store4); + return store4; + }; + var EMBED_CODE2 = identity.code; + var get13 = (cid, store4, fallback) => { + if (cid.multihash.code === EMBED_CODE2) { + return { cid, bytes: cid.multihash.digest }; + } + const block = ( + /** @type {API.Block|undefined} */ + store4.get(`${cid}`) + ); + return block ? block : fallback === void 0 ? notFound2(cid) : fallback; + }; + var notFound2 = (link10) => { + throw new Error(`Block for the ${link10} is not found`); + }; + var writeInto2 = async (source, store4, options = {}) => { + const codec = ( + /** @type {MF.BlockEncoder} */ + options.codec || cbor_exports3 + ); + const hasher = ( + /** @type {MF.MultihashHasher} */ + options.hasher || sha256 + ); + const bytes2 = codec.encode(source); + const digest3 = await hasher.digest(bytes2); + const link10 = create3(codec.code, digest3); + store4.set( + /** @type {API.ToString} */ + link10.toString(), + { + bytes: bytes2, + cid: link10 + } + ); + return { bytes: bytes2, cid: link10, data: source }; + }; + var addInto2 = ({ cid, bytes: bytes2 }, store4) => { + store4.set( + /** @type {API.ToString} */ + cid.toString(), + { + bytes: bytes2, + cid + } + ); + return { bytes: bytes2, cid }; + }; + var addEveryInto2 = (source, store4) => { + for (const block of source) { + addInto2(block, store4); + } + }; + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/delegation.js + var isLink3 = isLink; + var isDelegation2 = (proof) => !isLink(proof); + var allows2 = (...delegations) => { + let allow = {}; + for (const delegation of delegations) { + for (const { with: uri3, can, nb } of iterateCapabilities2(delegation)) { + const resource = allow[uri3] || (allow[uri3] = {}); + const abilities = resource[can] || (resource[can] = []); + abilities.push({ ...nb }); + } + } + return ( + /** @type {API.InferAllowedFromDelegations} */ + allow + ); + }; + var iterateCapabilities2 = function* ({ issuer, capabilities, proofs: proofs3 }) { + for (const own of capabilities) { + if (own.with === "ucan:*") { + yield { + ...own, + with: issuer.did() + }; + for (const proof of proofs3) { + if (isDelegation2(proof)) { + for (const capability3 of iterateCapabilities2(proof)) { + const can = matchAbility2(capability3.can, own.can); + if (can) { + yield { + ...capability3, + can, + // We do not know capability semantics so it is impossible + // for us to eliminate capabilities that do not satisfy imposed + // caveats (`own.nb`). Therefore we optimistically assume that + // `own.nb` further constraints `capability.nb` and do a shallow + // merge of the two. As a result we may include capabilities + // that during validation will be considered invalid due to + // constraint violations. While that is not ideal validator + // will treat them as if they were omitted and therefore it + // is a reasonable compromise. + nb: { ...capability3.nb, ...Object(own.nb) } + }; + } + } + } + } + } else { + yield own; + } + } + }; + var matchAbility2 = (provided, claimed) => { + if (provided === "*") { + return claimed; + } + if (claimed === "*") { + return provided; + } + if (claimed.endsWith("/*") && provided.startsWith(claimed.slice(0, -1))) { + return provided; + } + if (provided.endsWith("/*") && claimed.startsWith(provided.slice(0, -1))) { + return claimed; + } + if (provided === claimed) { + return provided; + } + return null; + }; + var Delegation3 = class { + /** + * @param {API.UCANBlock} root + * @param {DAG.BlockStore} [blocks] + */ + constructor(root3, blocks = /* @__PURE__ */ new Map()) { + this.root = root3; + this.blocks = blocks; + Object.defineProperties(this, { + blocks: { + enumerable: false + } + }); + } + /** + * @returns {API.AttachedLinkSet} + */ + get attachedLinks() { + const _attachedLinks = /* @__PURE__ */ new Set(); + const ucanView = this.data; + for (const capability3 of ucanView.capabilities) { + const links4 = getLinksFromObject2(capability3); + for (const link10 of links4) { + _attachedLinks.add(`${link10}`); + } + } + for (const fact of ucanView.facts) { + if (isLink(fact)) { + _attachedLinks.add(`${fact}`); + } else { + const links4 = Object.values(fact).filter((e12) => isLink(e12)); + for (const link10 of links4) { + _attachedLinks.add(`${link10}`); + } + } + } + return _attachedLinks; + } + get version() { + return this.data.version; + } + get signature() { + return this.data.signature; + } + get cid() { + return this.root.cid; + } + link() { + return this.root.cid; + } + get asCID() { + return this.cid; + } + get bytes() { + return this.root.bytes; + } + get data() { + const data = decode38(this.root); + Object.defineProperties(this, { data: { value: data, enumerable: false } }); + return data; + } + /** + * Attach a block to the delegation DAG so it would be included in the + * block iterator. + * ⚠️ You can only attach blocks that are referenced from the `capabilities` + * or `facts`. + * + * @param {API.Block} block + */ + attach(block) { + if (!this.attachedLinks.has(`${block.cid.link()}`)) { + throw new Error(`given block with ${block.cid} is not an attached link`); + } + this.blocks.set(`${block.cid}`, block); + } + export() { + return exportDAG2(this.root, this.blocks, this.attachedLinks); + } + iterateIPLDBlocks() { + return exportDAG2(this.root, this.blocks, this.attachedLinks); + } + /** + * @type {API.Proof[]} + */ + get proofs() { + return proofs2(this); + } + /** + * @type {API.Principal} + */ + get issuer() { + return this.data.issuer; + } + /** + * @type {API.Principal} + */ + get audience() { + return this.data.audience; + } + /** + * @returns {C} + */ + get capabilities() { + return ( + /** @type {C} */ + this.data.capabilities + ); + } + /** + * @returns {number} + */ + get expiration() { + return this.data.expiration; + } + /** + * @returns {undefined|number} + */ + get notBefore() { + return this.data.notBefore; + } + /** + * @returns {undefined|string} + */ + get nonce() { + return this.data.nonce; + } + /** + * @returns {API.Fact[]} + */ + get facts() { + return this.data.facts; + } + /** + * Iterate over the proofs + * + * @returns {IterableIterator} + */ + iterate() { + return it3(this); + } + delegate() { + return this; + } + buildIPLDView() { + return this; + } + /** + * @returns {API.DelegationJSON} + */ + toJSON() { + return ( + /** @type {any} */ + { + ...this.data.toJSON(), + "/": this.cid.toString(), + prf: this.proofs.map( + (proof) => isDelegation2(proof) ? proof : { "/": proof.toString() } + ) + } + ); + } + }; + var it3 = function* (delegation) { + for (const proof of delegation.proofs) { + if (isDelegation2(proof)) { + yield* it3(proof); + yield proof; + } + } + }; + var decodeCache2 = /* @__PURE__ */ new WeakMap(); + var decode38 = ({ bytes: bytes2 }) => { + const data = decodeCache2.get(bytes2); + if (!data) { + const data2 = decode19(bytes2); + decodeCache2.set(bytes2, data2); + return data2; + } + return data; + }; + var delegate5 = async ({ issuer, audience, proofs: proofs3 = [], attachedBlocks = /* @__PURE__ */ new Map(), ...input }, options) => { + const links4 = []; + const blocks = /* @__PURE__ */ new Map(); + for (const proof of proofs3) { + if (!isDelegation2(proof)) { + links4.push(proof); + } else { + links4.push(proof.cid); + for (const block of proof.export()) { + blocks.set(block.cid.toString(), block); + } + } + } + const data = await issue({ + ...input, + issuer, + audience, + proofs: links4 + }); + const { cid, bytes: bytes2 } = await write(data, options); + decodeCache2.set(cid, data); + const delegation = new Delegation3({ cid, bytes: bytes2 }, blocks); + Object.defineProperties(delegation, { proofs: { value: proofs3 } }); + for (const block of attachedBlocks.values()) { + delegation.attach(block); + } + return delegation; + }; + var exportDAG2 = function* (root3, blocks, attachedLinks) { + for (const link10 of decode38(root3).proofs) { + const root4 = ( + /** @type {UCAN.Block} */ + blocks.get(`${link10}`) + ); + if (root4) { + yield* exportSubDAG2(root4, blocks); + } + } + for (const link10 of attachedLinks.values()) { + const block = blocks.get(link10); + if (block) { + yield block; + } + } + yield root3; + }; + var exportSubDAG2 = function* (root3, blocks) { + for (const link10 of decode38(root3).proofs) { + const root4 = ( + /** @type {UCAN.Block} */ + blocks.get(`${link10}`) + ); + if (root4) { + yield* exportSubDAG2(root4, blocks); + } + } + yield root3; + }; + var importDAG2 = (dag) => { + let entries6 = []; + for (const block of dag) { + entries6.push([block.cid.toString(), block]); + } + const last2 = entries6.pop(); + if (!last2) { + throw new RangeError("Empty DAG can not be turned into a delegation"); + } else { + const [, root3] = last2; + return new Delegation3( + /** @type {API.UCANBlock} */ + root3, + new Map(entries6) + ); + } + }; + var create14 = ({ root: root3, blocks }) => new Delegation3(root3, blocks); + var view6 = ({ root: root3, blocks }, fallback) => { + const block = get13(root3, blocks, null); + return block ? create14({ root: block, blocks }) : ( + /** @type {T} */ + fallback + ); + }; + var proofs2 = (delegation) => { + const proofs3 = []; + const { root: root3, blocks } = delegation; + for (const link10 of decode38(root3).proofs) { + const root4 = ( + /** @type {UCAN.Block} */ + blocks.get(link10.toString()) + ); + proofs3.push(root4 ? create14({ root: root4, blocks }) : link10); + } + Object.defineProperty(delegation, "proofs", { value: proofs3 }); + return proofs3; + }; + function getLinksFromObject2(obj) { + const links4 = []; + function recurse(obj2) { + for (const key in obj2) { + const value = obj2[key]; + if (isLink(value)) { + links4.push(value); + } else if (value && typeof value === "object") { + recurse(value); + } + } + } + recurse(obj); + return links4; + } + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/invocation.js + var invocation_exports2 = {}; + __export(invocation_exports2, { + Invocation: () => Invocation2, + create: () => create15, + invoke: () => invoke2, + view: () => view7 + }); + init_dirname(); + init_buffer2(); + init_process(); + var invoke2 = (options) => new IssuedInvocation2(options); + var create15 = ({ root: root3, blocks }) => new Invocation2(root3, blocks); + var view7 = ({ root: root3, blocks }, fallback) => { + const block = get13(root3, blocks, null); + if (block == null) { + return fallback !== void 0 ? fallback : notFound2(root3); + } + return ( + /** @type {API.Invocation} */ + create15({ root: block, blocks }) + ); + }; + var IssuedInvocation2 = class { + /** + * @param {API.InvocationOptions} data + */ + constructor({ + issuer, + audience, + capability: capability3, + proofs: proofs3 = [], + expiration, + lifetimeInSeconds, + notBefore, + nonce, + facts = [] + }) { + this.issuer = issuer; + this.audience = audience; + this.proofs = proofs3; + this.capabilities = [capability3]; + this.expiration = expiration; + this.lifetimeInSeconds = lifetimeInSeconds; + this.notBefore = notBefore; + this.nonce = nonce; + this.facts = facts; + this.attachedBlocks = /* @__PURE__ */ new Map(); + } + /** + * Attach a block to the invocation DAG so it would be included in the + * block iterator. + * ⚠️ You should only attach blocks that are referenced from the `capabilities` + * or `facts`, if that is not the case you probably should reconsider. + * ⚠️ Once a delegation is de-serialized the attached blocks will not be re-attached. + * + * @param {API.Block} block + */ + attach(block) { + this.attachedBlocks.set(`${block.cid}`, block); + } + delegate() { + return delegate5(this); + } + buildIPLDView() { + return delegate5(this); + } + /** + * @template {API.InvocationService} Service + * @param {API.ConnectionView} connection + * @returns {Promise>} + */ + async execute(connection3) { + const invocation = this; + const [result] = await connection3.execute(invocation); + return result; + } + }; + var Invocation2 = class extends Delegation3 { + }; + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/message.js + var message_exports2 = {}; + __export(message_exports2, { + MessageSchema: () => MessageSchema2, + build: () => build2, + view: () => view9 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/receipt.js + var receipt_exports2 = {}; + __export(receipt_exports2, { + issue: () => issue3, + view: () => view8 + }); + init_dirname(); + init_buffer2(); + init_process(); + var view8 = ({ root: root3, blocks }, fallback) => { + const block = get13(root3, blocks, null); + if (block == null) { + return fallback !== void 0 ? fallback : notFound2(root3); + } + const data = decode6(block.bytes); + return new Receipt2({ root: { ...block, data }, store: blocks }); + }; + var Receipt2 = class { + /** + * @param {object} input + * @param {Required>>} input.root + * @param {DAG.BlockStore} input.store + * @param {API.Meta} [input.meta] + * @param {Ran|ReturnType} [input.ran] + * @param {API.EffectsModel} [input.fx] + * @param {API.SignatureView, SigAlg>} [input.signature] + * @param {API.UCAN.Principal} [input.issuer] + * @param {API.Proof[]} [input.proofs] + */ + constructor({ root: root3, store: store4, ran, issuer, signature, proofs: proofs3 }) { + this.store = store4; + this.root = root3; + this._ran = ran; + this._signature = signature; + this._proofs = proofs3; + this._issuer = issuer; + } + /** + * @returns {Ran|ReturnType} + */ + get ran() { + const ran = this._ran; + if (!ran) { + const ran2 = ( + /** @type {Ran} */ + view7( + { + root: this.root.data.ocm.ran, + blocks: this.store + }, + this.root.data.ocm.ran + ) + ); + this._ran = ran2; + return ran2; + } else { + return ran; + } + } + get proofs() { + const proofs3 = this._proofs; + if (proofs3) { + return proofs3; + } else { + const { store: store4, root: root3 } = this; + const { prf } = root3.data.ocm; + const proofs4 = []; + if (prf) { + for (const link10 of prf) { + const proof = view6({ root: link10, blocks: store4 }, link10); + proofs4.push(proof); + } + } + this._proofs = proofs4; + return proofs4; + } + } + get meta() { + return this.root.data.ocm.meta; + } + get issuer() { + const issuer = this._issuer; + if (issuer) { + return issuer; + } else { + const { iss } = this.root.data.ocm; + if (iss) { + const issuer2 = parse2(iss); + this._issuer = issuer2; + return issuer2; + } + } + } + get out() { + return this.root.data.ocm.out; + } + get fx() { + return this.root.data.ocm.fx; + } + get signature() { + const signature = this._signature; + if (signature) { + return signature; + } else { + const signature2 = ( + /** @type {API.SignatureView, SigAlg>} */ + view(this.root.data.sig) + ); + this._signature = signature2; + return signature2; + } + } + /** + * @param {API.Crypto.Verifier} signingPrincipal + */ + verifySignature(signingPrincipal) { + return this.signature.verify( + signingPrincipal, + encode32(this.root.data.ocm) + ); + } + buildIPLDView() { + return this; + } + *iterateIPLDBlocks() { + const { ran, fx, proofs: proofs3, root: root3 } = this; + yield* iterate4(ran); + for (const fork5 of fx.fork) { + yield* iterate4(fork5); + } + if (fx.join) { + yield* iterate4(fx.join); + } + for (const proof of proofs3) { + yield* iterate4(proof); + } + yield root3; + } + }; + var ReceptBuilder2 = class { + /** + * @param {object} options + * @param {API.Signer} options.issuer + * @param {Ran|ReturnType} options.ran + * @param {API.Result} options.result + * @param {API.EffectsModel} [options.fx] + * @param {API.Proof[]} [options.proofs] + * @param {Record} [options.meta] + */ + constructor({ issuer, result, ran, fx = NOFX2, proofs: proofs3 = [], meta = {} }) { + this.issuer = issuer; + this.result = result; + this.ran = ran; + this.fx = fx; + this.proofs = proofs3; + this.meta = meta; + } + async buildIPLDView({ hasher = sha256, codec = cbor_exports3 } = {}) { + const store4 = createStore2(); + addEveryInto2(iterate4(this.ran), store4); + for (const proof of this.proofs) { + addEveryInto2(iterate4(proof), store4); + } + const outcome = { + ran: ( + /** @type {ReturnType} */ + this.ran.link() + ), + out: this.result, + fx: this.fx, + meta: this.meta, + iss: this.issuer.did(), + prf: this.proofs.map((p8) => p8.link()) + }; + const signature = await this.issuer.sign(encode32(outcome)); + const model = { + ocm: outcome, + sig: signature + }; + const root3 = await writeInto2(model, store4, { + hasher, + codec + }); + return new Receipt2({ + root: root3, + store: store4, + signature, + proofs: this.proofs, + ran: this.ran + }); + } + }; + var NOFX2 = Object.freeze({ fork: Object.freeze([]) }); + var issue3 = (options) => new ReceptBuilder2(options).buildIPLDView(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/schema.js + var schema_exports5 = {}; + __export(schema_exports5, { + API: () => API2, + DID: () => did_exports3, + Link: () => link_exports5, + Text: () => text_exports2, + URI: () => uri_exports2, + and: () => and8, + array: () => array2, + boolean: () => boolean2, + dictionary: () => dictionary2, + did: () => match7, + endsWith: () => endsWith2, + enum: () => createEnum2, + error: () => error5, + float: () => float2, + greaterThan: () => greaterThan2, + integer: () => integer2, + intersection: () => intersection3, + lessThan: () => lessThan2, + link: () => match6, + literal: () => literal2, + memberError: () => memberError2, + never: () => never2, + nullable: () => nullable2, + number: () => number2, + ok: () => ok3, + optional: () => optional3, + or: () => or12, + refine: () => refine2, + startsWith: () => startsWith2, + string: () => string3, + struct: () => struct2, + text: () => match8, + tuple: () => tuple2, + typeError: () => typeError2, + unknown: () => unknown2, + uri: () => match5, + variant: () => variant2 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/schema/uri.js + var uri_exports2 = {}; + __export(uri_exports2, { + from: () => from16, + match: () => match5, + read: () => read9, + uri: () => uri2 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/schema/schema.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/schema/type.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/result.js + init_dirname(); + init_buffer2(); + init_process(); + var ok3 = (value) => { + if (value == null) { + throw new TypeError(`ok(${value}) is not allowed, consider ok({}) instead`); + } else { + return { ok: value }; + } + }; + var panic3 = (message2) => { + throw new Failure2(message2); + }; + var Failure2 = class extends Error { + describe() { + return this.toString(); + } + get message() { + return this.describe(); + } + toJSON() { + const { name: name15, message: message2, stack } = this; + return { name: name15, message: message2, stack }; + } + }; + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/schema/schema.js + var API2 = class { + /** + * @param {Settings} settings + */ + constructor(settings3) { + this.settings = settings3; + } + toString() { + return `new ${this.constructor.name}()`; + } + /** + * @abstract + * @param {I} input + * @param {Settings} settings + * @returns {Schema.ReadResult} + */ + /* c8 ignore next 3 */ + readWith(input, settings3) { + throw new Error(`Abstract method readWith must be implemented by subclass`); + } + /** + * @param {I} input + * @returns {Schema.ReadResult} + */ + read(input) { + return this.readWith(input, this.settings); + } + /** + * @param {unknown} value + * @returns {value is T} + */ + is(value) { + return !this.read( + /** @type {I} */ + value + )?.error; + } + /** + * @param {unknown} value + * @return {T} + */ + from(value) { + const result = this.read( + /** @type {I} */ + value + ); + if (result.error) { + throw result.error; + } else { + return result.ok; + } + } + /** + * @returns {Schema.Schema} + */ + optional() { + return optional3(this); + } + /** + * @returns {Schema.Schema} + */ + nullable() { + return nullable2(this); + } + /** + * @returns {Schema.Schema} + */ + array() { + return array2(this); + } + /** + * @template U + * @param {Schema.Reader} schema + * @returns {Schema.Schema} + */ + or(schema9) { + return or12(this, schema9); + } + /** + * @template U + * @param {Schema.Reader} schema + * @returns {Schema.Schema} + */ + and(schema9) { + return and8(this, schema9); + } + /** + * @template {T} U + * @param {Schema.Reader} schema + * @returns {Schema.Schema} + */ + refine(schema9) { + return refine2(this, schema9); + } + /** + * @template {string} Kind + * @param {Kind} [kind] + * @returns {Schema.Schema, I>} + */ + brand(kind) { + return ( + /** @type {Schema.Schema, I>} */ + this + ); + } + /** + * @param {Schema.NotUndefined} value + * @returns {Schema.DefaultSchema, I>} + */ + default(value) { + const fallback = this.from(value); + if (fallback === void 0) { + throw new Error(`Value of type undefined is not a valid default`); + } + const schema9 = new Default2({ + reader: ( + /** @type {Schema.Reader} */ + this + ), + value: ( + /** @type {Schema.NotUndefined} */ + fallback + ) + }); + return ( + /** @type {Schema.DefaultSchema, I>} */ + schema9 + ); + } + }; + var Never2 = class extends API2 { + toString() { + return "never()"; + } + /** + * @param {I} input + * @returns {Schema.ReadResult} + */ + read(input) { + return typeError2({ expect: "never", actual: input }); + } + }; + var never2 = () => new Never2(); + var Unknown2 = class extends API2 { + /** + * @param {I} input + */ + read(input) { + return ( + /** @type {Schema.ReadResult}*/ + { ok: input } + ); + } + toString() { + return "unknown()"; + } + }; + var unknown2 = () => new Unknown2(); + var Nullable2 = class extends API2 { + /** + * @param {I} input + * @param {Schema.Reader} reader + */ + readWith(input, reader2) { + const result = reader2.read(input); + if (result.error) { + return input === null ? { ok: null } : { + error: new UnionError2({ + causes: [ + result.error, + typeError2({ expect: "null", actual: input }).error + ] + }) + }; + } else { + return result; + } + } + toString() { + return `${this.settings}.nullable()`; + } + }; + var nullable2 = (schema9) => new Nullable2(schema9); + var Optional2 = class extends API2 { + optional() { + return this; + } + /** + * @param {I} input + * @param {Schema.Reader} reader + * @returns {Schema.ReadResult} + */ + readWith(input, reader2) { + const result = reader2.read(input); + return result.error && input === void 0 ? { ok: void 0 } : result; + } + toString() { + return `${this.settings}.optional()`; + } + }; + var Default2 = class extends API2 { + /** + * @returns {Schema.DefaultSchema, I>} + */ + optional() { + return ( + /** @type {Schema.DefaultSchema, I>} */ + this + ); + } + /** + * @param {I} input + * @param {object} options + * @param {Schema.Reader} options.reader + * @param {O} options.value + * @returns {Schema.ReadResult} + */ + readWith(input, { reader: reader2, value }) { + if (input === void 0) { + return ( + /** @type {Schema.ReadResult} */ + { ok: value } + ); + } else { + const result = reader2.read(input); + return result.error ? result : result.ok !== void 0 ? ( + // We just checked that result.ok is not undefined but still needs + // reassurance + /** @type {Schema.ReadResult} */ + result + ) : { ok: value }; + } + } + toString() { + return `${this.settings.reader}.default(${JSON.stringify( + this.settings.value + )})`; + } + get value() { + return this.settings.value; + } + }; + var optional3 = (schema9) => new Optional2(schema9); + var ArrayOf2 = class extends API2 { + /** + * @param {I} input + * @param {Schema.Reader} schema + */ + readWith(input, schema9) { + if (!Array.isArray(input)) { + return typeError2({ expect: "array", actual: input }); + } + const results = []; + for (const [index2, value] of input.entries()) { + const result = schema9.read(value); + if (result.error) { + return memberError2({ at: index2, cause: result.error }); + } else { + results.push(result.ok); + } + } + return { ok: results }; + } + get element() { + return this.settings; + } + toString() { + return `array(${this.element})`; + } + }; + var array2 = (schema9) => new ArrayOf2(schema9); + var Tuple2 = class extends API2 { + /** + * @param {I} input + * @param {U} shape + * @returns {Schema.ReadResult>} + */ + readWith(input, shape) { + if (!Array.isArray(input)) { + return typeError2({ expect: "array", actual: input }); + } + if (input.length !== this.shape.length) { + return error5(`Array must contain exactly ${this.shape.length} elements`); + } + const results = []; + for (const [index2, reader2] of shape.entries()) { + const result = reader2.read(input[index2]); + if (result.error) { + return memberError2({ at: index2, cause: result.error }); + } else { + results[index2] = result.ok; + } + } + return { ok: ( + /** @type {Schema.InferTuple} */ + results + ) }; + } + /** @type {U} */ + get shape() { + return this.settings; + } + toString() { + return `tuple([${this.shape.map((reader2) => reader2.toString()).join(", ")}])`; + } + }; + var tuple2 = (shape) => new Tuple2(shape); + var Dictionary2 = class _Dictionary extends API2 { + /** + * @param {I} input + * @param {object} schema + * @param {Schema.Reader} schema.key + * @param {Schema.Reader} schema.value + */ + readWith(input, { key, value }) { + if (typeof input != "object" || input === null || Array.isArray(input)) { + return typeError2({ + expect: "dictionary", + actual: input + }); + } + const dict = ( + /** @type {Schema.Dictionary} */ + {} + ); + for (const [k5, v7] of Object.entries(input)) { + const keyResult = key.read(k5); + if (keyResult.error) { + return memberError2({ at: k5, cause: keyResult.error }); + } + const valueResult = value.read(v7); + if (valueResult.error) { + return memberError2({ at: k5, cause: valueResult.error }); + } + if (valueResult.ok !== void 0) { + dict[keyResult.ok] = valueResult.ok; + } + } + return { ok: dict }; + } + get key() { + return this.settings.key; + } + get value() { + return this.settings.value; + } + partial() { + const { key, value } = this.settings; + return new _Dictionary({ + key, + value: optional3(value) + }); + } + toString() { + return `dictionary(${this.settings})`; + } + }; + var dictionary2 = ({ value, key }) => new Dictionary2({ + value, + key: key || /** @type {Schema.Reader} */ + string3() + }); + var Enum2 = class extends API2 { + /** + * @param {I} input + * @param {{type:string, variants:Set}} settings + * @returns {Schema.ReadResult} + */ + readWith(input, { variants, type: type3 }) { + if (variants.has(input)) { + return ( + /** @type {Schema.ReadResult} */ + { ok: input } + ); + } else { + return typeError2({ expect: type3, actual: input }); + } + } + toString() { + return this.settings.type; + } + }; + var createEnum2 = (variants) => new Enum2({ + type: variants.join("|"), + variants: new Set(variants) + }); + var Union2 = class extends API2 { + /** + * @param {I} input + * @param {U} variants + */ + readWith(input, variants) { + const causes = []; + for (const reader2 of variants) { + const result = reader2.read(input); + if (result.error) { + causes.push(result.error); + } else { + return ( + /** @type {Schema.ReadResult>} */ + result + ); + } + } + return { error: new UnionError2({ causes }) }; + } + get variants() { + return this.settings; + } + toString() { + return `union([${this.variants.map((type3) => type3.toString()).join(", ")}])`; + } + }; + var union2 = (variants) => new Union2(variants); + var or12 = (left, right) => union2([left, right]); + var Intersection2 = class extends API2 { + /** + * @param {I} input + * @param {U} schemas + * @returns {Schema.ReadResult>} + */ + readWith(input, schemas) { + const causes = []; + for (const schema9 of schemas) { + const result = schema9.read(input); + if (result.error) { + causes.push(result.error); + } + } + return causes.length > 0 ? { error: new IntersectionError2({ causes }) } : ( + /** @type {Schema.ReadResult>} */ + { + ok: input + } + ); + } + toString() { + return `intersection([${this.settings.map((type3) => type3.toString()).join(",")}])`; + } + }; + var intersection3 = (variants) => new Intersection2(variants); + var and8 = (left, right) => intersection3([left, right]); + var Boolean3 = class extends API2 { + /** + * @param {I} input + */ + readWith(input) { + switch (input) { + case true: + case false: + return { ok: ( + /** @type {boolean} */ + input + ) }; + default: + return typeError2({ + expect: "boolean", + actual: input + }); + } + } + toString() { + return `boolean()`; + } + }; + var anyBoolean2 = new Boolean3(); + var boolean2 = () => anyBoolean2; + var UnknownNumber2 = class extends API2 { + /** + * @param {number} n + */ + greaterThan(n9) { + return this.refine(greaterThan2(n9)); + } + /** + * @param {number} n + */ + lessThan(n9) { + return this.refine(lessThan2(n9)); + } + /** + * @template {O} U + * @param {Schema.Reader} schema + * @returns {Schema.NumberSchema} + */ + refine(schema9) { + return new RefinedNumber2({ base: this, schema: schema9 }); + } + }; + var AnyNumber2 = class extends UnknownNumber2 { + /** + * @param {I} input + * @returns {Schema.ReadResult} + */ + readWith(input) { + return typeof input === "number" ? { ok: input } : typeError2({ expect: "number", actual: input }); + } + toString() { + return `number()`; + } + }; + var anyNumber2 = new AnyNumber2(); + var number2 = () => anyNumber2; + var RefinedNumber2 = class extends UnknownNumber2 { + /** + * @param {I} input + * @param {{base:Schema.Reader, schema:Schema.Reader}} settings + * @returns {Schema.ReadResult} + */ + readWith(input, { base: base3, schema: schema9 }) { + const result = base3.read(input); + return result.error ? result : schema9.read(result.ok); + } + toString() { + return `${this.settings.base}.refine(${this.settings.schema})`; + } + }; + var LessThan2 = class extends API2 { + /** + * @param {T} input + * @param {number} number + * @returns {Schema.ReadResult} + */ + readWith(input, number3) { + if (input < number3) { + return { ok: input }; + } else { + return error5(`Expected ${input} < ${number3}`); + } + } + toString() { + return `lessThan(${this.settings})`; + } + }; + var lessThan2 = (n9) => new LessThan2(n9); + var GreaterThan2 = class extends API2 { + /** + * @param {T} input + * @param {number} number + * @returns {Schema.ReadResult} + */ + readWith(input, number3) { + if (input > number3) { + return { ok: input }; + } else { + return error5(`Expected ${input} > ${number3}`); + } + } + toString() { + return `greaterThan(${this.settings})`; + } + }; + var greaterThan2 = (n9) => new GreaterThan2(n9); + var Integer2 = { + /** + * @param {number} input + * @returns {Schema.ReadResult} + */ + read(input) { + return Number.isInteger(input) ? { ok: ( + /** @type {Schema.Integer} */ + input + ) } : typeError2({ + expect: "integer", + actual: input + }); + }, + toString() { + return `Integer`; + } + }; + var anyInteger2 = anyNumber2.refine(Integer2); + var integer2 = () => anyInteger2; + var Float2 = { + /** + * @param {number} number + * @returns {Schema.ReadResult} + */ + read(number3) { + return Number.isFinite(number3) ? { ok: ( + /** @type {Schema.Float} */ + number3 + ) } : typeError2({ + expect: "Float", + actual: number3 + }); + }, + toString() { + return "Float"; + } + }; + var anyFloat2 = anyNumber2.refine(Float2); + var float2 = () => anyFloat2; + var UnknownString2 = class extends API2 { + /** + * @template {O|unknown} U + * @param {Schema.Reader} schema + * @returns {Schema.StringSchema} + */ + refine(schema9) { + const other = ( + /** @type {Schema.Reader} */ + schema9 + ); + const rest = new RefinedString2({ + base: this, + schema: other + }); + return ( + /** @type {Schema.StringSchema} */ + rest + ); + } + /** + * @template {string} Prefix + * @param {Prefix} prefix + */ + startsWith(prefix) { + return this.refine(startsWith2(prefix)); + } + /** + * @template {string} Suffix + * @param {Suffix} suffix + */ + endsWith(suffix) { + return this.refine(endsWith2(suffix)); + } + toString() { + return `string()`; + } + }; + var RefinedString2 = class extends UnknownString2 { + /** + * @param {I} input + * @param {{base:Schema.Reader, schema:Schema.Reader}} settings + * @returns {Schema.ReadResult} + */ + readWith(input, { base: base3, schema: schema9 }) { + const result = base3.read(input); + return result.error ? result : ( + /** @type {Schema.ReadResult} */ + schema9.read(result.ok) + ); + } + toString() { + return `${this.settings.base}.refine(${this.settings.schema})`; + } + }; + var AnyString2 = class extends UnknownString2 { + /** + * @param {I} input + * @returns {Schema.ReadResult} + */ + readWith(input) { + return typeof input === "string" ? { ok: input } : typeError2({ expect: "string", actual: input }); + } + }; + var anyString2 = new AnyString2(); + var string3 = () => anyString2; + var StartsWith2 = class extends API2 { + /** + * @param {Body} input + * @param {Prefix} prefix + */ + readWith(input, prefix) { + const result = input.startsWith(prefix) ? ( + /** @type {Schema.ReadResult} */ + { + ok: input + } + ) : error5(`Expect string to start with "${prefix}" instead got "${input}"`); + return result; + } + get prefix() { + return this.settings; + } + toString() { + return `startsWith("${this.prefix}")`; + } + }; + var startsWith2 = (prefix) => new StartsWith2(prefix); + var EndsWith2 = class extends API2 { + /** + * @param {Body} input + * @param {Suffix} suffix + */ + readWith(input, suffix) { + return input.endsWith(suffix) ? ( + /** @type {Schema.ReadResult} */ + { + ok: input + } + ) : error5(`Expect string to end with "${suffix}" instead got "${input}"`); + } + get suffix() { + return this.settings; + } + toString() { + return `endsWith("${this.suffix}")`; + } + }; + var endsWith2 = (suffix) => new EndsWith2(suffix); + var Refine2 = class extends API2 { + /** + * @param {I} input + * @param {{ base: Schema.Reader, schema: Schema.Reader }} settings + */ + readWith(input, { base: base3, schema: schema9 }) { + const result = base3.read(input); + return result.error ? result : schema9.read(result.ok); + } + toString() { + return `${this.settings.base}.refine(${this.settings.schema})`; + } + }; + var refine2 = (base3, schema9) => new Refine2({ base: base3, schema: schema9 }); + var Literal2 = class extends API2 { + /** + * @param {I} input + * @param {T} expect + * @returns {Schema.ReadResult} + */ + readWith(input, expect) { + return input !== /** @type {unknown} */ + expect ? { error: new LiteralError2({ expect, actual: input }) } : { ok: expect }; + } + get value() { + return ( + /** @type {Exclude} */ + this.settings + ); + } + /** + * @template {Schema.NotUndefined} U + * @param {U} value + */ + default(value = ( + /** @type {U} */ + this.value + )) { + return super.default(value); + } + toString() { + return `literal(${displayTypeName2(this.value)})`; + } + }; + var literal2 = (value) => new Literal2(value); + var Struct2 = class _Struct extends API2 { + /** + * @param {I} input + * @param {U} shape + * @returns {Schema.ReadResult>} + */ + readWith(input, shape) { + if (typeof input != "object" || input === null || Array.isArray(input)) { + return typeError2({ + expect: "object", + actual: input + }); + } + const source = ( + /** @type {{[K in keyof U]: unknown}} */ + input + ); + const struct3 = ( + /** @type {{[K in keyof U]: Schema.Infer}} */ + {} + ); + const entries6 = ( + /** @type {{[K in keyof U]: [K & string, U[K]]}[keyof U][]} */ + Object.entries(shape) + ); + for (const [at2, reader2] of entries6) { + const result = reader2.read(source[at2]); + if (result.error) { + return memberError2({ at: at2, cause: result.error }); + } else if (result.ok !== void 0) { + struct3[at2] = /** @type {Schema.Infer} */ + result.ok; + } + } + return { ok: struct3 }; + } + /** + * @returns {Schema.MapRepresentation>> & Schema.StructSchema} + */ + partial() { + return new _Struct( + Object.fromEntries( + Object.entries(this.shape).map(([key, value]) => [key, optional3(value)]) + ) + ); + } + /** @type {U} */ + get shape() { + return this.settings; + } + toString() { + return [ + `struct({ `, + ...Object.entries(this.shape).map( + ([key, schema9]) => `${key}: ${schema9}, ` + ), + `})` + ].join(""); + } + /** + * @param {Schema.InferStructSource} data + */ + create(data) { + return this.from(data || {}); + } + /** + * @template {{[key:string]: Schema.Reader}} E + * @param {E} extension + * @returns {Schema.StructSchema} + */ + extend(extension) { + return new _Struct({ ...this.shape, ...extension }); + } + }; + var struct2 = (fields) => { + const shape = ( + /** @type {{[K in keyof U]: Schema.Reader}} */ + {} + ); + const entries6 = Object.entries(fields); + for (const [key, field] of entries6) { + switch (typeof field) { + case "number": + case "string": + case "boolean": + shape[key] = literal2(field); + break; + case "object": + shape[key] = field === null ? literal2(null) : field; + break; + default: + throw new Error( + `Invalid struct field "${key}", expected schema or literal, instead got ${typeof field}` + ); + } + } + return new Struct2( + /** @type {V} */ + shape + ); + }; + var Variant2 = class extends API2 { + /** + * @param {I} input + * @param {U} variants + * @returns {Schema.ReadResult>} + */ + readWith(input, variants) { + if (typeof input != "object" || input === null || Array.isArray(input)) { + return typeError2({ + expect: "object", + actual: input + }); + } + const keys2 = ( + /** @type {Array} */ + Object.keys(input) + ); + const [key] = keys2.length === 1 ? keys2 : []; + const reader2 = key ? variants[key] : void 0; + if (reader2) { + const result = reader2.read(input[key]); + return result.error ? memberError2({ at: key, cause: result.error }) : { ok: ( + /** @type {Schema.InferVariant} */ + { [key]: result.ok } + ) }; + } else if (variants._) { + const result = variants._.read(input); + return result.error ? result : { ok: ( + /** @type {Schema.InferVariant} */ + { _: result.ok } + ) }; + } else if (key) { + return error5( + `Expected an object with one of the these keys: ${Object.keys(variants).sort().join(", ")} instead got object with key ${key}` + ); + } else { + return error5( + "Expected an object with a single key instead got object with keys " + keys2.sort().join(", ") + ); + } + } + /** + * @template [E=never] + * @param {I} input + * @param {E} [fallback] + */ + match(input, fallback) { + const result = this.read(input); + if (result.error) { + if (fallback !== void 0) { + return [null, fallback]; + } else { + throw result.error; + } + } else { + const [key] = Object.keys(result.ok); + const value = result.ok[key]; + return ( + /** @type {any} */ + [key, value] + ); + } + } + /** + * @template {Schema.InferVariant} O + * @param {O} source + * @returns {O} + */ + create(source) { + return ( + /** @type {O} */ + this.from(source) + ); + } + }; + var variant2 = (variants) => new Variant2(variants); + var error5 = (message2) => ({ error: new SchemaError2(message2) }); + var SchemaError2 = class extends Failure2 { + get name() { + return "SchemaError"; + } + /* c8 ignore next 3 */ + describe() { + return this.name; + } + }; + var TypeError3 = class extends SchemaError2 { + /** + * @param {{expect:string, actual:unknown}} data + */ + constructor({ expect, actual }) { + super(); + this.expect = expect; + this.actual = actual; + } + get name() { + return "TypeError"; + } + describe() { + return `Expected value of type ${this.expect} instead got ${displayTypeName2( + this.actual + )}`; + } + }; + var typeError2 = (data) => ({ error: new TypeError3(data) }); + var displayTypeName2 = (value) => { + const type3 = typeof value; + switch (type3) { + case "boolean": + case "string": + return JSON.stringify(value); + case "bigint": + return `${value}n`; + case "number": + case "symbol": + case "undefined": + return String(value); + case "object": + return value === null ? "null" : Array.isArray(value) ? "array" : "object"; + default: + return type3; + } + }; + var LiteralError2 = class extends SchemaError2 { + /** + * @param {{ + * expect:string|number|boolean|null + * actual:unknown + * }} data + */ + constructor({ expect, actual }) { + super(); + this.expect = expect; + this.actual = actual; + } + get name() { + return "LiteralError"; + } + describe() { + return `Expected literal ${displayTypeName2( + this.expect + )} instead got ${displayTypeName2(this.actual)}`; + } + }; + var ElementError2 = class extends SchemaError2 { + /** + * @param {{at:number, cause:Schema.Error}} data + */ + constructor({ at: at2, cause }) { + super(); + this.at = at2; + this.cause = cause; + } + get name() { + return "ElementError"; + } + describe() { + return [ + `Array contains invalid element at ${this.at}:`, + li3(this.cause.message) + ].join("\n"); + } + }; + var FieldError2 = class extends SchemaError2 { + /** + * @param {{at:string, cause:Schema.Error}} data + */ + constructor({ at: at2, cause }) { + super(); + this.at = at2; + this.cause = cause; + } + get name() { + return "FieldError"; + } + describe() { + return [ + `Object contains invalid field "${this.at}":`, + li3(this.cause.message) + ].join("\n"); + } + }; + var memberError2 = ({ at: at2, cause }) => typeof at2 === "string" ? { error: new FieldError2({ at: at2, cause }) } : { error: new ElementError2({ at: at2, cause }) }; + var UnionError2 = class extends SchemaError2 { + /** + * @param {{causes: Schema.Error[]}} data + */ + constructor({ causes }) { + super(); + this.causes = causes; + } + get name() { + return "UnionError"; + } + describe() { + const { causes } = this; + return [ + `Value does not match any type of the union:`, + ...causes.map((cause) => li3(cause.message)) + ].join("\n"); + } + }; + var IntersectionError2 = class extends SchemaError2 { + /** + * @param {{causes: Schema.Error[]}} data + */ + constructor({ causes }) { + super(); + this.causes = causes; + } + get name() { + return "IntersectionError"; + } + describe() { + const { causes } = this; + return [ + `Value does not match following types of the intersection:`, + ...causes.map((cause) => li3(cause.message)) + ].join("\n"); + } + }; + var indent3 = (message2, indent5 = " ") => `${indent5}${message2.split("\n").join(` +${indent5}`)}`; + var li3 = (message2) => indent3(`- ${message2}`); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/schema/uri.js + var URISchema2 = class extends API2 { + /** + * @param {unknown} input + * @param {Partial} options + * @returns {Schema.ReadResult>} + */ + readWith(input, { protocol } = {}) { + if (typeof input !== "string" && !(input instanceof URL)) { + return error5( + `Expected URI but got ${input === null ? "null" : typeof input}` + ); + } + try { + const url = new URL(String(input)); + if (protocol != null && url.protocol !== protocol) { + return error5(`Expected ${protocol} URI instead got ${url.href}`); + } else { + return { ok: ( + /** @type {API.URI} */ + url.href + ) }; + } + } catch (_5) { + return error5(`Invalid URI`); + } + } + }; + var schema5 = new URISchema2({}); + var uri2 = () => schema5; + var read9 = (input) => schema5.read(input); + var match5 = (options) => new URISchema2(options); + var from16 = (input) => ( + /** @type {API.URI<`${Scheme}:`>} */ + schema5.from(input) + ); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/schema/link.js + var link_exports5 = {}; + __export(link_exports5, { + create: () => create3, + createLegacy: () => createLegacy, + isLink: () => isLink, + link: () => link7, + match: () => match6, + optional: () => optional4, + parse: () => parse, + read: () => read10, + schema: () => schema6 + }); + init_dirname(); + init_buffer2(); + init_process(); + var LinkSchema2 = class extends API2 { + /** + * + * @param {unknown} cid + * @param {Settings} settings + * @returns {Schema.ReadResult>} + */ + readWith(cid, { code: code15, multihash = {}, version: version3 }) { + if (cid == null) { + return error5(`Expected link but got ${cid} instead`); + } else { + if (!isLink(cid)) { + return error5(`Expected link to be a CID instead of ${cid}`); + } else { + if (code15 != null && cid.code !== code15) { + return error5( + `Expected link to be CID with 0x${code15.toString(16)} codec` + ); + } + if (multihash.code != null && cid.multihash.code !== multihash.code) + return error5( + `Expected link to be CID with 0x${multihash.code.toString( + 16 + )} hashing algorithm` + ); + if (version3 != null && cid.version !== version3) { + return error5( + `Expected link to be CID version ${version3} instead of ${cid.version}` + ); + } + const [expectDigest, actualDigest] = multihash.digest != null ? [ + base322.baseEncode(multihash.digest), + base322.baseEncode(cid.multihash.digest) + ] : ["", ""]; + if (expectDigest !== actualDigest) { + return error5( + `Expected link with "${expectDigest}" hash digest instead of "${actualDigest}"` + ); + } + return { + ok: ( + /** @type {API.Link} */ + cid + ) + }; + } + } + } + }; + var schema6 = new LinkSchema2({}); + var link7 = () => schema6; + var match6 = (options = {}) => new LinkSchema2(options); + var read10 = (input) => schema6.read(input); + var optional4 = () => schema6.optional(); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/schema/did.js + var did_exports3 = {}; + __export(did_exports3, { + did: () => did2, + from: () => from17, + match: () => match7, + read: () => read11 + }); + init_dirname(); + init_buffer2(); + init_process(); + var DIDSchema2 = class extends API2 { + /** + * @param {string} source + * @param {void|Method} method + */ + readWith(source, method) { + const prefix = method ? `did:${method}:` : `did:`; + if (!source.startsWith(prefix)) { + return error5(`Expected a ${prefix} but got "${source}" instead`); + } else { + return { ok: ( + /** @type {API.DID} */ + source + ) }; + } + } + }; + var schema7 = string3().refine(new DIDSchema2()); + var did2 = () => schema7; + var read11 = (input) => schema7.read(input); + var match7 = (options = {}) => ( + /** @type {Schema.Schema & API.URI<"did:">>} */ + string3().refine(new DIDSchema2(options.method)) + ); + var from17 = (input) => match7({}).from(input); + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/schema/text.js + var text_exports2 = {}; + __export(text_exports2, { + match: () => match8, + read: () => read12, + text: () => text2 + }); + init_dirname(); + init_buffer2(); + init_process(); + var schema8 = string3(); + var match8 = (options) => options ? schema8.refine(new Match3(options.pattern)) : schema8; + var text2 = match8; + var read12 = (input) => schema8.read(input); + var Match3 = class extends API2 { + /** + * @param {string} source + * @param {RegExp} pattern + */ + readWith(source, pattern) { + if (!pattern.test(source)) { + return error5( + `Expected to match ${pattern} but got "${source}" instead` + ); + } else { + return { ok: source }; + } + } + }; + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/message.js + var MessageSchema2 = variant2({ + "ucanto/message@7.0.0": struct2({ + execute: match6().array().optional(), + delegate: dictionary2({ + key: string3(), + value: ( + /** @type {API.Reader>} */ + match6() + ) + }).array().optional() + }) + }); + var build2 = ({ invocations, receipts }) => new MessageBuilder2({ invocations, receipts }).buildIPLDView(); + var view9 = ({ root: root3, store: store4 }, fallback) => { + const block = get13(root3, store4, null); + if (block === null) { + return fallback !== void 0 ? fallback : notFound2(root3); + } + const data = cbor_exports3.decode(block.bytes); + const [branch, value] = MessageSchema2.match(data, fallback); + switch (branch) { + case "ucanto/message@7.0.0": + return new Message2({ root: { ...block, data }, store: store4 }); + default: + return value; + } + }; + var MessageBuilder2 = class { + /** + * @param {object} source + * @param {I} [source.invocations] + * @param {R} [source.receipts] + */ + constructor({ invocations, receipts }) { + this.invocations = invocations; + this.receipts = receipts; + } + /** + * + * @param {API.BuildOptions} [options] + * @returns {Promise, Out: R }>>} + */ + async buildIPLDView(options) { + const store4 = /* @__PURE__ */ new Map(); + const { invocations, ...executeField } = await writeInvocations2( + this.invocations || [], + store4 + ); + const { receipts, ...receiptsField } = await writeReceipts2( + this.receipts || [], + store4 + ); + const root3 = await writeInto2( + /** @type {API.AgentMessageModel<{ In: API.InferInvocations, Out: R }>} */ + { + "ucanto/message@7.0.0": { + ...executeField, + ...receiptsField + } + }, + store4, + options + ); + return new Message2({ root: root3, store: store4 }, { receipts, invocations }); + } + }; + var writeInvocations2 = async (run, store4) => { + const invocations = []; + const execute3 = []; + for (const invocation of run) { + const view10 = await invocation.buildIPLDView(); + execute3.push(view10.link()); + invocations.push(view10); + for (const block of view10.iterateIPLDBlocks()) { + store4.set(`${block.cid}`, block); + } + } + return { invocations, ...execute3.length > 0 ? { execute: execute3 } : {} }; + }; + var writeReceipts2 = async (source, store4) => { + if (source.length === 0) { + return {}; + } + const receipts = /* @__PURE__ */ new Map(); + const report = {}; + for (const [n9, receipt] of source.entries()) { + const view10 = await receipt.buildIPLDView(); + for (const block of view10.iterateIPLDBlocks()) { + store4.set(`${block.cid}`, block); + } + const key = `${view10.ran.link()}`; + if (!(key in report)) { + report[key] = view10.root.cid; + receipts.set(key, view10); + } else { + receipts.set(`${key}@${n9}`, view10); + } + } + return { receipts, report }; + }; + var Message2 = class { + /** + * @param {object} source + * @param {Required>>} source.root + * @param {DAG.BlockStore} source.store + * @param {object} build + * @param {API.Invocation[]} [build.invocations] + * @param {Map} [build.receipts] + */ + constructor({ root: root3, store: store4 }, { invocations, receipts } = {}) { + this.root = root3; + this.store = store4; + this._invocations = invocations; + this._receipts = receipts; + } + *iterateIPLDBlocks() { + for (const invocation of this.invocations) { + yield* invocation.iterateIPLDBlocks(); + } + for (const receipt of this.receipts.values()) { + yield* receipt.iterateIPLDBlocks(); + } + yield this.root; + } + /** + * @template [E=never] + * @param {API.Link} link + * @param {E} [fallback] + * @returns {API.Receipt|E} + */ + get(link10, fallback) { + const receipts = this.root.data["ucanto/message@7.0.0"].report || {}; + const receipt = receipts[`${link10}`]; + if (receipt) { + return view8({ root: receipt, blocks: this.store }); + } else { + return fallback !== void 0 ? fallback : panic3(`Message does not include receipt for ${link10}`); + } + } + get invocationLinks() { + return this.root.data["ucanto/message@7.0.0"].execute || []; + } + get invocations() { + let invocations = this._invocations; + if (!invocations) { + invocations = this.invocationLinks.map((link10) => { + return invocation_exports2.view({ root: link10, blocks: this.store }); + }); + } + return invocations; + } + get receipts() { + let receipts = this._receipts; + if (!receipts) { + receipts = /* @__PURE__ */ new Map(); + const report = this.root.data["ucanto/message@7.0.0"].report || {}; + for (const [key, link10] of Object.entries(report)) { + const receipt = view8({ root: link10, blocks: this.store }); + receipts.set(`${receipt.ran.link()}`, receipt); + } + } + return receipts; + } + }; + + // ../../node_modules/.pnpm/@ucanto+core@7.1.1/node_modules/@ucanto/core/src/car.js + var car_exports4 = {}; + __export(car_exports4, { + code: () => code11, + contentType: () => contentType10, + createWriter: () => createWriter4, + decode: () => decode39, + encode: () => encode33, + link: () => link8, + name: () => name11, + write: () => write10 + }); + init_dirname(); + init_buffer2(); + init_process(); + var contentType10 = "application/vnd.ipld.car"; + var name11 = "CAR"; + var code11 = 514; + var Writer2 = class { + /** + * @param {API.IPLDBlock[]} blocks + * @param {number} byteLength + */ + constructor(blocks = [], byteLength = 0) { + this.written = /* @__PURE__ */ new Set(); + this.blocks = blocks; + this.byteLength = byteLength; + } + /** + * @param {API.IPLDBlock[]} blocks + */ + write(...blocks) { + for (const block of blocks) { + const id = block.cid.toString(base322); + if (!this.written.has(id)) { + this.blocks.push(block); + this.byteLength += blockLength( + /** @type {any} */ + block + ); + this.written.add(id); + } + } + return this; + } + /** + * @param {API.IPLDBlock[]} rootBlocks + */ + flush(...rootBlocks) { + const roots = []; + for (const block of rootBlocks.reverse()) { + const id = block.cid.toString(base322); + if (!this.written.has(id)) { + this.blocks.unshift(block); + this.byteLength += blockLength({ + cid: ( + /** @type {CarBufferWriter.CID} */ + block.cid + ), + bytes: block.bytes + }); + this.written.add(id); + } + roots.unshift( + /** @type {CarBufferWriter.CID} */ + block.cid + ); + } + this.byteLength += headerLength({ roots }); + const buffer4 = new ArrayBuffer(this.byteLength); + const writer2 = createWriter(buffer4, { roots }); + for ( + const block of + /** @type {CarBufferWriter.Block[]} */ + this.blocks + ) { + writer2.write(block); + } + return writer2.close(); + } + }; + var createWriter4 = () => new Writer2(); + var encode33 = ({ roots = [], blocks }) => { + const writer2 = new Writer2(); + if (blocks) { + writer2.write(...blocks.values()); + } + return writer2.flush(...roots); + }; + var decode39 = (bytes2) => { + const reader2 = CarBufferReader.fromBytes(bytes2); + const roots = []; + const blocks = /* @__PURE__ */ new Map(); + for (const root3 of reader2.getRoots()) { + const block = ( + /** @type {API.IPLDBlock} */ + reader2.get(root3) + ); + if (block) { + roots.push(block); + } + } + for (const block of reader2.blocks()) { + blocks.set(block.cid.toString(), block); + } + return { roots, blocks }; + }; + var link8 = async (bytes2, { hasher = sha256 } = {}) => { + return ( + /** @type {API.Link} */ + create3(code11, await hasher.digest(bytes2)) + ); + }; + var write10 = async (data, options) => { + const bytes2 = encode33(data); + const cid = await link8(bytes2, options); + return { bytes: bytes2, cid }; + }; + + // ../../node_modules/.pnpm/@ucanto+client@7.0.1/node_modules/@ucanto/client/src/connection.js + var connect2 = (options) => new Connection2(options); + var Connection2 = class { + /** + * @param {API.ConnectionOptions} options + */ + constructor(options) { + this.id = options.id; + this.options = options; + this.codec = options.codec; + this.channel = options.channel; + this.hasher = options.hasher || sha256; + } + /** + * @template {API.Capability} C + * @template {API.Tuple>} I + * @param {I} invocations + * @returns {Promise>} + */ + async execute(...invocations) { + return execute2(invocations, this); + } + }; + var execute2 = async (invocations, connection3) => { + const input = await message_exports2.build({ invocations }); + const request = await connection3.codec.encode(input, connection3); + const response = await connection3.channel.request(request); + try { + const output = await connection3.codec.decode(response); + const receipts = input.invocationLinks.map((link10) => output.get(link10)); + return ( + /** @type {API.InferReceipts} */ + receipts + ); + } catch (error7) { + const { message: message2, ...cause } = ( + /** @type {Error} */ + error7 + ); + const receipts = []; + for await (const ran of input.invocationLinks) { + const receipt = await receipt_exports2.issue({ + ran, + result: { error: { ...cause, message: message2 } }, + // @ts-expect-error - we can not really sign a receipt without having + // an access to a signer which client does not have. In the future + // we will change client API requiring a signer to be passed in but + // for now we just use a dummy signer. + issuer: { + did() { + return connection3.id.did(); + }, + sign() { + return signature_exports.createNonStandard("", new Uint8Array()); + } + } + }); + receipts.push(receipt); + } + return ( + /** @type {API.InferReceipts} */ + receipts + ); + } + }; + + // ../../node_modules/.pnpm/@ucanto+client@7.0.1/node_modules/@ucanto/client/src/lib.js + var delegate6 = delegation_exports2.delegate; + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/car.js + var car_exports5 = {}; + __export(car_exports5, { + codec: () => car_exports4, + contentType: () => contentType13, + inbound: () => inbound5, + outbound: () => outbound4, + request: () => request_exports3, + response: () => response_exports3 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/car/request.js + var request_exports3 = {}; + __export(request_exports3, { + codec: () => car_exports4, + contentType: () => contentType11, + decode: () => decode40, + encode: () => encode34 + }); + init_dirname(); + init_buffer2(); + init_process(); + var contentType11 = car_exports4.contentType; + var HEADERS4 = Object.freeze({ + "content-type": contentType11, + // We will signal that we want to receive a CAR file in the response + accept: contentType11 + }); + var encode34 = (message2, options) => { + const blocks = /* @__PURE__ */ new Map(); + for (const block of message2.iterateIPLDBlocks()) { + blocks.set(`${block.cid}`, block); + } + const body = car_exports4.encode({ + roots: [message2.root], + blocks + }); + return { + headers: options?.headers || HEADERS4, + body + }; + }; + var decode40 = async ({ headers, body }) => { + const { roots, blocks } = car_exports4.decode( + /** @type {Uint8Array} */ + body + ); + const message2 = message_exports2.view({ root: roots[0].cid, store: blocks }); + return ( + /** @type {Message} */ + message2 + ); + }; + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/car/response.js + var response_exports3 = {}; + __export(response_exports3, { + codec: () => car_exports4, + contentType: () => contentType12, + decode: () => decode41, + encode: () => encode35 + }); + init_dirname(); + init_buffer2(); + init_process(); + var contentType12 = car_exports4.contentType; + var HEADERS5 = Object.freeze({ + "content-type": contentType12 + }); + var encode35 = (message2, options) => { + const blocks = /* @__PURE__ */ new Map(); + for (const block of message2.iterateIPLDBlocks()) { + blocks.set(`${block.cid}`, block); + } + const body = car_exports4.encode({ + roots: [message2.root], + blocks + }); + return { + headers: HEADERS5, + body + }; + }; + var decode41 = async ({ headers, body }) => { + const { roots, blocks } = car_exports4.decode( + /** @type {Uint8Array} */ + body + ); + const message2 = message_exports2.view({ root: roots[0].cid, store: blocks }); + return ( + /** @type {Message} */ + message2 + ); + }; + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/codec.js + init_dirname(); + init_buffer2(); + init_process(); + var inbound4 = (source) => new Inbound2(source); + var Inbound2 = class { + /** + * @param {API.HTTPRequest} request + * @returns {API.Result} transport + */ + accept({ headers }) { + const contentType17 = headers["content-type"] || headers["Content-Type"]; + const decoder4 = this.decoders[contentType17]; + if (!decoder4) { + return { + error: { + status: 415, + message: `The server cannot process the request because the payload format is not supported. Please check the content-type header and try again with a supported media type.`, + headers: { + accept: Object.keys(this.decoders).join(", ") + } + } + }; + } + const accept = parseAcceptHeader2(headers.accept || headers.Accept || "*/*"); + for (const { category, type: type3 } of accept) { + for (const encoder4 of this.encoders) { + const select3 = (category === "*" || category === encoder4.category) && (type3 === "*" || type3 === encoder4.type); + if (select3) { + return { ok: { ...encoder4, decoder: decoder4 } }; + } + } + } + return { + error: { + status: 406, + message: `The requested resource cannot be served in the requested content type. Please specify a supported content type using the Accept header.`, + headers: { + accept: formatAcceptHeader2(Object.values(this.encoders)) + } + } + }; + } + /** + * @param {object} source + * @param {Record} source.decoders + * @param {Record} source.encoders + */ + constructor({ decoders = {}, encoders = {} }) { + this.decoders = decoders; + if (Object.keys(decoders).length === 0) { + throw new Error("At least one decoder MUST be provided"); + } + this.encoders = Object.entries(encoders).map(([mediaType, encoder4]) => { + return { ...parseMediaType2(mediaType), encoder: encoder4 }; + }).sort((a8, b6) => b6.preference - a8.preference); + if (this.encoders.length === 0) { + throw new Error("At least one encoder MUST be provided"); + } + } + }; + var outbound3 = (source) => new Outbound2(source); + var Outbound2 = class { + /** + * @param {object} source + * @param {Record} source.encoders + * @param {Record} source.decoders + */ + constructor({ decoders = {}, encoders = {} }) { + this.decoders = decoders; + if (Object.keys(decoders).length === 0) { + throw new Error("At least one decoder MUST be provided"); + } + this.encoders = Object.entries(encoders).map(([mediaType, encoder4]) => { + return { ...parseMediaType2(mediaType), encoder: encoder4 }; + }).sort((a8, b6) => b6.preference - a8.preference); + this.acceptType = formatAcceptHeader2(this.encoders); + if (this.encoders.length === 0) { + throw new Error("At least one encoder MUST be provided"); + } + this.encoder = this.encoders[0].encoder; + } + /** + * @template {API.AgentMessage} Message + * @param {Message} message + */ + encode(message2) { + return this.encoder.encode(message2, { + accept: this.acceptType + }); + } + /** + * @template {API.AgentMessage} Message + * @param {API.HTTPResponse} response + * @returns {API.Await} + */ + decode(response) { + const { headers } = response; + const contentType17 = headers["content-type"] || headers["Content-Type"]; + const decoder4 = this.decoders[contentType17] || this.decoders["*/*"]; + switch (response.status) { + case 415: + case 406: + throw Object.assign( + new RangeError(new TextDecoder().decode(response.body)), + { + status: response.status, + headers: response.headers + } + ); + } + if (!decoder4) { + throw Object.assign( + TypeError( + `Can not decode response with content-type '${contentType17}' because no matching transport decoder is configured.` + ), + { + error: true + } + ); + } + return decoder4.decode(response); + } + }; + var parseMediaType2 = (source) => { + const [mediaType = "*/*", mediaRange = ""] = source.trim().split(";"); + const [category = "*", type3 = "*"] = mediaType.split("/"); + const params = new URLSearchParams(mediaRange); + const preference = parseFloat(params.get("q") || "0"); + return { + category, + type: type3, + /* c8 ignore next */ + preference: isNaN(preference) ? 0 : preference + }; + }; + var formatMediaType2 = ({ category, type: type3, preference }) => ( + /** @type {MediaType} */ + `${category}/${type3}${preference ? `;q=${preference}` : ""}` + ); + var parseAcceptHeader2 = (source) => source.split(",").map(parseMediaType2).sort((a8, b6) => b6.preference - a8.preference); + var formatAcceptHeader2 = (source) => source.map(formatMediaType2).join(", "); + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/car.js + var contentType13 = car_exports4.contentType; + var inbound5 = inbound4({ + decoders: { + [contentType11]: request_exports3 + }, + encoders: { + [contentType12]: response_exports3 + } + }); + var outbound4 = outbound3({ + encoders: { + [contentType11]: request_exports3 + }, + decoders: { + [contentType12]: response_exports3 + } + }); + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/http.js + var http_exports2 = {}; + __export(http_exports2, { + open: () => open5 + }); + init_dirname(); + init_buffer2(); + init_process(); + var open5 = ({ url, method = "POST", fetch: fetch4 }) => { + if (!fetch4) { + if (typeof globalThis.fetch !== "undefined") { + fetch4 = globalThis.fetch.bind(globalThis); + } else { + throw new TypeError( + `ucanto HTTP transport got undefined \`fetch\`. Try passing in a \`fetch\` implementation explicitly.` + ); + } + } + return new Channel2({ url, method, fetch: fetch4 }); + }; + var Channel2 = class { + /** + * @param {object} options + * @param {URL} options.url + * @param {Fetcher} options.fetch + * @param {string} [options.method] + */ + constructor({ url, fetch: fetch4, method }) { + this.fetch = fetch4; + this.method = method; + this.url = url; + } + /** + * @template {API.Tuple>} I + * @param {API.HTTPRequest, Out: API.Tuple }>>} request + * @returns {Promise, In: API.Tuple }>>>} + */ + async request({ headers, body }) { + const response = await this.fetch(this.url.href, { + headers, + body, + method: this.method + }); + const buffer4 = response.ok ? await response.arrayBuffer() : HTTPError2.throw("HTTP Request failed", response); + return { + headers: response.headers.entries ? Object.fromEntries(response.headers.entries()) : ( + /* c8 ignore next */ + {} + ), + body: new Uint8Array(buffer4) + }; + } + }; + var HTTPError2 = class extends Error { + /** + * @param {string} message + * @param {Options} options + * @returns {never} + */ + static throw(message2, options) { + throw new this(message2, options); + } + /** + * @param {string} message + * @param {Options} options + */ + constructor(message2, { url, status = 500, statusText = "Server error" }) { + super(message2); + this.name = "HTTPError"; + this.url = url; + this.status = status; + this.statusText = statusText; + } + }; + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/utf8.js + init_dirname(); + init_buffer2(); + init_process(); + var encoder3 = new TextEncoder(); + var decoder3 = new TextDecoder(); + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/legacy.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/legacy/response.js + var response_exports4 = {}; + __export(response_exports4, { + contentType: () => contentType14, + encode: () => encode36 + }); + init_dirname(); + init_buffer2(); + init_process(); + var contentType14 = "application/cbor"; + var HEADERS6 = Object.freeze({ + "content-type": contentType14 + }); + var encode36 = (message2, options) => { + const legacyResults = []; + for (const receipt of message2.receipts.values()) { + const result = receipt.out; + if (result.ok) { + legacyResults.push(result.ok); + } else { + legacyResults.push({ + ...result.error, + error: true + }); + } + } + const body = encode32(legacyResults); + return ( + /** @type {API.HTTPResponse} */ + { + headers: HEADERS6, + body + } + ); + }; + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/legacy/request.js + var request_exports4 = {}; + __export(request_exports4, { + contentType: () => contentType15, + decode: () => decode42 + }); + init_dirname(); + init_buffer2(); + init_process(); + var contentType15 = "application/car"; + var decode42 = async ({ body }) => { + const { roots, blocks } = decode39( + /** @type {Uint8Array} */ + body + ); + const run = []; + for (const { cid } of roots) { + const invocation = invocation_exports2.view({ + root: ( + /** @type {API.Link} */ + cid + ), + blocks + }); + run.push(invocation); + } + const message2 = await message_exports2.build({ + invocations: ( + /** @type {API.Tuple} */ + run + ) + }); + return ( + /** @type {Message} */ + message2 + ); + }; + + // ../../node_modules/.pnpm/@ucanto+transport@7.0.3/node_modules/@ucanto/transport/src/legacy.js + var { contentType: contentType16 } = request_exports4; + var inbound6 = inbound4({ + decoders: { + [contentType16]: request_exports4, + [contentType13]: request_exports3 + }, + encoders: { + // Here we configure encoders such that if accept header is `*/*` (which is + // the default if omitted) we will encode the response in CBOR. If + // `application/vnd.ipld.car` is set we will encode the response in current + // format. + // Here we exploit the fact that legacy clients do not send an accept header + // and therefore will get response in legacy format. New clients on the other + // hand will send `application/vnd.ipld.car` and consequently get response + // in current format. + "*/*;q=0.1": response_exports4, + [contentType13]: response_exports3 + } + }); + + // ../../node_modules/.pnpm/@web3-storage+clock@0.3.0/node_modules/@web3-storage/clock/src/capabilities.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+validator@7.0.0/node_modules/@ucanto/validator/src/lib.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+validator@7.0.0/node_modules/@ucanto/validator/src/capability.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@ucanto+validator@7.0.0/node_modules/@ucanto/validator/src/util.js + init_dirname(); + init_buffer2(); + init_process(); + var the2 = (value) => value; + var entries3 = (object) => ( + /** @type {any} */ + Object.entries(object) + ); + var combine2 = ([first, ...rest]) => { + const results = first.map((value) => [value]); + for (const values2 of rest) { + const tuples = results.splice(0); + for (const value of values2) { + for (const tuple3 of tuples) { + results.push([...tuple3, value]); + } + } + } + return results; + }; + var intersection4 = (left, right) => { + const [result, other] = left.length < right.length ? [new Set(left), new Set(right)] : [new Set(right), new Set(left)]; + for (const item of result) { + if (!other.has(item)) { + result.delete(item); + } + } + return [...result]; + }; + + // ../../node_modules/.pnpm/@ucanto+validator@7.0.0/node_modules/@ucanto/validator/src/error.js + init_dirname(); + init_buffer2(); + init_process(); + var EscalatedCapability2 = class extends Failure2 { + /** + * @param {API.ParsedCapability} claimed + * @param {object} delegated + * @param {API.Failure} cause + */ + constructor(claimed, delegated, cause) { + super(); + this.claimed = claimed; + this.delegated = delegated; + this.cause = cause; + this.name = the2("EscalatedCapability"); + } + describe() { + return `Constraint violation: ${this.cause.message}`; + } + }; + var DelegationError2 = class extends Failure2 { + /** + * @param {(API.InvalidCapability | API.EscalatedDelegation | API.DelegationError)[]} causes + * @param {object} context + */ + constructor(causes, context2) { + super(); + this.name = the2("InvalidClaim"); + this.causes = causes; + this.context = context2; + } + describe() { + return [ + `Can not derive ${this.context} from delegated capabilities:`, + ...this.causes.map((cause) => li4(cause.message)) + ].join("\n"); + } + /** + * @type {API.InvalidCapability | API.EscalatedDelegation | API.DelegationError} + */ + get cause() { + if (this.causes.length !== 1) { + return this; + } else { + const [cause] = this.causes; + const value = cause.name === "InvalidClaim" ? cause.cause : cause; + Object.defineProperties(this, { cause: { value } }); + return value; + } + } + }; + var MalformedCapability2 = class extends Failure2 { + /** + * @param {API.Capability} capability + * @param {API.Failure} cause + */ + constructor(capability3, cause) { + super(); + this.name = the2("MalformedCapability"); + this.capability = capability3; + this.cause = cause; + } + describe() { + return [ + `Encountered malformed '${this.capability.can}' capability: ${format15( + this.capability + )}`, + li4(this.cause.message) + ].join("\n"); + } + }; + var UnknownCapability2 = class extends Failure2 { + /** + * @param {API.Capability} capability + */ + constructor(capability3) { + super(); + this.name = the2("UnknownCapability"); + this.capability = capability3; + } + /* c8 ignore next 3 */ + describe() { + return `Encountered unknown capability: ${format15(this.capability)}`; + } + }; + var format15 = (capability3, space3) => JSON.stringify( + capability3, + (_key, value) => { + if (isLink(value)) { + return value.toString(); + } else { + return value; + } + }, + space3 + ); + var indent4 = (message2, indent5 = " ") => `${indent5}${message2.split("\n").join(` +${indent5}`)}`; + var li4 = (message2) => indent4(`- ${message2}`); + + // ../../node_modules/.pnpm/@ucanto+validator@7.0.0/node_modules/@ucanto/validator/src/capability.js + var capability2 = ({ + derives = defaultDerives2, + nb = defaultNBSchema2, + ...etc + }) => new Capability2({ derives, nb, ...etc }); + var defaultNBSchema2 = ( + /** @type {Schema.MapRepresentation} */ + schema_exports5.struct({}) + ); + var or13 = (left, right) => new Or2(left, right); + var and9 = (...selectors) => new And2(selectors); + var derive3 = ({ from: from18, to, derives }) => new Derive2(from18, to, derives); + var View3 = class { + /** + * @param {API.Source} source + * @returns {API.MatchResult} + */ + /* c8 ignore next 3 */ + match(source) { + return { error: new UnknownCapability2(source.capability) }; + } + /** + * @param {API.Source[]} capabilities + * @returns {API.Select} + */ + select(capabilities) { + return select2(this, capabilities); + } + /** + * @template {API.ParsedCapability} U + * @param {object} source + * @param {API.TheCapabilityParser>} source.to + * @param {API.Derives>} source.derives + * @returns {API.TheCapabilityParser>} + */ + derive({ derives, to }) { + return derive3({ derives, to, from: this }); + } + }; + var Unit2 = class extends View3 { + /** + * @template {API.Match} W + * @param {API.MatchSelector} other + * @returns {API.CapabilityParser} + */ + or(other) { + return or13(this, other); + } + /** + * @template {API.Match} W + * @param {API.CapabilityParser} other + * @returns {API.CapabilitiesParser<[M, W]>} + */ + and(other) { + return and9( + /** @type {API.CapabilityParser} */ + this, + other + ); + } + }; + var Capability2 = class extends Unit2 { + /** + * @param {Required>} descriptor + */ + constructor(descriptor) { + super(); + this.descriptor = descriptor; + this.schema = schema_exports5.struct({ + can: schema_exports5.literal(descriptor.can), + with: descriptor.with, + nb: descriptor.nb + }); + } + /** + * @param {API.InferCreateOptions} options + */ + create(options) { + const { descriptor, can } = this; + const decoders = descriptor.nb; + const data = ( + /** @type {C} */ + options.nb || {} + ); + const resource = descriptor.with.read(options.with); + if (resource.error) { + throw Object.assign( + new Error(`Invalid 'with' - ${resource.error.message}`), + { + cause: resource + } + ); + } + const nb = descriptor.nb.read(data); + if (nb.error) { + throw Object.assign(new Error(`Invalid 'nb' - ${nb.error.message}`), { + cause: nb + }); + } + return createCapability2({ can, with: resource.ok, nb: nb.ok }); + } + /** + * @param {API.InferInvokeOptions} options + */ + invoke({ with: with_, nb, ...options }) { + return invoke2({ + ...options, + capability: this.create( + /** @type {API.InferCreateOptions} */ + { with: with_, nb } + ) + }); + } + /** + * @param {API.InferDelegationOptions} options + * @returns {Promise>]>>} + */ + async delegate({ nb: input = {}, with: with_, ...options }) { + const { descriptor, can } = this; + const readers = descriptor.nb; + const resource = descriptor.with.read(with_); + if (resource.error) { + throw Object.assign( + new Error(`Invalid 'with' - ${resource.error.message}`), + { + cause: resource + } + ); + } + const nb = descriptor.nb.partial().read(input); + if (nb.error) { + throw Object.assign(new Error(`Invalid 'nb' - ${nb.error.message}`), { + cause: nb + }); + } + return delegate5({ + capabilities: [createCapability2({ can, with: resource.ok, nb: nb.ok })], + ...options + }); + } + get can() { + return this.descriptor.can; + } + /** + * @param {API.Source} source + * @returns {API.MatchResult>>} + */ + match(source) { + const result = parseCapability2(this.descriptor, source); + return result.error ? result : { ok: new Match4(source, result.ok, this.descriptor) }; + } + toString() { + return JSON.stringify({ can: this.descriptor.can }); + } + }; + var createCapability2 = ({ can, with: with_, nb }) => ( + /** @type {API.InferCapability} */ + { + can, + with: with_, + ...isEmpty2(nb) ? {} : { nb } + } + ); + var isEmpty2 = (object) => { + for (const _5 in object) { + return false; + } + return true; + }; + var Or2 = class extends Unit2 { + /** + * @param {API.Matcher} left + * @param {API.Matcher} right + */ + constructor(left, right) { + super(); + this.left = left; + this.right = right; + } + /** + * @param {API.Source} capability + * @return {API.MatchResult} + */ + match(capability3) { + const left = this.left.match(capability3); + if (left.error) { + const right = this.right.match(capability3); + if (right.error) { + return right.error.name === "MalformedCapability" ? ( + // + right + ) : ( + // + left + ); + } else { + return right; + } + } else { + return left; + } + } + toString() { + return `${this.left.toString()}|${this.right.toString()}`; + } + }; + var And2 = class _And extends View3 { + /** + * @param {Selectors} selectors + */ + constructor(selectors) { + super(); + this.selectors = selectors; + } + /** + * @param {API.Source} capability + * @returns {API.MatchResult>>} + */ + match(capability3) { + const group2 = []; + for (const selector of this.selectors) { + const result = selector.match(capability3); + if (result.error) { + return result; + } else { + group2.push(result.ok); + } + } + return { + ok: new AndMatch2( + /** @type {API.InferMembers} */ + group2 + ) + }; + } + /** + * @param {API.Source[]} capabilities + */ + select(capabilities) { + return selectGroup2(this, capabilities); + } + /** + * @template E + * @template {API.Match} X + * @param {API.MatchSelector>} other + * @returns {API.CapabilitiesParser<[...API.InferMembers, API.Match]>} + */ + and(other) { + return new _And([...this.selectors, other]); + } + toString() { + return `[${this.selectors.map(String).join(", ")}]`; + } + }; + var Derive2 = class extends Unit2 { + /** + * @param {API.MatchSelector} from + * @param {API.TheCapabilityParser>} to + * @param {API.Derives>} derives + */ + constructor(from18, to, derives) { + super(); + this.from = from18; + this.to = to; + this.derives = derives; + } + /** + * @type {typeof this.to['create']} + */ + create(options) { + return this.to.create(options); + } + /** + * @type {typeof this.to['invoke']} + */ + invoke(options) { + return this.to.invoke(options); + } + /** + * @type {typeof this.to['delegate']} + */ + delegate(options) { + return this.to.delegate(options); + } + get can() { + return this.to.can; + } + /** + * @param {API.Source} capability + * @returns {API.MatchResult>} + */ + match(capability3) { + const match10 = this.to.match(capability3); + if (match10.error) { + return match10; + } else { + return { ok: new DerivedMatch2(match10.ok, this.from, this.derives) }; + } + } + toString() { + return this.to.toString(); + } + }; + var Match4 = class _Match { + /** + * @param {API.Source} source + * @param {API.ParsedCapability} value + * @param {Required>} descriptor + */ + constructor(source, value, descriptor) { + this.source = [source]; + this.value = value; + this.descriptor = descriptor; + } + get can() { + return this.value.can; + } + get proofs() { + const proofs3 = [this.source[0].delegation]; + Object.defineProperties(this, { + proofs: { value: proofs3 } + }); + return proofs3; + } + /** + * @param {API.CanIssue} context + * @returns {API.DirectMatch>|null} + */ + prune(context2) { + if (context2.canIssue(this.value, this.source[0].delegation.issuer.did())) { + return null; + } else { + return this; + } + } + /** + * @param {API.Source[]} capabilities + * @returns {API.Select>>} + */ + select(capabilities) { + const unknown3 = []; + const errors = []; + const matches = []; + for (const capability3 of capabilities) { + const result = resolveCapability2(this.descriptor, this.value, capability3); + if (result.ok) { + const claim4 = this.descriptor.derives(this.value, result.ok); + if (claim4.error) { + errors.push( + new DelegationError2( + [new EscalatedCapability2(this.value, result.ok, claim4.error)], + this + ) + ); + } else { + matches.push(new _Match(capability3, result.ok, this.descriptor)); + } + } else { + switch (result.error.name) { + case "UnknownCapability": + unknown3.push(result.error.capability); + break; + case "MalformedCapability": + default: + errors.push(new DelegationError2([result.error], this)); + } + } + } + return { matches, unknown: unknown3, errors }; + } + toString() { + const { nb } = this.value; + return JSON.stringify({ + can: this.descriptor.can, + with: this.value.with, + nb: nb && Object.keys(nb).length > 0 ? nb : void 0 + }); + } + }; + var DerivedMatch2 = class _DerivedMatch { + /** + * @param {API.DirectMatch} selected + * @param {API.MatchSelector} from + * @param {API.Derives>} derives + */ + constructor(selected, from18, derives) { + this.selected = selected; + this.from = from18; + this.derives = derives; + } + get can() { + return this.value.can; + } + get source() { + return this.selected.source; + } + get proofs() { + const proofs3 = []; + for (const { delegation } of this.selected.source) { + proofs3.push(delegation); + } + Object.defineProperties(this, { proofs: { value: proofs3 } }); + return proofs3; + } + get value() { + return this.selected.value; + } + /** + * @param {API.CanIssue} context + */ + prune(context2) { + const selected = ( + /** @type {API.DirectMatch|null} */ + this.selected.prune(context2) + ); + return selected ? new _DerivedMatch(selected, this.from, this.derives) : null; + } + /** + * @param {API.Source[]} capabilities + */ + select(capabilities) { + const { derives, selected, from: from18 } = this; + const { value } = selected; + const direct = selected.select(capabilities); + const derived = from18.select(capabilities); + const matches = []; + const errors = []; + for (const match10 of derived.matches) { + const result = derives(value, match10.value); + if (result.error) { + errors.push( + new DelegationError2( + [new EscalatedCapability2(value, match10.value, result.error)], + this + ) + ); + } else { + matches.push(match10); + } + } + return { + unknown: intersection4(direct.unknown, derived.unknown), + errors: [ + ...errors, + ...direct.errors, + ...derived.errors.map((error7) => new DelegationError2([error7], this)) + ], + matches: [ + ...direct.matches.map((match10) => new _DerivedMatch(match10, from18, derives)), + ...matches + ] + }; + } + toString() { + return this.selected.toString(); + } + }; + var AndMatch2 = class _AndMatch { + /** + * @param {API.Match[]} matches + */ + constructor(matches) { + this.matches = matches; + } + get selectors() { + return this.matches; + } + /** + * @returns {API.Source[]} + */ + get source() { + const source = []; + for (const match10 of this.matches) { + source.push(...match10.source); + } + Object.defineProperties(this, { source: { value: source } }); + return source; + } + /** + * @param {API.CanIssue} context + */ + prune(context2) { + const matches = []; + for (const match10 of this.matches) { + const pruned = match10.prune(context2); + if (pruned) { + matches.push(pruned); + } + } + return matches.length === 0 ? null : new _AndMatch(matches); + } + get proofs() { + const proofs3 = []; + for (const { delegation } of this.source) { + proofs3.push(delegation); + } + Object.defineProperties(this, { proofs: { value: proofs3 } }); + return proofs3; + } + /** + * @type {API.InferValue>} + */ + get value() { + const value = []; + for (const match10 of this.matches) { + value.push(match10.value); + } + Object.defineProperties(this, { value: { value } }); + return ( + /** @type {any} */ + value + ); + } + /** + * @param {API.Source[]} capabilities + */ + select(capabilities) { + return selectGroup2(this, capabilities); + } + toString() { + return `[${this.matches.map((match10) => match10.toString()).join(", ")}]`; + } + }; + var resolveAbility2 = (pattern, can, fallback) => { + switch (pattern) { + case can: + case "*": + return can; + default: + return pattern.endsWith("/*") && can.startsWith(pattern.slice(0, -1)) ? can : fallback; + } + }; + var resolveResource2 = (source, uri3, fallback) => { + switch (source) { + case uri3: + case "ucan:*": + return uri3; + default: + return fallback; + } + }; + var parseCapability2 = (descriptor, source) => { + const { delegation } = source; + const capability3 = ( + /** @type {API.Capability} */ + source.capability + ); + if (descriptor.can !== capability3.can) { + return { error: new UnknownCapability2(capability3) }; + } + const uri3 = descriptor.with.read(capability3.with); + if (uri3.error) { + return { error: new MalformedCapability2(capability3, uri3.error) }; + } + const nb = descriptor.nb.read(capability3.nb || {}); + if (nb.error) { + return { error: new MalformedCapability2(capability3, nb.error) }; + } + return { ok: new CapabilityView2(descriptor.can, uri3.ok, nb.ok, delegation) }; + }; + var resolveCapability2 = (descriptor, claimed, { capability: capability3, delegation }) => { + const can = resolveAbility2(capability3.can, claimed.can, null); + if (can == null) { + return { error: new UnknownCapability2(capability3) }; + } + const resource = resolveResource2( + capability3.with, + claimed.with, + capability3.with + ); + const uri3 = descriptor.with.read(resource); + if (uri3.error) { + return { error: new MalformedCapability2(capability3, uri3.error) }; + } + const nb = descriptor.nb.read({ + ...claimed.nb, + ...capability3.nb + }); + if (nb.error) { + return { error: new MalformedCapability2(capability3, nb.error) }; + } + return { ok: new CapabilityView2(can, uri3.ok, nb.ok, delegation) }; + }; + var CapabilityView2 = class { + /** + * @param {A} can + * @param {R} with_ + * @param {C} nb + * @param {API.Delegation} delegation + */ + constructor(can, with_, nb, delegation) { + this.can = can; + this.with = with_; + this.delegation = delegation; + this.nb = nb; + } + }; + var select2 = (matcher, capabilities) => { + const unknown3 = []; + const matches = []; + const errors = []; + for (const capability3 of capabilities) { + const result = matcher.match(capability3); + if (result.error) { + switch (result.error.name) { + case "UnknownCapability": + unknown3.push(result.error.capability); + break; + case "MalformedCapability": + default: + errors.push(new DelegationError2([result.error], result.error.capability)); + } + } else { + matches.push(result.ok); + } + } + return { matches, errors, unknown: unknown3 }; + }; + var selectGroup2 = (self2, capabilities) => { + let unknown3; + const data = []; + const errors = []; + for (const selector of self2.selectors) { + const selected = selector.select(capabilities); + unknown3 = unknown3 ? intersection4(unknown3, selected.unknown) : selected.unknown; + for (const error7 of selected.errors) { + errors.push(new DelegationError2([error7], self2)); + } + data.push(selected.matches); + } + const matches = combine2(data).map((group2) => new AndMatch2(group2)); + return { + unknown: ( + /* c8 ignore next */ + unknown3 || [] + ), + errors, + matches + }; + }; + var defaultDerives2 = (claimed, delegated) => { + if (delegated.with.endsWith("*")) { + if (!claimed.with.startsWith(delegated.with.slice(0, -1))) { + return schema_exports5.error( + `Resource ${claimed.with} does not match delegated ${delegated.with} ` + ); + } + } else if (delegated.with !== claimed.with) { + return schema_exports5.error( + `Resource ${claimed.with} is not contained by ${delegated.with}` + ); + } + const caveats = delegated.nb || {}; + const nb = claimed.nb || {}; + const kv = entries3(caveats); + for (const [name15, value] of kv) { + if (nb[name15] != value) { + return schema_exports5.error(`${String(name15)}: ${nb[name15]} violates ${value}`); + } + } + return { ok: true }; + }; + + // ../../node_modules/.pnpm/@web3-storage+clock@0.3.0/node_modules/@web3-storage/clock/src/capabilities.js + var clock = capability2({ + can: "clock/*", + with: uri_exports2.match({ protocol: "did:" }) + }); + var follow = capability2({ + can: "clock/follow", + with: uri_exports2.match({ protocol: "did:" }), + nb: schema_exports5.struct({ + iss: uri_exports2.match({ protocol: "did:" }).optional(), + with: uri_exports2.match({ protocol: "did:" }).optional() + }) + }); + var unfollow = capability2({ + can: "clock/unfollow", + with: uri_exports2.match({ protocol: "did:" }), + nb: schema_exports5.struct({ + iss: uri_exports2.match({ protocol: "did:" }).optional(), + with: uri_exports2.match({ protocol: "did:" }).optional() + }) + }); + var following = capability2({ + can: "clock/following", + with: uri_exports2.match({ protocol: "did:" }) + }); + var head = capability2({ + can: "clock/head", + with: uri_exports2.match({ protocol: "did:" }) + }); + var advance = capability2({ + can: "clock/advance", + with: uri_exports2.match({ protocol: "did:" }), + nb: schema_exports5.struct({ + event: link_exports5.match({ version: 1 }) + }) + }); + + // ../../node_modules/.pnpm/@web3-storage+clock@0.3.0/node_modules/@web3-storage/clock/src/client/api.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+clock@0.3.0/node_modules/@web3-storage/clock/src/service.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@web3-storage+clock@0.3.0/node_modules/@web3-storage/clock/src/client/index.js + var SERVICE_URL = "https://clock.web3.storage"; + var SERVICE_PRINCIPAL = "did:web:clock.web3.storage"; + async function advance2({ issuer, with: resource, proofs: proofs3, audience }, event, options) { + const conn = options?.connection ?? connect3(); + const facts = options?.blocks ? [Object.fromEntries(options.blocks.map((b6) => [b6.cid.toString(), b6.cid]))] : []; + const invocation = advance.invoke({ + issuer, + audience: audience ?? conn.id, + with: resource, + nb: { event }, + proofs: proofs3, + facts + }); + for (const block of options?.blocks ?? []) { + invocation.attach(block); + } + return invocation.execute(conn); + } + function connect3(options) { + const url = options?.serviceURL ?? new URL(SERVICE_URL); + return connect2({ + id: options?.servicePrincipal ?? parse2(SERVICE_PRINCIPAL), + codec: car_exports5.outbound, + channel: http_exports2.open({ url, method: "POST" }) + }); + } + + // ../../node_modules/.pnpm/@alanshaw+pail@0.3.3/node_modules/@alanshaw/pail/src/clock.js + init_dirname(); + init_buffer2(); + init_process(); + async function advance3(blocks, head2, event) { + const events = new EventFetcher(blocks); + const headmap = new Map(head2.map((cid) => [cid.toString(), cid])); + if (headmap.has(event.toString())) + return head2; + let changed = false; + for (const cid of head2) { + if (await contains(events, event, cid)) { + headmap.delete(cid.toString()); + headmap.set(event.toString(), event); + changed = true; + } + } + if (changed) { + return [...headmap.values()]; + } + for (const p8 of head2) { + if (await contains(events, p8, event)) { + return head2; + } + } + return head2.concat(event); + } + var EventBlock = class extends Block { + /** + * @param {object} config + * @param {EventLink} config.cid + * @param {Event} config.value + * @param {Uint8Array} config.bytes + * @param {string} config.prefix + */ + constructor({ cid, value, bytes: bytes2, prefix }) { + super({ cid, value, bytes: bytes2 }); + this.prefix = prefix; + } + /** + * @template T + * @param {T} data + * @param {EventLink[]} [parents] + */ + static create(data, parents) { + return encodeEventBlock({ data, parents: parents ?? [] }); + } + }; + var EventFetcher = class { + /** @param {import('./block').BlockFetcher} blocks */ + constructor(blocks) { + this._blocks = blocks; + } + /** + * @param {EventLink} link + * @returns {Promise>} + */ + async get(link10) { + const block = await this._blocks.get(link10); + if (!block) + throw new Error(`missing block: ${link10}`); + return decodeEventBlock(block.bytes); + } + }; + async function encodeEventBlock(value) { + const { cid, bytes: bytes2 } = await encode30({ value, codec: src_exports, hasher: sha256 }); + return new Block({ cid, value, bytes: bytes2 }); + } + async function decodeEventBlock(bytes2) { + const { cid, value } = await decode37({ bytes: bytes2, codec: src_exports, hasher: sha256 }); + return new Block({ cid, value, bytes: bytes2 }); + } + async function contains(events, a8, b6) { + if (a8.toString() === b6.toString()) + return true; + const [{ value: aevent }, { value: bevent }] = await Promise.all([events.get(a8), events.get(b6)]); + const links4 = [...aevent.parents]; + while (links4.length) { + const link10 = links4.shift(); + if (!link10) + break; + if (link10.toString() === b6.toString()) + return true; + if (bevent.parents.some((p8) => link10.toString() === p8.toString())) + continue; + const { value: event } = await events.get(link10); + links4.push(...event.parents); + } + return false; + } + async function* vis(blocks, head2, options = {}) { + const renderNodeLabel = options.renderNodeLabel ?? ((b6) => shortLink(b6.cid)); + const events = new EventFetcher(blocks); + yield "digraph clock {"; + yield ' node [shape=point fontname="Courier"]; head;'; + const hevents = await Promise.all(head2.map((link10) => events.get(link10))); + const links4 = []; + const nodes = /* @__PURE__ */ new Set(); + for (const e12 of hevents) { + nodes.add(e12.cid.toString()); + yield ` node [shape=oval fontname="Courier"]; ${e12.cid} [label="${renderNodeLabel(e12)}"];`; + yield ` head -> ${e12.cid};`; + for (const p8 of e12.value.parents) { + yield ` ${e12.cid} -> ${p8};`; + } + links4.push(...e12.value.parents); + } + while (links4.length) { + const link10 = links4.shift(); + if (!link10) + break; + if (nodes.has(link10.toString())) + continue; + nodes.add(link10.toString()); + const block = await events.get(link10); + yield ` node [shape=oval]; ${link10} [label="${renderNodeLabel(block)}" fontname="Courier"];`; + for (const p8 of block.value.parents) { + yield ` ${link10} -> ${p8};`; + } + links4.push(...block.value.parents); + } + yield "}"; + } + var shortLink = (l8) => `${String(l8).slice(0, 4)}..${String(l8).slice(-4)}`; + + // src/connect-web3.ts + var ConnectWeb3 = class { + constructor(email2) { + __publicField(this, "email"); + __publicField(this, "ready"); + __publicField(this, "client", null); + this.email = email2; + this.ready = this.initializeClient(); + } + async initializeClient() { + this.client = await getClient(this.email); + } + async download(params) { + validateParams(params); + if (params.type === "meta") { + return false; + } + console.log("w3 downloading", params); + const url = `https://${params.car}.ipfs.w3s.link/`; + const response = await fetch(url); + if (response.ok) { + return new Uint8Array(await response.arrayBuffer()); + } else { + console.log("failed to download", url, response); + throw new Error(`Failed to download ${url}`); + } + } + async upload(bytes2, params) { + await this.ready; + if (!this.client) { + throw new Error("client not initialized"); + } + if (params.type === "meta") { + const ag = this.client._agent; + console.log("w3 meta upload", params); + const space3 = this.client.currentSpace(); + if (!space3) { + throw new Error("space not initialized"); + } + const data = { + key: params.name, + branch: params.branch, + name: params.name + // we could extract this from the input type but it silly to do so + // key: + // car: + // parse('bafkreigh2akiscaildcqabsyg3dfr6chu3fgpregiymsck7e7aqa4s52zy') + }; + const event = await EventBlock.create(data); + const issuer = ag.issuer; + console.log("issuer", issuer, issuer.signatureAlgorithm, issuer.did()); + if (!issuer.signatureAlgorithm) { + throw new Error("issuer not valid"); + } + const claims = await this.client.capability.access.claim(); + const delegated = await clock.delegate({ + issuer: ag.issuer, + audience: ag.issuer, + // DID.parse('did:web:clock.web3.storage'), + with: space3.did(), + proofs: claims + }); + console.log("delegated", delegated); + const advanced = await advance2({ + issuer, + with: space3.did(), + proofs: claims + }, event.cid, { blocks: [event] }); + console.log("advanced", advanced.root.data?.ocm); + return; + } + validateParams(params); + console.log("w3 uploading car", params); + await this.client?.uploadFile(new Blob([bytes2])); + } + }; + async function getClient(email2) { + const client = await create13(); + if (client.currentSpace()?.registered()) { + const claims2 = await client.capability.access.claim(); + console.log("claims", claims2.map((c8) => { + return c8.data.model.att; + }), claims2); + return client; + } + console.log("authorizing", email2); + await client.authorize(email2); + console.log("authorized", client); + let space3 = client.currentSpace(); + const claims = await client.capability.access.claim(); + console.log("claims", claims); + if (space3 === void 0) { + const spaces = client.spaces(); + for (const s7 of spaces) { + if (s7.registered()) { + space3 = s7; + console.log("space", space3.registered(), space3.did(), space3.meta()); + break; + } + } + if (space3 === void 0) { + space3 = await client.createSpace("fp", [{ + // @ts-ignore + audience: client._agent.issuer + // audience: DID.parse('did:web:clock.web3.storage') + }]); + } + await client.setCurrentSpace(space3.did()); + } + if (!space3.registered()) { + console.log("registering space"); + await client.registerSpace(email2); + } + console.log("space", space3.did()); + return client; + } + + // src/connect.ts + var connect4 = { + s3: ({ _crdt: { blocks: { loader } } }, { upload: upload4, download }) => { + const connection3 = new ConnectS3(upload4, download); + loader.connectRemote(connection3); + return connection3; + }, + raw: ({ _crdt: { blocks: { loader } } }, { upload: upload4, download }) => { + const connection3 = { upload: upload4, download, ready: Promise.resolve() }; + loader.connectRemote(connection3); + return connection3; + }, + web3: ({ _crdt: { blocks: { loader } } }, email2) => { + console.log("connecting web3", email2); + const connection3 = new ConnectWeb3(email2); + loader.connectRemote(connection3); + } + }; + function validateParams(params) { + const { type: type3, name: name15, car, branch } = params; + if (!name15) + throw new Error("name is required"); + if (car && branch) { + throw new Error("car and branch are mutually exclusive"); + } + if (!car && !branch) { + throw new Error("car or branch is required"); + } + if (type3 !== "file" && type3 !== "data" && type3 !== "meta") { + throw new Error("type must be file, data or meta"); + } + } + + // src/database.ts + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/uuidv7@0.6.2/node_modules/uuidv7/dist/index.js + init_dirname(); + init_buffer2(); + init_process(); + var DIGITS = "0123456789abcdef"; + var UUID = class _UUID { + /** @param bytes - The 16-byte byte array representation. */ + constructor(bytes2) { + this.bytes = bytes2; + } + /** + * Creates an object from the internal representation, a 16-byte byte array + * containing the binary UUID representation in the big-endian byte order. + * + * This method does NOT shallow-copy the argument, and thus the created object + * holds the reference to the underlying buffer. + * + * @throws TypeError if the length of the argument is not 16. + */ + static ofInner(bytes2) { + if (bytes2.length !== 16) { + throw new TypeError("not 128-bit length"); + } else { + return new _UUID(bytes2); + } + } + /** + * Builds a byte array from UUIDv7 field values. + * + * @param unixTsMs - A 48-bit `unix_ts_ms` field value. + * @param randA - A 12-bit `rand_a` field value. + * @param randBHi - The higher 30 bits of 62-bit `rand_b` field value. + * @param randBLo - The lower 32 bits of 62-bit `rand_b` field value. + * @throws RangeError if any field value is out of the specified range. + */ + static fromFieldsV7(unixTsMs, randA, randBHi, randBLo) { + if (!Number.isInteger(unixTsMs) || !Number.isInteger(randA) || !Number.isInteger(randBHi) || !Number.isInteger(randBLo) || unixTsMs < 0 || randA < 0 || randBHi < 0 || randBLo < 0 || unixTsMs > 281474976710655 || randA > 4095 || randBHi > 1073741823 || randBLo > 4294967295) { + throw new RangeError("invalid field value"); + } + const bytes2 = new Uint8Array(16); + bytes2[0] = unixTsMs / 2 ** 40; + bytes2[1] = unixTsMs / 2 ** 32; + bytes2[2] = unixTsMs / 2 ** 24; + bytes2[3] = unixTsMs / 2 ** 16; + bytes2[4] = unixTsMs / 2 ** 8; + bytes2[5] = unixTsMs; + bytes2[6] = 112 | randA >>> 8; + bytes2[7] = randA; + bytes2[8] = 128 | randBHi >>> 24; + bytes2[9] = randBHi >>> 16; + bytes2[10] = randBHi >>> 8; + bytes2[11] = randBHi; + bytes2[12] = randBLo >>> 24; + bytes2[13] = randBLo >>> 16; + bytes2[14] = randBLo >>> 8; + bytes2[15] = randBLo; + return new _UUID(bytes2); + } + /** + * Builds a byte array from a string representation. + * + * This method accepts the following formats: + * + * - 32-digit hexadecimal format without hyphens: `0189dcd553117d408db09496a2eef37b` + * - 8-4-4-4-12 hyphenated format: `0189dcd5-5311-7d40-8db0-9496a2eef37b` + * - Hyphenated format with surrounding braces: `{0189dcd5-5311-7d40-8db0-9496a2eef37b}` + * - RFC 4122 URN format: `urn:uuid:0189dcd5-5311-7d40-8db0-9496a2eef37b` + * + * Leading and trailing whitespaces represents an error. + * + * @throws SyntaxError if the argument could not parse as a valid UUID string. + */ + static parse(uuid) { + var _a2, _b, _c, _d; + let hex = void 0; + switch (uuid.length) { + case 32: + hex = (_a2 = /^[0-9a-f]{32}$/i.exec(uuid)) === null || _a2 === void 0 ? void 0 : _a2[0]; + break; + case 36: + hex = (_b = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid)) === null || _b === void 0 ? void 0 : _b.slice(1, 6).join(""); + break; + case 38: + hex = (_c = /^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(uuid)) === null || _c === void 0 ? void 0 : _c.slice(1, 6).join(""); + break; + case 45: + hex = (_d = /^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid)) === null || _d === void 0 ? void 0 : _d.slice(1, 6).join(""); + break; + default: + break; + } + if (hex) { + const inner = new Uint8Array(16); + for (let i8 = 0; i8 < 16; i8 += 4) { + const n9 = parseInt(hex.substring(2 * i8, 2 * i8 + 8), 16); + inner[i8 + 0] = n9 >>> 24; + inner[i8 + 1] = n9 >>> 16; + inner[i8 + 2] = n9 >>> 8; + inner[i8 + 3] = n9; + } + return new _UUID(inner); + } else { + throw new SyntaxError("could not parse UUID string"); + } + } + /** + * @returns The 8-4-4-4-12 canonical hexadecimal string representation + * (`0189dcd5-5311-7d40-8db0-9496a2eef37b`). + */ + toString() { + let text3 = ""; + for (let i8 = 0; i8 < this.bytes.length; i8++) { + text3 += DIGITS.charAt(this.bytes[i8] >>> 4); + text3 += DIGITS.charAt(this.bytes[i8] & 15); + if (i8 === 3 || i8 === 5 || i8 === 7 || i8 === 9) { + text3 += "-"; + } + } + return text3; + } + /** + * @returns The 32-digit hexadecimal representation without hyphens + * (`0189dcd553117d408db09496a2eef37b`). + */ + toHex() { + let text3 = ""; + for (let i8 = 0; i8 < this.bytes.length; i8++) { + text3 += DIGITS.charAt(this.bytes[i8] >>> 4); + text3 += DIGITS.charAt(this.bytes[i8] & 15); + } + return text3; + } + /** @returns The 8-4-4-4-12 canonical hexadecimal string representation. */ + toJSON() { + return this.toString(); + } + /** + * Reports the variant field value of the UUID or, if appropriate, "NIL" or + * "MAX". + * + * For convenience, this method reports "NIL" or "MAX" if `this` represents + * the Nil or Max UUID, although the Nil and Max UUIDs are technically + * subsumed under the variants `0b0` and `0b111`, respectively. + */ + getVariant() { + const n9 = this.bytes[8] >>> 4; + if (n9 < 0) { + throw new Error("unreachable"); + } else if (n9 <= 7) { + return this.bytes.every((e12) => e12 === 0) ? "NIL" : "VAR_0"; + } else if (n9 <= 11) { + return "VAR_10"; + } else if (n9 <= 13) { + return "VAR_110"; + } else if (n9 <= 15) { + return this.bytes.every((e12) => e12 === 255) ? "MAX" : "VAR_RESERVED"; + } else { + throw new Error("unreachable"); + } + } + /** + * Returns the version field value of the UUID or `undefined` if the UUID does + * not have the variant field value of `0b10`. + */ + getVersion() { + return this.getVariant() === "VAR_10" ? this.bytes[6] >>> 4 : void 0; + } + /** Creates an object from `this`. */ + clone() { + return new _UUID(this.bytes.slice(0)); + } + /** Returns true if `this` is equivalent to `other`. */ + equals(other) { + return this.compareTo(other) === 0; + } + /** + * Returns a negative integer, zero, or positive integer if `this` is less + * than, equal to, or greater than `other`, respectively. + */ + compareTo(other) { + for (let i8 = 0; i8 < 16; i8++) { + const diff = this.bytes[i8] - other.bytes[i8]; + if (diff !== 0) { + return Math.sign(diff); + } + } + return 0; + } + }; + var V7Generator = class { + /** + * Creates a generator object with the default random number generator, or + * with the specified one if passed as an argument. The specified random + * number generator should be cryptographically strong and securely seeded. + */ + constructor(randomNumberGenerator) { + this.timestamp = 0; + this.counter = 0; + this.random = randomNumberGenerator !== null && randomNumberGenerator !== void 0 ? randomNumberGenerator : getDefaultRandom(); + } + /** + * Generates a new UUIDv7 object from the current timestamp, or resets the + * generator upon significant timestamp rollback. + * + * This method returns monotonically increasing UUIDs unless the up-to-date + * timestamp is significantly (by more than ten seconds) smaller than the one + * embedded in the immediately preceding UUID. If such a significant clock + * rollback is detected, this method resets the generator and returns a new + * UUID based on the current timestamp. + */ + generate() { + return this.generateOrResetCore(Date.now(), 1e4); + } + /** + * Generates a new UUIDv7 object from the current timestamp, or returns + * `undefined` upon significant timestamp rollback. + * + * This method returns monotonically increasing UUIDs unless the up-to-date + * timestamp is significantly (by more than ten seconds) smaller than the one + * embedded in the immediately preceding UUID. If such a significant clock + * rollback is detected, this method aborts and returns `undefined`. + */ + generateOrAbort() { + return this.generateOrAbortCore(Date.now(), 1e4); + } + /** + * Generates a new UUIDv7 object from the `unixTsMs` passed, or resets the + * generator upon significant timestamp rollback. + * + * This method is equivalent to {@link generate} except that it takes a custom + * timestamp and clock rollback allowance. + * + * @param rollbackAllowance - The amount of `unixTsMs` rollback that is + * considered significant. A suggested value is `10_000` (milliseconds). + * @throws RangeError if `unixTsMs` is not a 48-bit positive integer. + */ + generateOrResetCore(unixTsMs, rollbackAllowance) { + let value = this.generateOrAbortCore(unixTsMs, rollbackAllowance); + if (value === void 0) { + this.timestamp = 0; + value = this.generateOrAbortCore(unixTsMs, rollbackAllowance); + } + return value; + } + /** + * Generates a new UUIDv7 object from the `unixTsMs` passed, or returns + * `undefined` upon significant timestamp rollback. + * + * This method is equivalent to {@link generateOrAbort} except that it takes a + * custom timestamp and clock rollback allowance. + * + * @param rollbackAllowance - The amount of `unixTsMs` rollback that is + * considered significant. A suggested value is `10_000` (milliseconds). + * @throws RangeError if `unixTsMs` is not a 48-bit positive integer. + */ + generateOrAbortCore(unixTsMs, rollbackAllowance) { + const MAX_COUNTER = 4398046511103; + if (!Number.isInteger(unixTsMs) || unixTsMs < 1 || unixTsMs > 281474976710655) { + throw new RangeError("`unixTsMs` must be a 48-bit positive integer"); + } else if (rollbackAllowance < 0 || rollbackAllowance > 281474976710655) { + throw new RangeError("`rollbackAllowance` out of reasonable range"); + } + if (unixTsMs > this.timestamp) { + this.timestamp = unixTsMs; + this.resetCounter(); + } else if (unixTsMs + rollbackAllowance >= this.timestamp) { + this.counter++; + if (this.counter > MAX_COUNTER) { + this.timestamp++; + this.resetCounter(); + } + } else { + return void 0; + } + return UUID.fromFieldsV7(this.timestamp, Math.trunc(this.counter / 2 ** 30), this.counter & 2 ** 30 - 1, this.random.nextUint32()); + } + /** Initializes the counter at a 42-bit random integer. */ + resetCounter() { + this.counter = this.random.nextUint32() * 1024 + (this.random.nextUint32() & 1023); + } + /** + * Generates a new UUIDv4 object utilizing the random number generator inside. + * + * @internal + */ + generateV4() { + const bytes2 = new Uint8Array(Uint32Array.of(this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32()).buffer); + bytes2[6] = 64 | bytes2[6] >>> 4; + bytes2[8] = 128 | bytes2[8] >>> 2; + return UUID.ofInner(bytes2); + } + }; + var getDefaultRandom = () => { + if (typeof crypto !== "undefined" && typeof crypto.getRandomValues !== "undefined") { + return new BufferedCryptoRandom(); + } else { + if (typeof UUIDV7_DENY_WEAK_RNG !== "undefined" && UUIDV7_DENY_WEAK_RNG) { + throw new Error("no cryptographically strong RNG available"); + } + return { + nextUint32: () => Math.trunc(Math.random() * 65536) * 65536 + Math.trunc(Math.random() * 65536) + }; + } + }; + var BufferedCryptoRandom = class { + constructor() { + this.buffer = new Uint32Array(8); + this.cursor = 65535; + } + nextUint32() { + if (this.cursor >= this.buffer.length) { + crypto.getRandomValues(this.buffer); + this.cursor = 0; + } + return this.buffer[this.cursor++]; + } + }; + var defaultGenerator; + var uuidv7 = () => uuidv7obj().toString(); + var uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator())).generate(); + + // src/write-queue.ts + init_dirname(); + init_buffer2(); + init_process(); + function writeQueue(worker, payload = Infinity) { + const queue = []; + let isProcessing = false; + async function process3() { + if (isProcessing || queue.length === 0) + return; + isProcessing = true; + const tasksToProcess = queue.splice(0, payload); + const updates = tasksToProcess.map((item) => item.task); + try { + const result = await worker(updates); + tasksToProcess.forEach((task) => task.resolve(result)); + } catch (error7) { + tasksToProcess.forEach((task) => task.reject(error7)); + } + isProcessing = false; + void process3(); + } + return { + push(task) { + return new Promise((resolve7, reject) => { + queue.push({ task, resolve: resolve7, reject }); + void process3(); + }); + } + }; + } + + // src/crdt.ts + init_dirname(); + init_buffer2(); + init_process(); + + // src/transaction.ts + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@alanshaw+pail@0.3.3/node_modules/@alanshaw/pail/src/block.js + init_dirname(); + init_buffer2(); + init_process(); + var _blocks; + var MemoryBlockstore = class { + /** + * @param {Array} [blocks] + */ + constructor(blocks) { + /** @type {Map} */ + __privateAdd(this, _blocks, /* @__PURE__ */ new Map()); + if (blocks) { + __privateSet(this, _blocks, new Map(blocks.map((b6) => [b6.cid.toString(), b6.bytes]))); + } + } + /** + * @param {import('./link').AnyLink} cid + * @returns {Promise} + */ + async get(cid) { + const bytes2 = __privateGet(this, _blocks).get(cid.toString()); + if (!bytes2) + return; + return { cid, bytes: bytes2 }; + } + /** + * @param {import('./link').AnyLink} cid + * @param {Uint8Array} bytes + */ + async put(cid, bytes2) { + __privateGet(this, _blocks).set(cid.toString(), bytes2); + } + /** + * @param {import('./link').AnyLink} cid + * @param {Uint8Array} bytes + */ + putSync(cid, bytes2) { + __privateGet(this, _blocks).set(cid.toString(), bytes2); + } + /** @param {import('./link').AnyLink} cid */ + async delete(cid) { + __privateGet(this, _blocks).delete(cid.toString()); + } + /** @param {import('./link').AnyLink} cid */ + deleteSync(cid) { + __privateGet(this, _blocks).delete(cid.toString()); + } + *entries() { + for (const [str, bytes2] of __privateGet(this, _blocks)) { + yield { cid: parse(str), bytes: bytes2 }; + } + } + }; + _blocks = new WeakMap(); + var _fetchers; + var MultiBlockFetcher = class { + /** @param {BlockFetcher[]} fetchers */ + constructor(...fetchers) { + /** @type {BlockFetcher[]} */ + __privateAdd(this, _fetchers, void 0); + __privateSet(this, _fetchers, fetchers); + } + /** @param {import('./link').AnyLink} link */ + async get(link10) { + for (const f9 of __privateGet(this, _fetchers)) { + const v7 = await f9.get(link10); + if (v7) + return v7; + } + } + }; + _fetchers = new WeakMap(); + + // src/loaders.ts + init_dirname(); + init_buffer2(); + init_process(); + + // src/loader.ts + init_dirname(); + init_buffer2(); + init_process(); + + // src/loader-helpers.ts + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/block.js + init_dirname(); + init_buffer2(); + init_process(); + init_src(); + init_interface3(); + function readonly2({ enumerable = true, configurable = false } = {}) { + return { enumerable, configurable, writable: false }; + } + function* linksWithin2(path2, value) { + if (value != null && typeof value === "object") { + if (Array.isArray(value)) { + for (const [index2, element] of value.entries()) { + const elementPath = [...path2, index2]; + const cid = CID.asCID(element); + if (cid) { + yield [elementPath.join("/"), cid]; + } else if (typeof element === "object") { + yield* links3(element, elementPath); + } + } + } else { + const cid = CID.asCID(value); + if (cid) { + yield [path2.join("/"), cid]; + } else { + yield* links3(value, path2); + } + } + } + } + function* links3(source, base3) { + if (source == null || source instanceof Uint8Array) { + return; + } + const cid = CID.asCID(source); + if (cid) { + yield [base3.join("/"), cid]; + } + for (const [key, value] of Object.entries(source)) { + const path2 = ( + /** @type {[string|number, string]} */ + [...base3, key] + ); + yield* linksWithin2(path2, value); + } + } + function* treeWithin2(path2, value) { + if (Array.isArray(value)) { + for (const [index2, element] of value.entries()) { + const elementPath = [...path2, index2]; + yield elementPath.join("/"); + if (typeof element === "object" && !CID.asCID(element)) { + yield* tree2(element, elementPath); + } + } + } else { + yield* tree2(value, path2); + } + } + function* tree2(source, base3) { + if (source == null || typeof source !== "object") { + return; + } + for (const [key, value] of Object.entries(source)) { + const path2 = ( + /** @type {[string|number, string]} */ + [...base3, key] + ); + yield path2.join("/"); + if (value != null && !(value instanceof Uint8Array) && typeof value === "object" && !CID.asCID(value)) { + yield* treeWithin2(path2, value); + } + } + } + function get14(source, path2) { + let node = ( + /** @type {Record} */ + source + ); + for (const [index2, key] of path2.entries()) { + node = node[key]; + if (node == null) { + throw new Error(`Object has no property at ${path2.slice(0, index2 + 1).map((part) => `[${JSON.stringify(part)}]`).join("")}`); + } + const cid = CID.asCID(node); + if (cid) { + return { value: cid, remaining: path2.slice(index2 + 1).join("/") }; + } + } + return { value: node }; + } + var Block2 = class { + /** + * @param {object} options + * @param {CID} options.cid + * @param {API.ByteView} options.bytes + * @param {T} options.value + */ + constructor({ cid, bytes: bytes2, value }) { + if (!cid || !bytes2 || typeof value === "undefined") { + throw new Error("Missing required argument"); + } + this.cid = cid; + this.bytes = bytes2; + this.value = value; + this.asBlock = this; + Object.defineProperties(this, { + cid: readonly2(), + bytes: readonly2(), + value: readonly2(), + asBlock: readonly2() + }); + } + links() { + return links3(this.value, []); + } + tree() { + return tree2(this.value, []); + } + /** + * + * @param {string} [path] + * @returns {API.BlockCursorView} + */ + get(path2 = "/") { + return get14(this.value, path2.split("/").filter(Boolean)); + } + }; + async function encode37({ value, codec, hasher }) { + if (typeof value === "undefined") + throw new Error('Missing required argument "value"'); + if (!codec || !hasher) + throw new Error("Missing required argument: codec or hasher"); + const bytes2 = codec.encode(value); + const hash = await hasher.digest(bytes2); + const cid = CID.create( + 1, + codec.code, + hash + ); + return new Block2({ value, bytes: bytes2, cid }); + } + async function decode43({ bytes: bytes2, codec, hasher }) { + if (!bytes2) + throw new Error('Missing required argument "bytes"'); + if (!codec || !hasher) + throw new Error("Missing required argument: codec or hasher"); + const value = codec.decode(bytes2); + const hash = await hasher.digest(bytes2); + const cid = CID.create(1, codec.code, hash); + return new Block2({ value, bytes: bytes2, cid }); + } + function createUnsafe({ bytes: bytes2, cid, value: maybeValue, codec }) { + const value = maybeValue !== void 0 ? maybeValue : codec && codec.decode(bytes2); + if (value === void 0) + throw new Error('Missing required argument, must either provide "value" or "codec"'); + return new Block2({ + // eslint-disable-next-line object-shorthand + cid: ( + /** @type {CID} */ + cid + ), + bytes: bytes2, + value + }); + } + async function create16({ bytes: bytes2, cid, hasher, codec }) { + if (!bytes2) + throw new Error('Missing required argument "bytes"'); + if (!hasher) + throw new Error('Missing required argument "hasher"'); + const value = codec.decode(bytes2); + const hash = await hasher.digest(bytes2); + if (!bytes_exports2.equals(cid.multihash.bytes, hash.bytes)) { + throw new Error("CID hash does not match bytes"); + } + return createUnsafe({ + bytes: bytes2, + cid, + value, + codec + }); + } + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/hashes/sha2-browser.js + init_dirname(); + init_buffer2(); + init_process(); + init_hasher(); + var sha2 = (name15) => ( + /** + * @param {Uint8Array} data + */ + async (data) => new Uint8Array(await crypto.subtle.digest(name15, data)) + ); + var sha2562 = from5({ + name: "sha2-256", + code: 18, + encode: sha2("SHA-256") + }); + var sha5122 = from5({ + name: "sha2-512", + code: 19, + encode: sha2("SHA-512") + }); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/codecs/raw.js + var raw_exports2 = {}; + __export(raw_exports2, { + code: () => code12, + decode: () => decode44, + encode: () => encode38, + name: () => name12 + }); + init_dirname(); + init_buffer2(); + init_process(); + init_bytes2(); + var name12 = "raw"; + var code12 = 85; + var encode38 = (node) => coerce(node); + var decode44 = (data) => coerce(data); + + // src/loader-helpers.ts + async function clearMakeCarFile(fp, t9) { + const { cid, bytes: bytes2 } = await encodeCarHeader(fp); + await t9.put(cid, bytes2); + return encodeCarFile(cid, t9); + } + async function encodeCarFile(carHeaderBlockCid, t9) { + let size4 = 0; + const headerSize = headerLength({ roots: [carHeaderBlockCid] }); + size4 += headerSize; + for (const { cid, bytes: bytes2 } of t9.entries()) { + size4 += blockLength({ cid, bytes: bytes2 }); + } + const buffer4 = new Uint8Array(size4); + const writer2 = createWriter(buffer4, { headerSize }); + writer2.addRoot(carHeaderBlockCid); + for (const { cid, bytes: bytes2 } of t9.entries()) { + writer2.write({ cid, bytes: bytes2 }); + } + writer2.close(); + return await encode37({ value: writer2.bytes, hasher: sha2562, codec: raw_exports2 }); + } + async function encodeCarHeader(fp) { + return await encode37({ + value: { fp }, + hasher: sha2562, + codec: src_exports + }); + } + async function parseCarFile(reader2) { + const roots = await reader2.getRoots(); + const header = await reader2.get(roots[0]); + if (!header) + throw new Error("missing header block"); + const { value } = await decode43({ bytes: header.bytes, hasher: sha2562, codec: src_exports }); + if (value && value.fp === void 0) + throw new Error("missing fp"); + const { fp } = value; + return fp; + } + + // src/encrypt-helpers.ts + init_dirname(); + init_buffer2(); + init_process(); + + // src/crypto.ts + init_dirname(); + init_buffer2(); + init_process(); + + // src/encrypted-block.ts + var encrypted_block_exports = {}; + __export(encrypted_block_exports, { + code: () => code13, + crypto: () => cryptoFn, + decode: () => decode45, + decrypt: () => decrypt, + encode: () => encode39, + encrypt: () => encrypt, + getCrypto: () => getCrypto, + name: () => name13, + randomBytes: () => randomBytes2 + }); + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@peculiar+webcrypto@1.4.3/node_modules/@peculiar/webcrypto/build/webcrypto.es.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/webcrypto-core@1.7.7/node_modules/webcrypto-core/build/webcrypto-core.es.js + init_dirname(); + init_buffer2(); + init_process(); + var import_pvtsutils4 = __toESM(require_build()); + var import_pvtsutils5 = __toESM(require_build()); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/converters.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/asn1js@3.0.5/node_modules/asn1js/build/index.es.js + var index_es_exports = {}; + __export(index_es_exports, { + Any: () => Any, + BaseBlock: () => BaseBlock, + BaseStringBlock: () => BaseStringBlock, + BitString: () => BitString, + BmpString: () => BmpString, + Boolean: () => Boolean4, + CharacterString: () => CharacterString, + Choice: () => Choice, + Constructed: () => Constructed, + DATE: () => DATE, + DateTime: () => DateTime, + Duration: () => Duration, + EndOfContent: () => EndOfContent, + Enumerated: () => Enumerated, + GeneralString: () => GeneralString, + GeneralizedTime: () => GeneralizedTime, + GraphicString: () => GraphicString, + HexBlock: () => HexBlock, + IA5String: () => IA5String, + Integer: () => Integer3, + Null: () => Null, + NumericString: () => NumericString, + ObjectIdentifier: () => ObjectIdentifier, + OctetString: () => OctetString, + Primitive: () => Primitive, + PrintableString: () => PrintableString, + RawData: () => RawData, + RelativeObjectIdentifier: () => RelativeObjectIdentifier, + Repeated: () => Repeated, + Sequence: () => Sequence, + Set: () => Set2, + TIME: () => TIME, + TeletexString: () => TeletexString, + TimeOfDay: () => TimeOfDay, + UTCTime: () => UTCTime, + UniversalString: () => UniversalString, + Utf8String: () => Utf8String, + ValueBlock: () => ValueBlock, + VideotexString: () => VideotexString, + ViewWriter: () => ViewWriter, + VisibleString: () => VisibleString, + compareSchema: () => compareSchema, + fromBER: () => fromBER, + verifySchema: () => verifySchema + }); + init_dirname(); + init_buffer2(); + init_process(); + var pvtsutils = __toESM(require_build()); + + // ../../node_modules/.pnpm/pvutils@1.1.3/node_modules/pvutils/build/utils.es.js + init_dirname(); + init_buffer2(); + init_process(); + function utilFromBase(inputBuffer, inputBase) { + let result = 0; + if (inputBuffer.length === 1) { + return inputBuffer[0]; + } + for (let i8 = inputBuffer.length - 1; i8 >= 0; i8--) { + result += inputBuffer[inputBuffer.length - 1 - i8] * Math.pow(2, inputBase * i8); + } + return result; + } + function utilToBase(value, base3, reserved = -1) { + const internalReserved = reserved; + let internalValue = value; + let result = 0; + let biggest = Math.pow(2, base3); + for (let i8 = 1; i8 < 8; i8++) { + if (value < biggest) { + let retBuf; + if (internalReserved < 0) { + retBuf = new ArrayBuffer(i8); + result = i8; + } else { + if (internalReserved < i8) { + return new ArrayBuffer(0); + } + retBuf = new ArrayBuffer(internalReserved); + result = internalReserved; + } + const retView = new Uint8Array(retBuf); + for (let j5 = i8 - 1; j5 >= 0; j5--) { + const basis = Math.pow(2, j5 * base3); + retView[result - j5 - 1] = Math.floor(internalValue / basis); + internalValue -= retView[result - j5 - 1] * basis; + } + return retBuf; + } + biggest *= Math.pow(2, base3); + } + return new ArrayBuffer(0); + } + function utilConcatView(...views) { + let outputLength = 0; + let prevLength = 0; + for (const view10 of views) { + outputLength += view10.length; + } + const retBuf = new ArrayBuffer(outputLength); + const retView = new Uint8Array(retBuf); + for (const view10 of views) { + retView.set(view10, prevLength); + prevLength += view10.length; + } + return retView; + } + function utilDecodeTC() { + const buf3 = new Uint8Array(this.valueHex); + if (this.valueHex.byteLength >= 2) { + const condition1 = buf3[0] === 255 && buf3[1] & 128; + const condition2 = buf3[0] === 0 && (buf3[1] & 128) === 0; + if (condition1 || condition2) { + this.warnings.push("Needlessly long format"); + } + } + const bigIntBuffer = new ArrayBuffer(this.valueHex.byteLength); + const bigIntView = new Uint8Array(bigIntBuffer); + for (let i8 = 0; i8 < this.valueHex.byteLength; i8++) { + bigIntView[i8] = 0; + } + bigIntView[0] = buf3[0] & 128; + const bigInt = utilFromBase(bigIntView, 8); + const smallIntBuffer = new ArrayBuffer(this.valueHex.byteLength); + const smallIntView = new Uint8Array(smallIntBuffer); + for (let j5 = 0; j5 < this.valueHex.byteLength; j5++) { + smallIntView[j5] = buf3[j5]; + } + smallIntView[0] &= 127; + const smallInt = utilFromBase(smallIntView, 8); + return smallInt - bigInt; + } + function utilEncodeTC(value) { + const modValue = value < 0 ? value * -1 : value; + let bigInt = 128; + for (let i8 = 1; i8 < 8; i8++) { + if (modValue <= bigInt) { + if (value < 0) { + const smallInt = bigInt - modValue; + const retBuf2 = utilToBase(smallInt, 8, i8); + const retView2 = new Uint8Array(retBuf2); + retView2[0] |= 128; + return retBuf2; + } + let retBuf = utilToBase(modValue, 8, i8); + let retView = new Uint8Array(retBuf); + if (retView[0] & 128) { + const tempBuf = retBuf.slice(0); + const tempView = new Uint8Array(tempBuf); + retBuf = new ArrayBuffer(retBuf.byteLength + 1); + retView = new Uint8Array(retBuf); + for (let k5 = 0; k5 < tempBuf.byteLength; k5++) { + retView[k5 + 1] = tempView[k5]; + } + retView[0] = 0; + } + return retBuf; + } + bigInt *= Math.pow(2, 8); + } + return new ArrayBuffer(0); + } + function isEqualBuffer(inputBuffer1, inputBuffer2) { + if (inputBuffer1.byteLength !== inputBuffer2.byteLength) { + return false; + } + const view1 = new Uint8Array(inputBuffer1); + const view22 = new Uint8Array(inputBuffer2); + for (let i8 = 0; i8 < view1.length; i8++) { + if (view1[i8] !== view22[i8]) { + return false; + } + } + return true; + } + function padNumber(inputNumber, fullLength) { + const str = inputNumber.toString(10); + if (fullLength < str.length) { + return ""; + } + const dif = fullLength - str.length; + const padding = new Array(dif); + for (let i8 = 0; i8 < dif; i8++) { + padding[i8] = "0"; + } + const paddingString = padding.join(""); + return paddingString.concat(str); + } + var log22 = Math.log(2); + + // ../../node_modules/.pnpm/asn1js@3.0.5/node_modules/asn1js/build/index.es.js + function assertBigInt() { + if (typeof BigInt === "undefined") { + throw new Error("BigInt is not defined. Your environment doesn't implement BigInt."); + } + } + function concat4(buffers) { + let outputLength = 0; + let prevLength = 0; + for (let i8 = 0; i8 < buffers.length; i8++) { + const buffer4 = buffers[i8]; + outputLength += buffer4.byteLength; + } + const retView = new Uint8Array(outputLength); + for (let i8 = 0; i8 < buffers.length; i8++) { + const buffer4 = buffers[i8]; + retView.set(new Uint8Array(buffer4), prevLength); + prevLength += buffer4.byteLength; + } + return retView.buffer; + } + function checkBufferParams(baseBlock, inputBuffer, inputOffset, inputLength) { + if (!(inputBuffer instanceof Uint8Array)) { + baseBlock.error = "Wrong parameter: inputBuffer must be 'Uint8Array'"; + return false; + } + if (!inputBuffer.byteLength) { + baseBlock.error = "Wrong parameter: inputBuffer has zero length"; + return false; + } + if (inputOffset < 0) { + baseBlock.error = "Wrong parameter: inputOffset less than zero"; + return false; + } + if (inputLength < 0) { + baseBlock.error = "Wrong parameter: inputLength less than zero"; + return false; + } + if (inputBuffer.byteLength - inputOffset - inputLength < 0) { + baseBlock.error = "End of input reached before message was fully decoded (inconsistent offset and length values)"; + return false; + } + return true; + } + var ViewWriter = class { + constructor() { + this.items = []; + } + write(buf3) { + this.items.push(buf3); + } + final() { + return concat4(this.items); + } + }; + var powers2 = [new Uint8Array([1])]; + var digitsString = "0123456789"; + var NAME = "name"; + var VALUE_HEX_VIEW = "valueHexView"; + var IS_HEX_ONLY = "isHexOnly"; + var ID_BLOCK = "idBlock"; + var TAG_CLASS = "tagClass"; + var TAG_NUMBER = "tagNumber"; + var IS_CONSTRUCTED = "isConstructed"; + var FROM_BER = "fromBER"; + var TO_BER = "toBER"; + var LOCAL = "local"; + var EMPTY_STRING = ""; + var EMPTY_BUFFER3 = new ArrayBuffer(0); + var EMPTY_VIEW = new Uint8Array(0); + var END_OF_CONTENT_NAME = "EndOfContent"; + var OCTET_STRING_NAME = "OCTET STRING"; + var BIT_STRING_NAME = "BIT STRING"; + function HexBlock(BaseClass) { + var _a2; + return _a2 = class Some extends BaseClass { + constructor(...args) { + var _a3; + super(...args); + const params = args[0] || {}; + this.isHexOnly = (_a3 = params.isHexOnly) !== null && _a3 !== void 0 ? _a3 : false; + this.valueHexView = params.valueHex ? pvtsutils.BufferSourceConverter.toUint8Array(params.valueHex) : EMPTY_VIEW; + } + get valueHex() { + return this.valueHexView.slice().buffer; + } + set valueHex(value) { + this.valueHexView = new Uint8Array(value); + } + fromBER(inputBuffer, inputOffset, inputLength) { + const view10 = inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer; + if (!checkBufferParams(this, view10, inputOffset, inputLength)) { + return -1; + } + const endLength = inputOffset + inputLength; + this.valueHexView = view10.subarray(inputOffset, endLength); + if (!this.valueHexView.length) { + this.warnings.push("Zero buffer length"); + return inputOffset; + } + this.blockLength = inputLength; + return endLength; + } + toBER(sizeOnly = false) { + if (!this.isHexOnly) { + this.error = "Flag 'isHexOnly' is not set, abort"; + return EMPTY_BUFFER3; + } + if (sizeOnly) { + return new ArrayBuffer(this.valueHexView.byteLength); + } + return this.valueHexView.byteLength === this.valueHexView.buffer.byteLength ? this.valueHexView.buffer : this.valueHexView.slice().buffer; + } + toJSON() { + return { + ...super.toJSON(), + isHexOnly: this.isHexOnly, + valueHex: pvtsutils.Convert.ToHex(this.valueHexView) + }; + } + }, _a2.NAME = "hexBlock", _a2; + } + var LocalBaseBlock = class { + constructor({ blockLength: blockLength2 = 0, error: error7 = EMPTY_STRING, warnings = [], valueBeforeDecode = EMPTY_VIEW } = {}) { + this.blockLength = blockLength2; + this.error = error7; + this.warnings = warnings; + this.valueBeforeDecodeView = pvtsutils.BufferSourceConverter.toUint8Array(valueBeforeDecode); + } + static blockName() { + return this.NAME; + } + get valueBeforeDecode() { + return this.valueBeforeDecodeView.slice().buffer; + } + set valueBeforeDecode(value) { + this.valueBeforeDecodeView = new Uint8Array(value); + } + toJSON() { + return { + blockName: this.constructor.NAME, + blockLength: this.blockLength, + error: this.error, + warnings: this.warnings, + valueBeforeDecode: pvtsutils.Convert.ToHex(this.valueBeforeDecodeView) + }; + } + }; + LocalBaseBlock.NAME = "baseBlock"; + var ValueBlock = class extends LocalBaseBlock { + fromBER(inputBuffer, inputOffset, inputLength) { + throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'"); + } + toBER(sizeOnly, writer2) { + throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'"); + } + }; + ValueBlock.NAME = "valueBlock"; + var LocalIdentificationBlock = class extends HexBlock(LocalBaseBlock) { + constructor({ idBlock = {} } = {}) { + var _a2, _b, _c, _d; + super(); + if (idBlock) { + this.isHexOnly = (_a2 = idBlock.isHexOnly) !== null && _a2 !== void 0 ? _a2 : false; + this.valueHexView = idBlock.valueHex ? pvtsutils.BufferSourceConverter.toUint8Array(idBlock.valueHex) : EMPTY_VIEW; + this.tagClass = (_b = idBlock.tagClass) !== null && _b !== void 0 ? _b : -1; + this.tagNumber = (_c = idBlock.tagNumber) !== null && _c !== void 0 ? _c : -1; + this.isConstructed = (_d = idBlock.isConstructed) !== null && _d !== void 0 ? _d : false; + } else { + this.tagClass = -1; + this.tagNumber = -1; + this.isConstructed = false; + } + } + toBER(sizeOnly = false) { + let firstOctet = 0; + switch (this.tagClass) { + case 1: + firstOctet |= 0; + break; + case 2: + firstOctet |= 64; + break; + case 3: + firstOctet |= 128; + break; + case 4: + firstOctet |= 192; + break; + default: + this.error = "Unknown tag class"; + return EMPTY_BUFFER3; + } + if (this.isConstructed) + firstOctet |= 32; + if (this.tagNumber < 31 && !this.isHexOnly) { + const retView2 = new Uint8Array(1); + if (!sizeOnly) { + let number3 = this.tagNumber; + number3 &= 31; + firstOctet |= number3; + retView2[0] = firstOctet; + } + return retView2.buffer; + } + if (!this.isHexOnly) { + const encodedBuf = utilToBase(this.tagNumber, 7); + const encodedView = new Uint8Array(encodedBuf); + const size4 = encodedBuf.byteLength; + const retView2 = new Uint8Array(size4 + 1); + retView2[0] = firstOctet | 31; + if (!sizeOnly) { + for (let i8 = 0; i8 < size4 - 1; i8++) + retView2[i8 + 1] = encodedView[i8] | 128; + retView2[size4] = encodedView[size4 - 1]; + } + return retView2.buffer; + } + const retView = new Uint8Array(this.valueHexView.byteLength + 1); + retView[0] = firstOctet | 31; + if (!sizeOnly) { + const curView = this.valueHexView; + for (let i8 = 0; i8 < curView.length - 1; i8++) + retView[i8 + 1] = curView[i8] | 128; + retView[this.valueHexView.byteLength] = curView[curView.length - 1]; + } + return retView.buffer; + } + fromBER(inputBuffer, inputOffset, inputLength) { + const inputView = pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer); + if (!checkBufferParams(this, inputView, inputOffset, inputLength)) { + return -1; + } + const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength); + if (intBuffer.length === 0) { + this.error = "Zero buffer length"; + return -1; + } + const tagClassMask = intBuffer[0] & 192; + switch (tagClassMask) { + case 0: + this.tagClass = 1; + break; + case 64: + this.tagClass = 2; + break; + case 128: + this.tagClass = 3; + break; + case 192: + this.tagClass = 4; + break; + default: + this.error = "Unknown tag class"; + return -1; + } + this.isConstructed = (intBuffer[0] & 32) === 32; + this.isHexOnly = false; + const tagNumberMask = intBuffer[0] & 31; + if (tagNumberMask !== 31) { + this.tagNumber = tagNumberMask; + this.blockLength = 1; + } else { + let count = 1; + let intTagNumberBuffer = this.valueHexView = new Uint8Array(255); + let tagNumberBufferMaxLength = 255; + while (intBuffer[count] & 128) { + intTagNumberBuffer[count - 1] = intBuffer[count] & 127; + count++; + if (count >= intBuffer.length) { + this.error = "End of input reached before message was fully decoded"; + return -1; + } + if (count === tagNumberBufferMaxLength) { + tagNumberBufferMaxLength += 255; + const tempBufferView2 = new Uint8Array(tagNumberBufferMaxLength); + for (let i8 = 0; i8 < intTagNumberBuffer.length; i8++) + tempBufferView2[i8] = intTagNumberBuffer[i8]; + intTagNumberBuffer = this.valueHexView = new Uint8Array(tagNumberBufferMaxLength); + } + } + this.blockLength = count + 1; + intTagNumberBuffer[count - 1] = intBuffer[count] & 127; + const tempBufferView = new Uint8Array(count); + for (let i8 = 0; i8 < count; i8++) + tempBufferView[i8] = intTagNumberBuffer[i8]; + intTagNumberBuffer = this.valueHexView = new Uint8Array(count); + intTagNumberBuffer.set(tempBufferView); + if (this.blockLength <= 9) + this.tagNumber = utilFromBase(intTagNumberBuffer, 7); + else { + this.isHexOnly = true; + this.warnings.push("Tag too long, represented as hex-coded"); + } + } + if (this.tagClass === 1 && this.isConstructed) { + switch (this.tagNumber) { + case 1: + case 2: + case 5: + case 6: + case 9: + case 13: + case 14: + case 23: + case 24: + case 31: + case 32: + case 33: + case 34: + this.error = "Constructed encoding used for primitive type"; + return -1; + } + } + return inputOffset + this.blockLength; + } + toJSON() { + return { + ...super.toJSON(), + tagClass: this.tagClass, + tagNumber: this.tagNumber, + isConstructed: this.isConstructed + }; + } + }; + LocalIdentificationBlock.NAME = "identificationBlock"; + var LocalLengthBlock = class extends LocalBaseBlock { + constructor({ lenBlock = {} } = {}) { + var _a2, _b, _c; + super(); + this.isIndefiniteForm = (_a2 = lenBlock.isIndefiniteForm) !== null && _a2 !== void 0 ? _a2 : false; + this.longFormUsed = (_b = lenBlock.longFormUsed) !== null && _b !== void 0 ? _b : false; + this.length = (_c = lenBlock.length) !== null && _c !== void 0 ? _c : 0; + } + fromBER(inputBuffer, inputOffset, inputLength) { + const view10 = pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer); + if (!checkBufferParams(this, view10, inputOffset, inputLength)) { + return -1; + } + const intBuffer = view10.subarray(inputOffset, inputOffset + inputLength); + if (intBuffer.length === 0) { + this.error = "Zero buffer length"; + return -1; + } + if (intBuffer[0] === 255) { + this.error = "Length block 0xFF is reserved by standard"; + return -1; + } + this.isIndefiniteForm = intBuffer[0] === 128; + if (this.isIndefiniteForm) { + this.blockLength = 1; + return inputOffset + this.blockLength; + } + this.longFormUsed = !!(intBuffer[0] & 128); + if (this.longFormUsed === false) { + this.length = intBuffer[0]; + this.blockLength = 1; + return inputOffset + this.blockLength; + } + const count = intBuffer[0] & 127; + if (count > 8) { + this.error = "Too big integer"; + return -1; + } + if (count + 1 > intBuffer.length) { + this.error = "End of input reached before message was fully decoded"; + return -1; + } + const lenOffset = inputOffset + 1; + const lengthBufferView = view10.subarray(lenOffset, lenOffset + count); + if (lengthBufferView[count - 1] === 0) + this.warnings.push("Needlessly long encoded length"); + this.length = utilFromBase(lengthBufferView, 8); + if (this.longFormUsed && this.length <= 127) + this.warnings.push("Unnecessary usage of long length form"); + this.blockLength = count + 1; + return inputOffset + this.blockLength; + } + toBER(sizeOnly = false) { + let retBuf; + let retView; + if (this.length > 127) + this.longFormUsed = true; + if (this.isIndefiniteForm) { + retBuf = new ArrayBuffer(1); + if (sizeOnly === false) { + retView = new Uint8Array(retBuf); + retView[0] = 128; + } + return retBuf; + } + if (this.longFormUsed) { + const encodedBuf = utilToBase(this.length, 8); + if (encodedBuf.byteLength > 127) { + this.error = "Too big length"; + return EMPTY_BUFFER3; + } + retBuf = new ArrayBuffer(encodedBuf.byteLength + 1); + if (sizeOnly) + return retBuf; + const encodedView = new Uint8Array(encodedBuf); + retView = new Uint8Array(retBuf); + retView[0] = encodedBuf.byteLength | 128; + for (let i8 = 0; i8 < encodedBuf.byteLength; i8++) + retView[i8 + 1] = encodedView[i8]; + return retBuf; + } + retBuf = new ArrayBuffer(1); + if (sizeOnly === false) { + retView = new Uint8Array(retBuf); + retView[0] = this.length; + } + return retBuf; + } + toJSON() { + return { + ...super.toJSON(), + isIndefiniteForm: this.isIndefiniteForm, + longFormUsed: this.longFormUsed, + length: this.length + }; + } + }; + LocalLengthBlock.NAME = "lengthBlock"; + var typeStore = {}; + var BaseBlock = class extends LocalBaseBlock { + constructor({ name: name15 = EMPTY_STRING, optional: optional5 = false, primitiveSchema, ...parameters } = {}, valueBlockType) { + super(parameters); + this.name = name15; + this.optional = optional5; + if (primitiveSchema) { + this.primitiveSchema = primitiveSchema; + } + this.idBlock = new LocalIdentificationBlock(parameters); + this.lenBlock = new LocalLengthBlock(parameters); + this.valueBlock = valueBlockType ? new valueBlockType(parameters) : new ValueBlock(parameters); + } + fromBER(inputBuffer, inputOffset, inputLength) { + const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length); + if (resultOffset === -1) { + this.error = this.valueBlock.error; + return resultOffset; + } + if (!this.idBlock.error.length) + this.blockLength += this.idBlock.blockLength; + if (!this.lenBlock.error.length) + this.blockLength += this.lenBlock.blockLength; + if (!this.valueBlock.error.length) + this.blockLength += this.valueBlock.blockLength; + return resultOffset; + } + toBER(sizeOnly, writer2) { + const _writer = writer2 || new ViewWriter(); + if (!writer2) { + prepareIndefiniteForm(this); + } + const idBlockBuf = this.idBlock.toBER(sizeOnly); + _writer.write(idBlockBuf); + if (this.lenBlock.isIndefiniteForm) { + _writer.write(new Uint8Array([128]).buffer); + this.valueBlock.toBER(sizeOnly, _writer); + _writer.write(new ArrayBuffer(2)); + } else { + const valueBlockBuf = this.valueBlock.toBER(sizeOnly); + this.lenBlock.length = valueBlockBuf.byteLength; + const lenBlockBuf = this.lenBlock.toBER(sizeOnly); + _writer.write(lenBlockBuf); + _writer.write(valueBlockBuf); + } + if (!writer2) { + return _writer.final(); + } + return EMPTY_BUFFER3; + } + toJSON() { + const object = { + ...super.toJSON(), + idBlock: this.idBlock.toJSON(), + lenBlock: this.lenBlock.toJSON(), + valueBlock: this.valueBlock.toJSON(), + name: this.name, + optional: this.optional + }; + if (this.primitiveSchema) + object.primitiveSchema = this.primitiveSchema.toJSON(); + return object; + } + toString(encoding = "ascii") { + if (encoding === "ascii") { + return this.onAsciiEncoding(); + } + return pvtsutils.Convert.ToHex(this.toBER()); + } + onAsciiEncoding() { + return `${this.constructor.NAME} : ${pvtsutils.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`; + } + isEqual(other) { + if (this === other) { + return true; + } + if (!(other instanceof this.constructor)) { + return false; + } + const thisRaw = this.toBER(); + const otherRaw = other.toBER(); + return isEqualBuffer(thisRaw, otherRaw); + } + }; + BaseBlock.NAME = "BaseBlock"; + function prepareIndefiniteForm(baseBlock) { + if (baseBlock instanceof typeStore.Constructed) { + for (const value of baseBlock.valueBlock.value) { + if (prepareIndefiniteForm(value)) { + baseBlock.lenBlock.isIndefiniteForm = true; + } + } + } + return !!baseBlock.lenBlock.isIndefiniteForm; + } + var BaseStringBlock = class extends BaseBlock { + constructor({ value = EMPTY_STRING, ...parameters } = {}, stringValueBlockType) { + super(parameters, stringValueBlockType); + if (value) { + this.fromString(value); + } + } + getValue() { + return this.valueBlock.value; + } + setValue(value) { + this.valueBlock.value = value; + } + fromBER(inputBuffer, inputOffset, inputLength) { + const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length); + if (resultOffset === -1) { + this.error = this.valueBlock.error; + return resultOffset; + } + this.fromBuffer(this.valueBlock.valueHexView); + if (!this.idBlock.error.length) + this.blockLength += this.idBlock.blockLength; + if (!this.lenBlock.error.length) + this.blockLength += this.lenBlock.blockLength; + if (!this.valueBlock.error.length) + this.blockLength += this.valueBlock.blockLength; + return resultOffset; + } + onAsciiEncoding() { + return `${this.constructor.NAME} : '${this.valueBlock.value}'`; + } + }; + BaseStringBlock.NAME = "BaseStringBlock"; + var LocalPrimitiveValueBlock = class extends HexBlock(ValueBlock) { + constructor({ isHexOnly = true, ...parameters } = {}) { + super(parameters); + this.isHexOnly = isHexOnly; + } + }; + LocalPrimitiveValueBlock.NAME = "PrimitiveValueBlock"; + var _a$w; + var Primitive = class extends BaseBlock { + constructor(parameters = {}) { + super(parameters, LocalPrimitiveValueBlock); + this.idBlock.isConstructed = false; + } + }; + _a$w = Primitive; + (() => { + typeStore.Primitive = _a$w; + })(); + Primitive.NAME = "PRIMITIVE"; + function localChangeType(inputObject, newType) { + if (inputObject instanceof newType) { + return inputObject; + } + const newObject = new newType(); + newObject.idBlock = inputObject.idBlock; + newObject.lenBlock = inputObject.lenBlock; + newObject.warnings = inputObject.warnings; + newObject.valueBeforeDecodeView = inputObject.valueBeforeDecodeView; + return newObject; + } + function localFromBER(inputBuffer, inputOffset = 0, inputLength = inputBuffer.length) { + const incomingOffset = inputOffset; + let returnObject = new BaseBlock({}, ValueBlock); + const baseBlock = new LocalBaseBlock(); + if (!checkBufferParams(baseBlock, inputBuffer, inputOffset, inputLength)) { + returnObject.error = baseBlock.error; + return { + offset: -1, + result: returnObject + }; + } + const intBuffer = inputBuffer.subarray(inputOffset, inputOffset + inputLength); + if (!intBuffer.length) { + returnObject.error = "Zero buffer length"; + return { + offset: -1, + result: returnObject + }; + } + let resultOffset = returnObject.idBlock.fromBER(inputBuffer, inputOffset, inputLength); + if (returnObject.idBlock.warnings.length) { + returnObject.warnings.concat(returnObject.idBlock.warnings); + } + if (resultOffset === -1) { + returnObject.error = returnObject.idBlock.error; + return { + offset: -1, + result: returnObject + }; + } + inputOffset = resultOffset; + inputLength -= returnObject.idBlock.blockLength; + resultOffset = returnObject.lenBlock.fromBER(inputBuffer, inputOffset, inputLength); + if (returnObject.lenBlock.warnings.length) { + returnObject.warnings.concat(returnObject.lenBlock.warnings); + } + if (resultOffset === -1) { + returnObject.error = returnObject.lenBlock.error; + return { + offset: -1, + result: returnObject + }; + } + inputOffset = resultOffset; + inputLength -= returnObject.lenBlock.blockLength; + if (!returnObject.idBlock.isConstructed && returnObject.lenBlock.isIndefiniteForm) { + returnObject.error = "Indefinite length form used for primitive encoding form"; + return { + offset: -1, + result: returnObject + }; + } + let newASN1Type = BaseBlock; + switch (returnObject.idBlock.tagClass) { + case 1: + if (returnObject.idBlock.tagNumber >= 37 && returnObject.idBlock.isHexOnly === false) { + returnObject.error = "UNIVERSAL 37 and upper tags are reserved by ASN.1 standard"; + return { + offset: -1, + result: returnObject + }; + } + switch (returnObject.idBlock.tagNumber) { + case 0: + if (returnObject.idBlock.isConstructed && returnObject.lenBlock.length > 0) { + returnObject.error = "Type [UNIVERSAL 0] is reserved"; + return { + offset: -1, + result: returnObject + }; + } + newASN1Type = typeStore.EndOfContent; + break; + case 1: + newASN1Type = typeStore.Boolean; + break; + case 2: + newASN1Type = typeStore.Integer; + break; + case 3: + newASN1Type = typeStore.BitString; + break; + case 4: + newASN1Type = typeStore.OctetString; + break; + case 5: + newASN1Type = typeStore.Null; + break; + case 6: + newASN1Type = typeStore.ObjectIdentifier; + break; + case 10: + newASN1Type = typeStore.Enumerated; + break; + case 12: + newASN1Type = typeStore.Utf8String; + break; + case 13: + newASN1Type = typeStore.RelativeObjectIdentifier; + break; + case 14: + newASN1Type = typeStore.TIME; + break; + case 15: + returnObject.error = "[UNIVERSAL 15] is reserved by ASN.1 standard"; + return { + offset: -1, + result: returnObject + }; + case 16: + newASN1Type = typeStore.Sequence; + break; + case 17: + newASN1Type = typeStore.Set; + break; + case 18: + newASN1Type = typeStore.NumericString; + break; + case 19: + newASN1Type = typeStore.PrintableString; + break; + case 20: + newASN1Type = typeStore.TeletexString; + break; + case 21: + newASN1Type = typeStore.VideotexString; + break; + case 22: + newASN1Type = typeStore.IA5String; + break; + case 23: + newASN1Type = typeStore.UTCTime; + break; + case 24: + newASN1Type = typeStore.GeneralizedTime; + break; + case 25: + newASN1Type = typeStore.GraphicString; + break; + case 26: + newASN1Type = typeStore.VisibleString; + break; + case 27: + newASN1Type = typeStore.GeneralString; + break; + case 28: + newASN1Type = typeStore.UniversalString; + break; + case 29: + newASN1Type = typeStore.CharacterString; + break; + case 30: + newASN1Type = typeStore.BmpString; + break; + case 31: + newASN1Type = typeStore.DATE; + break; + case 32: + newASN1Type = typeStore.TimeOfDay; + break; + case 33: + newASN1Type = typeStore.DateTime; + break; + case 34: + newASN1Type = typeStore.Duration; + break; + default: { + const newObject = returnObject.idBlock.isConstructed ? new typeStore.Constructed() : new typeStore.Primitive(); + newObject.idBlock = returnObject.idBlock; + newObject.lenBlock = returnObject.lenBlock; + newObject.warnings = returnObject.warnings; + returnObject = newObject; + } + } + break; + case 2: + case 3: + case 4: + default: { + newASN1Type = returnObject.idBlock.isConstructed ? typeStore.Constructed : typeStore.Primitive; + } + } + returnObject = localChangeType(returnObject, newASN1Type); + resultOffset = returnObject.fromBER(inputBuffer, inputOffset, returnObject.lenBlock.isIndefiniteForm ? inputLength : returnObject.lenBlock.length); + returnObject.valueBeforeDecodeView = inputBuffer.subarray(incomingOffset, incomingOffset + returnObject.blockLength); + return { + offset: resultOffset, + result: returnObject + }; + } + function fromBER(inputBuffer) { + if (!inputBuffer.byteLength) { + const result = new BaseBlock({}, ValueBlock); + result.error = "Input buffer has zero length"; + return { + offset: -1, + result + }; + } + return localFromBER(pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer).slice(), 0, inputBuffer.byteLength); + } + function checkLen(indefiniteLength, length3) { + if (indefiniteLength) { + return 1; + } + return length3; + } + var LocalConstructedValueBlock = class extends ValueBlock { + constructor({ value = [], isIndefiniteForm = false, ...parameters } = {}) { + super(parameters); + this.value = value; + this.isIndefiniteForm = isIndefiniteForm; + } + fromBER(inputBuffer, inputOffset, inputLength) { + const view10 = pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer); + if (!checkBufferParams(this, view10, inputOffset, inputLength)) { + return -1; + } + this.valueBeforeDecodeView = view10.subarray(inputOffset, inputOffset + inputLength); + if (this.valueBeforeDecodeView.length === 0) { + this.warnings.push("Zero buffer length"); + return inputOffset; + } + let currentOffset = inputOffset; + while (checkLen(this.isIndefiniteForm, inputLength) > 0) { + const returnObject = localFromBER(view10, currentOffset, inputLength); + if (returnObject.offset === -1) { + this.error = returnObject.result.error; + this.warnings.concat(returnObject.result.warnings); + return -1; + } + currentOffset = returnObject.offset; + this.blockLength += returnObject.result.blockLength; + inputLength -= returnObject.result.blockLength; + this.value.push(returnObject.result); + if (this.isIndefiniteForm && returnObject.result.constructor.NAME === END_OF_CONTENT_NAME) { + break; + } + } + if (this.isIndefiniteForm) { + if (this.value[this.value.length - 1].constructor.NAME === END_OF_CONTENT_NAME) { + this.value.pop(); + } else { + this.warnings.push("No EndOfContent block encoded"); + } + } + return currentOffset; + } + toBER(sizeOnly, writer2) { + const _writer = writer2 || new ViewWriter(); + for (let i8 = 0; i8 < this.value.length; i8++) { + this.value[i8].toBER(sizeOnly, _writer); + } + if (!writer2) { + return _writer.final(); + } + return EMPTY_BUFFER3; + } + toJSON() { + const object = { + ...super.toJSON(), + isIndefiniteForm: this.isIndefiniteForm, + value: [] + }; + for (const value of this.value) { + object.value.push(value.toJSON()); + } + return object; + } + }; + LocalConstructedValueBlock.NAME = "ConstructedValueBlock"; + var _a$v; + var Constructed = class extends BaseBlock { + constructor(parameters = {}) { + super(parameters, LocalConstructedValueBlock); + this.idBlock.isConstructed = true; + } + fromBER(inputBuffer, inputOffset, inputLength) { + this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm; + const resultOffset = this.valueBlock.fromBER(inputBuffer, inputOffset, this.lenBlock.isIndefiniteForm ? inputLength : this.lenBlock.length); + if (resultOffset === -1) { + this.error = this.valueBlock.error; + return resultOffset; + } + if (!this.idBlock.error.length) + this.blockLength += this.idBlock.blockLength; + if (!this.lenBlock.error.length) + this.blockLength += this.lenBlock.blockLength; + if (!this.valueBlock.error.length) + this.blockLength += this.valueBlock.blockLength; + return resultOffset; + } + onAsciiEncoding() { + const values2 = []; + for (const value of this.valueBlock.value) { + values2.push(value.toString("ascii").split("\n").map((o9) => ` ${o9}`).join("\n")); + } + const blockName = this.idBlock.tagClass === 3 ? `[${this.idBlock.tagNumber}]` : this.constructor.NAME; + return values2.length ? `${blockName} : +${values2.join("\n")}` : `${blockName} :`; + } + }; + _a$v = Constructed; + (() => { + typeStore.Constructed = _a$v; + })(); + Constructed.NAME = "CONSTRUCTED"; + var LocalEndOfContentValueBlock = class extends ValueBlock { + fromBER(inputBuffer, inputOffset, inputLength) { + return inputOffset; + } + toBER(sizeOnly) { + return EMPTY_BUFFER3; + } + }; + LocalEndOfContentValueBlock.override = "EndOfContentValueBlock"; + var _a$u; + var EndOfContent = class extends BaseBlock { + constructor(parameters = {}) { + super(parameters, LocalEndOfContentValueBlock); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 0; + } + }; + _a$u = EndOfContent; + (() => { + typeStore.EndOfContent = _a$u; + })(); + EndOfContent.NAME = END_OF_CONTENT_NAME; + var _a$t; + var Null = class extends BaseBlock { + constructor(parameters = {}) { + super(parameters, ValueBlock); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 5; + } + fromBER(inputBuffer, inputOffset, inputLength) { + if (this.lenBlock.length > 0) + this.warnings.push("Non-zero length of value block for Null type"); + if (!this.idBlock.error.length) + this.blockLength += this.idBlock.blockLength; + if (!this.lenBlock.error.length) + this.blockLength += this.lenBlock.blockLength; + this.blockLength += inputLength; + if (inputOffset + inputLength > inputBuffer.byteLength) { + this.error = "End of input reached before message was fully decoded (inconsistent offset and length values)"; + return -1; + } + return inputOffset + inputLength; + } + toBER(sizeOnly, writer2) { + const retBuf = new ArrayBuffer(2); + if (!sizeOnly) { + const retView = new Uint8Array(retBuf); + retView[0] = 5; + retView[1] = 0; + } + if (writer2) { + writer2.write(retBuf); + } + return retBuf; + } + onAsciiEncoding() { + return `${this.constructor.NAME}`; + } + }; + _a$t = Null; + (() => { + typeStore.Null = _a$t; + })(); + Null.NAME = "NULL"; + var LocalBooleanValueBlock = class extends HexBlock(ValueBlock) { + constructor({ value, ...parameters } = {}) { + super(parameters); + if (parameters.valueHex) { + this.valueHexView = pvtsutils.BufferSourceConverter.toUint8Array(parameters.valueHex); + } else { + this.valueHexView = new Uint8Array(1); + } + if (value) { + this.value = value; + } + } + get value() { + for (const octet of this.valueHexView) { + if (octet > 0) { + return true; + } + } + return false; + } + set value(value) { + this.valueHexView[0] = value ? 255 : 0; + } + fromBER(inputBuffer, inputOffset, inputLength) { + const inputView = pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer); + if (!checkBufferParams(this, inputView, inputOffset, inputLength)) { + return -1; + } + this.valueHexView = inputView.subarray(inputOffset, inputOffset + inputLength); + if (inputLength > 1) + this.warnings.push("Boolean value encoded in more then 1 octet"); + this.isHexOnly = true; + utilDecodeTC.call(this); + this.blockLength = inputLength; + return inputOffset + inputLength; + } + toBER() { + return this.valueHexView.slice(); + } + toJSON() { + return { + ...super.toJSON(), + value: this.value + }; + } + }; + LocalBooleanValueBlock.NAME = "BooleanValueBlock"; + var _a$s; + var Boolean4 = class extends BaseBlock { + constructor(parameters = {}) { + super(parameters, LocalBooleanValueBlock); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 1; + } + getValue() { + return this.valueBlock.value; + } + setValue(value) { + this.valueBlock.value = value; + } + onAsciiEncoding() { + return `${this.constructor.NAME} : ${this.getValue}`; + } + }; + _a$s = Boolean4; + (() => { + typeStore.Boolean = _a$s; + })(); + Boolean4.NAME = "BOOLEAN"; + var LocalOctetStringValueBlock = class extends HexBlock(LocalConstructedValueBlock) { + constructor({ isConstructed = false, ...parameters } = {}) { + super(parameters); + this.isConstructed = isConstructed; + } + fromBER(inputBuffer, inputOffset, inputLength) { + let resultOffset = 0; + if (this.isConstructed) { + this.isHexOnly = false; + resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength); + if (resultOffset === -1) + return resultOffset; + for (let i8 = 0; i8 < this.value.length; i8++) { + const currentBlockName = this.value[i8].constructor.NAME; + if (currentBlockName === END_OF_CONTENT_NAME) { + if (this.isIndefiniteForm) + break; + else { + this.error = "EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only"; + return -1; + } + } + if (currentBlockName !== OCTET_STRING_NAME) { + this.error = "OCTET STRING may consists of OCTET STRINGs only"; + return -1; + } + } + } else { + this.isHexOnly = true; + resultOffset = super.fromBER(inputBuffer, inputOffset, inputLength); + this.blockLength = inputLength; + } + return resultOffset; + } + toBER(sizeOnly, writer2) { + if (this.isConstructed) + return LocalConstructedValueBlock.prototype.toBER.call(this, sizeOnly, writer2); + return sizeOnly ? new ArrayBuffer(this.valueHexView.byteLength) : this.valueHexView.slice().buffer; + } + toJSON() { + return { + ...super.toJSON(), + isConstructed: this.isConstructed + }; + } + }; + LocalOctetStringValueBlock.NAME = "OctetStringValueBlock"; + var _a$r; + var OctetString = class _OctetString extends BaseBlock { + constructor({ idBlock = {}, lenBlock = {}, ...parameters } = {}) { + var _b, _c; + (_b = parameters.isConstructed) !== null && _b !== void 0 ? _b : parameters.isConstructed = !!((_c = parameters.value) === null || _c === void 0 ? void 0 : _c.length); + super({ + idBlock: { + isConstructed: parameters.isConstructed, + ...idBlock + }, + lenBlock: { + ...lenBlock, + isIndefiniteForm: !!parameters.isIndefiniteForm + }, + ...parameters + }, LocalOctetStringValueBlock); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 4; + } + fromBER(inputBuffer, inputOffset, inputLength) { + this.valueBlock.isConstructed = this.idBlock.isConstructed; + this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm; + if (inputLength === 0) { + if (this.idBlock.error.length === 0) + this.blockLength += this.idBlock.blockLength; + if (this.lenBlock.error.length === 0) + this.blockLength += this.lenBlock.blockLength; + return inputOffset; + } + if (!this.valueBlock.isConstructed) { + const view10 = inputBuffer instanceof ArrayBuffer ? new Uint8Array(inputBuffer) : inputBuffer; + const buf3 = view10.subarray(inputOffset, inputOffset + inputLength); + try { + if (buf3.byteLength) { + const asn = localFromBER(buf3, 0, buf3.byteLength); + if (asn.offset !== -1 && asn.offset === inputLength) { + this.valueBlock.value = [asn.result]; + } + } + } catch (e12) { + } + } + return super.fromBER(inputBuffer, inputOffset, inputLength); + } + onAsciiEncoding() { + if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) { + return Constructed.prototype.onAsciiEncoding.call(this); + } + return `${this.constructor.NAME} : ${pvtsutils.Convert.ToHex(this.valueBlock.valueHexView)}`; + } + getValue() { + if (!this.idBlock.isConstructed) { + return this.valueBlock.valueHexView.slice().buffer; + } + const array3 = []; + for (const content of this.valueBlock.value) { + if (content instanceof _OctetString) { + array3.push(content.valueBlock.valueHexView); + } + } + return pvtsutils.BufferSourceConverter.concat(array3); + } + }; + _a$r = OctetString; + (() => { + typeStore.OctetString = _a$r; + })(); + OctetString.NAME = OCTET_STRING_NAME; + var LocalBitStringValueBlock = class extends HexBlock(LocalConstructedValueBlock) { + constructor({ unusedBits = 0, isConstructed = false, ...parameters } = {}) { + super(parameters); + this.unusedBits = unusedBits; + this.isConstructed = isConstructed; + this.blockLength = this.valueHexView.byteLength; + } + fromBER(inputBuffer, inputOffset, inputLength) { + if (!inputLength) { + return inputOffset; + } + let resultOffset = -1; + if (this.isConstructed) { + resultOffset = LocalConstructedValueBlock.prototype.fromBER.call(this, inputBuffer, inputOffset, inputLength); + if (resultOffset === -1) + return resultOffset; + for (const value of this.value) { + const currentBlockName = value.constructor.NAME; + if (currentBlockName === END_OF_CONTENT_NAME) { + if (this.isIndefiniteForm) + break; + else { + this.error = "EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only"; + return -1; + } + } + if (currentBlockName !== BIT_STRING_NAME) { + this.error = "BIT STRING may consists of BIT STRINGs only"; + return -1; + } + const valueBlock = value.valueBlock; + if (this.unusedBits > 0 && valueBlock.unusedBits > 0) { + this.error = 'Using of "unused bits" inside constructive BIT STRING allowed for least one only'; + return -1; + } + this.unusedBits = valueBlock.unusedBits; + } + return resultOffset; + } + const inputView = pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer); + if (!checkBufferParams(this, inputView, inputOffset, inputLength)) { + return -1; + } + const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength); + this.unusedBits = intBuffer[0]; + if (this.unusedBits > 7) { + this.error = "Unused bits for BitString must be in range 0-7"; + return -1; + } + if (!this.unusedBits) { + const buf3 = intBuffer.subarray(1); + try { + if (buf3.byteLength) { + const asn = localFromBER(buf3, 0, buf3.byteLength); + if (asn.offset !== -1 && asn.offset === inputLength - 1) { + this.value = [asn.result]; + } + } + } catch (e12) { + } + } + this.valueHexView = intBuffer.subarray(1); + this.blockLength = intBuffer.length; + return inputOffset + inputLength; + } + toBER(sizeOnly, writer2) { + if (this.isConstructed) { + return LocalConstructedValueBlock.prototype.toBER.call(this, sizeOnly, writer2); + } + if (sizeOnly) { + return new ArrayBuffer(this.valueHexView.byteLength + 1); + } + if (!this.valueHexView.byteLength) { + return EMPTY_BUFFER3; + } + const retView = new Uint8Array(this.valueHexView.length + 1); + retView[0] = this.unusedBits; + retView.set(this.valueHexView, 1); + return retView.buffer; + } + toJSON() { + return { + ...super.toJSON(), + unusedBits: this.unusedBits, + isConstructed: this.isConstructed + }; + } + }; + LocalBitStringValueBlock.NAME = "BitStringValueBlock"; + var _a$q; + var BitString = class extends BaseBlock { + constructor({ idBlock = {}, lenBlock = {}, ...parameters } = {}) { + var _b, _c; + (_b = parameters.isConstructed) !== null && _b !== void 0 ? _b : parameters.isConstructed = !!((_c = parameters.value) === null || _c === void 0 ? void 0 : _c.length); + super({ + idBlock: { + isConstructed: parameters.isConstructed, + ...idBlock + }, + lenBlock: { + ...lenBlock, + isIndefiniteForm: !!parameters.isIndefiniteForm + }, + ...parameters + }, LocalBitStringValueBlock); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 3; + } + fromBER(inputBuffer, inputOffset, inputLength) { + this.valueBlock.isConstructed = this.idBlock.isConstructed; + this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm; + return super.fromBER(inputBuffer, inputOffset, inputLength); + } + onAsciiEncoding() { + if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length) { + return Constructed.prototype.onAsciiEncoding.call(this); + } else { + const bits = []; + const valueHex = this.valueBlock.valueHexView; + for (const byte of valueHex) { + bits.push(byte.toString(2).padStart(8, "0")); + } + const bitsStr = bits.join(""); + return `${this.constructor.NAME} : ${bitsStr.substring(0, bitsStr.length - this.valueBlock.unusedBits)}`; + } + } + }; + _a$q = BitString; + (() => { + typeStore.BitString = _a$q; + })(); + BitString.NAME = BIT_STRING_NAME; + var _a$p; + function viewAdd(first, second) { + const c8 = new Uint8Array([0]); + const firstView = new Uint8Array(first); + const secondView = new Uint8Array(second); + let firstViewCopy = firstView.slice(0); + const firstViewCopyLength = firstViewCopy.length - 1; + const secondViewCopy = secondView.slice(0); + const secondViewCopyLength = secondViewCopy.length - 1; + let value = 0; + const max = secondViewCopyLength < firstViewCopyLength ? firstViewCopyLength : secondViewCopyLength; + let counter = 0; + for (let i8 = max; i8 >= 0; i8--, counter++) { + switch (true) { + case counter < secondViewCopy.length: + value = firstViewCopy[firstViewCopyLength - counter] + secondViewCopy[secondViewCopyLength - counter] + c8[0]; + break; + default: + value = firstViewCopy[firstViewCopyLength - counter] + c8[0]; + } + c8[0] = value / 10; + switch (true) { + case counter >= firstViewCopy.length: + firstViewCopy = utilConcatView(new Uint8Array([value % 10]), firstViewCopy); + break; + default: + firstViewCopy[firstViewCopyLength - counter] = value % 10; + } + } + if (c8[0] > 0) + firstViewCopy = utilConcatView(c8, firstViewCopy); + return firstViewCopy; + } + function power2(n9) { + if (n9 >= powers2.length) { + for (let p8 = powers2.length; p8 <= n9; p8++) { + const c8 = new Uint8Array([0]); + let digits = powers2[p8 - 1].slice(0); + for (let i8 = digits.length - 1; i8 >= 0; i8--) { + const newValue = new Uint8Array([(digits[i8] << 1) + c8[0]]); + c8[0] = newValue[0] / 10; + digits[i8] = newValue[0] % 10; + } + if (c8[0] > 0) + digits = utilConcatView(c8, digits); + powers2.push(digits); + } + } + return powers2[n9]; + } + function viewSub(first, second) { + let b6 = 0; + const firstView = new Uint8Array(first); + const secondView = new Uint8Array(second); + const firstViewCopy = firstView.slice(0); + const firstViewCopyLength = firstViewCopy.length - 1; + const secondViewCopy = secondView.slice(0); + const secondViewCopyLength = secondViewCopy.length - 1; + let value; + let counter = 0; + for (let i8 = secondViewCopyLength; i8 >= 0; i8--, counter++) { + value = firstViewCopy[firstViewCopyLength - counter] - secondViewCopy[secondViewCopyLength - counter] - b6; + switch (true) { + case value < 0: + b6 = 1; + firstViewCopy[firstViewCopyLength - counter] = value + 10; + break; + default: + b6 = 0; + firstViewCopy[firstViewCopyLength - counter] = value; + } + } + if (b6 > 0) { + for (let i8 = firstViewCopyLength - secondViewCopyLength + 1; i8 >= 0; i8--, counter++) { + value = firstViewCopy[firstViewCopyLength - counter] - b6; + if (value < 0) { + b6 = 1; + firstViewCopy[firstViewCopyLength - counter] = value + 10; + } else { + b6 = 0; + firstViewCopy[firstViewCopyLength - counter] = value; + break; + } + } + } + return firstViewCopy.slice(); + } + var LocalIntegerValueBlock = class extends HexBlock(ValueBlock) { + constructor({ value, ...parameters } = {}) { + super(parameters); + this._valueDec = 0; + if (parameters.valueHex) { + this.setValueHex(); + } + if (value !== void 0) { + this.valueDec = value; + } + } + setValueHex() { + if (this.valueHexView.length >= 4) { + this.warnings.push("Too big Integer for decoding, hex only"); + this.isHexOnly = true; + this._valueDec = 0; + } else { + this.isHexOnly = false; + if (this.valueHexView.length > 0) { + this._valueDec = utilDecodeTC.call(this); + } + } + } + set valueDec(v7) { + this._valueDec = v7; + this.isHexOnly = false; + this.valueHexView = new Uint8Array(utilEncodeTC(v7)); + } + get valueDec() { + return this._valueDec; + } + fromDER(inputBuffer, inputOffset, inputLength, expectedLength = 0) { + const offset2 = this.fromBER(inputBuffer, inputOffset, inputLength); + if (offset2 === -1) + return offset2; + const view10 = this.valueHexView; + if (view10[0] === 0 && (view10[1] & 128) !== 0) { + this.valueHexView = view10.subarray(1); + } else { + if (expectedLength !== 0) { + if (view10.length < expectedLength) { + if (expectedLength - view10.length > 1) + expectedLength = view10.length + 1; + this.valueHexView = view10.subarray(expectedLength - view10.length); + } + } + } + return offset2; + } + toDER(sizeOnly = false) { + const view10 = this.valueHexView; + switch (true) { + case (view10[0] & 128) !== 0: + { + const updatedView = new Uint8Array(this.valueHexView.length + 1); + updatedView[0] = 0; + updatedView.set(view10, 1); + this.valueHexView = updatedView; + } + break; + case (view10[0] === 0 && (view10[1] & 128) === 0): + { + this.valueHexView = this.valueHexView.subarray(1); + } + break; + } + return this.toBER(sizeOnly); + } + fromBER(inputBuffer, inputOffset, inputLength) { + const resultOffset = super.fromBER(inputBuffer, inputOffset, inputLength); + if (resultOffset === -1) { + return resultOffset; + } + this.setValueHex(); + return resultOffset; + } + toBER(sizeOnly) { + return sizeOnly ? new ArrayBuffer(this.valueHexView.length) : this.valueHexView.slice().buffer; + } + toJSON() { + return { + ...super.toJSON(), + valueDec: this.valueDec + }; + } + toString() { + const firstBit = this.valueHexView.length * 8 - 1; + let digits = new Uint8Array(this.valueHexView.length * 8 / 3); + let bitNumber = 0; + let currentByte; + const asn1View = this.valueHexView; + let result = ""; + let flag = false; + for (let byteNumber = asn1View.byteLength - 1; byteNumber >= 0; byteNumber--) { + currentByte = asn1View[byteNumber]; + for (let i8 = 0; i8 < 8; i8++) { + if ((currentByte & 1) === 1) { + switch (bitNumber) { + case firstBit: + digits = viewSub(power2(bitNumber), digits); + result = "-"; + break; + default: + digits = viewAdd(digits, power2(bitNumber)); + } + } + bitNumber++; + currentByte >>= 1; + } + } + for (let i8 = 0; i8 < digits.length; i8++) { + if (digits[i8]) + flag = true; + if (flag) + result += digitsString.charAt(digits[i8]); + } + if (flag === false) + result += digitsString.charAt(0); + return result; + } + }; + _a$p = LocalIntegerValueBlock; + LocalIntegerValueBlock.NAME = "IntegerValueBlock"; + (() => { + Object.defineProperty(_a$p.prototype, "valueHex", { + set: function(v7) { + this.valueHexView = new Uint8Array(v7); + this.setValueHex(); + }, + get: function() { + return this.valueHexView.slice().buffer; + } + }); + })(); + var _a$o; + var Integer3 = class _Integer extends BaseBlock { + constructor(parameters = {}) { + super(parameters, LocalIntegerValueBlock); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 2; + } + toBigInt() { + assertBigInt(); + return BigInt(this.valueBlock.toString()); + } + static fromBigInt(value) { + assertBigInt(); + const bigIntValue = BigInt(value); + const writer2 = new ViewWriter(); + const hex = bigIntValue.toString(16).replace(/^-/, ""); + const view10 = new Uint8Array(pvtsutils.Convert.FromHex(hex)); + if (bigIntValue < 0) { + const first = new Uint8Array(view10.length + (view10[0] & 128 ? 1 : 0)); + first[0] |= 128; + const firstInt = BigInt(`0x${pvtsutils.Convert.ToHex(first)}`); + const secondInt = firstInt + bigIntValue; + const second = pvtsutils.BufferSourceConverter.toUint8Array(pvtsutils.Convert.FromHex(secondInt.toString(16))); + second[0] |= 128; + writer2.write(second); + } else { + if (view10[0] & 128) { + writer2.write(new Uint8Array([0])); + } + writer2.write(view10); + } + const res = new _Integer({ + valueHex: writer2.final() + }); + return res; + } + convertToDER() { + const integer3 = new _Integer({ valueHex: this.valueBlock.valueHexView }); + integer3.valueBlock.toDER(); + return integer3; + } + convertFromDER() { + return new _Integer({ + valueHex: this.valueBlock.valueHexView[0] === 0 ? this.valueBlock.valueHexView.subarray(1) : this.valueBlock.valueHexView + }); + } + onAsciiEncoding() { + return `${this.constructor.NAME} : ${this.valueBlock.toString()}`; + } + }; + _a$o = Integer3; + (() => { + typeStore.Integer = _a$o; + })(); + Integer3.NAME = "INTEGER"; + var _a$n; + var Enumerated = class extends Integer3 { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 10; + } + }; + _a$n = Enumerated; + (() => { + typeStore.Enumerated = _a$n; + })(); + Enumerated.NAME = "ENUMERATED"; + var LocalSidValueBlock = class extends HexBlock(ValueBlock) { + constructor({ valueDec = -1, isFirstSid = false, ...parameters } = {}) { + super(parameters); + this.valueDec = valueDec; + this.isFirstSid = isFirstSid; + } + fromBER(inputBuffer, inputOffset, inputLength) { + if (!inputLength) { + return inputOffset; + } + const inputView = pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer); + if (!checkBufferParams(this, inputView, inputOffset, inputLength)) { + return -1; + } + const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength); + this.valueHexView = new Uint8Array(inputLength); + for (let i8 = 0; i8 < inputLength; i8++) { + this.valueHexView[i8] = intBuffer[i8] & 127; + this.blockLength++; + if ((intBuffer[i8] & 128) === 0) + break; + } + const tempView = new Uint8Array(this.blockLength); + for (let i8 = 0; i8 < this.blockLength; i8++) { + tempView[i8] = this.valueHexView[i8]; + } + this.valueHexView = tempView; + if ((intBuffer[this.blockLength - 1] & 128) !== 0) { + this.error = "End of input reached before message was fully decoded"; + return -1; + } + if (this.valueHexView[0] === 0) + this.warnings.push("Needlessly long format of SID encoding"); + if (this.blockLength <= 8) + this.valueDec = utilFromBase(this.valueHexView, 7); + else { + this.isHexOnly = true; + this.warnings.push("Too big SID for decoding, hex only"); + } + return inputOffset + this.blockLength; + } + set valueBigInt(value) { + assertBigInt(); + let bits = BigInt(value).toString(2); + while (bits.length % 7) { + bits = "0" + bits; + } + const bytes2 = new Uint8Array(bits.length / 7); + for (let i8 = 0; i8 < bytes2.length; i8++) { + bytes2[i8] = parseInt(bits.slice(i8 * 7, i8 * 7 + 7), 2) + (i8 + 1 < bytes2.length ? 128 : 0); + } + this.fromBER(bytes2.buffer, 0, bytes2.length); + } + toBER(sizeOnly) { + if (this.isHexOnly) { + if (sizeOnly) + return new ArrayBuffer(this.valueHexView.byteLength); + const curView = this.valueHexView; + const retView2 = new Uint8Array(this.blockLength); + for (let i8 = 0; i8 < this.blockLength - 1; i8++) + retView2[i8] = curView[i8] | 128; + retView2[this.blockLength - 1] = curView[this.blockLength - 1]; + return retView2.buffer; + } + const encodedBuf = utilToBase(this.valueDec, 7); + if (encodedBuf.byteLength === 0) { + this.error = "Error during encoding SID value"; + return EMPTY_BUFFER3; + } + const retView = new Uint8Array(encodedBuf.byteLength); + if (!sizeOnly) { + const encodedView = new Uint8Array(encodedBuf); + const len = encodedBuf.byteLength - 1; + for (let i8 = 0; i8 < len; i8++) + retView[i8] = encodedView[i8] | 128; + retView[len] = encodedView[len]; + } + return retView; + } + toString() { + let result = ""; + if (this.isHexOnly) + result = pvtsutils.Convert.ToHex(this.valueHexView); + else { + if (this.isFirstSid) { + let sidValue = this.valueDec; + if (this.valueDec <= 39) + result = "0."; + else { + if (this.valueDec <= 79) { + result = "1."; + sidValue -= 40; + } else { + result = "2."; + sidValue -= 80; + } + } + result += sidValue.toString(); + } else + result = this.valueDec.toString(); + } + return result; + } + toJSON() { + return { + ...super.toJSON(), + valueDec: this.valueDec, + isFirstSid: this.isFirstSid + }; + } + }; + LocalSidValueBlock.NAME = "sidBlock"; + var LocalObjectIdentifierValueBlock = class extends ValueBlock { + constructor({ value = EMPTY_STRING, ...parameters } = {}) { + super(parameters); + this.value = []; + if (value) { + this.fromString(value); + } + } + fromBER(inputBuffer, inputOffset, inputLength) { + let resultOffset = inputOffset; + while (inputLength > 0) { + const sidBlock = new LocalSidValueBlock(); + resultOffset = sidBlock.fromBER(inputBuffer, resultOffset, inputLength); + if (resultOffset === -1) { + this.blockLength = 0; + this.error = sidBlock.error; + return resultOffset; + } + if (this.value.length === 0) + sidBlock.isFirstSid = true; + this.blockLength += sidBlock.blockLength; + inputLength -= sidBlock.blockLength; + this.value.push(sidBlock); + } + return resultOffset; + } + toBER(sizeOnly) { + const retBuffers = []; + for (let i8 = 0; i8 < this.value.length; i8++) { + const valueBuf = this.value[i8].toBER(sizeOnly); + if (valueBuf.byteLength === 0) { + this.error = this.value[i8].error; + return EMPTY_BUFFER3; + } + retBuffers.push(valueBuf); + } + return concat4(retBuffers); + } + fromString(string4) { + this.value = []; + let pos1 = 0; + let pos2 = 0; + let sid = ""; + let flag = false; + do { + pos2 = string4.indexOf(".", pos1); + if (pos2 === -1) + sid = string4.substring(pos1); + else + sid = string4.substring(pos1, pos2); + pos1 = pos2 + 1; + if (flag) { + const sidBlock = this.value[0]; + let plus = 0; + switch (sidBlock.valueDec) { + case 0: + break; + case 1: + plus = 40; + break; + case 2: + plus = 80; + break; + default: + this.value = []; + return; + } + const parsedSID = parseInt(sid, 10); + if (isNaN(parsedSID)) + return; + sidBlock.valueDec = parsedSID + plus; + flag = false; + } else { + const sidBlock = new LocalSidValueBlock(); + if (sid > Number.MAX_SAFE_INTEGER) { + assertBigInt(); + const sidValue = BigInt(sid); + sidBlock.valueBigInt = sidValue; + } else { + sidBlock.valueDec = parseInt(sid, 10); + if (isNaN(sidBlock.valueDec)) + return; + } + if (!this.value.length) { + sidBlock.isFirstSid = true; + flag = true; + } + this.value.push(sidBlock); + } + } while (pos2 !== -1); + } + toString() { + let result = ""; + let isHexOnly = false; + for (let i8 = 0; i8 < this.value.length; i8++) { + isHexOnly = this.value[i8].isHexOnly; + let sidStr = this.value[i8].toString(); + if (i8 !== 0) + result = `${result}.`; + if (isHexOnly) { + sidStr = `{${sidStr}}`; + if (this.value[i8].isFirstSid) + result = `2.{${sidStr} - 80}`; + else + result += sidStr; + } else + result += sidStr; + } + return result; + } + toJSON() { + const object = { + ...super.toJSON(), + value: this.toString(), + sidArray: [] + }; + for (let i8 = 0; i8 < this.value.length; i8++) { + object.sidArray.push(this.value[i8].toJSON()); + } + return object; + } + }; + LocalObjectIdentifierValueBlock.NAME = "ObjectIdentifierValueBlock"; + var _a$m; + var ObjectIdentifier = class extends BaseBlock { + constructor(parameters = {}) { + super(parameters, LocalObjectIdentifierValueBlock); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 6; + } + getValue() { + return this.valueBlock.toString(); + } + setValue(value) { + this.valueBlock.fromString(value); + } + onAsciiEncoding() { + return `${this.constructor.NAME} : ${this.valueBlock.toString() || "empty"}`; + } + toJSON() { + return { + ...super.toJSON(), + value: this.getValue() + }; + } + }; + _a$m = ObjectIdentifier; + (() => { + typeStore.ObjectIdentifier = _a$m; + })(); + ObjectIdentifier.NAME = "OBJECT IDENTIFIER"; + var LocalRelativeSidValueBlock = class extends HexBlock(LocalBaseBlock) { + constructor({ valueDec = 0, ...parameters } = {}) { + super(parameters); + this.valueDec = valueDec; + } + fromBER(inputBuffer, inputOffset, inputLength) { + if (inputLength === 0) + return inputOffset; + const inputView = pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer); + if (!checkBufferParams(this, inputView, inputOffset, inputLength)) + return -1; + const intBuffer = inputView.subarray(inputOffset, inputOffset + inputLength); + this.valueHexView = new Uint8Array(inputLength); + for (let i8 = 0; i8 < inputLength; i8++) { + this.valueHexView[i8] = intBuffer[i8] & 127; + this.blockLength++; + if ((intBuffer[i8] & 128) === 0) + break; + } + const tempView = new Uint8Array(this.blockLength); + for (let i8 = 0; i8 < this.blockLength; i8++) + tempView[i8] = this.valueHexView[i8]; + this.valueHexView = tempView; + if ((intBuffer[this.blockLength - 1] & 128) !== 0) { + this.error = "End of input reached before message was fully decoded"; + return -1; + } + if (this.valueHexView[0] === 0) + this.warnings.push("Needlessly long format of SID encoding"); + if (this.blockLength <= 8) + this.valueDec = utilFromBase(this.valueHexView, 7); + else { + this.isHexOnly = true; + this.warnings.push("Too big SID for decoding, hex only"); + } + return inputOffset + this.blockLength; + } + toBER(sizeOnly) { + if (this.isHexOnly) { + if (sizeOnly) + return new ArrayBuffer(this.valueHexView.byteLength); + const curView = this.valueHexView; + const retView2 = new Uint8Array(this.blockLength); + for (let i8 = 0; i8 < this.blockLength - 1; i8++) + retView2[i8] = curView[i8] | 128; + retView2[this.blockLength - 1] = curView[this.blockLength - 1]; + return retView2.buffer; + } + const encodedBuf = utilToBase(this.valueDec, 7); + if (encodedBuf.byteLength === 0) { + this.error = "Error during encoding SID value"; + return EMPTY_BUFFER3; + } + const retView = new Uint8Array(encodedBuf.byteLength); + if (!sizeOnly) { + const encodedView = new Uint8Array(encodedBuf); + const len = encodedBuf.byteLength - 1; + for (let i8 = 0; i8 < len; i8++) + retView[i8] = encodedView[i8] | 128; + retView[len] = encodedView[len]; + } + return retView.buffer; + } + toString() { + let result = ""; + if (this.isHexOnly) + result = pvtsutils.Convert.ToHex(this.valueHexView); + else { + result = this.valueDec.toString(); + } + return result; + } + toJSON() { + return { + ...super.toJSON(), + valueDec: this.valueDec + }; + } + }; + LocalRelativeSidValueBlock.NAME = "relativeSidBlock"; + var LocalRelativeObjectIdentifierValueBlock = class extends ValueBlock { + constructor({ value = EMPTY_STRING, ...parameters } = {}) { + super(parameters); + this.value = []; + if (value) { + this.fromString(value); + } + } + fromBER(inputBuffer, inputOffset, inputLength) { + let resultOffset = inputOffset; + while (inputLength > 0) { + const sidBlock = new LocalRelativeSidValueBlock(); + resultOffset = sidBlock.fromBER(inputBuffer, resultOffset, inputLength); + if (resultOffset === -1) { + this.blockLength = 0; + this.error = sidBlock.error; + return resultOffset; + } + this.blockLength += sidBlock.blockLength; + inputLength -= sidBlock.blockLength; + this.value.push(sidBlock); + } + return resultOffset; + } + toBER(sizeOnly, writer2) { + const retBuffers = []; + for (let i8 = 0; i8 < this.value.length; i8++) { + const valueBuf = this.value[i8].toBER(sizeOnly); + if (valueBuf.byteLength === 0) { + this.error = this.value[i8].error; + return EMPTY_BUFFER3; + } + retBuffers.push(valueBuf); + } + return concat4(retBuffers); + } + fromString(string4) { + this.value = []; + let pos1 = 0; + let pos2 = 0; + let sid = ""; + do { + pos2 = string4.indexOf(".", pos1); + if (pos2 === -1) + sid = string4.substring(pos1); + else + sid = string4.substring(pos1, pos2); + pos1 = pos2 + 1; + const sidBlock = new LocalRelativeSidValueBlock(); + sidBlock.valueDec = parseInt(sid, 10); + if (isNaN(sidBlock.valueDec)) + return true; + this.value.push(sidBlock); + } while (pos2 !== -1); + return true; + } + toString() { + let result = ""; + let isHexOnly = false; + for (let i8 = 0; i8 < this.value.length; i8++) { + isHexOnly = this.value[i8].isHexOnly; + let sidStr = this.value[i8].toString(); + if (i8 !== 0) + result = `${result}.`; + if (isHexOnly) { + sidStr = `{${sidStr}}`; + result += sidStr; + } else + result += sidStr; + } + return result; + } + toJSON() { + const object = { + ...super.toJSON(), + value: this.toString(), + sidArray: [] + }; + for (let i8 = 0; i8 < this.value.length; i8++) + object.sidArray.push(this.value[i8].toJSON()); + return object; + } + }; + LocalRelativeObjectIdentifierValueBlock.NAME = "RelativeObjectIdentifierValueBlock"; + var _a$l; + var RelativeObjectIdentifier = class extends BaseBlock { + constructor(parameters = {}) { + super(parameters, LocalRelativeObjectIdentifierValueBlock); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 13; + } + getValue() { + return this.valueBlock.toString(); + } + setValue(value) { + this.valueBlock.fromString(value); + } + onAsciiEncoding() { + return `${this.constructor.NAME} : ${this.valueBlock.toString() || "empty"}`; + } + toJSON() { + return { + ...super.toJSON(), + value: this.getValue() + }; + } + }; + _a$l = RelativeObjectIdentifier; + (() => { + typeStore.RelativeObjectIdentifier = _a$l; + })(); + RelativeObjectIdentifier.NAME = "RelativeObjectIdentifier"; + var _a$k; + var Sequence = class extends Constructed { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 16; + } + }; + _a$k = Sequence; + (() => { + typeStore.Sequence = _a$k; + })(); + Sequence.NAME = "SEQUENCE"; + var _a$j; + var Set2 = class extends Constructed { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 17; + } + }; + _a$j = Set2; + (() => { + typeStore.Set = _a$j; + })(); + Set2.NAME = "SET"; + var LocalStringValueBlock = class extends HexBlock(ValueBlock) { + constructor({ ...parameters } = {}) { + super(parameters); + this.isHexOnly = true; + this.value = EMPTY_STRING; + } + toJSON() { + return { + ...super.toJSON(), + value: this.value + }; + } + }; + LocalStringValueBlock.NAME = "StringValueBlock"; + var LocalSimpleStringValueBlock = class extends LocalStringValueBlock { + }; + LocalSimpleStringValueBlock.NAME = "SimpleStringValueBlock"; + var LocalSimpleStringBlock = class extends BaseStringBlock { + constructor({ ...parameters } = {}) { + super(parameters, LocalSimpleStringValueBlock); + } + fromBuffer(inputBuffer) { + this.valueBlock.value = String.fromCharCode.apply(null, pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer)); + } + fromString(inputString) { + const strLen = inputString.length; + const view10 = this.valueBlock.valueHexView = new Uint8Array(strLen); + for (let i8 = 0; i8 < strLen; i8++) + view10[i8] = inputString.charCodeAt(i8); + this.valueBlock.value = inputString; + } + }; + LocalSimpleStringBlock.NAME = "SIMPLE STRING"; + var LocalUtf8StringValueBlock = class extends LocalSimpleStringBlock { + fromBuffer(inputBuffer) { + this.valueBlock.valueHexView = pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer); + try { + this.valueBlock.value = pvtsutils.Convert.ToUtf8String(inputBuffer); + } catch (ex) { + this.warnings.push(`Error during "decodeURIComponent": ${ex}, using raw string`); + this.valueBlock.value = pvtsutils.Convert.ToBinary(inputBuffer); + } + } + fromString(inputString) { + this.valueBlock.valueHexView = new Uint8Array(pvtsutils.Convert.FromUtf8String(inputString)); + this.valueBlock.value = inputString; + } + }; + LocalUtf8StringValueBlock.NAME = "Utf8StringValueBlock"; + var _a$i; + var Utf8String = class extends LocalUtf8StringValueBlock { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 12; + } + }; + _a$i = Utf8String; + (() => { + typeStore.Utf8String = _a$i; + })(); + Utf8String.NAME = "UTF8String"; + var LocalBmpStringValueBlock = class extends LocalSimpleStringBlock { + fromBuffer(inputBuffer) { + this.valueBlock.value = pvtsutils.Convert.ToUtf16String(inputBuffer); + this.valueBlock.valueHexView = pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer); + } + fromString(inputString) { + this.valueBlock.value = inputString; + this.valueBlock.valueHexView = new Uint8Array(pvtsutils.Convert.FromUtf16String(inputString)); + } + }; + LocalBmpStringValueBlock.NAME = "BmpStringValueBlock"; + var _a$h; + var BmpString = class extends LocalBmpStringValueBlock { + constructor({ ...parameters } = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 30; + } + }; + _a$h = BmpString; + (() => { + typeStore.BmpString = _a$h; + })(); + BmpString.NAME = "BMPString"; + var LocalUniversalStringValueBlock = class extends LocalSimpleStringBlock { + fromBuffer(inputBuffer) { + const copyBuffer = ArrayBuffer.isView(inputBuffer) ? inputBuffer.slice().buffer : inputBuffer.slice(0); + const valueView = new Uint8Array(copyBuffer); + for (let i8 = 0; i8 < valueView.length; i8 += 4) { + valueView[i8] = valueView[i8 + 3]; + valueView[i8 + 1] = valueView[i8 + 2]; + valueView[i8 + 2] = 0; + valueView[i8 + 3] = 0; + } + this.valueBlock.value = String.fromCharCode.apply(null, new Uint32Array(copyBuffer)); + } + fromString(inputString) { + const strLength = inputString.length; + const valueHexView = this.valueBlock.valueHexView = new Uint8Array(strLength * 4); + for (let i8 = 0; i8 < strLength; i8++) { + const codeBuf = utilToBase(inputString.charCodeAt(i8), 8); + const codeView = new Uint8Array(codeBuf); + if (codeView.length > 4) + continue; + const dif = 4 - codeView.length; + for (let j5 = codeView.length - 1; j5 >= 0; j5--) + valueHexView[i8 * 4 + j5 + dif] = codeView[j5]; + } + this.valueBlock.value = inputString; + } + }; + LocalUniversalStringValueBlock.NAME = "UniversalStringValueBlock"; + var _a$g; + var UniversalString = class extends LocalUniversalStringValueBlock { + constructor({ ...parameters } = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 28; + } + }; + _a$g = UniversalString; + (() => { + typeStore.UniversalString = _a$g; + })(); + UniversalString.NAME = "UniversalString"; + var _a$f; + var NumericString = class extends LocalSimpleStringBlock { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 18; + } + }; + _a$f = NumericString; + (() => { + typeStore.NumericString = _a$f; + })(); + NumericString.NAME = "NumericString"; + var _a$e; + var PrintableString = class extends LocalSimpleStringBlock { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 19; + } + }; + _a$e = PrintableString; + (() => { + typeStore.PrintableString = _a$e; + })(); + PrintableString.NAME = "PrintableString"; + var _a$d; + var TeletexString = class extends LocalSimpleStringBlock { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 20; + } + }; + _a$d = TeletexString; + (() => { + typeStore.TeletexString = _a$d; + })(); + TeletexString.NAME = "TeletexString"; + var _a$c; + var VideotexString = class extends LocalSimpleStringBlock { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 21; + } + }; + _a$c = VideotexString; + (() => { + typeStore.VideotexString = _a$c; + })(); + VideotexString.NAME = "VideotexString"; + var _a$b; + var IA5String = class extends LocalSimpleStringBlock { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 22; + } + }; + _a$b = IA5String; + (() => { + typeStore.IA5String = _a$b; + })(); + IA5String.NAME = "IA5String"; + var _a$a; + var GraphicString = class extends LocalSimpleStringBlock { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 25; + } + }; + _a$a = GraphicString; + (() => { + typeStore.GraphicString = _a$a; + })(); + GraphicString.NAME = "GraphicString"; + var _a$9; + var VisibleString = class extends LocalSimpleStringBlock { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 26; + } + }; + _a$9 = VisibleString; + (() => { + typeStore.VisibleString = _a$9; + })(); + VisibleString.NAME = "VisibleString"; + var _a$8; + var GeneralString = class extends LocalSimpleStringBlock { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 27; + } + }; + _a$8 = GeneralString; + (() => { + typeStore.GeneralString = _a$8; + })(); + GeneralString.NAME = "GeneralString"; + var _a$7; + var CharacterString = class extends LocalSimpleStringBlock { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 29; + } + }; + _a$7 = CharacterString; + (() => { + typeStore.CharacterString = _a$7; + })(); + CharacterString.NAME = "CharacterString"; + var _a$6; + var UTCTime = class extends VisibleString { + constructor({ value, valueDate, ...parameters } = {}) { + super(parameters); + this.year = 0; + this.month = 0; + this.day = 0; + this.hour = 0; + this.minute = 0; + this.second = 0; + if (value) { + this.fromString(value); + this.valueBlock.valueHexView = new Uint8Array(value.length); + for (let i8 = 0; i8 < value.length; i8++) + this.valueBlock.valueHexView[i8] = value.charCodeAt(i8); + } + if (valueDate) { + this.fromDate(valueDate); + this.valueBlock.valueHexView = new Uint8Array(this.toBuffer()); + } + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 23; + } + fromBuffer(inputBuffer) { + this.fromString(String.fromCharCode.apply(null, pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer))); + } + toBuffer() { + const str = this.toString(); + const buffer4 = new ArrayBuffer(str.length); + const view10 = new Uint8Array(buffer4); + for (let i8 = 0; i8 < str.length; i8++) + view10[i8] = str.charCodeAt(i8); + return buffer4; + } + fromDate(inputDate) { + this.year = inputDate.getUTCFullYear(); + this.month = inputDate.getUTCMonth() + 1; + this.day = inputDate.getUTCDate(); + this.hour = inputDate.getUTCHours(); + this.minute = inputDate.getUTCMinutes(); + this.second = inputDate.getUTCSeconds(); + } + toDate() { + return new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second)); + } + fromString(inputString) { + const parser = /(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig; + const parserArray = parser.exec(inputString); + if (parserArray === null) { + this.error = "Wrong input string for conversion"; + return; + } + const year = parseInt(parserArray[1], 10); + if (year >= 50) + this.year = 1900 + year; + else + this.year = 2e3 + year; + this.month = parseInt(parserArray[2], 10); + this.day = parseInt(parserArray[3], 10); + this.hour = parseInt(parserArray[4], 10); + this.minute = parseInt(parserArray[5], 10); + this.second = parseInt(parserArray[6], 10); + } + toString(encoding = "iso") { + if (encoding === "iso") { + const outputArray = new Array(7); + outputArray[0] = padNumber(this.year < 2e3 ? this.year - 1900 : this.year - 2e3, 2); + outputArray[1] = padNumber(this.month, 2); + outputArray[2] = padNumber(this.day, 2); + outputArray[3] = padNumber(this.hour, 2); + outputArray[4] = padNumber(this.minute, 2); + outputArray[5] = padNumber(this.second, 2); + outputArray[6] = "Z"; + return outputArray.join(""); + } + return super.toString(encoding); + } + onAsciiEncoding() { + return `${this.constructor.NAME} : ${this.toDate().toISOString()}`; + } + toJSON() { + return { + ...super.toJSON(), + year: this.year, + month: this.month, + day: this.day, + hour: this.hour, + minute: this.minute, + second: this.second + }; + } + }; + _a$6 = UTCTime; + (() => { + typeStore.UTCTime = _a$6; + })(); + UTCTime.NAME = "UTCTime"; + var _a$5; + var GeneralizedTime = class extends UTCTime { + constructor(parameters = {}) { + var _b; + super(parameters); + (_b = this.millisecond) !== null && _b !== void 0 ? _b : this.millisecond = 0; + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 24; + } + fromDate(inputDate) { + super.fromDate(inputDate); + this.millisecond = inputDate.getUTCMilliseconds(); + } + toDate() { + return new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millisecond)); + } + fromString(inputString) { + let isUTC = false; + let timeString = ""; + let dateTimeString = ""; + let fractionPart = 0; + let parser; + let hourDifference = 0; + let minuteDifference = 0; + if (inputString[inputString.length - 1] === "Z") { + timeString = inputString.substring(0, inputString.length - 1); + isUTC = true; + } else { + const number3 = new Number(inputString[inputString.length - 1]); + if (isNaN(number3.valueOf())) + throw new Error("Wrong input string for conversion"); + timeString = inputString; + } + if (isUTC) { + if (timeString.indexOf("+") !== -1) + throw new Error("Wrong input string for conversion"); + if (timeString.indexOf("-") !== -1) + throw new Error("Wrong input string for conversion"); + } else { + let multiplier = 1; + let differencePosition = timeString.indexOf("+"); + let differenceString = ""; + if (differencePosition === -1) { + differencePosition = timeString.indexOf("-"); + multiplier = -1; + } + if (differencePosition !== -1) { + differenceString = timeString.substring(differencePosition + 1); + timeString = timeString.substring(0, differencePosition); + if (differenceString.length !== 2 && differenceString.length !== 4) + throw new Error("Wrong input string for conversion"); + let number3 = parseInt(differenceString.substring(0, 2), 10); + if (isNaN(number3.valueOf())) + throw new Error("Wrong input string for conversion"); + hourDifference = multiplier * number3; + if (differenceString.length === 4) { + number3 = parseInt(differenceString.substring(2, 4), 10); + if (isNaN(number3.valueOf())) + throw new Error("Wrong input string for conversion"); + minuteDifference = multiplier * number3; + } + } + } + let fractionPointPosition = timeString.indexOf("."); + if (fractionPointPosition === -1) + fractionPointPosition = timeString.indexOf(","); + if (fractionPointPosition !== -1) { + const fractionPartCheck = new Number(`0${timeString.substring(fractionPointPosition)}`); + if (isNaN(fractionPartCheck.valueOf())) + throw new Error("Wrong input string for conversion"); + fractionPart = fractionPartCheck.valueOf(); + dateTimeString = timeString.substring(0, fractionPointPosition); + } else + dateTimeString = timeString; + switch (true) { + case dateTimeString.length === 8: + parser = /(\d{4})(\d{2})(\d{2})/ig; + if (fractionPointPosition !== -1) + throw new Error("Wrong input string for conversion"); + break; + case dateTimeString.length === 10: + parser = /(\d{4})(\d{2})(\d{2})(\d{2})/ig; + if (fractionPointPosition !== -1) { + let fractionResult = 60 * fractionPart; + this.minute = Math.floor(fractionResult); + fractionResult = 60 * (fractionResult - this.minute); + this.second = Math.floor(fractionResult); + fractionResult = 1e3 * (fractionResult - this.second); + this.millisecond = Math.floor(fractionResult); + } + break; + case dateTimeString.length === 12: + parser = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig; + if (fractionPointPosition !== -1) { + let fractionResult = 60 * fractionPart; + this.second = Math.floor(fractionResult); + fractionResult = 1e3 * (fractionResult - this.second); + this.millisecond = Math.floor(fractionResult); + } + break; + case dateTimeString.length === 14: + parser = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig; + if (fractionPointPosition !== -1) { + const fractionResult = 1e3 * fractionPart; + this.millisecond = Math.floor(fractionResult); + } + break; + default: + throw new Error("Wrong input string for conversion"); + } + const parserArray = parser.exec(dateTimeString); + if (parserArray === null) + throw new Error("Wrong input string for conversion"); + for (let j5 = 1; j5 < parserArray.length; j5++) { + switch (j5) { + case 1: + this.year = parseInt(parserArray[j5], 10); + break; + case 2: + this.month = parseInt(parserArray[j5], 10); + break; + case 3: + this.day = parseInt(parserArray[j5], 10); + break; + case 4: + this.hour = parseInt(parserArray[j5], 10) + hourDifference; + break; + case 5: + this.minute = parseInt(parserArray[j5], 10) + minuteDifference; + break; + case 6: + this.second = parseInt(parserArray[j5], 10); + break; + default: + throw new Error("Wrong input string for conversion"); + } + } + if (isUTC === false) { + const tempDate = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond); + this.year = tempDate.getUTCFullYear(); + this.month = tempDate.getUTCMonth(); + this.day = tempDate.getUTCDay(); + this.hour = tempDate.getUTCHours(); + this.minute = tempDate.getUTCMinutes(); + this.second = tempDate.getUTCSeconds(); + this.millisecond = tempDate.getUTCMilliseconds(); + } + } + toString(encoding = "iso") { + if (encoding === "iso") { + const outputArray = []; + outputArray.push(padNumber(this.year, 4)); + outputArray.push(padNumber(this.month, 2)); + outputArray.push(padNumber(this.day, 2)); + outputArray.push(padNumber(this.hour, 2)); + outputArray.push(padNumber(this.minute, 2)); + outputArray.push(padNumber(this.second, 2)); + if (this.millisecond !== 0) { + outputArray.push("."); + outputArray.push(padNumber(this.millisecond, 3)); + } + outputArray.push("Z"); + return outputArray.join(""); + } + return super.toString(encoding); + } + toJSON() { + return { + ...super.toJSON(), + millisecond: this.millisecond + }; + } + }; + _a$5 = GeneralizedTime; + (() => { + typeStore.GeneralizedTime = _a$5; + })(); + GeneralizedTime.NAME = "GeneralizedTime"; + var _a$4; + var DATE = class extends Utf8String { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 31; + } + }; + _a$4 = DATE; + (() => { + typeStore.DATE = _a$4; + })(); + DATE.NAME = "DATE"; + var _a$3; + var TimeOfDay = class extends Utf8String { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 32; + } + }; + _a$3 = TimeOfDay; + (() => { + typeStore.TimeOfDay = _a$3; + })(); + TimeOfDay.NAME = "TimeOfDay"; + var _a$2; + var DateTime = class extends Utf8String { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 33; + } + }; + _a$2 = DateTime; + (() => { + typeStore.DateTime = _a$2; + })(); + DateTime.NAME = "DateTime"; + var _a$1; + var Duration = class extends Utf8String { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 34; + } + }; + _a$1 = Duration; + (() => { + typeStore.Duration = _a$1; + })(); + Duration.NAME = "Duration"; + var _a; + var TIME = class extends Utf8String { + constructor(parameters = {}) { + super(parameters); + this.idBlock.tagClass = 1; + this.idBlock.tagNumber = 14; + } + }; + _a = TIME; + (() => { + typeStore.TIME = _a; + })(); + TIME.NAME = "TIME"; + var Any = class { + constructor({ name: name15 = EMPTY_STRING, optional: optional5 = false } = {}) { + this.name = name15; + this.optional = optional5; + } + }; + var Choice = class extends Any { + constructor({ value = [], ...parameters } = {}) { + super(parameters); + this.value = value; + } + }; + var Repeated = class extends Any { + constructor({ value = new Any(), local = false, ...parameters } = {}) { + super(parameters); + this.value = value; + this.local = local; + } + }; + var RawData = class { + constructor({ data = EMPTY_VIEW } = {}) { + this.dataView = pvtsutils.BufferSourceConverter.toUint8Array(data); + } + get data() { + return this.dataView.slice().buffer; + } + set data(value) { + this.dataView = pvtsutils.BufferSourceConverter.toUint8Array(value); + } + fromBER(inputBuffer, inputOffset, inputLength) { + const endLength = inputOffset + inputLength; + this.dataView = pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer).subarray(inputOffset, endLength); + return endLength; + } + toBER(sizeOnly) { + return this.dataView.slice().buffer; + } + }; + function compareSchema(root3, inputData, inputSchema) { + if (inputSchema instanceof Choice) { + for (let j5 = 0; j5 < inputSchema.value.length; j5++) { + const result = compareSchema(root3, inputData, inputSchema.value[j5]); + if (result.verified) { + return { + verified: true, + result: root3 + }; + } + } + { + const _result = { + verified: false, + result: { + error: "Wrong values for Choice type" + } + }; + if (inputSchema.hasOwnProperty(NAME)) + _result.name = inputSchema.name; + return _result; + } + } + if (inputSchema instanceof Any) { + if (inputSchema.hasOwnProperty(NAME)) + root3[inputSchema.name] = inputData; + return { + verified: true, + result: root3 + }; + } + if (root3 instanceof Object === false) { + return { + verified: false, + result: { error: "Wrong root object" } + }; + } + if (inputData instanceof Object === false) { + return { + verified: false, + result: { error: "Wrong ASN.1 data" } + }; + } + if (inputSchema instanceof Object === false) { + return { + verified: false, + result: { error: "Wrong ASN.1 schema" } + }; + } + if (ID_BLOCK in inputSchema === false) { + return { + verified: false, + result: { error: "Wrong ASN.1 schema" } + }; + } + if (FROM_BER in inputSchema.idBlock === false) { + return { + verified: false, + result: { error: "Wrong ASN.1 schema" } + }; + } + if (TO_BER in inputSchema.idBlock === false) { + return { + verified: false, + result: { error: "Wrong ASN.1 schema" } + }; + } + const encodedId = inputSchema.idBlock.toBER(false); + if (encodedId.byteLength === 0) { + return { + verified: false, + result: { error: "Error encoding idBlock for ASN.1 schema" } + }; + } + const decodedOffset = inputSchema.idBlock.fromBER(encodedId, 0, encodedId.byteLength); + if (decodedOffset === -1) { + return { + verified: false, + result: { error: "Error decoding idBlock for ASN.1 schema" } + }; + } + if (inputSchema.idBlock.hasOwnProperty(TAG_CLASS) === false) { + return { + verified: false, + result: { error: "Wrong ASN.1 schema" } + }; + } + if (inputSchema.idBlock.tagClass !== inputData.idBlock.tagClass) { + return { + verified: false, + result: root3 + }; + } + if (inputSchema.idBlock.hasOwnProperty(TAG_NUMBER) === false) { + return { + verified: false, + result: { error: "Wrong ASN.1 schema" } + }; + } + if (inputSchema.idBlock.tagNumber !== inputData.idBlock.tagNumber) { + return { + verified: false, + result: root3 + }; + } + if (inputSchema.idBlock.hasOwnProperty(IS_CONSTRUCTED) === false) { + return { + verified: false, + result: { error: "Wrong ASN.1 schema" } + }; + } + if (inputSchema.idBlock.isConstructed !== inputData.idBlock.isConstructed) { + return { + verified: false, + result: root3 + }; + } + if (!(IS_HEX_ONLY in inputSchema.idBlock)) { + return { + verified: false, + result: { error: "Wrong ASN.1 schema" } + }; + } + if (inputSchema.idBlock.isHexOnly !== inputData.idBlock.isHexOnly) { + return { + verified: false, + result: root3 + }; + } + if (inputSchema.idBlock.isHexOnly) { + if (VALUE_HEX_VIEW in inputSchema.idBlock === false) { + return { + verified: false, + result: { error: "Wrong ASN.1 schema" } + }; + } + const schemaView = inputSchema.idBlock.valueHexView; + const asn1View = inputData.idBlock.valueHexView; + if (schemaView.length !== asn1View.length) { + return { + verified: false, + result: root3 + }; + } + for (let i8 = 0; i8 < schemaView.length; i8++) { + if (schemaView[i8] !== asn1View[1]) { + return { + verified: false, + result: root3 + }; + } + } + } + if (inputSchema.name) { + inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING); + if (inputSchema.name) + root3[inputSchema.name] = inputData; + } + if (inputSchema instanceof typeStore.Constructed) { + let admission = 0; + let result = { + verified: false, + result: { + error: "Unknown error" + } + }; + let maxLength = inputSchema.valueBlock.value.length; + if (maxLength > 0) { + if (inputSchema.valueBlock.value[0] instanceof Repeated) { + maxLength = inputData.valueBlock.value.length; + } + } + if (maxLength === 0) { + return { + verified: true, + result: root3 + }; + } + if (inputData.valueBlock.value.length === 0 && inputSchema.valueBlock.value.length !== 0) { + let _optional = true; + for (let i8 = 0; i8 < inputSchema.valueBlock.value.length; i8++) + _optional = _optional && (inputSchema.valueBlock.value[i8].optional || false); + if (_optional) { + return { + verified: true, + result: root3 + }; + } + if (inputSchema.name) { + inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING); + if (inputSchema.name) + delete root3[inputSchema.name]; + } + root3.error = "Inconsistent object length"; + return { + verified: false, + result: root3 + }; + } + for (let i8 = 0; i8 < maxLength; i8++) { + if (i8 - admission >= inputData.valueBlock.value.length) { + if (inputSchema.valueBlock.value[i8].optional === false) { + const _result = { + verified: false, + result: root3 + }; + root3.error = "Inconsistent length between ASN.1 data and schema"; + if (inputSchema.name) { + inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING); + if (inputSchema.name) { + delete root3[inputSchema.name]; + _result.name = inputSchema.name; + } + } + return _result; + } + } else { + if (inputSchema.valueBlock.value[0] instanceof Repeated) { + result = compareSchema(root3, inputData.valueBlock.value[i8], inputSchema.valueBlock.value[0].value); + if (result.verified === false) { + if (inputSchema.valueBlock.value[0].optional) + admission++; + else { + if (inputSchema.name) { + inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING); + if (inputSchema.name) + delete root3[inputSchema.name]; + } + return result; + } + } + if (NAME in inputSchema.valueBlock.value[0] && inputSchema.valueBlock.value[0].name.length > 0) { + let arrayRoot = {}; + if (LOCAL in inputSchema.valueBlock.value[0] && inputSchema.valueBlock.value[0].local) + arrayRoot = inputData; + else + arrayRoot = root3; + if (typeof arrayRoot[inputSchema.valueBlock.value[0].name] === "undefined") + arrayRoot[inputSchema.valueBlock.value[0].name] = []; + arrayRoot[inputSchema.valueBlock.value[0].name].push(inputData.valueBlock.value[i8]); + } + } else { + result = compareSchema(root3, inputData.valueBlock.value[i8 - admission], inputSchema.valueBlock.value[i8]); + if (result.verified === false) { + if (inputSchema.valueBlock.value[i8].optional) + admission++; + else { + if (inputSchema.name) { + inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING); + if (inputSchema.name) + delete root3[inputSchema.name]; + } + return result; + } + } + } + } + } + if (result.verified === false) { + const _result = { + verified: false, + result: root3 + }; + if (inputSchema.name) { + inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING); + if (inputSchema.name) { + delete root3[inputSchema.name]; + _result.name = inputSchema.name; + } + } + return _result; + } + return { + verified: true, + result: root3 + }; + } + if (inputSchema.primitiveSchema && VALUE_HEX_VIEW in inputData.valueBlock) { + const asn1 = localFromBER(inputData.valueBlock.valueHexView); + if (asn1.offset === -1) { + const _result = { + verified: false, + result: asn1.result + }; + if (inputSchema.name) { + inputSchema.name = inputSchema.name.replace(/^\s+|\s+$/g, EMPTY_STRING); + if (inputSchema.name) { + delete root3[inputSchema.name]; + _result.name = inputSchema.name; + } + } + return _result; + } + return compareSchema(root3, asn1.result, inputSchema.primitiveSchema); + } + return { + verified: true, + result: root3 + }; + } + function verifySchema(inputBuffer, inputSchema) { + if (inputSchema instanceof Object === false) { + return { + verified: false, + result: { error: "Wrong ASN.1 schema type" } + }; + } + const asn1 = localFromBER(pvtsutils.BufferSourceConverter.toUint8Array(inputBuffer)); + if (asn1.offset === -1) { + return { + verified: false, + result: asn1.result + }; + } + return compareSchema(asn1.result, asn1.result, inputSchema); + } + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/enums.js + init_dirname(); + init_buffer2(); + init_process(); + var AsnTypeTypes; + (function(AsnTypeTypes2) { + AsnTypeTypes2[AsnTypeTypes2["Sequence"] = 0] = "Sequence"; + AsnTypeTypes2[AsnTypeTypes2["Set"] = 1] = "Set"; + AsnTypeTypes2[AsnTypeTypes2["Choice"] = 2] = "Choice"; + })(AsnTypeTypes || (AsnTypeTypes = {})); + var AsnPropTypes; + (function(AsnPropTypes2) { + AsnPropTypes2[AsnPropTypes2["Any"] = 1] = "Any"; + AsnPropTypes2[AsnPropTypes2["Boolean"] = 2] = "Boolean"; + AsnPropTypes2[AsnPropTypes2["OctetString"] = 3] = "OctetString"; + AsnPropTypes2[AsnPropTypes2["BitString"] = 4] = "BitString"; + AsnPropTypes2[AsnPropTypes2["Integer"] = 5] = "Integer"; + AsnPropTypes2[AsnPropTypes2["Enumerated"] = 6] = "Enumerated"; + AsnPropTypes2[AsnPropTypes2["ObjectIdentifier"] = 7] = "ObjectIdentifier"; + AsnPropTypes2[AsnPropTypes2["Utf8String"] = 8] = "Utf8String"; + AsnPropTypes2[AsnPropTypes2["BmpString"] = 9] = "BmpString"; + AsnPropTypes2[AsnPropTypes2["UniversalString"] = 10] = "UniversalString"; + AsnPropTypes2[AsnPropTypes2["NumericString"] = 11] = "NumericString"; + AsnPropTypes2[AsnPropTypes2["PrintableString"] = 12] = "PrintableString"; + AsnPropTypes2[AsnPropTypes2["TeletexString"] = 13] = "TeletexString"; + AsnPropTypes2[AsnPropTypes2["VideotexString"] = 14] = "VideotexString"; + AsnPropTypes2[AsnPropTypes2["IA5String"] = 15] = "IA5String"; + AsnPropTypes2[AsnPropTypes2["GraphicString"] = 16] = "GraphicString"; + AsnPropTypes2[AsnPropTypes2["VisibleString"] = 17] = "VisibleString"; + AsnPropTypes2[AsnPropTypes2["GeneralString"] = 18] = "GeneralString"; + AsnPropTypes2[AsnPropTypes2["CharacterString"] = 19] = "CharacterString"; + AsnPropTypes2[AsnPropTypes2["UTCTime"] = 20] = "UTCTime"; + AsnPropTypes2[AsnPropTypes2["GeneralizedTime"] = 21] = "GeneralizedTime"; + AsnPropTypes2[AsnPropTypes2["DATE"] = 22] = "DATE"; + AsnPropTypes2[AsnPropTypes2["TimeOfDay"] = 23] = "TimeOfDay"; + AsnPropTypes2[AsnPropTypes2["DateTime"] = 24] = "DateTime"; + AsnPropTypes2[AsnPropTypes2["Duration"] = 25] = "Duration"; + AsnPropTypes2[AsnPropTypes2["TIME"] = 26] = "TIME"; + AsnPropTypes2[AsnPropTypes2["Null"] = 27] = "Null"; + })(AsnPropTypes || (AsnPropTypes = {})); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/types/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/types/bit_string.js + init_dirname(); + init_buffer2(); + init_process(); + var import_pvtsutils = __toESM(require_build()); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/types/octet_string.js + init_dirname(); + init_buffer2(); + init_process(); + var import_pvtsutils2 = __toESM(require_build()); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/converters.js + var AsnAnyConverter = { + fromASN: (value) => value instanceof Null ? null : value.valueBeforeDecodeView, + toASN: (value) => { + if (value === null) { + return new Null(); + } + const schema9 = fromBER(value); + if (schema9.result.error) { + throw new Error(schema9.result.error); + } + return schema9.result; + } + }; + var AsnIntegerConverter = { + fromASN: (value) => value.valueBlock.valueHexView.byteLength >= 4 ? value.valueBlock.toString() : value.valueBlock.valueDec, + toASN: (value) => new Integer3({ value: +value }) + }; + var AsnEnumeratedConverter = { + fromASN: (value) => value.valueBlock.valueDec, + toASN: (value) => new Enumerated({ value }) + }; + var AsnBitStringConverter = { + fromASN: (value) => value.valueBlock.valueHexView, + toASN: (value) => new BitString({ valueHex: value }) + }; + var AsnObjectIdentifierConverter = { + fromASN: (value) => value.valueBlock.toString(), + toASN: (value) => new ObjectIdentifier({ value }) + }; + var AsnBooleanConverter = { + fromASN: (value) => value.valueBlock.value, + toASN: (value) => new Boolean4({ value }) + }; + var AsnOctetStringConverter = { + fromASN: (value) => value.valueBlock.valueHexView, + toASN: (value) => new OctetString({ valueHex: value }) + }; + function createStringConverter(Asn1Type) { + return { + fromASN: (value) => value.valueBlock.value, + toASN: (value) => new Asn1Type({ value }) + }; + } + var AsnUtf8StringConverter = createStringConverter(Utf8String); + var AsnBmpStringConverter = createStringConverter(BmpString); + var AsnUniversalStringConverter = createStringConverter(UniversalString); + var AsnNumericStringConverter = createStringConverter(NumericString); + var AsnPrintableStringConverter = createStringConverter(PrintableString); + var AsnTeletexStringConverter = createStringConverter(TeletexString); + var AsnVideotexStringConverter = createStringConverter(VideotexString); + var AsnIA5StringConverter = createStringConverter(IA5String); + var AsnGraphicStringConverter = createStringConverter(GraphicString); + var AsnVisibleStringConverter = createStringConverter(VisibleString); + var AsnGeneralStringConverter = createStringConverter(GeneralString); + var AsnCharacterStringConverter = createStringConverter(CharacterString); + var AsnUTCTimeConverter = { + fromASN: (value) => value.toDate(), + toASN: (value) => new UTCTime({ valueDate: value }) + }; + var AsnGeneralizedTimeConverter = { + fromASN: (value) => value.toDate(), + toASN: (value) => new GeneralizedTime({ valueDate: value }) + }; + var AsnNullConverter = { + fromASN: () => null, + toASN: () => { + return new Null(); + } + }; + function defaultConverter(type3) { + switch (type3) { + case AsnPropTypes.Any: + return AsnAnyConverter; + case AsnPropTypes.BitString: + return AsnBitStringConverter; + case AsnPropTypes.BmpString: + return AsnBmpStringConverter; + case AsnPropTypes.Boolean: + return AsnBooleanConverter; + case AsnPropTypes.CharacterString: + return AsnCharacterStringConverter; + case AsnPropTypes.Enumerated: + return AsnEnumeratedConverter; + case AsnPropTypes.GeneralString: + return AsnGeneralStringConverter; + case AsnPropTypes.GeneralizedTime: + return AsnGeneralizedTimeConverter; + case AsnPropTypes.GraphicString: + return AsnGraphicStringConverter; + case AsnPropTypes.IA5String: + return AsnIA5StringConverter; + case AsnPropTypes.Integer: + return AsnIntegerConverter; + case AsnPropTypes.Null: + return AsnNullConverter; + case AsnPropTypes.NumericString: + return AsnNumericStringConverter; + case AsnPropTypes.ObjectIdentifier: + return AsnObjectIdentifierConverter; + case AsnPropTypes.OctetString: + return AsnOctetStringConverter; + case AsnPropTypes.PrintableString: + return AsnPrintableStringConverter; + case AsnPropTypes.TeletexString: + return AsnTeletexStringConverter; + case AsnPropTypes.UTCTime: + return AsnUTCTimeConverter; + case AsnPropTypes.UniversalString: + return AsnUniversalStringConverter; + case AsnPropTypes.Utf8String: + return AsnUtf8StringConverter; + case AsnPropTypes.VideotexString: + return AsnVideotexStringConverter; + case AsnPropTypes.VisibleString: + return AsnVisibleStringConverter; + default: + return null; + } + } + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/decorators.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/storage.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/schema.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/helper.js + init_dirname(); + init_buffer2(); + init_process(); + function isConvertible(target) { + if (typeof target === "function" && target.prototype) { + if (target.prototype.toASN && target.prototype.fromASN) { + return true; + } else { + return isConvertible(target.prototype); + } + } else { + return !!(target && typeof target === "object" && "toASN" in target && "fromASN" in target); + } + } + function isTypeOfArray(target) { + var _a2; + if (target) { + const proto = Object.getPrototypeOf(target); + if (((_a2 = proto === null || proto === void 0 ? void 0 : proto.prototype) === null || _a2 === void 0 ? void 0 : _a2.constructor) === Array) { + return true; + } + return isTypeOfArray(proto); + } + return false; + } + function isArrayEqual(bytes1, bytes2) { + if (!(bytes1 && bytes2)) { + return false; + } + if (bytes1.byteLength !== bytes2.byteLength) { + return false; + } + const b1 = new Uint8Array(bytes1); + const b22 = new Uint8Array(bytes2); + for (let i8 = 0; i8 < bytes1.byteLength; i8++) { + if (b1[i8] !== b22[i8]) { + return false; + } + } + return true; + } + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/schema.js + var AsnSchemaStorage = class { + constructor() { + this.items = /* @__PURE__ */ new WeakMap(); + } + has(target) { + return this.items.has(target); + } + get(target, checkSchema = false) { + const schema9 = this.items.get(target); + if (!schema9) { + throw new Error(`Cannot get schema for '${target.prototype.constructor.name}' target`); + } + if (checkSchema && !schema9.schema) { + throw new Error(`Schema '${target.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`); + } + return schema9; + } + cache(target) { + const schema9 = this.get(target); + if (!schema9.schema) { + schema9.schema = this.create(target, true); + } + } + createDefault(target) { + const schema9 = { + type: AsnTypeTypes.Sequence, + items: {} + }; + const parentSchema = this.findParentSchema(target); + if (parentSchema) { + Object.assign(schema9, parentSchema); + schema9.items = Object.assign({}, schema9.items, parentSchema.items); + } + return schema9; + } + create(target, useNames) { + const schema9 = this.items.get(target) || this.createDefault(target); + const asn1Value = []; + for (const key in schema9.items) { + const item = schema9.items[key]; + const name15 = useNames ? key : ""; + let asn1Item; + if (typeof item.type === "number") { + const Asn1TypeName = AsnPropTypes[item.type]; + const Asn1Type = index_es_exports[Asn1TypeName]; + if (!Asn1Type) { + throw new Error(`Cannot get ASN1 class by name '${Asn1TypeName}'`); + } + asn1Item = new Asn1Type({ name: name15 }); + } else if (isConvertible(item.type)) { + const instance = new item.type(); + asn1Item = instance.toSchema(name15); + } else if (item.optional) { + const itemSchema = this.get(item.type); + if (itemSchema.type === AsnTypeTypes.Choice) { + asn1Item = new Any({ name: name15 }); + } else { + asn1Item = this.create(item.type, false); + asn1Item.name = name15; + } + } else { + asn1Item = new Any({ name: name15 }); + } + const optional5 = !!item.optional || item.defaultValue !== void 0; + if (item.repeated) { + asn1Item.name = ""; + const Container = item.repeated === "set" ? Set2 : Sequence; + asn1Item = new Container({ + name: "", + value: [ + new Repeated({ + name: name15, + value: asn1Item + }) + ] + }); + } + if (item.context !== null && item.context !== void 0) { + if (item.implicit) { + if (typeof item.type === "number" || isConvertible(item.type)) { + const Container = item.repeated ? Constructed : Primitive; + asn1Value.push(new Container({ + name: name15, + optional: optional5, + idBlock: { + tagClass: 3, + tagNumber: item.context + } + })); + } else { + this.cache(item.type); + const isRepeated = !!item.repeated; + let value = !isRepeated ? this.get(item.type, true).schema : asn1Item; + value = "valueBlock" in value ? value.valueBlock.value : value.value; + asn1Value.push(new Constructed({ + name: !isRepeated ? name15 : "", + optional: optional5, + idBlock: { + tagClass: 3, + tagNumber: item.context + }, + value + })); + } + } else { + asn1Value.push(new Constructed({ + optional: optional5, + idBlock: { + tagClass: 3, + tagNumber: item.context + }, + value: [asn1Item] + })); + } + } else { + asn1Item.optional = optional5; + asn1Value.push(asn1Item); + } + } + switch (schema9.type) { + case AsnTypeTypes.Sequence: + return new Sequence({ value: asn1Value, name: "" }); + case AsnTypeTypes.Set: + return new Set2({ value: asn1Value, name: "" }); + case AsnTypeTypes.Choice: + return new Choice({ value: asn1Value, name: "" }); + default: + throw new Error(`Unsupported ASN1 type in use`); + } + } + set(target, schema9) { + this.items.set(target, schema9); + return this; + } + findParentSchema(target) { + const parent = Object.getPrototypeOf(target); + if (parent) { + const schema9 = this.items.get(parent); + return schema9 || this.findParentSchema(parent); + } + return null; + } + }; + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/storage.js + var schemaStorage = new AsnSchemaStorage(); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/decorators.js + var AsnType = (options) => (target) => { + let schema9; + if (!schemaStorage.has(target)) { + schema9 = schemaStorage.createDefault(target); + schemaStorage.set(target, schema9); + } else { + schema9 = schemaStorage.get(target); + } + Object.assign(schema9, options); + }; + var AsnProp = (options) => (target, propertyKey) => { + let schema9; + if (!schemaStorage.has(target.constructor)) { + schema9 = schemaStorage.createDefault(target.constructor); + schemaStorage.set(target.constructor, schema9); + } else { + schema9 = schemaStorage.get(target.constructor); + } + const copyOptions = Object.assign({}, options); + if (typeof copyOptions.type === "number" && !copyOptions.converter) { + const defaultConverter2 = defaultConverter(options.type); + if (!defaultConverter2) { + throw new Error(`Cannot get default converter for property '${propertyKey}' of ${target.constructor.name}`); + } + copyOptions.converter = defaultConverter2; + } + schema9.items[propertyKey] = copyOptions; + }; + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/parser.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/errors/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/errors/schema_validation.js + init_dirname(); + init_buffer2(); + init_process(); + var AsnSchemaValidationError = class extends Error { + constructor() { + super(...arguments); + this.schemas = []; + } + }; + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/parser.js + var AsnParser = class { + static parse(data, target) { + const asn1Parsed = fromBER(data); + if (asn1Parsed.result.error) { + throw new Error(asn1Parsed.result.error); + } + const res = this.fromASN(asn1Parsed.result, target); + return res; + } + static fromASN(asn1Schema, target) { + var _a2; + try { + if (isConvertible(target)) { + const value = new target(); + return value.fromASN(asn1Schema); + } + const schema9 = schemaStorage.get(target); + schemaStorage.cache(target); + let targetSchema = schema9.schema; + if (asn1Schema.constructor === Constructed && schema9.type !== AsnTypeTypes.Choice) { + targetSchema = new Constructed({ + idBlock: { + tagClass: 3, + tagNumber: asn1Schema.idBlock.tagNumber + }, + value: schema9.schema.valueBlock.value + }); + for (const key in schema9.items) { + delete asn1Schema[key]; + } + } + const asn1ComparedSchema = compareSchema({}, asn1Schema, targetSchema); + if (!asn1ComparedSchema.verified) { + throw new AsnSchemaValidationError(`Data does not match to ${target.name} ASN1 schema. ${asn1ComparedSchema.result.error}`); + } + const res = new target(); + if (isTypeOfArray(target)) { + if (!("value" in asn1Schema.valueBlock && Array.isArray(asn1Schema.valueBlock.value))) { + throw new Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`); + } + const itemType = schema9.itemType; + if (typeof itemType === "number") { + const converter = defaultConverter(itemType); + if (!converter) { + throw new Error(`Cannot get default converter for array item of ${target.name} ASN1 schema`); + } + return target.from(asn1Schema.valueBlock.value, (element) => converter.fromASN(element)); + } else { + return target.from(asn1Schema.valueBlock.value, (element) => this.fromASN(element, itemType)); + } + } + for (const key in schema9.items) { + const asn1SchemaValue = asn1ComparedSchema.result[key]; + if (!asn1SchemaValue) { + continue; + } + const schemaItem = schema9.items[key]; + const schemaItemType = schemaItem.type; + if (typeof schemaItemType === "number" || isConvertible(schemaItemType)) { + const converter = (_a2 = schemaItem.converter) !== null && _a2 !== void 0 ? _a2 : isConvertible(schemaItemType) ? new schemaItemType() : null; + if (!converter) { + throw new Error("Converter is empty"); + } + if (schemaItem.repeated) { + if (schemaItem.implicit) { + const Container = schemaItem.repeated === "sequence" ? Sequence : Set2; + const newItem = new Container(); + newItem.valueBlock = asn1SchemaValue.valueBlock; + const newItemAsn = fromBER(newItem.toBER(false)); + if (newItemAsn.offset === -1) { + throw new Error(`Cannot parse the child item. ${newItemAsn.result.error}`); + } + if (!("value" in newItemAsn.result.valueBlock && Array.isArray(newItemAsn.result.valueBlock.value))) { + throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed."); + } + const value = newItemAsn.result.valueBlock.value; + res[key] = Array.from(value, (element) => converter.fromASN(element)); + } else { + res[key] = Array.from(asn1SchemaValue, (element) => converter.fromASN(element)); + } + } else { + let value = asn1SchemaValue; + if (schemaItem.implicit) { + let newItem; + if (isConvertible(schemaItemType)) { + newItem = new schemaItemType().toSchema(""); + } else { + const Asn1TypeName = AsnPropTypes[schemaItemType]; + const Asn1Type = index_es_exports[Asn1TypeName]; + if (!Asn1Type) { + throw new Error(`Cannot get '${Asn1TypeName}' class from asn1js module`); + } + newItem = new Asn1Type(); + } + newItem.valueBlock = value.valueBlock; + value = fromBER(newItem.toBER(false)).result; + } + res[key] = converter.fromASN(value); + } + } else { + if (schemaItem.repeated) { + if (!Array.isArray(asn1SchemaValue)) { + throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable."); + } + res[key] = Array.from(asn1SchemaValue, (element) => this.fromASN(element, schemaItemType)); + } else { + res[key] = this.fromASN(asn1SchemaValue, schemaItemType); + } + } + } + return res; + } catch (error7) { + if (error7 instanceof AsnSchemaValidationError) { + error7.schemas.push(target.name); + } + throw error7; + } + } + }; + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/serializer.js + init_dirname(); + init_buffer2(); + init_process(); + var AsnSerializer = class _AsnSerializer { + static serialize(obj) { + if (obj instanceof BaseBlock) { + return obj.toBER(false); + } + return this.toASN(obj).toBER(false); + } + static toASN(obj) { + if (obj && typeof obj === "object" && isConvertible(obj)) { + return obj.toASN(); + } + if (!(obj && typeof obj === "object")) { + throw new TypeError("Parameter 1 should be type of Object."); + } + const target = obj.constructor; + const schema9 = schemaStorage.get(target); + schemaStorage.cache(target); + let asn1Value = []; + if (schema9.itemType) { + if (!Array.isArray(obj)) { + throw new TypeError("Parameter 1 should be type of Array."); + } + if (typeof schema9.itemType === "number") { + const converter = defaultConverter(schema9.itemType); + if (!converter) { + throw new Error(`Cannot get default converter for array item of ${target.name} ASN1 schema`); + } + asn1Value = obj.map((o9) => converter.toASN(o9)); + } else { + asn1Value = obj.map((o9) => this.toAsnItem({ type: schema9.itemType }, "[]", target, o9)); + } + } else { + for (const key in schema9.items) { + const schemaItem = schema9.items[key]; + const objProp = obj[key]; + if (objProp === void 0 || schemaItem.defaultValue === objProp || typeof schemaItem.defaultValue === "object" && typeof objProp === "object" && isArrayEqual(this.serialize(schemaItem.defaultValue), this.serialize(objProp))) { + continue; + } + const asn1Item = _AsnSerializer.toAsnItem(schemaItem, key, target, objProp); + if (typeof schemaItem.context === "number") { + if (schemaItem.implicit) { + if (!schemaItem.repeated && (typeof schemaItem.type === "number" || isConvertible(schemaItem.type))) { + const value = {}; + value.valueHex = asn1Item instanceof Null ? asn1Item.valueBeforeDecodeView : asn1Item.valueBlock.toBER(); + asn1Value.push(new Primitive({ + optional: schemaItem.optional, + idBlock: { + tagClass: 3, + tagNumber: schemaItem.context + }, + ...value + })); + } else { + asn1Value.push(new Constructed({ + optional: schemaItem.optional, + idBlock: { + tagClass: 3, + tagNumber: schemaItem.context + }, + value: asn1Item.valueBlock.value + })); + } + } else { + asn1Value.push(new Constructed({ + optional: schemaItem.optional, + idBlock: { + tagClass: 3, + tagNumber: schemaItem.context + }, + value: [asn1Item] + })); + } + } else if (schemaItem.repeated) { + asn1Value = asn1Value.concat(asn1Item); + } else { + asn1Value.push(asn1Item); + } + } + } + let asnSchema; + switch (schema9.type) { + case AsnTypeTypes.Sequence: + asnSchema = new Sequence({ value: asn1Value }); + break; + case AsnTypeTypes.Set: + asnSchema = new Set2({ value: asn1Value }); + break; + case AsnTypeTypes.Choice: + if (!asn1Value[0]) { + throw new Error(`Schema '${target.name}' has wrong data. Choice cannot be empty.`); + } + asnSchema = asn1Value[0]; + break; + } + return asnSchema; + } + static toAsnItem(schemaItem, key, target, objProp) { + let asn1Item; + if (typeof schemaItem.type === "number") { + const converter = schemaItem.converter; + if (!converter) { + throw new Error(`Property '${key}' doesn't have converter for type ${AsnPropTypes[schemaItem.type]} in schema '${target.name}'`); + } + if (schemaItem.repeated) { + if (!Array.isArray(objProp)) { + throw new TypeError("Parameter 'objProp' should be type of Array."); + } + const items = Array.from(objProp, (element) => converter.toASN(element)); + const Container = schemaItem.repeated === "sequence" ? Sequence : Set2; + asn1Item = new Container({ + value: items + }); + } else { + asn1Item = converter.toASN(objProp); + } + } else { + if (schemaItem.repeated) { + if (!Array.isArray(objProp)) { + throw new TypeError("Parameter 'objProp' should be type of Array."); + } + const items = Array.from(objProp, (element) => this.toASN(element)); + const Container = schemaItem.repeated === "sequence" ? Sequence : Set2; + asn1Item = new Container({ + value: items + }); + } else { + asn1Item = this.toASN(objProp); + } + } + return asn1Item; + } + }; + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/objects.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@peculiar+asn1-schema@2.3.6/node_modules/@peculiar/asn1-schema/build/es2015/convert.js + init_dirname(); + init_buffer2(); + init_process(); + var import_pvtsutils3 = __toESM(require_build()); + var AsnConvert = class _AsnConvert { + static serialize(obj) { + return AsnSerializer.serialize(obj); + } + static parse(data, target) { + return AsnParser.parse(data, target); + } + static toString(data) { + const buf3 = import_pvtsutils3.BufferSourceConverter.isBufferSource(data) ? import_pvtsutils3.BufferSourceConverter.toArrayBuffer(data) : _AsnConvert.serialize(data); + const asn = fromBER(buf3); + if (asn.offset === -1) { + throw new Error(`Cannot decode ASN.1 data. ${asn.result.error}`); + } + return asn.result.toString(); + } + }; + + // ../../node_modules/.pnpm/tslib@2.6.1/node_modules/tslib/tslib.es6.mjs + init_dirname(); + init_buffer2(); + init_process(); + function __decorate(decorators, target, key, desc) { + var c8 = arguments.length, r10 = c8 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d7; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") + r10 = Reflect.decorate(decorators, target, key, desc); + else + for (var i8 = decorators.length - 1; i8 >= 0; i8--) + if (d7 = decorators[i8]) + r10 = (c8 < 3 ? d7(r10) : c8 > 3 ? d7(target, key, r10) : d7(target, key)) || r10; + return c8 > 3 && r10 && Object.defineProperty(target, key, r10), r10; + } + + // ../../node_modules/.pnpm/@peculiar+json-schema@1.1.12/node_modules/@peculiar/json-schema/build/index.es.js + init_dirname(); + init_buffer2(); + init_process(); + var JsonError = class extends Error { + constructor(message2, innerError) { + super(innerError ? `${message2}. See the inner exception for more details.` : message2); + this.message = message2; + this.innerError = innerError; + } + }; + var TransformError = class extends JsonError { + constructor(schema9, message2, innerError) { + super(message2, innerError); + this.schema = schema9; + } + }; + var ParserError = class extends TransformError { + constructor(schema9, message2, innerError) { + super(schema9, `JSON doesn't match to '${schema9.target.name}' schema. ${message2}`, innerError); + } + }; + var ValidationError = class extends JsonError { + }; + var SerializerError = class extends JsonError { + constructor(schemaName, message2, innerError) { + super(`Cannot serialize by '${schemaName}' schema. ${message2}`, innerError); + this.schemaName = schemaName; + } + }; + var KeyError = class extends ParserError { + constructor(schema9, keys2, errors = {}) { + super(schema9, "Some keys doesn't match to schema"); + this.keys = keys2; + this.errors = errors; + } + }; + var JsonPropTypes; + (function(JsonPropTypes2) { + JsonPropTypes2[JsonPropTypes2["Any"] = 0] = "Any"; + JsonPropTypes2[JsonPropTypes2["Boolean"] = 1] = "Boolean"; + JsonPropTypes2[JsonPropTypes2["Number"] = 2] = "Number"; + JsonPropTypes2[JsonPropTypes2["String"] = 3] = "String"; + })(JsonPropTypes || (JsonPropTypes = {})); + function checkType(value, type3) { + switch (type3) { + case JsonPropTypes.Boolean: + return typeof value === "boolean"; + case JsonPropTypes.Number: + return typeof value === "number"; + case JsonPropTypes.String: + return typeof value === "string"; + } + return true; + } + function throwIfTypeIsWrong(value, type3) { + if (!checkType(value, type3)) { + throw new TypeError(`Value must be ${JsonPropTypes[type3]}`); + } + } + function isConvertible2(target) { + if (target && target.prototype) { + if (target.prototype.toJSON && target.prototype.fromJSON) { + return true; + } else { + return isConvertible2(target.prototype); + } + } else { + return !!(target && target.toJSON && target.fromJSON); + } + } + var JsonSchemaStorage = class { + constructor() { + this.items = /* @__PURE__ */ new Map(); + } + has(target) { + return this.items.has(target) || !!this.findParentSchema(target); + } + get(target) { + const schema9 = this.items.get(target) || this.findParentSchema(target); + if (!schema9) { + throw new Error("Cannot get schema for current target"); + } + return schema9; + } + create(target) { + const schema9 = { names: {} }; + const parentSchema = this.findParentSchema(target); + if (parentSchema) { + Object.assign(schema9, parentSchema); + schema9.names = {}; + for (const name15 in parentSchema.names) { + schema9.names[name15] = Object.assign({}, parentSchema.names[name15]); + } + } + schema9.target = target; + return schema9; + } + set(target, schema9) { + this.items.set(target, schema9); + return this; + } + findParentSchema(target) { + const parent = target.__proto__; + if (parent) { + const schema9 = this.items.get(parent); + return schema9 || this.findParentSchema(parent); + } + return null; + } + }; + var DEFAULT_SCHEMA = "default"; + var schemaStorage2 = new JsonSchemaStorage(); + var PatternValidation = class { + constructor(pattern) { + this.pattern = new RegExp(pattern); + } + validate(value) { + const pattern = new RegExp(this.pattern.source, this.pattern.flags); + if (typeof value !== "string") { + throw new ValidationError("Incoming value must be string"); + } + if (!pattern.exec(value)) { + throw new ValidationError(`Value doesn't match to pattern '${pattern.toString()}'`); + } + } + }; + var InclusiveValidation = class { + constructor(min = Number.MIN_VALUE, max = Number.MAX_VALUE) { + this.min = min; + this.max = max; + } + validate(value) { + throwIfTypeIsWrong(value, JsonPropTypes.Number); + if (!(this.min <= value && value <= this.max)) { + const min = this.min === Number.MIN_VALUE ? "MIN" : this.min; + const max = this.max === Number.MAX_VALUE ? "MAX" : this.max; + throw new ValidationError(`Value doesn't match to diapason [${min},${max}]`); + } + } + }; + var ExclusiveValidation = class { + constructor(min = Number.MIN_VALUE, max = Number.MAX_VALUE) { + this.min = min; + this.max = max; + } + validate(value) { + throwIfTypeIsWrong(value, JsonPropTypes.Number); + if (!(this.min < value && value < this.max)) { + const min = this.min === Number.MIN_VALUE ? "MIN" : this.min; + const max = this.max === Number.MAX_VALUE ? "MAX" : this.max; + throw new ValidationError(`Value doesn't match to diapason (${min},${max})`); + } + } + }; + var LengthValidation = class { + constructor(length3, minLength, maxLength) { + this.length = length3; + this.minLength = minLength; + this.maxLength = maxLength; + } + validate(value) { + if (this.length !== void 0) { + if (value.length !== this.length) { + throw new ValidationError(`Value length must be exactly ${this.length}.`); + } + return; + } + if (this.minLength !== void 0) { + if (value.length < this.minLength) { + throw new ValidationError(`Value length must be more than ${this.minLength}.`); + } + } + if (this.maxLength !== void 0) { + if (value.length > this.maxLength) { + throw new ValidationError(`Value length must be less than ${this.maxLength}.`); + } + } + } + }; + var EnumerationValidation = class { + constructor(enumeration2) { + this.enumeration = enumeration2; + } + validate(value) { + throwIfTypeIsWrong(value, JsonPropTypes.String); + if (!this.enumeration.includes(value)) { + throw new ValidationError(`Value must be one of ${this.enumeration.map((v7) => `'${v7}'`).join(", ")}`); + } + } + }; + var JsonTransform = class { + static checkValues(data, schemaItem) { + const values2 = Array.isArray(data) ? data : [data]; + for (const value of values2) { + for (const validation of schemaItem.validations) { + if (validation instanceof LengthValidation && schemaItem.repeated) { + validation.validate(data); + } else { + validation.validate(value); + } + } + } + } + static checkTypes(value, schemaItem) { + if (schemaItem.repeated && !Array.isArray(value)) { + throw new TypeError("Value must be Array"); + } + if (typeof schemaItem.type === "number") { + const values2 = Array.isArray(value) ? value : [value]; + for (const v7 of values2) { + throwIfTypeIsWrong(v7, schemaItem.type); + } + } + } + static getSchemaByName(schema9, name15 = DEFAULT_SCHEMA) { + return { ...schema9.names[DEFAULT_SCHEMA], ...schema9.names[name15] }; + } + }; + var JsonSerializer = class extends JsonTransform { + static serialize(obj, options, replacer, space3) { + const json = this.toJSON(obj, options); + return JSON.stringify(json, replacer, space3); + } + static toJSON(obj, options = {}) { + let res; + let targetSchema = options.targetSchema; + const schemaName = options.schemaName || DEFAULT_SCHEMA; + if (isConvertible2(obj)) { + return obj.toJSON(); + } + if (Array.isArray(obj)) { + res = []; + for (const item of obj) { + res.push(this.toJSON(item, options)); + } + } else if (typeof obj === "object") { + if (targetSchema && !schemaStorage2.has(targetSchema)) { + throw new JsonError("Cannot get schema for `targetSchema` param"); + } + targetSchema = targetSchema || obj.constructor; + if (schemaStorage2.has(targetSchema)) { + const schema9 = schemaStorage2.get(targetSchema); + res = {}; + const namedSchema = this.getSchemaByName(schema9, schemaName); + for (const key in namedSchema) { + try { + const item = namedSchema[key]; + const objItem = obj[key]; + let value; + if (item.optional && objItem === void 0 || item.defaultValue !== void 0 && objItem === item.defaultValue) { + continue; + } + if (!item.optional && objItem === void 0) { + throw new SerializerError(targetSchema.name, `Property '${key}' is required.`); + } + if (typeof item.type === "number") { + if (item.converter) { + if (item.repeated) { + value = objItem.map((el) => item.converter.toJSON(el, obj)); + } else { + value = item.converter.toJSON(objItem, obj); + } + } else { + value = objItem; + } + } else { + if (item.repeated) { + value = objItem.map((el) => this.toJSON(el, { schemaName })); + } else { + value = this.toJSON(objItem, { schemaName }); + } + } + this.checkTypes(value, item); + this.checkValues(value, item); + res[item.name || key] = value; + } catch (e12) { + if (e12 instanceof SerializerError) { + throw e12; + } else { + throw new SerializerError(schema9.target.name, `Property '${key}' is wrong. ${e12.message}`, e12); + } + } + } + } else { + res = {}; + for (const key in obj) { + res[key] = this.toJSON(obj[key], { schemaName }); + } + } + } else { + res = obj; + } + return res; + } + }; + var JsonParser = class _JsonParser extends JsonTransform { + static parse(data, options) { + const obj = JSON.parse(data); + return this.fromJSON(obj, options); + } + static fromJSON(target, options) { + const targetSchema = options.targetSchema; + const schemaName = options.schemaName || DEFAULT_SCHEMA; + const obj = new targetSchema(); + if (isConvertible2(obj)) { + return obj.fromJSON(target); + } + const schema9 = schemaStorage2.get(targetSchema); + const namedSchema = this.getSchemaByName(schema9, schemaName); + const keyErrors = {}; + if (options.strictProperty && !Array.isArray(target)) { + _JsonParser.checkStrictProperty(target, namedSchema, schema9); + } + for (const key in namedSchema) { + try { + const item = namedSchema[key]; + const name15 = item.name || key; + const value = target[name15]; + if (value === void 0 && (item.optional || item.defaultValue !== void 0)) { + continue; + } + if (!item.optional && value === void 0) { + throw new ParserError(schema9, `Property '${name15}' is required.`); + } + this.checkTypes(value, item); + this.checkValues(value, item); + if (typeof item.type === "number") { + if (item.converter) { + if (item.repeated) { + obj[key] = value.map((el) => item.converter.fromJSON(el, obj)); + } else { + obj[key] = item.converter.fromJSON(value, obj); + } + } else { + obj[key] = value; + } + } else { + const newOptions = { + ...options, + targetSchema: item.type, + schemaName + }; + if (item.repeated) { + obj[key] = value.map((el) => this.fromJSON(el, newOptions)); + } else { + obj[key] = this.fromJSON(value, newOptions); + } + } + } catch (e12) { + if (!(e12 instanceof ParserError)) { + e12 = new ParserError(schema9, `Property '${key}' is wrong. ${e12.message}`, e12); + } + if (options.strictAllKeys) { + keyErrors[key] = e12; + } else { + throw e12; + } + } + } + const keys2 = Object.keys(keyErrors); + if (keys2.length) { + throw new KeyError(schema9, keys2, keyErrors); + } + return obj; + } + static checkStrictProperty(target, namedSchema, schema9) { + const jsonProps = Object.keys(target); + const schemaProps = Object.keys(namedSchema); + const keys2 = []; + for (const key of jsonProps) { + if (schemaProps.indexOf(key) === -1) { + keys2.push(key); + } + } + if (keys2.length) { + throw new KeyError(schema9, keys2); + } + } + }; + function getValidations(item) { + const validations = []; + if (item.pattern) { + validations.push(new PatternValidation(item.pattern)); + } + if (item.type === JsonPropTypes.Number || item.type === JsonPropTypes.Any) { + if (item.minInclusive !== void 0 || item.maxInclusive !== void 0) { + validations.push(new InclusiveValidation(item.minInclusive, item.maxInclusive)); + } + if (item.minExclusive !== void 0 || item.maxExclusive !== void 0) { + validations.push(new ExclusiveValidation(item.minExclusive, item.maxExclusive)); + } + if (item.enumeration !== void 0) { + validations.push(new EnumerationValidation(item.enumeration)); + } + } + if (item.type === JsonPropTypes.String || item.repeated || item.type === JsonPropTypes.Any) { + if (item.length !== void 0 || item.minLength !== void 0 || item.maxLength !== void 0) { + validations.push(new LengthValidation(item.length, item.minLength, item.maxLength)); + } + } + return validations; + } + var JsonProp = (options = {}) => (target, propertyKey) => { + const errorMessage = `Cannot set type for ${propertyKey} property of ${target.constructor.name} schema`; + let schema9; + if (!schemaStorage2.has(target.constructor)) { + schema9 = schemaStorage2.create(target.constructor); + schemaStorage2.set(target.constructor, schema9); + } else { + schema9 = schemaStorage2.get(target.constructor); + if (schema9.target !== target.constructor) { + schema9 = schemaStorage2.create(target.constructor); + schemaStorage2.set(target.constructor, schema9); + } + } + const defaultSchema = { + type: JsonPropTypes.Any, + validations: [] + }; + const copyOptions = Object.assign(defaultSchema, options); + copyOptions.validations = getValidations(copyOptions); + if (typeof copyOptions.type !== "number") { + if (!schemaStorage2.has(copyOptions.type) && !isConvertible2(copyOptions.type)) { + throw new Error(`${errorMessage}. Assigning type doesn't have schema.`); + } + } + let schemaNames; + if (Array.isArray(options.schema)) { + schemaNames = options.schema; + } else { + schemaNames = [options.schema || DEFAULT_SCHEMA]; + } + for (const schemaName of schemaNames) { + if (!schema9.names[schemaName]) { + schema9.names[schemaName] = {}; + } + const namedSchema = schema9.names[schemaName]; + namedSchema[propertyKey] = copyOptions; + } + }; + + // ../../node_modules/.pnpm/webcrypto-core@1.7.7/node_modules/webcrypto-core/build/webcrypto-core.es.js + var CryptoError = class extends Error { + }; + var AlgorithmError = class extends CryptoError { + }; + var UnsupportedOperationError = class extends CryptoError { + constructor(methodName) { + super(`Unsupported operation: ${methodName ? `${methodName}` : ""}`); + } + }; + var OperationError = class extends CryptoError { + }; + var RequiredPropertyError = class extends CryptoError { + constructor(propName) { + super(`${propName}: Missing required property`); + } + }; + function isJWK(data) { + return typeof data === "object" && "kty" in data; + } + var ProviderCrypto = class { + async digest(...args) { + this.checkDigest.apply(this, args); + return this.onDigest.apply(this, args); + } + checkDigest(algorithm2, data) { + this.checkAlgorithmName(algorithm2); + } + async onDigest(algorithm2, data) { + throw new UnsupportedOperationError("digest"); + } + async generateKey(...args) { + this.checkGenerateKey.apply(this, args); + return this.onGenerateKey.apply(this, args); + } + checkGenerateKey(algorithm2, extractable, keyUsages, ...args) { + this.checkAlgorithmName(algorithm2); + this.checkGenerateKeyParams(algorithm2); + if (!(keyUsages && keyUsages.length)) { + throw new TypeError(`Usages cannot be empty when creating a key.`); + } + let allowedUsages; + if (Array.isArray(this.usages)) { + allowedUsages = this.usages; + } else { + allowedUsages = this.usages.privateKey.concat(this.usages.publicKey); + } + this.checkKeyUsages(keyUsages, allowedUsages); + } + checkGenerateKeyParams(algorithm2) { + } + async onGenerateKey(algorithm2, extractable, keyUsages, ...args) { + throw new UnsupportedOperationError("generateKey"); + } + async sign(...args) { + this.checkSign.apply(this, args); + return this.onSign.apply(this, args); + } + checkSign(algorithm2, key, data, ...args) { + this.checkAlgorithmName(algorithm2); + this.checkAlgorithmParams(algorithm2); + this.checkCryptoKey(key, "sign"); + } + async onSign(algorithm2, key, data, ...args) { + throw new UnsupportedOperationError("sign"); + } + async verify(...args) { + this.checkVerify.apply(this, args); + return this.onVerify.apply(this, args); + } + checkVerify(algorithm2, key, signature, data, ...args) { + this.checkAlgorithmName(algorithm2); + this.checkAlgorithmParams(algorithm2); + this.checkCryptoKey(key, "verify"); + } + async onVerify(algorithm2, key, signature, data, ...args) { + throw new UnsupportedOperationError("verify"); + } + async encrypt(...args) { + this.checkEncrypt.apply(this, args); + return this.onEncrypt.apply(this, args); + } + checkEncrypt(algorithm2, key, data, options = {}, ...args) { + this.checkAlgorithmName(algorithm2); + this.checkAlgorithmParams(algorithm2); + this.checkCryptoKey(key, options.keyUsage ? "encrypt" : void 0); + } + async onEncrypt(algorithm2, key, data, ...args) { + throw new UnsupportedOperationError("encrypt"); + } + async decrypt(...args) { + this.checkDecrypt.apply(this, args); + return this.onDecrypt.apply(this, args); + } + checkDecrypt(algorithm2, key, data, options = {}, ...args) { + this.checkAlgorithmName(algorithm2); + this.checkAlgorithmParams(algorithm2); + this.checkCryptoKey(key, options.keyUsage ? "decrypt" : void 0); + } + async onDecrypt(algorithm2, key, data, ...args) { + throw new UnsupportedOperationError("decrypt"); + } + async deriveBits(...args) { + this.checkDeriveBits.apply(this, args); + return this.onDeriveBits.apply(this, args); + } + checkDeriveBits(algorithm2, baseKey, length3, options = {}, ...args) { + this.checkAlgorithmName(algorithm2); + this.checkAlgorithmParams(algorithm2); + this.checkCryptoKey(baseKey, options.keyUsage ? "deriveBits" : void 0); + if (length3 % 8 !== 0) { + throw new OperationError("length: Is not multiple of 8"); + } + } + async onDeriveBits(algorithm2, baseKey, length3, ...args) { + throw new UnsupportedOperationError("deriveBits"); + } + async exportKey(...args) { + this.checkExportKey.apply(this, args); + return this.onExportKey.apply(this, args); + } + checkExportKey(format16, key, ...args) { + this.checkKeyFormat(format16); + this.checkCryptoKey(key); + if (!key.extractable) { + throw new CryptoError("key: Is not extractable"); + } + } + async onExportKey(format16, key, ...args) { + throw new UnsupportedOperationError("exportKey"); + } + async importKey(...args) { + this.checkImportKey.apply(this, args); + return this.onImportKey.apply(this, args); + } + checkImportKey(format16, keyData, algorithm2, extractable, keyUsages, ...args) { + this.checkKeyFormat(format16); + this.checkKeyData(format16, keyData); + this.checkAlgorithmName(algorithm2); + this.checkImportParams(algorithm2); + if (Array.isArray(this.usages)) { + this.checkKeyUsages(keyUsages, this.usages); + } + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages, ...args) { + throw new UnsupportedOperationError("importKey"); + } + checkAlgorithmName(algorithm2) { + if (algorithm2.name.toLowerCase() !== this.name.toLowerCase()) { + throw new AlgorithmError("Unrecognized name"); + } + } + checkAlgorithmParams(algorithm2) { + } + checkDerivedKeyParams(algorithm2) { + } + checkKeyUsages(usages, allowed) { + for (const usage of usages) { + if (allowed.indexOf(usage) === -1) { + throw new TypeError("Cannot create a key using the specified key usages"); + } + } + } + checkCryptoKey(key, keyUsage) { + this.checkAlgorithmName(key.algorithm); + if (keyUsage && key.usages.indexOf(keyUsage) === -1) { + throw new CryptoError(`key does not match that of operation`); + } + } + checkRequiredProperty(data, propName) { + if (!(propName in data)) { + throw new RequiredPropertyError(propName); + } + } + checkHashAlgorithm(algorithm2, hashAlgorithms) { + for (const item of hashAlgorithms) { + if (item.toLowerCase() === algorithm2.name.toLowerCase()) { + return; + } + } + throw new OperationError(`hash: Must be one of ${hashAlgorithms.join(", ")}`); + } + checkImportParams(algorithm2) { + } + checkKeyFormat(format16) { + switch (format16) { + case "raw": + case "pkcs8": + case "spki": + case "jwk": + break; + default: + throw new TypeError("format: Is invalid value. Must be 'jwk', 'raw', 'spki', or 'pkcs8'"); + } + } + checkKeyData(format16, keyData) { + if (!keyData) { + throw new TypeError("keyData: Cannot be empty on empty on key importing"); + } + if (format16 === "jwk") { + if (!isJWK(keyData)) { + throw new TypeError("keyData: Is not JsonWebToken"); + } + } else if (!import_pvtsutils4.BufferSourceConverter.isBufferSource(keyData)) { + throw new TypeError("keyData: Is not ArrayBufferView or ArrayBuffer"); + } + } + prepareData(data) { + return import_pvtsutils4.BufferSourceConverter.toArrayBuffer(data); + } + }; + var AesProvider = class extends ProviderCrypto { + checkGenerateKeyParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "length"); + if (typeof algorithm2.length !== "number") { + throw new TypeError("length: Is not of type Number"); + } + switch (algorithm2.length) { + case 128: + case 192: + case 256: + break; + default: + throw new TypeError("length: Must be 128, 192, or 256"); + } + } + checkDerivedKeyParams(algorithm2) { + this.checkGenerateKeyParams(algorithm2); + } + }; + var AesCbcProvider = class extends AesProvider { + constructor() { + super(...arguments); + this.name = "AES-CBC"; + this.usages = ["encrypt", "decrypt", "wrapKey", "unwrapKey"]; + } + checkAlgorithmParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "iv"); + if (!(algorithm2.iv instanceof ArrayBuffer || ArrayBuffer.isView(algorithm2.iv))) { + throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'"); + } + if (algorithm2.iv.byteLength !== 16) { + throw new TypeError("iv: Must have length 16 bytes"); + } + } + }; + var AesCmacProvider = class extends AesProvider { + constructor() { + super(...arguments); + this.name = "AES-CMAC"; + this.usages = ["sign", "verify"]; + } + checkAlgorithmParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "length"); + if (typeof algorithm2.length !== "number") { + throw new TypeError("length: Is not a Number"); + } + if (algorithm2.length < 1) { + throw new OperationError("length: Must be more than 0"); + } + } + }; + var AesCtrProvider = class extends AesProvider { + constructor() { + super(...arguments); + this.name = "AES-CTR"; + this.usages = ["encrypt", "decrypt", "wrapKey", "unwrapKey"]; + } + checkAlgorithmParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "counter"); + if (!(algorithm2.counter instanceof ArrayBuffer || ArrayBuffer.isView(algorithm2.counter))) { + throw new TypeError("counter: Is not of type '(ArrayBuffer or ArrayBufferView)'"); + } + if (algorithm2.counter.byteLength !== 16) { + throw new TypeError("iv: Must have length 16 bytes"); + } + this.checkRequiredProperty(algorithm2, "length"); + if (typeof algorithm2.length !== "number") { + throw new TypeError("length: Is not a Number"); + } + if (algorithm2.length < 1) { + throw new OperationError("length: Must be more than 0"); + } + } + }; + var AesEcbProvider = class extends AesProvider { + constructor() { + super(...arguments); + this.name = "AES-ECB"; + this.usages = ["encrypt", "decrypt", "wrapKey", "unwrapKey"]; + } + }; + var AesGcmProvider = class extends AesProvider { + constructor() { + super(...arguments); + this.name = "AES-GCM"; + this.usages = ["encrypt", "decrypt", "wrapKey", "unwrapKey"]; + } + checkAlgorithmParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "iv"); + if (!(algorithm2.iv instanceof ArrayBuffer || ArrayBuffer.isView(algorithm2.iv))) { + throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'"); + } + if (algorithm2.iv.byteLength < 1) { + throw new OperationError("iv: Must have length more than 0 and less than 2^64 - 1"); + } + if (!("tagLength" in algorithm2)) { + algorithm2.tagLength = 128; + } + switch (algorithm2.tagLength) { + case 32: + case 64: + case 96: + case 104: + case 112: + case 120: + case 128: + break; + default: + throw new OperationError("tagLength: Must be one of 32, 64, 96, 104, 112, 120 or 128"); + } + } + }; + var AesKwProvider = class extends AesProvider { + constructor() { + super(...arguments); + this.name = "AES-KW"; + this.usages = ["wrapKey", "unwrapKey"]; + } + }; + var DesProvider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.usages = ["encrypt", "decrypt", "wrapKey", "unwrapKey"]; + } + checkAlgorithmParams(algorithm2) { + if (this.ivSize) { + this.checkRequiredProperty(algorithm2, "iv"); + if (!(algorithm2.iv instanceof ArrayBuffer || ArrayBuffer.isView(algorithm2.iv))) { + throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'"); + } + if (algorithm2.iv.byteLength !== this.ivSize) { + throw new TypeError(`iv: Must have length ${this.ivSize} bytes`); + } + } + } + checkGenerateKeyParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "length"); + if (typeof algorithm2.length !== "number") { + throw new TypeError("length: Is not of type Number"); + } + if (algorithm2.length !== this.keySizeBits) { + throw new OperationError(`algorithm.length: Must be ${this.keySizeBits}`); + } + } + checkDerivedKeyParams(algorithm2) { + this.checkGenerateKeyParams(algorithm2); + } + }; + var RsaProvider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.hashAlgorithms = ["SHA-1", "SHA-256", "SHA-384", "SHA-512"]; + } + checkGenerateKeyParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "hash"); + this.checkHashAlgorithm(algorithm2.hash, this.hashAlgorithms); + this.checkRequiredProperty(algorithm2, "publicExponent"); + if (!(algorithm2.publicExponent && algorithm2.publicExponent instanceof Uint8Array)) { + throw new TypeError("publicExponent: Missing or not a Uint8Array"); + } + const publicExponent = import_pvtsutils4.Convert.ToBase64(algorithm2.publicExponent); + if (!(publicExponent === "Aw==" || publicExponent === "AQAB")) { + throw new TypeError("publicExponent: Must be [3] or [1,0,1]"); + } + this.checkRequiredProperty(algorithm2, "modulusLength"); + if (algorithm2.modulusLength % 8 || algorithm2.modulusLength < 256 || algorithm2.modulusLength > 16384) { + throw new TypeError("The modulus length must be a multiple of 8 bits and >= 256 and <= 16384"); + } + } + checkImportParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "hash"); + this.checkHashAlgorithm(algorithm2.hash, this.hashAlgorithms); + } + }; + var RsaSsaProvider = class extends RsaProvider { + constructor() { + super(...arguments); + this.name = "RSASSA-PKCS1-v1_5"; + this.usages = { + privateKey: ["sign"], + publicKey: ["verify"] + }; + } + }; + var RsaPssProvider = class extends RsaProvider { + constructor() { + super(...arguments); + this.name = "RSA-PSS"; + this.usages = { + privateKey: ["sign"], + publicKey: ["verify"] + }; + } + checkAlgorithmParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "saltLength"); + if (typeof algorithm2.saltLength !== "number") { + throw new TypeError("saltLength: Is not a Number"); + } + if (algorithm2.saltLength < 0) { + throw new RangeError("saltLength: Must be positive number"); + } + } + }; + var RsaOaepProvider = class extends RsaProvider { + constructor() { + super(...arguments); + this.name = "RSA-OAEP"; + this.usages = { + privateKey: ["decrypt", "unwrapKey"], + publicKey: ["encrypt", "wrapKey"] + }; + } + checkAlgorithmParams(algorithm2) { + if (algorithm2.label && !(algorithm2.label instanceof ArrayBuffer || ArrayBuffer.isView(algorithm2.label))) { + throw new TypeError("label: Is not of type '(ArrayBuffer or ArrayBufferView)'"); + } + } + }; + var EllipticProvider = class extends ProviderCrypto { + checkGenerateKeyParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "namedCurve"); + this.checkNamedCurve(algorithm2.namedCurve); + } + checkNamedCurve(namedCurve) { + for (const item of this.namedCurves) { + if (item.toLowerCase() === namedCurve.toLowerCase()) { + return; + } + } + throw new OperationError(`namedCurve: Must be one of ${this.namedCurves.join(", ")}`); + } + }; + var EcdsaProvider = class extends EllipticProvider { + constructor() { + super(...arguments); + this.name = "ECDSA"; + this.hashAlgorithms = ["SHA-1", "SHA-256", "SHA-384", "SHA-512"]; + this.usages = { + privateKey: ["sign"], + publicKey: ["verify"] + }; + this.namedCurves = ["P-256", "P-384", "P-521", "K-256"]; + } + checkAlgorithmParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "hash"); + this.checkHashAlgorithm(algorithm2.hash, this.hashAlgorithms); + } + }; + var KEY_TYPES = ["secret", "private", "public"]; + var CryptoKey = class { + static create(algorithm2, type3, extractable, usages) { + const key = new this(); + key.algorithm = algorithm2; + key.type = type3; + key.extractable = extractable; + key.usages = usages; + return key; + } + static isKeyType(data) { + return KEY_TYPES.indexOf(data) !== -1; + } + get [Symbol.toStringTag]() { + return "CryptoKey"; + } + }; + var EcdhProvider = class extends EllipticProvider { + constructor() { + super(...arguments); + this.name = "ECDH"; + this.usages = { + privateKey: ["deriveBits", "deriveKey"], + publicKey: [] + }; + this.namedCurves = ["P-256", "P-384", "P-521", "K-256"]; + } + checkAlgorithmParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "public"); + if (!(algorithm2.public instanceof CryptoKey)) { + throw new TypeError("public: Is not a CryptoKey"); + } + if (algorithm2.public.type !== "public") { + throw new OperationError("public: Is not a public key"); + } + if (algorithm2.public.algorithm.name !== this.name) { + throw new OperationError(`public: Is not ${this.name} key`); + } + } + }; + var EcdhEsProvider = class extends EcdhProvider { + constructor() { + super(...arguments); + this.name = "ECDH-ES"; + this.namedCurves = ["X25519", "X448"]; + } + }; + var EdDsaProvider = class extends EllipticProvider { + constructor() { + super(...arguments); + this.name = "EdDSA"; + this.usages = { + privateKey: ["sign"], + publicKey: ["verify"] + }; + this.namedCurves = ["Ed25519", "Ed448"]; + } + }; + var ObjectIdentifier2 = class ObjectIdentifier3 { + constructor(value) { + if (value) { + this.value = value; + } + } + }; + __decorate([ + AsnProp({ type: AsnPropTypes.ObjectIdentifier }) + ], ObjectIdentifier2.prototype, "value", void 0); + ObjectIdentifier2 = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) + ], ObjectIdentifier2); + var AlgorithmIdentifier = class { + constructor(params) { + Object.assign(this, params); + } + }; + __decorate([ + AsnProp({ + type: AsnPropTypes.ObjectIdentifier + }) + ], AlgorithmIdentifier.prototype, "algorithm", void 0); + __decorate([ + AsnProp({ + type: AsnPropTypes.Any, + optional: true + }) + ], AlgorithmIdentifier.prototype, "parameters", void 0); + var PrivateKeyInfo = class { + constructor() { + this.version = 0; + this.privateKeyAlgorithm = new AlgorithmIdentifier(); + this.privateKey = new ArrayBuffer(0); + } + }; + __decorate([ + AsnProp({ type: AsnPropTypes.Integer }) + ], PrivateKeyInfo.prototype, "version", void 0); + __decorate([ + AsnProp({ type: AlgorithmIdentifier }) + ], PrivateKeyInfo.prototype, "privateKeyAlgorithm", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.OctetString }) + ], PrivateKeyInfo.prototype, "privateKey", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Any, optional: true }) + ], PrivateKeyInfo.prototype, "attributes", void 0); + var PublicKeyInfo = class { + constructor() { + this.publicKeyAlgorithm = new AlgorithmIdentifier(); + this.publicKey = new ArrayBuffer(0); + } + }; + __decorate([ + AsnProp({ type: AlgorithmIdentifier }) + ], PublicKeyInfo.prototype, "publicKeyAlgorithm", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.BitString }) + ], PublicKeyInfo.prototype, "publicKey", void 0); + var JsonBase64UrlArrayBufferConverter = { + fromJSON: (value) => import_pvtsutils4.Convert.FromBase64Url(value), + toJSON: (value) => import_pvtsutils4.Convert.ToBase64Url(new Uint8Array(value)) + }; + var AsnIntegerArrayBufferConverter = { + fromASN: (value) => { + const valueHex = value.valueBlock.valueHex; + return !new Uint8Array(valueHex)[0] ? value.valueBlock.valueHex.slice(1) : value.valueBlock.valueHex; + }, + toASN: (value) => { + const valueHex = new Uint8Array(value)[0] > 127 ? (0, import_pvtsutils4.combine)(new Uint8Array([0]).buffer, value) : value; + return new Integer3({ valueHex }); + } + }; + var RsaPrivateKey = class { + constructor() { + this.version = 0; + this.modulus = new ArrayBuffer(0); + this.publicExponent = new ArrayBuffer(0); + this.privateExponent = new ArrayBuffer(0); + this.prime1 = new ArrayBuffer(0); + this.prime2 = new ArrayBuffer(0); + this.exponent1 = new ArrayBuffer(0); + this.exponent2 = new ArrayBuffer(0); + this.coefficient = new ArrayBuffer(0); + } + }; + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerConverter }) + ], RsaPrivateKey.prototype, "version", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter }), + JsonProp({ name: "n", converter: JsonBase64UrlArrayBufferConverter }) + ], RsaPrivateKey.prototype, "modulus", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter }), + JsonProp({ name: "e", converter: JsonBase64UrlArrayBufferConverter }) + ], RsaPrivateKey.prototype, "publicExponent", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter }), + JsonProp({ name: "d", converter: JsonBase64UrlArrayBufferConverter }) + ], RsaPrivateKey.prototype, "privateExponent", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter }), + JsonProp({ name: "p", converter: JsonBase64UrlArrayBufferConverter }) + ], RsaPrivateKey.prototype, "prime1", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter }), + JsonProp({ name: "q", converter: JsonBase64UrlArrayBufferConverter }) + ], RsaPrivateKey.prototype, "prime2", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter }), + JsonProp({ name: "dp", converter: JsonBase64UrlArrayBufferConverter }) + ], RsaPrivateKey.prototype, "exponent1", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter }), + JsonProp({ name: "dq", converter: JsonBase64UrlArrayBufferConverter }) + ], RsaPrivateKey.prototype, "exponent2", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter }), + JsonProp({ name: "qi", converter: JsonBase64UrlArrayBufferConverter }) + ], RsaPrivateKey.prototype, "coefficient", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Any, optional: true }) + ], RsaPrivateKey.prototype, "otherPrimeInfos", void 0); + var RsaPublicKey = class { + constructor() { + this.modulus = new ArrayBuffer(0); + this.publicExponent = new ArrayBuffer(0); + } + }; + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter }), + JsonProp({ name: "n", converter: JsonBase64UrlArrayBufferConverter }) + ], RsaPublicKey.prototype, "modulus", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerArrayBufferConverter }), + JsonProp({ name: "e", converter: JsonBase64UrlArrayBufferConverter }) + ], RsaPublicKey.prototype, "publicExponent", void 0); + var EcPublicKey = class EcPublicKey2 { + constructor(value) { + this.value = new ArrayBuffer(0); + if (value) { + this.value = value; + } + } + toJSON() { + let bytes2 = new Uint8Array(this.value); + if (bytes2[0] !== 4) { + throw new CryptoError("Wrong ECPoint. Current version supports only Uncompressed (0x04) point"); + } + bytes2 = new Uint8Array(this.value.slice(1)); + const size4 = bytes2.length / 2; + const offset2 = 0; + const json = { + x: import_pvtsutils4.Convert.ToBase64Url(bytes2.buffer.slice(offset2, offset2 + size4)), + y: import_pvtsutils4.Convert.ToBase64Url(bytes2.buffer.slice(offset2 + size4, offset2 + size4 + size4)) + }; + return json; + } + fromJSON(json) { + if (!("x" in json)) { + throw new Error("x: Missing required property"); + } + if (!("y" in json)) { + throw new Error("y: Missing required property"); + } + const x5 = import_pvtsutils4.Convert.FromBase64Url(json.x); + const y7 = import_pvtsutils4.Convert.FromBase64Url(json.y); + const value = (0, import_pvtsutils4.combine)(new Uint8Array([4]).buffer, x5, y7); + this.value = new Uint8Array(value).buffer; + return this; + } + }; + __decorate([ + AsnProp({ type: AsnPropTypes.OctetString }) + ], EcPublicKey.prototype, "value", void 0); + EcPublicKey = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) + ], EcPublicKey); + var EcPrivateKey = class { + constructor() { + this.version = 1; + this.privateKey = new ArrayBuffer(0); + } + fromJSON(json) { + if (!("d" in json)) { + throw new Error("d: Missing required property"); + } + this.privateKey = import_pvtsutils4.Convert.FromBase64Url(json.d); + if ("x" in json) { + const publicKey = new EcPublicKey(); + publicKey.fromJSON(json); + const asn = AsnSerializer.toASN(publicKey); + if ("valueHex" in asn.valueBlock) { + this.publicKey = asn.valueBlock.valueHex; + } + } + return this; + } + toJSON() { + const jwk = {}; + jwk.d = import_pvtsutils4.Convert.ToBase64Url(this.privateKey); + if (this.publicKey) { + Object.assign(jwk, new EcPublicKey(this.publicKey).toJSON()); + } + return jwk; + } + }; + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerConverter }) + ], EcPrivateKey.prototype, "version", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.OctetString }) + ], EcPrivateKey.prototype, "privateKey", void 0); + __decorate([ + AsnProp({ context: 0, type: AsnPropTypes.Any, optional: true }) + ], EcPrivateKey.prototype, "parameters", void 0); + __decorate([ + AsnProp({ context: 1, type: AsnPropTypes.BitString, optional: true }) + ], EcPrivateKey.prototype, "publicKey", void 0); + var AsnIntegerWithoutPaddingConverter = { + fromASN: (value) => { + const bytes2 = new Uint8Array(value.valueBlock.valueHex); + return bytes2[0] === 0 ? bytes2.buffer.slice(1) : bytes2.buffer; + }, + toASN: (value) => { + const bytes2 = new Uint8Array(value); + if (bytes2[0] > 127) { + const newValue = new Uint8Array(bytes2.length + 1); + newValue.set(bytes2, 1); + return new Integer3({ valueHex: newValue.buffer }); + } + return new Integer3({ valueHex: value }); + } + }; + var index$2 = /* @__PURE__ */ Object.freeze({ + __proto__: null, + AsnIntegerWithoutPaddingConverter + }); + var EcUtils = class { + static decodePoint(data, pointSize) { + const view10 = import_pvtsutils4.BufferSourceConverter.toUint8Array(data); + if (view10.length === 0 || view10[0] !== 4) { + throw new Error("Only uncompressed point format supported"); + } + const n9 = (view10.length - 1) / 2; + if (n9 !== Math.ceil(pointSize / 8)) { + throw new Error("Point does not match field size"); + } + const xb = view10.slice(1, n9 + 1); + const yb = view10.slice(n9 + 1, n9 + 1 + n9); + return { x: xb, y: yb }; + } + static encodePoint(point, pointSize) { + const size4 = Math.ceil(pointSize / 8); + if (point.x.byteLength !== size4 || point.y.byteLength !== size4) { + throw new Error("X,Y coordinates don't match point size criteria"); + } + const x5 = import_pvtsutils4.BufferSourceConverter.toUint8Array(point.x); + const y7 = import_pvtsutils4.BufferSourceConverter.toUint8Array(point.y); + const res = new Uint8Array(size4 * 2 + 1); + res[0] = 4; + res.set(x5, 1); + res.set(y7, size4 + 1); + return res; + } + static getSize(pointSize) { + return Math.ceil(pointSize / 8); + } + static encodeSignature(signature, pointSize) { + const size4 = this.getSize(pointSize); + const r10 = import_pvtsutils4.BufferSourceConverter.toUint8Array(signature.r); + const s7 = import_pvtsutils4.BufferSourceConverter.toUint8Array(signature.s); + const res = new Uint8Array(size4 * 2); + res.set(this.padStart(r10, size4)); + res.set(this.padStart(s7, size4), size4); + return res; + } + static decodeSignature(data, pointSize) { + const size4 = this.getSize(pointSize); + const view10 = import_pvtsutils4.BufferSourceConverter.toUint8Array(data); + if (view10.length !== size4 * 2) { + throw new Error("Incorrect size of the signature"); + } + const r10 = view10.slice(0, size4); + const s7 = view10.slice(size4); + return { + r: this.trimStart(r10), + s: this.trimStart(s7) + }; + } + static trimStart(data) { + let i8 = 0; + while (i8 < data.length - 1 && data[i8] === 0) { + i8++; + } + if (i8 === 0) { + return data; + } + return data.slice(i8, data.length); + } + static padStart(data, size4) { + if (size4 === data.length) { + return data; + } + const res = new Uint8Array(size4); + res.set(data, size4 - data.length); + return res; + } + }; + var EcDsaSignature = class _EcDsaSignature { + constructor() { + this.r = new ArrayBuffer(0); + this.s = new ArrayBuffer(0); + } + static fromWebCryptoSignature(value) { + const pointSize = value.byteLength / 2; + const point = EcUtils.decodeSignature(value, pointSize * 8); + const ecSignature = new _EcDsaSignature(); + ecSignature.r = import_pvtsutils4.BufferSourceConverter.toArrayBuffer(point.r); + ecSignature.s = import_pvtsutils4.BufferSourceConverter.toArrayBuffer(point.s); + return ecSignature; + } + toWebCryptoSignature(pointSize) { + pointSize !== null && pointSize !== void 0 ? pointSize : pointSize = Math.max(this.r.byteLength, this.s.byteLength) * 8; + const signature = EcUtils.encodeSignature(this, pointSize); + return signature.buffer; + } + }; + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerWithoutPaddingConverter }) + ], EcDsaSignature.prototype, "r", void 0); + __decorate([ + AsnProp({ type: AsnPropTypes.Integer, converter: AsnIntegerWithoutPaddingConverter }) + ], EcDsaSignature.prototype, "s", void 0); + var OneAsymmetricKey = class extends PrivateKeyInfo { + }; + __decorate([ + AsnProp({ context: 1, implicit: true, type: AsnPropTypes.BitString, optional: true }) + ], OneAsymmetricKey.prototype, "publicKey", void 0); + var EdPrivateKey = class EdPrivateKey2 { + constructor() { + this.value = new ArrayBuffer(0); + } + fromJSON(json) { + if (!json.d) { + throw new Error("d: Missing required property"); + } + this.value = import_pvtsutils4.Convert.FromBase64Url(json.d); + return this; + } + toJSON() { + const jwk = { + d: import_pvtsutils4.Convert.ToBase64Url(this.value) + }; + return jwk; + } + }; + __decorate([ + AsnProp({ type: AsnPropTypes.OctetString }) + ], EdPrivateKey.prototype, "value", void 0); + EdPrivateKey = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) + ], EdPrivateKey); + var EdPublicKey = class EdPublicKey2 { + constructor(value) { + this.value = new ArrayBuffer(0); + if (value) { + this.value = value; + } + } + toJSON() { + const json = { + x: import_pvtsutils4.Convert.ToBase64Url(this.value) + }; + return json; + } + fromJSON(json) { + if (!("x" in json)) { + throw new Error("x: Missing required property"); + } + this.value = import_pvtsutils4.Convert.FromBase64Url(json.x); + return this; + } + }; + __decorate([ + AsnProp({ type: AsnPropTypes.BitString }) + ], EdPublicKey.prototype, "value", void 0); + EdPublicKey = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) + ], EdPublicKey); + var CurvePrivateKey = class CurvePrivateKey2 { + }; + __decorate([ + AsnProp({ type: AsnPropTypes.OctetString }), + JsonProp({ type: JsonPropTypes.String, converter: JsonBase64UrlArrayBufferConverter }) + ], CurvePrivateKey.prototype, "d", void 0); + CurvePrivateKey = __decorate([ + AsnType({ type: AsnTypeTypes.Choice }) + ], CurvePrivateKey); + var idSecp256r1 = "1.2.840.10045.3.1.7"; + var idEllipticCurve = "1.3.132.0"; + var idSecp384r1 = `${idEllipticCurve}.34`; + var idSecp521r1 = `${idEllipticCurve}.35`; + var idSecp256k1 = `${idEllipticCurve}.10`; + var idVersionOne = "1.3.36.3.3.2.8.1.1"; + var idBrainpoolP160r1 = `${idVersionOne}.1`; + var idBrainpoolP160t1 = `${idVersionOne}.2`; + var idBrainpoolP192r1 = `${idVersionOne}.3`; + var idBrainpoolP192t1 = `${idVersionOne}.4`; + var idBrainpoolP224r1 = `${idVersionOne}.5`; + var idBrainpoolP224t1 = `${idVersionOne}.6`; + var idBrainpoolP256r1 = `${idVersionOne}.7`; + var idBrainpoolP256t1 = `${idVersionOne}.8`; + var idBrainpoolP320r1 = `${idVersionOne}.9`; + var idBrainpoolP320t1 = `${idVersionOne}.10`; + var idBrainpoolP384r1 = `${idVersionOne}.11`; + var idBrainpoolP384t1 = `${idVersionOne}.12`; + var idBrainpoolP512r1 = `${idVersionOne}.13`; + var idBrainpoolP512t1 = `${idVersionOne}.14`; + var idX25519 = "1.3.101.110"; + var idX448 = "1.3.101.111"; + var idEd25519 = "1.3.101.112"; + var idEd448 = "1.3.101.113"; + var index$1 = /* @__PURE__ */ Object.freeze({ + __proto__: null, + AlgorithmIdentifier, + get CurvePrivateKey() { + return CurvePrivateKey; + }, + EcDsaSignature, + EcPrivateKey, + get EcPublicKey() { + return EcPublicKey; + }, + get EdPrivateKey() { + return EdPrivateKey; + }, + get EdPublicKey() { + return EdPublicKey; + }, + get ObjectIdentifier() { + return ObjectIdentifier2; + }, + OneAsymmetricKey, + PrivateKeyInfo, + PublicKeyInfo, + RsaPrivateKey, + RsaPublicKey, + converters: index$2, + idBrainpoolP160r1, + idBrainpoolP160t1, + idBrainpoolP192r1, + idBrainpoolP192t1, + idBrainpoolP224r1, + idBrainpoolP224t1, + idBrainpoolP256r1, + idBrainpoolP256t1, + idBrainpoolP320r1, + idBrainpoolP320t1, + idBrainpoolP384r1, + idBrainpoolP384t1, + idBrainpoolP512r1, + idBrainpoolP512t1, + idEd25519, + idEd448, + idEllipticCurve, + idSecp256k1, + idSecp256r1, + idSecp384r1, + idSecp521r1, + idVersionOne, + idX25519, + idX448 + }); + var EcCurves = class { + constructor() { + } + static register(item) { + const oid = new ObjectIdentifier2(); + oid.value = item.id; + const raw = AsnConvert.serialize(oid); + this.items.push({ + ...item, + raw + }); + this.names.push(item.name); + } + static find(nameOrId) { + nameOrId = nameOrId.toUpperCase(); + for (const item of this.items) { + if (item.name.toUpperCase() === nameOrId || item.id.toUpperCase() === nameOrId) { + return item; + } + } + return null; + } + static get(nameOrId) { + const res = this.find(nameOrId); + if (!res) { + throw new Error(`Unsupported EC named curve '${nameOrId}'`); + } + return res; + } + }; + EcCurves.items = []; + EcCurves.names = []; + EcCurves.register({ name: "P-256", id: idSecp256r1, size: 256 }); + EcCurves.register({ name: "P-384", id: idSecp384r1, size: 384 }); + EcCurves.register({ name: "P-521", id: idSecp521r1, size: 521 }); + EcCurves.register({ name: "K-256", id: idSecp256k1, size: 256 }); + EcCurves.register({ name: "brainpoolP160r1", id: idBrainpoolP160r1, size: 160 }); + EcCurves.register({ name: "brainpoolP160t1", id: idBrainpoolP160t1, size: 160 }); + EcCurves.register({ name: "brainpoolP192r1", id: idBrainpoolP192r1, size: 192 }); + EcCurves.register({ name: "brainpoolP192t1", id: idBrainpoolP192t1, size: 192 }); + EcCurves.register({ name: "brainpoolP224r1", id: idBrainpoolP224r1, size: 224 }); + EcCurves.register({ name: "brainpoolP224t1", id: idBrainpoolP224t1, size: 224 }); + EcCurves.register({ name: "brainpoolP256r1", id: idBrainpoolP256r1, size: 256 }); + EcCurves.register({ name: "brainpoolP256t1", id: idBrainpoolP256t1, size: 256 }); + EcCurves.register({ name: "brainpoolP320r1", id: idBrainpoolP320r1, size: 320 }); + EcCurves.register({ name: "brainpoolP320t1", id: idBrainpoolP320t1, size: 320 }); + EcCurves.register({ name: "brainpoolP384r1", id: idBrainpoolP384r1, size: 384 }); + EcCurves.register({ name: "brainpoolP384t1", id: idBrainpoolP384t1, size: 384 }); + EcCurves.register({ name: "brainpoolP512r1", id: idBrainpoolP512r1, size: 512 }); + EcCurves.register({ name: "brainpoolP512t1", id: idBrainpoolP512t1, size: 512 }); + var HmacProvider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.name = "HMAC"; + this.hashAlgorithms = ["SHA-1", "SHA-256", "SHA-384", "SHA-512"]; + this.usages = ["sign", "verify"]; + } + getDefaultLength(algName) { + switch (algName.toUpperCase()) { + case "SHA-1": + case "SHA-256": + case "SHA-384": + case "SHA-512": + return 512; + default: + throw new Error(`Unknown algorithm name '${algName}'`); + } + } + checkGenerateKeyParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "hash"); + this.checkHashAlgorithm(algorithm2.hash, this.hashAlgorithms); + if ("length" in algorithm2) { + if (typeof algorithm2.length !== "number") { + throw new TypeError("length: Is not a Number"); + } + if (algorithm2.length < 1) { + throw new RangeError("length: Number is out of range"); + } + } + } + checkImportParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "hash"); + this.checkHashAlgorithm(algorithm2.hash, this.hashAlgorithms); + } + }; + var Pbkdf2Provider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.name = "PBKDF2"; + this.hashAlgorithms = ["SHA-1", "SHA-256", "SHA-384", "SHA-512"]; + this.usages = ["deriveBits", "deriveKey"]; + } + checkAlgorithmParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "hash"); + this.checkHashAlgorithm(algorithm2.hash, this.hashAlgorithms); + this.checkRequiredProperty(algorithm2, "salt"); + if (!(algorithm2.salt instanceof ArrayBuffer || ArrayBuffer.isView(algorithm2.salt))) { + throw new TypeError("salt: Is not of type '(ArrayBuffer or ArrayBufferView)'"); + } + this.checkRequiredProperty(algorithm2, "iterations"); + if (typeof algorithm2.iterations !== "number") { + throw new TypeError("iterations: Is not a Number"); + } + if (algorithm2.iterations < 1) { + throw new TypeError("iterations: Is less than 1"); + } + } + checkImportKey(format16, keyData, algorithm2, extractable, keyUsages, ...args) { + super.checkImportKey(format16, keyData, algorithm2, extractable, keyUsages); + if (extractable) { + throw new SyntaxError("extractable: Must be 'false'"); + } + } + }; + var HkdfProvider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.name = "HKDF"; + this.hashAlgorithms = ["SHA-1", "SHA-256", "SHA-384", "SHA-512"]; + this.usages = ["deriveKey", "deriveBits"]; + } + checkAlgorithmParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "hash"); + this.checkHashAlgorithm(algorithm2.hash, this.hashAlgorithms); + this.checkRequiredProperty(algorithm2, "salt"); + if (!import_pvtsutils4.BufferSourceConverter.isBufferSource(algorithm2.salt)) { + throw new TypeError("salt: Is not of type '(ArrayBuffer or ArrayBufferView)'"); + } + this.checkRequiredProperty(algorithm2, "info"); + if (!import_pvtsutils4.BufferSourceConverter.isBufferSource(algorithm2.info)) { + throw new TypeError("salt: Is not of type '(ArrayBuffer or ArrayBufferView)'"); + } + } + checkImportKey(format16, keyData, algorithm2, extractable, keyUsages, ...args) { + super.checkImportKey(format16, keyData, algorithm2, extractable, keyUsages); + if (extractable) { + throw new SyntaxError("extractable: Must be 'false'"); + } + } + }; + var ShakeProvider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.usages = []; + this.defaultLength = 0; + } + digest(...args) { + args[0] = { length: this.defaultLength, ...args[0] }; + return super.digest.apply(this, args); + } + checkDigest(algorithm2, data) { + super.checkDigest(algorithm2, data); + const length3 = algorithm2.length || 0; + if (typeof length3 !== "number") { + throw new TypeError("length: Is not a Number"); + } + if (length3 < 0) { + throw new TypeError("length: Is negative"); + } + } + }; + var Shake128Provider = class extends ShakeProvider { + constructor() { + super(...arguments); + this.name = "shake128"; + this.defaultLength = 16; + } + }; + var Shake256Provider = class extends ShakeProvider { + constructor() { + super(...arguments); + this.name = "shake256"; + this.defaultLength = 32; + } + }; + var Crypto = class { + get [Symbol.toStringTag]() { + return "Crypto"; + } + randomUUID() { + const b6 = this.getRandomValues(new Uint8Array(16)); + b6[6] = b6[6] & 15 | 64; + b6[8] = b6[8] & 63 | 128; + const uuid = import_pvtsutils4.Convert.ToHex(b6).toLowerCase(); + return `${uuid.substring(0, 8)}-${uuid.substring(8, 12)}-${uuid.substring(12, 16)}-${uuid.substring(16, 20)}-${uuid.substring(20)}`; + } + }; + var ProviderStorage = class { + constructor() { + this.items = {}; + } + get(algorithmName) { + return this.items[algorithmName.toLowerCase()] || null; + } + set(provider) { + this.items[provider.name.toLowerCase()] = provider; + } + removeAt(algorithmName) { + const provider = this.get(algorithmName.toLowerCase()); + if (provider) { + delete this.items[algorithmName]; + } + return provider; + } + has(name15) { + return !!this.get(name15); + } + get length() { + return Object.keys(this.items).length; + } + get algorithms() { + const algorithms = []; + for (const key in this.items) { + const provider = this.items[key]; + algorithms.push(provider.name); + } + return algorithms.sort(); + } + }; + var SubtleCrypto = class _SubtleCrypto { + constructor() { + this.providers = new ProviderStorage(); + } + static isHashedAlgorithm(data) { + return data && typeof data === "object" && "name" in data && "hash" in data ? true : false; + } + get [Symbol.toStringTag]() { + return "SubtleCrypto"; + } + async digest(...args) { + this.checkRequiredArguments(args, 2, "digest"); + const [algorithm2, data, ...params] = args; + const preparedAlgorithm = this.prepareAlgorithm(algorithm2); + const preparedData = import_pvtsutils4.BufferSourceConverter.toArrayBuffer(data); + const provider = this.getProvider(preparedAlgorithm.name); + const result = await provider.digest(preparedAlgorithm, preparedData, ...params); + return result; + } + async generateKey(...args) { + this.checkRequiredArguments(args, 3, "generateKey"); + const [algorithm2, extractable, keyUsages, ...params] = args; + const preparedAlgorithm = this.prepareAlgorithm(algorithm2); + const provider = this.getProvider(preparedAlgorithm.name); + const result = await provider.generateKey({ ...preparedAlgorithm, name: provider.name }, extractable, keyUsages, ...params); + return result; + } + async sign(...args) { + this.checkRequiredArguments(args, 3, "sign"); + const [algorithm2, key, data, ...params] = args; + this.checkCryptoKey(key); + const preparedAlgorithm = this.prepareAlgorithm(algorithm2); + const preparedData = import_pvtsutils4.BufferSourceConverter.toArrayBuffer(data); + const provider = this.getProvider(preparedAlgorithm.name); + const result = await provider.sign({ ...preparedAlgorithm, name: provider.name }, key, preparedData, ...params); + return result; + } + async verify(...args) { + this.checkRequiredArguments(args, 4, "verify"); + const [algorithm2, key, signature, data, ...params] = args; + this.checkCryptoKey(key); + const preparedAlgorithm = this.prepareAlgorithm(algorithm2); + const preparedData = import_pvtsutils4.BufferSourceConverter.toArrayBuffer(data); + const preparedSignature = import_pvtsutils4.BufferSourceConverter.toArrayBuffer(signature); + const provider = this.getProvider(preparedAlgorithm.name); + const result = await provider.verify({ ...preparedAlgorithm, name: provider.name }, key, preparedSignature, preparedData, ...params); + return result; + } + async encrypt(...args) { + this.checkRequiredArguments(args, 3, "encrypt"); + const [algorithm2, key, data, ...params] = args; + this.checkCryptoKey(key); + const preparedAlgorithm = this.prepareAlgorithm(algorithm2); + const preparedData = import_pvtsutils4.BufferSourceConverter.toArrayBuffer(data); + const provider = this.getProvider(preparedAlgorithm.name); + const result = await provider.encrypt({ ...preparedAlgorithm, name: provider.name }, key, preparedData, { keyUsage: true }, ...params); + return result; + } + async decrypt(...args) { + this.checkRequiredArguments(args, 3, "decrypt"); + const [algorithm2, key, data, ...params] = args; + this.checkCryptoKey(key); + const preparedAlgorithm = this.prepareAlgorithm(algorithm2); + const preparedData = import_pvtsutils4.BufferSourceConverter.toArrayBuffer(data); + const provider = this.getProvider(preparedAlgorithm.name); + const result = await provider.decrypt({ ...preparedAlgorithm, name: provider.name }, key, preparedData, { keyUsage: true }, ...params); + return result; + } + async deriveBits(...args) { + this.checkRequiredArguments(args, 3, "deriveBits"); + const [algorithm2, baseKey, length3, ...params] = args; + this.checkCryptoKey(baseKey); + const preparedAlgorithm = this.prepareAlgorithm(algorithm2); + const provider = this.getProvider(preparedAlgorithm.name); + const result = await provider.deriveBits({ ...preparedAlgorithm, name: provider.name }, baseKey, length3, { keyUsage: true }, ...params); + return result; + } + async deriveKey(...args) { + this.checkRequiredArguments(args, 5, "deriveKey"); + const [algorithm2, baseKey, derivedKeyType, extractable, keyUsages, ...params] = args; + const preparedDerivedKeyType = this.prepareAlgorithm(derivedKeyType); + const importProvider = this.getProvider(preparedDerivedKeyType.name); + importProvider.checkDerivedKeyParams(preparedDerivedKeyType); + const preparedAlgorithm = this.prepareAlgorithm(algorithm2); + const provider = this.getProvider(preparedAlgorithm.name); + provider.checkCryptoKey(baseKey, "deriveKey"); + const derivedBits = await provider.deriveBits({ ...preparedAlgorithm, name: provider.name }, baseKey, derivedKeyType.length || 512, { keyUsage: false }, ...params); + return this.importKey("raw", derivedBits, derivedKeyType, extractable, keyUsages, ...params); + } + async exportKey(...args) { + this.checkRequiredArguments(args, 2, "exportKey"); + const [format16, key, ...params] = args; + this.checkCryptoKey(key); + const provider = this.getProvider(key.algorithm.name); + const result = await provider.exportKey(format16, key, ...params); + return result; + } + async importKey(...args) { + this.checkRequiredArguments(args, 5, "importKey"); + const [format16, keyData, algorithm2, extractable, keyUsages, ...params] = args; + const preparedAlgorithm = this.prepareAlgorithm(algorithm2); + const provider = this.getProvider(preparedAlgorithm.name); + if (["pkcs8", "spki", "raw"].indexOf(format16) !== -1) { + const preparedData = import_pvtsutils4.BufferSourceConverter.toArrayBuffer(keyData); + return provider.importKey(format16, preparedData, { ...preparedAlgorithm, name: provider.name }, extractable, keyUsages, ...params); + } else { + if (!keyData.kty) { + throw new TypeError("keyData: Is not JSON"); + } + } + return provider.importKey(format16, keyData, { ...preparedAlgorithm, name: provider.name }, extractable, keyUsages, ...params); + } + async wrapKey(format16, key, wrappingKey, wrapAlgorithm, ...args) { + let keyData = await this.exportKey(format16, key, ...args); + if (format16 === "jwk") { + const json = JSON.stringify(keyData); + keyData = import_pvtsutils4.Convert.FromUtf8String(json); + } + const preparedAlgorithm = this.prepareAlgorithm(wrapAlgorithm); + const preparedData = import_pvtsutils4.BufferSourceConverter.toArrayBuffer(keyData); + const provider = this.getProvider(preparedAlgorithm.name); + return provider.encrypt({ ...preparedAlgorithm, name: provider.name }, wrappingKey, preparedData, { keyUsage: false }, ...args); + } + async unwrapKey(format16, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages, ...args) { + const preparedAlgorithm = this.prepareAlgorithm(unwrapAlgorithm); + const preparedData = import_pvtsutils4.BufferSourceConverter.toArrayBuffer(wrappedKey); + const provider = this.getProvider(preparedAlgorithm.name); + let keyData = await provider.decrypt({ ...preparedAlgorithm, name: provider.name }, unwrappingKey, preparedData, { keyUsage: false }, ...args); + if (format16 === "jwk") { + try { + keyData = JSON.parse(import_pvtsutils4.Convert.ToUtf8String(keyData)); + } catch (e12) { + const error7 = new TypeError("wrappedKey: Is not a JSON"); + error7.internal = e12; + throw error7; + } + } + return this.importKey(format16, keyData, unwrappedKeyAlgorithm, extractable, keyUsages, ...args); + } + checkRequiredArguments(args, size4, methodName) { + if (args.length < size4) { + throw new TypeError(`Failed to execute '${methodName}' on 'SubtleCrypto': ${size4} arguments required, but only ${args.length} present`); + } + } + prepareAlgorithm(algorithm2) { + if (typeof algorithm2 === "string") { + return { + name: algorithm2 + }; + } + if (_SubtleCrypto.isHashedAlgorithm(algorithm2)) { + const preparedAlgorithm = { ...algorithm2 }; + preparedAlgorithm.hash = this.prepareAlgorithm(algorithm2.hash); + return preparedAlgorithm; + } + return { ...algorithm2 }; + } + getProvider(name15) { + const provider = this.providers.get(name15); + if (!provider) { + throw new AlgorithmError("Unrecognized name"); + } + return provider; + } + checkCryptoKey(key) { + if (!(key instanceof CryptoKey)) { + throw new TypeError(`Key is not of type 'CryptoKey'`); + } + } + }; + + // ../../node_modules/.pnpm/@peculiar+webcrypto@1.4.3/node_modules/@peculiar/webcrypto/build/webcrypto.es.js + init_empty(); + var import_pvtsutils6 = __toESM(require_build()); + var JsonBase64UrlConverter = { + fromJSON: (value) => Buffer.from(import_pvtsutils6.Convert.FromBase64Url(value)), + toJSON: (value) => import_pvtsutils6.Convert.ToBase64Url(value) + }; + var CryptoKey2 = class extends CryptoKey { + constructor() { + super(...arguments); + this.data = Buffer.alloc(0); + this.algorithm = { name: "" }; + this.extractable = false; + this.type = "secret"; + this.usages = []; + this.kty = "oct"; + this.alg = ""; + } + }; + __decorate([ + JsonProp({ name: "ext", type: JsonPropTypes.Boolean, optional: true }) + ], CryptoKey2.prototype, "extractable", void 0); + __decorate([ + JsonProp({ name: "key_ops", type: JsonPropTypes.String, repeated: true, optional: true }) + ], CryptoKey2.prototype, "usages", void 0); + __decorate([ + JsonProp({ type: JsonPropTypes.String }) + ], CryptoKey2.prototype, "kty", void 0); + __decorate([ + JsonProp({ type: JsonPropTypes.String, optional: true }) + ], CryptoKey2.prototype, "alg", void 0); + var SymmetricKey = class extends CryptoKey2 { + constructor() { + super(...arguments); + this.kty = "oct"; + this.type = "secret"; + } + }; + var AsymmetricKey = class extends CryptoKey2 { + }; + var AesCryptoKey = class extends SymmetricKey { + get alg() { + switch (this.algorithm.name.toUpperCase()) { + case "AES-CBC": + return `A${this.algorithm.length}CBC`; + case "AES-CTR": + return `A${this.algorithm.length}CTR`; + case "AES-GCM": + return `A${this.algorithm.length}GCM`; + case "AES-KW": + return `A${this.algorithm.length}KW`; + case "AES-CMAC": + return `A${this.algorithm.length}CMAC`; + case "AES-ECB": + return `A${this.algorithm.length}ECB`; + default: + throw new AlgorithmError("Unsupported algorithm name"); + } + } + set alg(value) { + } + }; + __decorate([ + JsonProp({ name: "k", converter: JsonBase64UrlConverter }) + ], AesCryptoKey.prototype, "data", void 0); + var AesCrypto = class { + static async generateKey(algorithm2, extractable, keyUsages) { + const key = new AesCryptoKey(); + key.algorithm = algorithm2; + key.extractable = extractable; + key.usages = keyUsages; + key.data = exports6.randomBytes(algorithm2.length >> 3); + return key; + } + static async exportKey(format16, key) { + if (!(key instanceof AesCryptoKey)) { + throw new Error("key: Is not AesCryptoKey"); + } + switch (format16.toLowerCase()) { + case "jwk": + return JsonSerializer.toJSON(key); + case "raw": + return new Uint8Array(key.data).buffer; + default: + throw new OperationError("format: Must be 'jwk' or 'raw'"); + } + } + static async importKey(format16, keyData, algorithm2, extractable, keyUsages) { + let key; + switch (format16.toLowerCase()) { + case "jwk": + key = JsonParser.fromJSON(keyData, { targetSchema: AesCryptoKey }); + break; + case "raw": + key = new AesCryptoKey(); + key.data = Buffer.from(keyData); + break; + default: + throw new OperationError("format: Must be 'jwk' or 'raw'"); + } + key.algorithm = algorithm2; + key.algorithm.length = key.data.length << 3; + key.extractable = extractable; + key.usages = keyUsages; + switch (key.algorithm.length) { + case 128: + case 192: + case 256: + break; + default: + throw new OperationError("keyData: Is wrong key length"); + } + return key; + } + static async encrypt(algorithm2, key, data) { + switch (algorithm2.name.toUpperCase()) { + case "AES-CBC": + return this.encryptAesCBC(algorithm2, key, Buffer.from(data)); + case "AES-CTR": + return this.encryptAesCTR(algorithm2, key, Buffer.from(data)); + case "AES-GCM": + return this.encryptAesGCM(algorithm2, key, Buffer.from(data)); + case "AES-KW": + return this.encryptAesKW(algorithm2, key, Buffer.from(data)); + case "AES-ECB": + return this.encryptAesECB(algorithm2, key, Buffer.from(data)); + default: + throw new OperationError("algorithm: Is not recognized"); + } + } + static async decrypt(algorithm2, key, data) { + if (!(key instanceof AesCryptoKey)) { + throw new Error("key: Is not AesCryptoKey"); + } + switch (algorithm2.name.toUpperCase()) { + case "AES-CBC": + return this.decryptAesCBC(algorithm2, key, Buffer.from(data)); + case "AES-CTR": + return this.decryptAesCTR(algorithm2, key, Buffer.from(data)); + case "AES-GCM": + return this.decryptAesGCM(algorithm2, key, Buffer.from(data)); + case "AES-KW": + return this.decryptAesKW(algorithm2, key, Buffer.from(data)); + case "AES-ECB": + return this.decryptAesECB(algorithm2, key, Buffer.from(data)); + default: + throw new OperationError("algorithm: Is not recognized"); + } + } + static async encryptAesCBC(algorithm2, key, data) { + const cipher = exports6.createCipheriv(`aes-${key.algorithm.length}-cbc`, key.data, new Uint8Array(algorithm2.iv)); + let enc = cipher.update(data); + enc = Buffer.concat([enc, cipher.final()]); + const res = new Uint8Array(enc).buffer; + return res; + } + static async decryptAesCBC(algorithm2, key, data) { + const decipher = exports6.createDecipheriv(`aes-${key.algorithm.length}-cbc`, key.data, new Uint8Array(algorithm2.iv)); + let dec = decipher.update(data); + dec = Buffer.concat([dec, decipher.final()]); + return new Uint8Array(dec).buffer; + } + static async encryptAesCTR(algorithm2, key, data) { + const cipher = exports6.createCipheriv(`aes-${key.algorithm.length}-ctr`, key.data, Buffer.from(algorithm2.counter)); + let enc = cipher.update(data); + enc = Buffer.concat([enc, cipher.final()]); + const res = new Uint8Array(enc).buffer; + return res; + } + static async decryptAesCTR(algorithm2, key, data) { + const decipher = exports6.createDecipheriv(`aes-${key.algorithm.length}-ctr`, key.data, new Uint8Array(algorithm2.counter)); + let dec = decipher.update(data); + dec = Buffer.concat([dec, decipher.final()]); + return new Uint8Array(dec).buffer; + } + static async encryptAesGCM(algorithm2, key, data) { + const cipher = exports6.createCipheriv(`aes-${key.algorithm.length}-gcm`, key.data, Buffer.from(algorithm2.iv), { + authTagLength: (algorithm2.tagLength || 128) >> 3 + }); + if (algorithm2.additionalData) { + cipher.setAAD(Buffer.from(algorithm2.additionalData)); + } + let enc = cipher.update(data); + enc = Buffer.concat([enc, cipher.final(), cipher.getAuthTag()]); + const res = new Uint8Array(enc).buffer; + return res; + } + static async decryptAesGCM(algorithm2, key, data) { + const decipher = exports6.createDecipheriv(`aes-${key.algorithm.length}-gcm`, key.data, new Uint8Array(algorithm2.iv)); + const tagLength = (algorithm2.tagLength || 128) >> 3; + const enc = data.slice(0, data.length - tagLength); + const tag2 = data.slice(data.length - tagLength); + if (algorithm2.additionalData) { + decipher.setAAD(Buffer.from(algorithm2.additionalData)); + } + decipher.setAuthTag(tag2); + let dec = decipher.update(enc); + dec = Buffer.concat([dec, decipher.final()]); + return new Uint8Array(dec).buffer; + } + static async encryptAesKW(algorithm2, key, data) { + const cipher = exports6.createCipheriv(`id-aes${key.algorithm.length}-wrap`, key.data, this.AES_KW_IV); + let enc = cipher.update(data); + enc = Buffer.concat([enc, cipher.final()]); + return new Uint8Array(enc).buffer; + } + static async decryptAesKW(algorithm2, key, data) { + const decipher = exports6.createDecipheriv(`id-aes${key.algorithm.length}-wrap`, key.data, this.AES_KW_IV); + let dec = decipher.update(data); + dec = Buffer.concat([dec, decipher.final()]); + return new Uint8Array(dec).buffer; + } + static async encryptAesECB(algorithm2, key, data) { + const cipher = exports6.createCipheriv(`aes-${key.algorithm.length}-ecb`, key.data, new Uint8Array(0)); + let enc = cipher.update(data); + enc = Buffer.concat([enc, cipher.final()]); + const res = new Uint8Array(enc).buffer; + return res; + } + static async decryptAesECB(algorithm2, key, data) { + const decipher = exports6.createDecipheriv(`aes-${key.algorithm.length}-ecb`, key.data, new Uint8Array(0)); + let dec = decipher.update(data); + dec = Buffer.concat([dec, decipher.final()]); + return new Uint8Array(dec).buffer; + } + }; + AesCrypto.AES_KW_IV = Buffer.from("A6A6A6A6A6A6A6A6", "hex"); + var keyStorage = /* @__PURE__ */ new WeakMap(); + function getCryptoKey(key) { + const res = keyStorage.get(key); + if (!res) { + throw new OperationError("Cannot get CryptoKey from secure storage"); + } + return res; + } + function setCryptoKey(value) { + const key = CryptoKey.create(value.algorithm, value.type, value.extractable, value.usages); + Object.freeze(key); + keyStorage.set(key, value); + return key; + } + var AesCbcProvider2 = class extends AesCbcProvider { + async onGenerateKey(algorithm2, extractable, keyUsages) { + const key = await AesCrypto.generateKey({ + name: this.name, + length: algorithm2.length + }, extractable, keyUsages); + return setCryptoKey(key); + } + async onEncrypt(algorithm2, key, data) { + return AesCrypto.encrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onDecrypt(algorithm2, key, data) { + return AesCrypto.decrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onExportKey(format16, key) { + return AesCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const key = await AesCrypto.importKey(format16, keyData, { name: algorithm2.name }, extractable, keyUsages); + return setCryptoKey(key); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + if (!(getCryptoKey(key) instanceof AesCryptoKey)) { + throw new TypeError("key: Is not a AesCryptoKey"); + } + } + }; + var zero = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + var rb = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 135]); + var blockSize = 16; + function bitShiftLeft(buffer4) { + const shifted = Buffer.alloc(buffer4.length); + const last2 = buffer4.length - 1; + for (let index2 = 0; index2 < last2; index2++) { + shifted[index2] = buffer4[index2] << 1; + if (buffer4[index2 + 1] & 128) { + shifted[index2] += 1; + } + } + shifted[last2] = buffer4[last2] << 1; + return shifted; + } + function xor2(a8, b6) { + const length3 = Math.min(a8.length, b6.length); + const output = Buffer.alloc(length3); + for (let index2 = 0; index2 < length3; index2++) { + output[index2] = a8[index2] ^ b6[index2]; + } + return output; + } + function aes(key, message2) { + const cipher = createCipheriv(`aes${key.length << 3}`, key, zero); + const result = cipher.update(message2); + cipher.final(); + return result; + } + function getMessageBlock(message2, blockIndex) { + const block = Buffer.alloc(blockSize); + const start = blockIndex * blockSize; + const end = start + blockSize; + message2.copy(block, 0, start, end); + return block; + } + function getPaddedMessageBlock(message2, blockIndex) { + const block = Buffer.alloc(blockSize); + const start = blockIndex * blockSize; + const end = message2.length; + block.fill(0); + message2.copy(block, 0, start, end); + block[end - start] = 128; + return block; + } + function generateSubkeys(key) { + const l8 = aes(key, zero); + let subkey1 = bitShiftLeft(l8); + if (l8[0] & 128) { + subkey1 = xor2(subkey1, rb); + } + let subkey2 = bitShiftLeft(subkey1); + if (subkey1[0] & 128) { + subkey2 = xor2(subkey2, rb); + } + return { subkey1, subkey2 }; + } + function aesCmac(key, message2) { + const subkeys = generateSubkeys(key); + let blockCount = Math.ceil(message2.length / blockSize); + let lastBlockCompleteFlag; + let lastBlock; + if (blockCount === 0) { + blockCount = 1; + lastBlockCompleteFlag = false; + } else { + lastBlockCompleteFlag = message2.length % blockSize === 0; + } + const lastBlockIndex = blockCount - 1; + if (lastBlockCompleteFlag) { + lastBlock = xor2(getMessageBlock(message2, lastBlockIndex), subkeys.subkey1); + } else { + lastBlock = xor2(getPaddedMessageBlock(message2, lastBlockIndex), subkeys.subkey2); + } + let x5 = zero; + let y7; + for (let index2 = 0; index2 < lastBlockIndex; index2++) { + y7 = xor2(x5, getMessageBlock(message2, index2)); + x5 = aes(key, y7); + } + y7 = xor2(lastBlock, x5); + return aes(key, y7); + } + var AesCmacProvider2 = class extends AesCmacProvider { + async onGenerateKey(algorithm2, extractable, keyUsages) { + const key = await AesCrypto.generateKey({ + name: this.name, + length: algorithm2.length + }, extractable, keyUsages); + return setCryptoKey(key); + } + async onSign(algorithm2, key, data) { + const result = aesCmac(getCryptoKey(key).data, Buffer.from(data)); + return new Uint8Array(result).buffer; + } + async onVerify(algorithm2, key, signature, data) { + const signature2 = await this.sign(algorithm2, key, data); + return Buffer.from(signature).compare(Buffer.from(signature2)) === 0; + } + async onExportKey(format16, key) { + return AesCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const res = await AesCrypto.importKey(format16, keyData, { name: algorithm2.name }, extractable, keyUsages); + return setCryptoKey(res); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + if (!(getCryptoKey(key) instanceof AesCryptoKey)) { + throw new TypeError("key: Is not a AesCryptoKey"); + } + } + }; + var AesCtrProvider2 = class extends AesCtrProvider { + async onGenerateKey(algorithm2, extractable, keyUsages) { + const key = await AesCrypto.generateKey({ + name: this.name, + length: algorithm2.length + }, extractable, keyUsages); + return setCryptoKey(key); + } + async onEncrypt(algorithm2, key, data) { + return AesCrypto.encrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onDecrypt(algorithm2, key, data) { + return AesCrypto.decrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onExportKey(format16, key) { + return AesCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const res = await AesCrypto.importKey(format16, keyData, { name: algorithm2.name }, extractable, keyUsages); + return setCryptoKey(res); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + if (!(getCryptoKey(key) instanceof AesCryptoKey)) { + throw new TypeError("key: Is not a AesCryptoKey"); + } + } + }; + var AesGcmProvider2 = class extends AesGcmProvider { + async onGenerateKey(algorithm2, extractable, keyUsages) { + const key = await AesCrypto.generateKey({ + name: this.name, + length: algorithm2.length + }, extractable, keyUsages); + return setCryptoKey(key); + } + async onEncrypt(algorithm2, key, data) { + return AesCrypto.encrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onDecrypt(algorithm2, key, data) { + return AesCrypto.decrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onExportKey(format16, key) { + return AesCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const res = await AesCrypto.importKey(format16, keyData, { name: algorithm2.name }, extractable, keyUsages); + return setCryptoKey(res); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + if (!(getCryptoKey(key) instanceof AesCryptoKey)) { + throw new TypeError("key: Is not a AesCryptoKey"); + } + } + }; + var AesKwProvider2 = class extends AesKwProvider { + async onGenerateKey(algorithm2, extractable, keyUsages) { + const res = await AesCrypto.generateKey({ + name: this.name, + length: algorithm2.length + }, extractable, keyUsages); + return setCryptoKey(res); + } + async onExportKey(format16, key) { + return AesCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const res = await AesCrypto.importKey(format16, keyData, { name: algorithm2.name }, extractable, keyUsages); + return setCryptoKey(res); + } + async onEncrypt(algorithm2, key, data) { + return AesCrypto.encrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onDecrypt(algorithm2, key, data) { + return AesCrypto.decrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + if (!(getCryptoKey(key) instanceof AesCryptoKey)) { + throw new TypeError("key: Is not a AesCryptoKey"); + } + } + }; + var AesEcbProvider2 = class extends AesEcbProvider { + async onGenerateKey(algorithm2, extractable, keyUsages) { + const key = await AesCrypto.generateKey({ + name: this.name, + length: algorithm2.length + }, extractable, keyUsages); + return setCryptoKey(key); + } + async onEncrypt(algorithm2, key, data) { + return AesCrypto.encrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onDecrypt(algorithm2, key, data) { + return AesCrypto.decrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onExportKey(format16, key) { + return AesCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const res = await AesCrypto.importKey(format16, keyData, { name: algorithm2.name }, extractable, keyUsages); + return setCryptoKey(res); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + if (!(getCryptoKey(key) instanceof AesCryptoKey)) { + throw new TypeError("key: Is not a AesCryptoKey"); + } + } + }; + var DesCryptoKey = class extends SymmetricKey { + get alg() { + switch (this.algorithm.name.toUpperCase()) { + case "DES-CBC": + return `DES-CBC`; + case "DES-EDE3-CBC": + return `3DES-CBC`; + default: + throw new AlgorithmError("Unsupported algorithm name"); + } + } + set alg(value) { + } + }; + __decorate([ + JsonProp({ name: "k", converter: JsonBase64UrlConverter }) + ], DesCryptoKey.prototype, "data", void 0); + var DesCrypto = class { + static async generateKey(algorithm2, extractable, keyUsages) { + const key = new DesCryptoKey(); + key.algorithm = algorithm2; + key.extractable = extractable; + key.usages = keyUsages; + key.data = exports6.randomBytes(algorithm2.length >> 3); + return key; + } + static async exportKey(format16, key) { + switch (format16.toLowerCase()) { + case "jwk": + return JsonSerializer.toJSON(key); + case "raw": + return new Uint8Array(key.data).buffer; + default: + throw new OperationError("format: Must be 'jwk' or 'raw'"); + } + } + static async importKey(format16, keyData, algorithm2, extractable, keyUsages) { + let key; + switch (format16.toLowerCase()) { + case "jwk": + key = JsonParser.fromJSON(keyData, { targetSchema: DesCryptoKey }); + break; + case "raw": + key = new DesCryptoKey(); + key.data = Buffer.from(keyData); + break; + default: + throw new OperationError("format: Must be 'jwk' or 'raw'"); + } + key.algorithm = algorithm2; + key.extractable = extractable; + key.usages = keyUsages; + return key; + } + static async encrypt(algorithm2, key, data) { + switch (algorithm2.name.toUpperCase()) { + case "DES-CBC": + return this.encryptDesCBC(algorithm2, key, Buffer.from(data)); + case "DES-EDE3-CBC": + return this.encryptDesEDE3CBC(algorithm2, key, Buffer.from(data)); + default: + throw new OperationError("algorithm: Is not recognized"); + } + } + static async decrypt(algorithm2, key, data) { + if (!(key instanceof DesCryptoKey)) { + throw new Error("key: Is not DesCryptoKey"); + } + switch (algorithm2.name.toUpperCase()) { + case "DES-CBC": + return this.decryptDesCBC(algorithm2, key, Buffer.from(data)); + case "DES-EDE3-CBC": + return this.decryptDesEDE3CBC(algorithm2, key, Buffer.from(data)); + default: + throw new OperationError("algorithm: Is not recognized"); + } + } + static async encryptDesCBC(algorithm2, key, data) { + const cipher = exports6.createCipheriv(`des-cbc`, key.data, new Uint8Array(algorithm2.iv)); + let enc = cipher.update(data); + enc = Buffer.concat([enc, cipher.final()]); + const res = new Uint8Array(enc).buffer; + return res; + } + static async decryptDesCBC(algorithm2, key, data) { + const decipher = exports6.createDecipheriv(`des-cbc`, key.data, new Uint8Array(algorithm2.iv)); + let dec = decipher.update(data); + dec = Buffer.concat([dec, decipher.final()]); + return new Uint8Array(dec).buffer; + } + static async encryptDesEDE3CBC(algorithm2, key, data) { + const cipher = exports6.createCipheriv(`des-ede3-cbc`, key.data, Buffer.from(algorithm2.iv)); + let enc = cipher.update(data); + enc = Buffer.concat([enc, cipher.final()]); + const res = new Uint8Array(enc).buffer; + return res; + } + static async decryptDesEDE3CBC(algorithm2, key, data) { + const decipher = exports6.createDecipheriv(`des-ede3-cbc`, key.data, new Uint8Array(algorithm2.iv)); + let dec = decipher.update(data); + dec = Buffer.concat([dec, decipher.final()]); + return new Uint8Array(dec).buffer; + } + }; + var DesCbcProvider = class extends DesProvider { + constructor() { + super(...arguments); + this.keySizeBits = 64; + this.ivSize = 8; + this.name = "DES-CBC"; + } + async onGenerateKey(algorithm2, extractable, keyUsages) { + const key = await DesCrypto.generateKey({ + name: this.name, + length: this.keySizeBits + }, extractable, keyUsages); + return setCryptoKey(key); + } + async onEncrypt(algorithm2, key, data) { + return DesCrypto.encrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onDecrypt(algorithm2, key, data) { + return DesCrypto.decrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onExportKey(format16, key) { + return DesCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const key = await DesCrypto.importKey(format16, keyData, { name: this.name, length: this.keySizeBits }, extractable, keyUsages); + if (key.data.length !== this.keySizeBits >> 3) { + throw new OperationError("keyData: Wrong key size"); + } + return setCryptoKey(key); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + if (!(getCryptoKey(key) instanceof DesCryptoKey)) { + throw new TypeError("key: Is not a DesCryptoKey"); + } + } + }; + var DesEde3CbcProvider = class extends DesProvider { + constructor() { + super(...arguments); + this.keySizeBits = 192; + this.ivSize = 8; + this.name = "DES-EDE3-CBC"; + } + async onGenerateKey(algorithm2, extractable, keyUsages) { + const key = await DesCrypto.generateKey({ + name: this.name, + length: this.keySizeBits + }, extractable, keyUsages); + return setCryptoKey(key); + } + async onEncrypt(algorithm2, key, data) { + return DesCrypto.encrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onDecrypt(algorithm2, key, data) { + return DesCrypto.decrypt(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onExportKey(format16, key) { + return DesCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const key = await DesCrypto.importKey(format16, keyData, { name: this.name, length: this.keySizeBits }, extractable, keyUsages); + if (key.data.length !== this.keySizeBits >> 3) { + throw new OperationError("keyData: Wrong key size"); + } + return setCryptoKey(key); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + if (!(getCryptoKey(key) instanceof DesCryptoKey)) { + throw new TypeError("key: Is not a DesCryptoKey"); + } + } + }; + function getJwkAlgorithm(algorithm2) { + switch (algorithm2.name.toUpperCase()) { + case "RSA-OAEP": { + const mdSize = /(\d+)$/.exec(algorithm2.hash.name)[1]; + return `RSA-OAEP${mdSize !== "1" ? `-${mdSize}` : ""}`; + } + case "RSASSA-PKCS1-V1_5": + return `RS${/(\d+)$/.exec(algorithm2.hash.name)[1]}`; + case "RSA-PSS": + return `PS${/(\d+)$/.exec(algorithm2.hash.name)[1]}`; + case "RSA-PKCS1": + return `RS1`; + default: + throw new OperationError("algorithm: Is not recognized"); + } + } + var RsaPrivateKey2 = class extends AsymmetricKey { + constructor() { + super(...arguments); + this.type = "private"; + } + getKey() { + const keyInfo = AsnParser.parse(this.data, index$1.PrivateKeyInfo); + return AsnParser.parse(keyInfo.privateKey, index$1.RsaPrivateKey); + } + toJSON() { + const key = this.getKey(); + const json = { + kty: "RSA", + alg: getJwkAlgorithm(this.algorithm), + key_ops: this.usages, + ext: this.extractable + }; + return Object.assign(json, JsonSerializer.toJSON(key)); + } + fromJSON(json) { + const key = JsonParser.fromJSON(json, { targetSchema: index$1.RsaPrivateKey }); + const keyInfo = new index$1.PrivateKeyInfo(); + keyInfo.privateKeyAlgorithm.algorithm = "1.2.840.113549.1.1.1"; + keyInfo.privateKeyAlgorithm.parameters = null; + keyInfo.privateKey = AsnSerializer.serialize(key); + this.data = Buffer.from(AsnSerializer.serialize(keyInfo)); + } + }; + var RsaPublicKey2 = class extends AsymmetricKey { + constructor() { + super(...arguments); + this.type = "public"; + } + getKey() { + const keyInfo = AsnParser.parse(this.data, index$1.PublicKeyInfo); + return AsnParser.parse(keyInfo.publicKey, index$1.RsaPublicKey); + } + toJSON() { + const key = this.getKey(); + const json = { + kty: "RSA", + alg: getJwkAlgorithm(this.algorithm), + key_ops: this.usages, + ext: this.extractable + }; + return Object.assign(json, JsonSerializer.toJSON(key)); + } + fromJSON(json) { + const key = JsonParser.fromJSON(json, { targetSchema: index$1.RsaPublicKey }); + const keyInfo = new index$1.PublicKeyInfo(); + keyInfo.publicKeyAlgorithm.algorithm = "1.2.840.113549.1.1.1"; + keyInfo.publicKeyAlgorithm.parameters = null; + keyInfo.publicKey = AsnSerializer.serialize(key); + this.data = Buffer.from(AsnSerializer.serialize(keyInfo)); + } + }; + var RsaCrypto = class { + static async generateKey(algorithm2, extractable, keyUsages) { + const privateKey = new RsaPrivateKey2(); + privateKey.algorithm = algorithm2; + privateKey.extractable = extractable; + privateKey.usages = keyUsages.filter((usage) => this.privateKeyUsages.indexOf(usage) !== -1); + const publicKey = new RsaPublicKey2(); + publicKey.algorithm = algorithm2; + publicKey.extractable = true; + publicKey.usages = keyUsages.filter((usage) => this.publicKeyUsages.indexOf(usage) !== -1); + const publicExponent = Buffer.concat([ + Buffer.alloc(4 - algorithm2.publicExponent.byteLength, 0), + Buffer.from(algorithm2.publicExponent) + ]).readInt32BE(0); + const keys2 = exports6.generateKeyPairSync("rsa", { + modulusLength: algorithm2.modulusLength, + publicExponent, + publicKeyEncoding: { + format: "der", + type: "spki" + }, + privateKeyEncoding: { + format: "der", + type: "pkcs8" + } + }); + privateKey.data = keys2.privateKey; + publicKey.data = keys2.publicKey; + const res = { + privateKey, + publicKey + }; + return res; + } + static async exportKey(format16, key) { + switch (format16.toLowerCase()) { + case "jwk": + return JsonSerializer.toJSON(key); + case "pkcs8": + case "spki": + return new Uint8Array(key.data).buffer; + default: + throw new OperationError("format: Must be 'jwk', 'pkcs8' or 'spki'"); + } + } + static async importKey(format16, keyData, algorithm2, extractable, keyUsages) { + switch (format16.toLowerCase()) { + case "jwk": { + const jwk = keyData; + if (jwk.d) { + const asnKey = JsonParser.fromJSON(keyData, { targetSchema: index$1.RsaPrivateKey }); + return this.importPrivateKey(asnKey, algorithm2, extractable, keyUsages); + } else { + const asnKey = JsonParser.fromJSON(keyData, { targetSchema: index$1.RsaPublicKey }); + return this.importPublicKey(asnKey, algorithm2, extractable, keyUsages); + } + } + case "spki": { + const keyInfo = AsnParser.parse(new Uint8Array(keyData), index$1.PublicKeyInfo); + const asnKey = AsnParser.parse(keyInfo.publicKey, index$1.RsaPublicKey); + return this.importPublicKey(asnKey, algorithm2, extractable, keyUsages); + } + case "pkcs8": { + const keyInfo = AsnParser.parse(new Uint8Array(keyData), index$1.PrivateKeyInfo); + const asnKey = AsnParser.parse(keyInfo.privateKey, index$1.RsaPrivateKey); + return this.importPrivateKey(asnKey, algorithm2, extractable, keyUsages); + } + default: + throw new OperationError("format: Must be 'jwk', 'pkcs8' or 'spki'"); + } + } + static async sign(algorithm2, key, data) { + switch (algorithm2.name.toUpperCase()) { + case "RSA-PSS": + case "RSASSA-PKCS1-V1_5": + return this.signRsa(algorithm2, key, data); + default: + throw new OperationError("algorithm: Is not recognized"); + } + } + static async verify(algorithm2, key, signature, data) { + switch (algorithm2.name.toUpperCase()) { + case "RSA-PSS": + case "RSASSA-PKCS1-V1_5": + return this.verifySSA(algorithm2, key, data, signature); + default: + throw new OperationError("algorithm: Is not recognized"); + } + } + static async encrypt(algorithm2, key, data) { + switch (algorithm2.name.toUpperCase()) { + case "RSA-OAEP": + return this.encryptOAEP(algorithm2, key, data); + default: + throw new OperationError("algorithm: Is not recognized"); + } + } + static async decrypt(algorithm2, key, data) { + switch (algorithm2.name.toUpperCase()) { + case "RSA-OAEP": + return this.decryptOAEP(algorithm2, key, data); + default: + throw new OperationError("algorithm: Is not recognized"); + } + } + static importPrivateKey(asnKey, algorithm2, extractable, keyUsages) { + const keyInfo = new index$1.PrivateKeyInfo(); + keyInfo.privateKeyAlgorithm.algorithm = "1.2.840.113549.1.1.1"; + keyInfo.privateKeyAlgorithm.parameters = null; + keyInfo.privateKey = AsnSerializer.serialize(asnKey); + const key = new RsaPrivateKey2(); + key.data = Buffer.from(AsnSerializer.serialize(keyInfo)); + key.algorithm = Object.assign({}, algorithm2); + key.algorithm.publicExponent = new Uint8Array(asnKey.publicExponent); + key.algorithm.modulusLength = asnKey.modulus.byteLength << 3; + key.extractable = extractable; + key.usages = keyUsages; + return key; + } + static importPublicKey(asnKey, algorithm2, extractable, keyUsages) { + const keyInfo = new index$1.PublicKeyInfo(); + keyInfo.publicKeyAlgorithm.algorithm = "1.2.840.113549.1.1.1"; + keyInfo.publicKeyAlgorithm.parameters = null; + keyInfo.publicKey = AsnSerializer.serialize(asnKey); + const key = new RsaPublicKey2(); + key.data = Buffer.from(AsnSerializer.serialize(keyInfo)); + key.algorithm = Object.assign({}, algorithm2); + key.algorithm.publicExponent = new Uint8Array(asnKey.publicExponent); + key.algorithm.modulusLength = asnKey.modulus.byteLength << 3; + key.extractable = extractable; + key.usages = keyUsages; + return key; + } + static getCryptoAlgorithm(alg) { + switch (alg.hash.name.toUpperCase()) { + case "SHA-1": + return "RSA-SHA1"; + case "SHA-256": + return "RSA-SHA256"; + case "SHA-384": + return "RSA-SHA384"; + case "SHA-512": + return "RSA-SHA512"; + case "SHA3-256": + return "RSA-SHA3-256"; + case "SHA3-384": + return "RSA-SHA3-384"; + case "SHA3-512": + return "RSA-SHA3-512"; + default: + throw new OperationError("algorithm.hash: Is not recognized"); + } + } + static signRsa(algorithm2, key, data) { + const cryptoAlg = this.getCryptoAlgorithm(key.algorithm); + const signer = exports6.createSign(cryptoAlg); + signer.update(Buffer.from(data)); + if (!key.pem) { + key.pem = `-----BEGIN PRIVATE KEY----- +${key.data.toString("base64")} +-----END PRIVATE KEY-----`; + } + const options = { + key: key.pem + }; + if (algorithm2.name.toUpperCase() === "RSA-PSS") { + options.padding = exports6.constants.RSA_PKCS1_PSS_PADDING; + options.saltLength = algorithm2.saltLength; + } + const signature = signer.sign(options); + return new Uint8Array(signature).buffer; + } + static verifySSA(algorithm2, key, data, signature) { + const cryptoAlg = this.getCryptoAlgorithm(key.algorithm); + const signer = exports6.createVerify(cryptoAlg); + signer.update(Buffer.from(data)); + if (!key.pem) { + key.pem = `-----BEGIN PUBLIC KEY----- +${key.data.toString("base64")} +-----END PUBLIC KEY-----`; + } + const options = { + key: key.pem + }; + if (algorithm2.name.toUpperCase() === "RSA-PSS") { + options.padding = exports6.constants.RSA_PKCS1_PSS_PADDING; + options.saltLength = algorithm2.saltLength; + } + const ok4 = signer.verify(options, signature); + return ok4; + } + static encryptOAEP(algorithm2, key, data) { + const options = { + key: `-----BEGIN PUBLIC KEY----- +${key.data.toString("base64")} +-----END PUBLIC KEY-----`, + padding: exports6.constants.RSA_PKCS1_OAEP_PADDING + }; + if (algorithm2.label) + ; + return new Uint8Array(exports6.publicEncrypt(options, data)).buffer; + } + static decryptOAEP(algorithm2, key, data) { + const options = { + key: `-----BEGIN PRIVATE KEY----- +${key.data.toString("base64")} +-----END PRIVATE KEY-----`, + padding: exports6.constants.RSA_PKCS1_OAEP_PADDING + }; + if (algorithm2.label) + ; + return new Uint8Array(exports6.privateDecrypt(options, data)).buffer; + } + }; + RsaCrypto.publicKeyUsages = ["verify", "encrypt", "wrapKey"]; + RsaCrypto.privateKeyUsages = ["sign", "decrypt", "unwrapKey"]; + var RsaSsaProvider2 = class extends RsaSsaProvider { + constructor() { + super(...arguments); + this.hashAlgorithms = [ + "SHA-1", + "SHA-256", + "SHA-384", + "SHA-512", + "shake128", + "shake256", + "SHA3-256", + "SHA3-384", + "SHA3-512" + ]; + } + async onGenerateKey(algorithm2, extractable, keyUsages) { + const keys2 = await RsaCrypto.generateKey({ + ...algorithm2, + name: this.name + }, extractable, keyUsages); + return { + privateKey: setCryptoKey(keys2.privateKey), + publicKey: setCryptoKey(keys2.publicKey) + }; + } + async onSign(algorithm2, key, data) { + return RsaCrypto.sign(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onVerify(algorithm2, key, signature, data) { + return RsaCrypto.verify(algorithm2, getCryptoKey(key), new Uint8Array(signature), new Uint8Array(data)); + } + async onExportKey(format16, key) { + return RsaCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const key = await RsaCrypto.importKey(format16, keyData, { ...algorithm2, name: this.name }, extractable, keyUsages); + return setCryptoKey(key); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + const internalKey = getCryptoKey(key); + if (!(internalKey instanceof RsaPrivateKey2 || internalKey instanceof RsaPublicKey2)) { + throw new TypeError("key: Is not RSA CryptoKey"); + } + } + }; + var RsaPssProvider2 = class extends RsaPssProvider { + constructor() { + super(...arguments); + this.hashAlgorithms = [ + "SHA-1", + "SHA-256", + "SHA-384", + "SHA-512", + "shake128", + "shake256", + "SHA3-256", + "SHA3-384", + "SHA3-512" + ]; + } + async onGenerateKey(algorithm2, extractable, keyUsages) { + const keys2 = await RsaCrypto.generateKey({ + ...algorithm2, + name: this.name + }, extractable, keyUsages); + return { + privateKey: setCryptoKey(keys2.privateKey), + publicKey: setCryptoKey(keys2.publicKey) + }; + } + async onSign(algorithm2, key, data) { + return RsaCrypto.sign(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onVerify(algorithm2, key, signature, data) { + return RsaCrypto.verify(algorithm2, getCryptoKey(key), new Uint8Array(signature), new Uint8Array(data)); + } + async onExportKey(format16, key) { + return RsaCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const key = await RsaCrypto.importKey(format16, keyData, { ...algorithm2, name: this.name }, extractable, keyUsages); + return setCryptoKey(key); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + const internalKey = getCryptoKey(key); + if (!(internalKey instanceof RsaPrivateKey2 || internalKey instanceof RsaPublicKey2)) { + throw new TypeError("key: Is not RSA CryptoKey"); + } + } + }; + var ShaCrypto = class { + static size(algorithm2) { + switch (algorithm2.name.toUpperCase()) { + case "SHA-1": + return 160; + case "SHA-256": + case "SHA3-256": + return 256; + case "SHA-384": + case "SHA3-384": + return 384; + case "SHA-512": + case "SHA3-512": + return 512; + default: + throw new Error("Unrecognized name"); + } + } + static getAlgorithmName(algorithm2) { + switch (algorithm2.name.toUpperCase()) { + case "SHA-1": + return "sha1"; + case "SHA-256": + return "sha256"; + case "SHA-384": + return "sha384"; + case "SHA-512": + return "sha512"; + case "SHA3-256": + return "sha3-256"; + case "SHA3-384": + return "sha3-384"; + case "SHA3-512": + return "sha3-512"; + default: + throw new Error("Unrecognized name"); + } + } + static digest(algorithm2, data) { + const hashAlg = this.getAlgorithmName(algorithm2); + const hash = exports6.createHash(hashAlg).update(Buffer.from(data)).digest(); + return new Uint8Array(hash).buffer; + } + }; + var RsaOaepProvider2 = class extends RsaOaepProvider { + async onGenerateKey(algorithm2, extractable, keyUsages) { + const keys2 = await RsaCrypto.generateKey({ + ...algorithm2, + name: this.name + }, extractable, keyUsages); + return { + privateKey: setCryptoKey(keys2.privateKey), + publicKey: setCryptoKey(keys2.publicKey) + }; + } + async onEncrypt(algorithm2, key, data) { + const internalKey = getCryptoKey(key); + const dataView3 = new Uint8Array(data); + const keySize = Math.ceil(internalKey.algorithm.modulusLength >> 3); + const hashSize = ShaCrypto.size(internalKey.algorithm.hash) >> 3; + const dataLength = dataView3.byteLength; + const psLength = keySize - dataLength - 2 * hashSize - 2; + if (dataLength > keySize - 2 * hashSize - 2) { + throw new Error("Data too large"); + } + const message2 = new Uint8Array(keySize); + const seed = message2.subarray(1, hashSize + 1); + const dataBlock = message2.subarray(hashSize + 1); + dataBlock.set(dataView3, hashSize + psLength + 1); + const labelHash = exports6.createHash(internalKey.algorithm.hash.name.replace("-", "")).update(import_pvtsutils5.BufferSourceConverter.toUint8Array(algorithm2.label || new Uint8Array(0))).digest(); + dataBlock.set(labelHash, 0); + dataBlock[hashSize + psLength] = 1; + exports6.randomFillSync(seed); + const dataBlockMask = this.mgf1(internalKey.algorithm.hash, seed, dataBlock.length); + for (let i8 = 0; i8 < dataBlock.length; i8++) { + dataBlock[i8] ^= dataBlockMask[i8]; + } + const seedMask = this.mgf1(internalKey.algorithm.hash, dataBlock, seed.length); + for (let i8 = 0; i8 < seed.length; i8++) { + seed[i8] ^= seedMask[i8]; + } + if (!internalKey.pem) { + internalKey.pem = `-----BEGIN PUBLIC KEY----- +${internalKey.data.toString("base64")} +-----END PUBLIC KEY-----`; + } + const pkcs0 = exports6.publicEncrypt({ + key: internalKey.pem, + padding: exports6.constants.RSA_NO_PADDING + }, Buffer.from(message2)); + return new Uint8Array(pkcs0).buffer; + } + async onDecrypt(algorithm2, key, data) { + const internalKey = getCryptoKey(key); + const keySize = Math.ceil(internalKey.algorithm.modulusLength >> 3); + const hashSize = ShaCrypto.size(internalKey.algorithm.hash) >> 3; + const dataLength = data.byteLength; + if (dataLength !== keySize) { + throw new Error("Bad data"); + } + if (!internalKey.pem) { + internalKey.pem = `-----BEGIN PRIVATE KEY----- +${internalKey.data.toString("base64")} +-----END PRIVATE KEY-----`; + } + let pkcs0 = exports6.privateDecrypt({ + key: internalKey.pem, + padding: exports6.constants.RSA_NO_PADDING + }, Buffer.from(data)); + const z6 = pkcs0[0]; + const seed = pkcs0.subarray(1, hashSize + 1); + const dataBlock = pkcs0.subarray(hashSize + 1); + if (z6 !== 0) { + throw new Error("Decryption failed"); + } + const seedMask = this.mgf1(internalKey.algorithm.hash, dataBlock, seed.length); + for (let i8 = 0; i8 < seed.length; i8++) { + seed[i8] ^= seedMask[i8]; + } + const dataBlockMask = this.mgf1(internalKey.algorithm.hash, seed, dataBlock.length); + for (let i8 = 0; i8 < dataBlock.length; i8++) { + dataBlock[i8] ^= dataBlockMask[i8]; + } + const labelHash = exports6.createHash(internalKey.algorithm.hash.name.replace("-", "")).update(import_pvtsutils5.BufferSourceConverter.toUint8Array(algorithm2.label || new Uint8Array(0))).digest(); + for (let i8 = 0; i8 < hashSize; i8++) { + if (labelHash[i8] !== dataBlock[i8]) { + throw new Error("Decryption failed"); + } + } + let psEnd = hashSize; + for (; psEnd < dataBlock.length; psEnd++) { + const psz = dataBlock[psEnd]; + if (psz === 1) { + break; + } + if (psz !== 0) { + throw new Error("Decryption failed"); + } + } + if (psEnd === dataBlock.length) { + throw new Error("Decryption failed"); + } + pkcs0 = dataBlock.subarray(psEnd + 1); + return new Uint8Array(pkcs0).buffer; + } + async onExportKey(format16, key) { + return RsaCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const key = await RsaCrypto.importKey(format16, keyData, { ...algorithm2, name: this.name }, extractable, keyUsages); + return setCryptoKey(key); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + const internalKey = getCryptoKey(key); + if (!(internalKey instanceof RsaPrivateKey2 || internalKey instanceof RsaPublicKey2)) { + throw new TypeError("key: Is not RSA CryptoKey"); + } + } + mgf1(algorithm2, seed, length3 = 0) { + const hashSize = ShaCrypto.size(algorithm2) >> 3; + const mask2 = new Uint8Array(length3); + const counter = new Uint8Array(4); + const chunks = Math.ceil(length3 / hashSize); + for (let i8 = 0; i8 < chunks; i8++) { + counter[0] = i8 >>> 24; + counter[1] = i8 >>> 16 & 255; + counter[2] = i8 >>> 8 & 255; + counter[3] = i8 & 255; + const submask = mask2.subarray(i8 * hashSize); + let chunk = exports6.createHash(algorithm2.name.replace("-", "")).update(seed).update(counter).digest(); + if (chunk.length > submask.length) { + chunk = chunk.subarray(0, submask.length); + } + submask.set(chunk); + } + return mask2; + } + }; + var RsaEsProvider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.name = "RSAES-PKCS1-v1_5"; + this.usages = { + publicKey: ["encrypt", "wrapKey"], + privateKey: ["decrypt", "unwrapKey"] + }; + } + async onGenerateKey(algorithm2, extractable, keyUsages) { + const keys2 = await RsaCrypto.generateKey({ + ...algorithm2, + name: this.name + }, extractable, keyUsages); + return { + privateKey: setCryptoKey(keys2.privateKey), + publicKey: setCryptoKey(keys2.publicKey) + }; + } + checkGenerateKeyParams(algorithm2) { + this.checkRequiredProperty(algorithm2, "publicExponent"); + if (!(algorithm2.publicExponent && algorithm2.publicExponent instanceof Uint8Array)) { + throw new TypeError("publicExponent: Missing or not a Uint8Array"); + } + const publicExponent = import_pvtsutils6.Convert.ToBase64(algorithm2.publicExponent); + if (!(publicExponent === "Aw==" || publicExponent === "AQAB")) { + throw new TypeError("publicExponent: Must be [3] or [1,0,1]"); + } + this.checkRequiredProperty(algorithm2, "modulusLength"); + switch (algorithm2.modulusLength) { + case 1024: + case 2048: + case 4096: + break; + default: + throw new TypeError("modulusLength: Must be 1024, 2048, or 4096"); + } + } + async onEncrypt(algorithm2, key, data) { + const options = this.toCryptoOptions(key); + const enc = publicEncrypt(options, new Uint8Array(data)); + return new Uint8Array(enc).buffer; + } + async onDecrypt(algorithm2, key, data) { + const options = this.toCryptoOptions(key); + const dec = privateDecrypt(options, new Uint8Array(data)); + return new Uint8Array(dec).buffer; + } + async onExportKey(format16, key) { + return RsaCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const key = await RsaCrypto.importKey(format16, keyData, { ...algorithm2, name: this.name }, extractable, keyUsages); + return setCryptoKey(key); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + const internalKey = getCryptoKey(key); + if (!(internalKey instanceof RsaPrivateKey2 || internalKey instanceof RsaPublicKey2)) { + throw new TypeError("key: Is not RSA CryptoKey"); + } + } + toCryptoOptions(key) { + const type3 = key.type.toUpperCase(); + return { + key: `-----BEGIN ${type3} KEY----- +${getCryptoKey(key).data.toString("base64")} +-----END ${type3} KEY-----`, + padding: constants.RSA_PKCS1_PADDING + }; + } + }; + var namedOIDs = { + "1.2.840.10045.3.1.7": "P-256", + "P-256": "1.2.840.10045.3.1.7", + "1.3.132.0.34": "P-384", + "P-384": "1.3.132.0.34", + "1.3.132.0.35": "P-521", + "P-521": "1.3.132.0.35", + "1.3.132.0.10": "K-256", + "K-256": "1.3.132.0.10", + "brainpoolP160r1": "1.3.36.3.3.2.8.1.1.1", + "1.3.36.3.3.2.8.1.1.1": "brainpoolP160r1", + "brainpoolP160t1": "1.3.36.3.3.2.8.1.1.2", + "1.3.36.3.3.2.8.1.1.2": "brainpoolP160t1", + "brainpoolP192r1": "1.3.36.3.3.2.8.1.1.3", + "1.3.36.3.3.2.8.1.1.3": "brainpoolP192r1", + "brainpoolP192t1": "1.3.36.3.3.2.8.1.1.4", + "1.3.36.3.3.2.8.1.1.4": "brainpoolP192t1", + "brainpoolP224r1": "1.3.36.3.3.2.8.1.1.5", + "1.3.36.3.3.2.8.1.1.5": "brainpoolP224r1", + "brainpoolP224t1": "1.3.36.3.3.2.8.1.1.6", + "1.3.36.3.3.2.8.1.1.6": "brainpoolP224t1", + "brainpoolP256r1": "1.3.36.3.3.2.8.1.1.7", + "1.3.36.3.3.2.8.1.1.7": "brainpoolP256r1", + "brainpoolP256t1": "1.3.36.3.3.2.8.1.1.8", + "1.3.36.3.3.2.8.1.1.8": "brainpoolP256t1", + "brainpoolP320r1": "1.3.36.3.3.2.8.1.1.9", + "1.3.36.3.3.2.8.1.1.9": "brainpoolP320r1", + "brainpoolP320t1": "1.3.36.3.3.2.8.1.1.10", + "1.3.36.3.3.2.8.1.1.10": "brainpoolP320t1", + "brainpoolP384r1": "1.3.36.3.3.2.8.1.1.11", + "1.3.36.3.3.2.8.1.1.11": "brainpoolP384r1", + "brainpoolP384t1": "1.3.36.3.3.2.8.1.1.12", + "1.3.36.3.3.2.8.1.1.12": "brainpoolP384t1", + "brainpoolP512r1": "1.3.36.3.3.2.8.1.1.13", + "1.3.36.3.3.2.8.1.1.13": "brainpoolP512r1", + "brainpoolP512t1": "1.3.36.3.3.2.8.1.1.14", + "1.3.36.3.3.2.8.1.1.14": "brainpoolP512t1" + }; + function getOidByNamedCurve$1(namedCurve) { + const oid = namedOIDs[namedCurve]; + if (!oid) { + throw new OperationError(`Cannot convert WebCrypto named curve '${namedCurve}' to OID`); + } + return oid; + } + var EcPrivateKey2 = class extends AsymmetricKey { + constructor() { + super(...arguments); + this.type = "private"; + } + getKey() { + const keyInfo = AsnParser.parse(this.data, index$1.PrivateKeyInfo); + return AsnParser.parse(keyInfo.privateKey, index$1.EcPrivateKey); + } + toJSON() { + const key = this.getKey(); + const json = { + kty: "EC", + crv: this.algorithm.namedCurve, + key_ops: this.usages, + ext: this.extractable + }; + return Object.assign(json, JsonSerializer.toJSON(key)); + } + fromJSON(json) { + if (!json.crv) { + throw new OperationError(`Cannot get named curve from JWK. Property 'crv' is required`); + } + const keyInfo = new index$1.PrivateKeyInfo(); + keyInfo.privateKeyAlgorithm.algorithm = "1.2.840.10045.2.1"; + keyInfo.privateKeyAlgorithm.parameters = AsnSerializer.serialize(new index$1.ObjectIdentifier(getOidByNamedCurve$1(json.crv))); + const key = JsonParser.fromJSON(json, { targetSchema: index$1.EcPrivateKey }); + keyInfo.privateKey = AsnSerializer.serialize(key); + this.data = Buffer.from(AsnSerializer.serialize(keyInfo)); + return this; + } + }; + var EcPublicKey3 = class extends AsymmetricKey { + constructor() { + super(...arguments); + this.type = "public"; + } + getKey() { + const keyInfo = AsnParser.parse(this.data, index$1.PublicKeyInfo); + return new index$1.EcPublicKey(keyInfo.publicKey); + } + toJSON() { + const key = this.getKey(); + const json = { + kty: "EC", + crv: this.algorithm.namedCurve, + key_ops: this.usages, + ext: this.extractable + }; + return Object.assign(json, JsonSerializer.toJSON(key)); + } + fromJSON(json) { + if (!json.crv) { + throw new OperationError(`Cannot get named curve from JWK. Property 'crv' is required`); + } + const key = JsonParser.fromJSON(json, { targetSchema: index$1.EcPublicKey }); + const keyInfo = new index$1.PublicKeyInfo(); + keyInfo.publicKeyAlgorithm.algorithm = "1.2.840.10045.2.1"; + keyInfo.publicKeyAlgorithm.parameters = AsnSerializer.serialize(new index$1.ObjectIdentifier(getOidByNamedCurve$1(json.crv))); + keyInfo.publicKey = AsnSerializer.toASN(key).valueHex; + this.data = Buffer.from(AsnSerializer.serialize(keyInfo)); + return this; + } + }; + var Sha1Provider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.name = "SHA-1"; + this.usages = []; + } + async onDigest(algorithm2, data) { + return ShaCrypto.digest(algorithm2, data); + } + }; + var Sha256Provider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.name = "SHA-256"; + this.usages = []; + } + async onDigest(algorithm2, data) { + return ShaCrypto.digest(algorithm2, data); + } + }; + var Sha384Provider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.name = "SHA-384"; + this.usages = []; + } + async onDigest(algorithm2, data) { + return ShaCrypto.digest(algorithm2, data); + } + }; + var Sha512Provider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.name = "SHA-512"; + this.usages = []; + } + async onDigest(algorithm2, data) { + return ShaCrypto.digest(algorithm2, data); + } + }; + var Sha3256Provider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.name = "SHA3-256"; + this.usages = []; + } + async onDigest(algorithm2, data) { + return ShaCrypto.digest(algorithm2, data); + } + }; + var Sha3384Provider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.name = "SHA3-384"; + this.usages = []; + } + async onDigest(algorithm2, data) { + return ShaCrypto.digest(algorithm2, data); + } + }; + var Sha3512Provider = class extends ProviderCrypto { + constructor() { + super(...arguments); + this.name = "SHA3-512"; + this.usages = []; + } + async onDigest(algorithm2, data) { + return ShaCrypto.digest(algorithm2, data); + } + }; + var EcCrypto = class { + static async generateKey(algorithm2, extractable, keyUsages) { + const privateKey = new EcPrivateKey2(); + privateKey.algorithm = algorithm2; + privateKey.extractable = extractable; + privateKey.usages = keyUsages.filter((usage) => this.privateKeyUsages.indexOf(usage) !== -1); + const publicKey = new EcPublicKey3(); + publicKey.algorithm = algorithm2; + publicKey.extractable = true; + publicKey.usages = keyUsages.filter((usage) => this.publicKeyUsages.indexOf(usage) !== -1); + const keys2 = exports6.generateKeyPairSync("ec", { + namedCurve: this.getOpenSSLNamedCurve(algorithm2.namedCurve), + publicKeyEncoding: { + format: "der", + type: "spki" + }, + privateKeyEncoding: { + format: "der", + type: "pkcs8" + } + }); + privateKey.data = keys2.privateKey; + publicKey.data = keys2.publicKey; + const res = { + privateKey, + publicKey + }; + return res; + } + static async sign(algorithm2, key, data) { + const cryptoAlg = ShaCrypto.getAlgorithmName(algorithm2.hash); + const signer = exports6.createSign(cryptoAlg); + signer.update(Buffer.from(data)); + if (!key.pem) { + key.pem = `-----BEGIN PRIVATE KEY----- +${key.data.toString("base64")} +-----END PRIVATE KEY-----`; + } + const options = { + key: key.pem + }; + const signature = signer.sign(options); + const ecSignature = AsnParser.parse(signature, index$1.EcDsaSignature); + const signatureRaw = EcUtils.encodeSignature(ecSignature, EcCurves.get(key.algorithm.namedCurve).size); + return signatureRaw.buffer; + } + static async verify(algorithm2, key, signature, data) { + const cryptoAlg = ShaCrypto.getAlgorithmName(algorithm2.hash); + const signer = exports6.createVerify(cryptoAlg); + signer.update(Buffer.from(data)); + if (!key.pem) { + key.pem = `-----BEGIN PUBLIC KEY----- +${key.data.toString("base64")} +-----END PUBLIC KEY-----`; + } + const options = { + key: key.pem + }; + const ecSignature = new index$1.EcDsaSignature(); + const namedCurve = EcCurves.get(key.algorithm.namedCurve); + const signaturePoint = EcUtils.decodeSignature(signature, namedCurve.size); + ecSignature.r = import_pvtsutils6.BufferSourceConverter.toArrayBuffer(signaturePoint.r); + ecSignature.s = import_pvtsutils6.BufferSourceConverter.toArrayBuffer(signaturePoint.s); + const ecSignatureRaw = Buffer.from(AsnSerializer.serialize(ecSignature)); + const ok4 = signer.verify(options, ecSignatureRaw); + return ok4; + } + static async deriveBits(algorithm2, baseKey, length3) { + const cryptoAlg = this.getOpenSSLNamedCurve(baseKey.algorithm.namedCurve); + const ecdh = exports6.createECDH(cryptoAlg); + const asnPrivateKey = AsnParser.parse(baseKey.data, index$1.PrivateKeyInfo); + const asnEcPrivateKey = AsnParser.parse(asnPrivateKey.privateKey, index$1.EcPrivateKey); + ecdh.setPrivateKey(Buffer.from(asnEcPrivateKey.privateKey)); + const asnPublicKey = AsnParser.parse(algorithm2.public.data, index$1.PublicKeyInfo); + const bits = ecdh.computeSecret(Buffer.from(asnPublicKey.publicKey)); + if (length3 === null) { + return bits; + } + return new Uint8Array(bits).buffer.slice(0, length3 >> 3); + } + static async exportKey(format16, key) { + switch (format16.toLowerCase()) { + case "jwk": + return JsonSerializer.toJSON(key); + case "pkcs8": + case "spki": + return new Uint8Array(key.data).buffer; + case "raw": { + const publicKeyInfo = AsnParser.parse(key.data, index$1.PublicKeyInfo); + return publicKeyInfo.publicKey; + } + default: + throw new OperationError("format: Must be 'jwk', 'raw', pkcs8' or 'spki'"); + } + } + static async importKey(format16, keyData, algorithm2, extractable, keyUsages) { + switch (format16.toLowerCase()) { + case "jwk": { + const jwk = keyData; + if (jwk.d) { + const asnKey = JsonParser.fromJSON(keyData, { targetSchema: index$1.EcPrivateKey }); + return this.importPrivateKey(asnKey, algorithm2, extractable, keyUsages); + } else { + const asnKey = JsonParser.fromJSON(keyData, { targetSchema: index$1.EcPublicKey }); + return this.importPublicKey(asnKey, algorithm2, extractable, keyUsages); + } + } + case "raw": { + const asnKey = new index$1.EcPublicKey(keyData); + return this.importPublicKey(asnKey, algorithm2, extractable, keyUsages); + } + case "spki": { + const keyInfo = AsnParser.parse(new Uint8Array(keyData), index$1.PublicKeyInfo); + const asnKey = new index$1.EcPublicKey(keyInfo.publicKey); + this.assertKeyParameters(keyInfo.publicKeyAlgorithm.parameters, algorithm2.namedCurve); + return this.importPublicKey(asnKey, algorithm2, extractable, keyUsages); + } + case "pkcs8": { + const keyInfo = AsnParser.parse(new Uint8Array(keyData), index$1.PrivateKeyInfo); + const asnKey = AsnParser.parse(keyInfo.privateKey, index$1.EcPrivateKey); + this.assertKeyParameters(keyInfo.privateKeyAlgorithm.parameters, algorithm2.namedCurve); + return this.importPrivateKey(asnKey, algorithm2, extractable, keyUsages); + } + default: + throw new OperationError("format: Must be 'jwk', 'raw', 'pkcs8' or 'spki'"); + } + } + static assertKeyParameters(parameters, namedCurve) { + if (!parameters) { + throw new CryptoError("Key info doesn't have required parameters"); + } + let namedCurveIdentifier = ""; + try { + namedCurveIdentifier = AsnParser.parse(parameters, index$1.ObjectIdentifier).value; + } catch (e12) { + throw new CryptoError("Cannot read key info parameters"); + } + if (getOidByNamedCurve$1(namedCurve) !== namedCurveIdentifier) { + throw new CryptoError("Key info parameter doesn't match to named curve"); + } + } + static async importPrivateKey(asnKey, algorithm2, extractable, keyUsages) { + const keyInfo = new index$1.PrivateKeyInfo(); + keyInfo.privateKeyAlgorithm.algorithm = "1.2.840.10045.2.1"; + keyInfo.privateKeyAlgorithm.parameters = AsnSerializer.serialize(new index$1.ObjectIdentifier(getOidByNamedCurve$1(algorithm2.namedCurve))); + keyInfo.privateKey = AsnSerializer.serialize(asnKey); + const key = new EcPrivateKey2(); + key.data = Buffer.from(AsnSerializer.serialize(keyInfo)); + key.algorithm = Object.assign({}, algorithm2); + key.extractable = extractable; + key.usages = keyUsages; + return key; + } + static async importPublicKey(asnKey, algorithm2, extractable, keyUsages) { + const keyInfo = new index$1.PublicKeyInfo(); + keyInfo.publicKeyAlgorithm.algorithm = "1.2.840.10045.2.1"; + const namedCurve = getOidByNamedCurve$1(algorithm2.namedCurve); + keyInfo.publicKeyAlgorithm.parameters = AsnSerializer.serialize(new index$1.ObjectIdentifier(namedCurve)); + keyInfo.publicKey = asnKey.value; + const key = new EcPublicKey3(); + key.data = Buffer.from(AsnSerializer.serialize(keyInfo)); + key.algorithm = Object.assign({}, algorithm2); + key.extractable = extractable; + key.usages = keyUsages; + return key; + } + static getOpenSSLNamedCurve(curve) { + switch (curve.toUpperCase()) { + case "P-256": + return "prime256v1"; + case "K-256": + return "secp256k1"; + case "P-384": + return "secp384r1"; + case "P-521": + return "secp521r1"; + default: + return curve; + } + } + }; + EcCrypto.publicKeyUsages = ["verify"]; + EcCrypto.privateKeyUsages = ["sign", "deriveKey", "deriveBits"]; + var EcdsaProvider2 = class extends EcdsaProvider { + constructor() { + super(...arguments); + this.namedCurves = EcCurves.names; + this.hashAlgorithms = [ + "SHA-1", + "SHA-256", + "SHA-384", + "SHA-512", + "shake128", + "shake256", + "SHA3-256", + "SHA3-384", + "SHA3-512" + ]; + } + async onGenerateKey(algorithm2, extractable, keyUsages) { + const keys2 = await EcCrypto.generateKey({ + ...algorithm2, + name: this.name + }, extractable, keyUsages); + return { + privateKey: setCryptoKey(keys2.privateKey), + publicKey: setCryptoKey(keys2.publicKey) + }; + } + async onSign(algorithm2, key, data) { + return EcCrypto.sign(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onVerify(algorithm2, key, signature, data) { + return EcCrypto.verify(algorithm2, getCryptoKey(key), new Uint8Array(signature), new Uint8Array(data)); + } + async onExportKey(format16, key) { + return EcCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const key = await EcCrypto.importKey(format16, keyData, { ...algorithm2, name: this.name }, extractable, keyUsages); + return setCryptoKey(key); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + const internalKey = getCryptoKey(key); + if (!(internalKey instanceof EcPrivateKey2 || internalKey instanceof EcPublicKey3)) { + throw new TypeError("key: Is not EC CryptoKey"); + } + } + }; + var EcdhProvider2 = class extends EcdhProvider { + constructor() { + super(...arguments); + this.namedCurves = EcCurves.names; + } + async onGenerateKey(algorithm2, extractable, keyUsages) { + const keys2 = await EcCrypto.generateKey({ + ...algorithm2, + name: this.name + }, extractable, keyUsages); + return { + privateKey: setCryptoKey(keys2.privateKey), + publicKey: setCryptoKey(keys2.publicKey) + }; + } + async onExportKey(format16, key) { + return EcCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const key = await EcCrypto.importKey(format16, keyData, { ...algorithm2, name: this.name }, extractable, keyUsages); + return setCryptoKey(key); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + const internalKey = getCryptoKey(key); + if (!(internalKey instanceof EcPrivateKey2 || internalKey instanceof EcPublicKey3)) { + throw new TypeError("key: Is not EC CryptoKey"); + } + } + async onDeriveBits(algorithm2, baseKey, length3) { + const bits = await EcCrypto.deriveBits({ ...algorithm2, public: getCryptoKey(algorithm2.public) }, getCryptoKey(baseKey), length3); + return bits; + } + }; + var edOIDs = { + [index$1.idEd448]: "Ed448", + "ed448": index$1.idEd448, + [index$1.idX448]: "X448", + "x448": index$1.idX448, + [index$1.idEd25519]: "Ed25519", + "ed25519": index$1.idEd25519, + [index$1.idX25519]: "X25519", + "x25519": index$1.idX25519 + }; + function getOidByNamedCurve(namedCurve) { + const oid = edOIDs[namedCurve.toLowerCase()]; + if (!oid) { + throw new OperationError(`Cannot convert WebCrypto named curve '${namedCurve}' to OID`); + } + return oid; + } + var EdPrivateKey3 = class extends AsymmetricKey { + constructor() { + super(...arguments); + this.type = "private"; + } + getKey() { + const keyInfo = AsnParser.parse(this.data, index$1.PrivateKeyInfo); + return AsnParser.parse(keyInfo.privateKey, index$1.CurvePrivateKey); + } + toJSON() { + const key = this.getKey(); + const json = { + kty: "OKP", + crv: this.algorithm.namedCurve, + key_ops: this.usages, + ext: this.extractable + }; + return Object.assign(json, JsonSerializer.toJSON(key)); + } + fromJSON(json) { + if (!json.crv) { + throw new OperationError(`Cannot get named curve from JWK. Property 'crv' is required`); + } + const keyInfo = new index$1.PrivateKeyInfo(); + keyInfo.privateKeyAlgorithm.algorithm = getOidByNamedCurve(json.crv); + const key = JsonParser.fromJSON(json, { targetSchema: index$1.CurvePrivateKey }); + keyInfo.privateKey = AsnSerializer.serialize(key); + this.data = Buffer.from(AsnSerializer.serialize(keyInfo)); + return this; + } + }; + var EdPublicKey3 = class extends AsymmetricKey { + constructor() { + super(...arguments); + this.type = "public"; + } + getKey() { + const keyInfo = AsnParser.parse(this.data, index$1.PublicKeyInfo); + return keyInfo.publicKey; + } + toJSON() { + const key = this.getKey(); + const json = { + kty: "OKP", + crv: this.algorithm.namedCurve, + key_ops: this.usages, + ext: this.extractable + }; + return Object.assign(json, { + x: import_pvtsutils6.Convert.ToBase64Url(key) + }); + } + fromJSON(json) { + if (!json.crv) { + throw new OperationError(`Cannot get named curve from JWK. Property 'crv' is required`); + } + if (!json.x) { + throw new OperationError(`Cannot get property from JWK. Property 'x' is required`); + } + const keyInfo = new index$1.PublicKeyInfo(); + keyInfo.publicKeyAlgorithm.algorithm = getOidByNamedCurve(json.crv); + keyInfo.publicKey = import_pvtsutils6.Convert.FromBase64Url(json.x); + this.data = Buffer.from(AsnSerializer.serialize(keyInfo)); + return this; + } + }; + var EdCrypto = class { + static async generateKey(algorithm2, extractable, keyUsages) { + const privateKey = new EdPrivateKey3(); + privateKey.algorithm = algorithm2; + privateKey.extractable = extractable; + privateKey.usages = keyUsages.filter((usage) => this.privateKeyUsages.indexOf(usage) !== -1); + const publicKey = new EdPublicKey3(); + publicKey.algorithm = algorithm2; + publicKey.extractable = true; + publicKey.usages = keyUsages.filter((usage) => this.publicKeyUsages.indexOf(usage) !== -1); + const type3 = algorithm2.namedCurve.toLowerCase(); + const keys2 = exports6.generateKeyPairSync(type3, { + publicKeyEncoding: { + format: "der", + type: "spki" + }, + privateKeyEncoding: { + format: "der", + type: "pkcs8" + } + }); + privateKey.data = keys2.privateKey; + publicKey.data = keys2.publicKey; + const res = { + privateKey, + publicKey + }; + return res; + } + static async sign(algorithm2, key, data) { + if (!key.pem) { + key.pem = `-----BEGIN PRIVATE KEY----- +${key.data.toString("base64")} +-----END PRIVATE KEY-----`; + } + const options = { + key: key.pem + }; + const signature = exports6.sign(null, Buffer.from(data), options); + return import_pvtsutils5.BufferSourceConverter.toArrayBuffer(signature); + } + static async verify(algorithm2, key, signature, data) { + if (!key.pem) { + key.pem = `-----BEGIN PUBLIC KEY----- +${key.data.toString("base64")} +-----END PUBLIC KEY-----`; + } + const options = { + key: key.pem + }; + const ok4 = exports6.verify(null, Buffer.from(data), options, Buffer.from(signature)); + return ok4; + } + static async deriveBits(algorithm2, baseKey, length3) { + const publicKey = exports6.createPublicKey({ + key: algorithm2.public.data, + format: "der", + type: "spki" + }); + const privateKey = exports6.createPrivateKey({ + key: baseKey.data, + format: "der", + type: "pkcs8" + }); + const bits = exports6.diffieHellman({ + publicKey, + privateKey + }); + return new Uint8Array(bits).buffer.slice(0, length3 >> 3); + } + static async exportKey(format16, key) { + switch (format16.toLowerCase()) { + case "jwk": + return JsonSerializer.toJSON(key); + case "pkcs8": + case "spki": + return new Uint8Array(key.data).buffer; + case "raw": { + const publicKeyInfo = AsnParser.parse(key.data, index$1.PublicKeyInfo); + return publicKeyInfo.publicKey; + } + default: + throw new OperationError("format: Must be 'jwk', 'raw', pkcs8' or 'spki'"); + } + } + static async importKey(format16, keyData, algorithm2, extractable, keyUsages) { + switch (format16.toLowerCase()) { + case "jwk": { + const jwk = keyData; + if (jwk.d) { + const asnKey = JsonParser.fromJSON(keyData, { targetSchema: index$1.CurvePrivateKey }); + return this.importPrivateKey(asnKey, algorithm2, extractable, keyUsages); + } else { + if (!jwk.x) { + throw new TypeError("keyData: Cannot get required 'x' filed"); + } + return this.importPublicKey(import_pvtsutils6.Convert.FromBase64Url(jwk.x), algorithm2, extractable, keyUsages); + } + } + case "raw": { + return this.importPublicKey(keyData, algorithm2, extractable, keyUsages); + } + case "spki": { + const keyInfo = AsnParser.parse(new Uint8Array(keyData), index$1.PublicKeyInfo); + return this.importPublicKey(keyInfo.publicKey, algorithm2, extractable, keyUsages); + } + case "pkcs8": { + const keyInfo = AsnParser.parse(new Uint8Array(keyData), index$1.PrivateKeyInfo); + const asnKey = AsnParser.parse(keyInfo.privateKey, index$1.CurvePrivateKey); + return this.importPrivateKey(asnKey, algorithm2, extractable, keyUsages); + } + default: + throw new OperationError("format: Must be 'jwk', 'raw', 'pkcs8' or 'spki'"); + } + } + static importPrivateKey(asnKey, algorithm2, extractable, keyUsages) { + const key = new EdPrivateKey3(); + key.fromJSON({ + crv: algorithm2.namedCurve, + d: import_pvtsutils6.Convert.ToBase64Url(asnKey.d) + }); + key.algorithm = Object.assign({}, algorithm2); + key.extractable = extractable; + key.usages = keyUsages; + return key; + } + static async importPublicKey(asnKey, algorithm2, extractable, keyUsages) { + const key = new EdPublicKey3(); + key.fromJSON({ + crv: algorithm2.namedCurve, + x: import_pvtsutils6.Convert.ToBase64Url(asnKey) + }); + key.algorithm = Object.assign({}, algorithm2); + key.extractable = extractable; + key.usages = keyUsages; + return key; + } + }; + EdCrypto.publicKeyUsages = ["verify"]; + EdCrypto.privateKeyUsages = ["sign", "deriveKey", "deriveBits"]; + var EdDsaProvider2 = class extends EdDsaProvider { + async onGenerateKey(algorithm2, extractable, keyUsages) { + const keys2 = await EdCrypto.generateKey({ + name: this.name, + namedCurve: algorithm2.namedCurve.replace(/^ed/i, "Ed") + }, extractable, keyUsages); + return { + privateKey: setCryptoKey(keys2.privateKey), + publicKey: setCryptoKey(keys2.publicKey) + }; + } + async onSign(algorithm2, key, data) { + return EdCrypto.sign(algorithm2, getCryptoKey(key), new Uint8Array(data)); + } + async onVerify(algorithm2, key, signature, data) { + return EdCrypto.verify(algorithm2, getCryptoKey(key), new Uint8Array(signature), new Uint8Array(data)); + } + async onExportKey(format16, key) { + return EdCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const key = await EdCrypto.importKey(format16, keyData, { ...algorithm2, name: this.name }, extractable, keyUsages); + return setCryptoKey(key); + } + }; + var EcdhEsProvider2 = class extends EcdhEsProvider { + async onGenerateKey(algorithm2, extractable, keyUsages) { + const keys2 = await EdCrypto.generateKey({ + name: this.name, + namedCurve: algorithm2.namedCurve.toUpperCase() + }, extractable, keyUsages); + return { + privateKey: setCryptoKey(keys2.privateKey), + publicKey: setCryptoKey(keys2.publicKey) + }; + } + async onDeriveBits(algorithm2, baseKey, length3) { + const bits = await EdCrypto.deriveBits({ ...algorithm2, public: getCryptoKey(algorithm2.public) }, getCryptoKey(baseKey), length3); + return bits; + } + async onExportKey(format16, key) { + return EdCrypto.exportKey(format16, getCryptoKey(key)); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + const key = await EdCrypto.importKey(format16, keyData, { ...algorithm2, name: this.name }, extractable, keyUsages); + return setCryptoKey(key); + } + }; + var PbkdfCryptoKey = class extends CryptoKey2 { + }; + var Pbkdf2Provider2 = class extends Pbkdf2Provider { + async onDeriveBits(algorithm2, baseKey, length3) { + return new Promise((resolve7, reject) => { + const salt = import_pvtsutils5.BufferSourceConverter.toArrayBuffer(algorithm2.salt); + const hash = algorithm2.hash.name.replace("-", ""); + exports6.pbkdf2(getCryptoKey(baseKey).data, Buffer.from(salt), algorithm2.iterations, length3 >> 3, hash, (err, derivedBits) => { + if (err) { + reject(err); + } else { + resolve7(new Uint8Array(derivedBits).buffer); + } + }); + }); + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + if (format16 === "raw") { + const key = new PbkdfCryptoKey(); + key.data = Buffer.from(keyData); + key.algorithm = { name: this.name }; + key.extractable = false; + key.usages = keyUsages; + return setCryptoKey(key); + } + throw new OperationError("format: Must be 'raw'"); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + if (!(getCryptoKey(key) instanceof PbkdfCryptoKey)) { + throw new TypeError("key: Is not PBKDF CryptoKey"); + } + } + }; + var HmacCryptoKey = class extends CryptoKey2 { + get alg() { + const hash = this.algorithm.hash.name.toUpperCase(); + return `HS${hash.replace("SHA-", "")}`; + } + set alg(value) { + } + }; + __decorate([ + JsonProp({ name: "k", converter: JsonBase64UrlConverter }) + ], HmacCryptoKey.prototype, "data", void 0); + var HmacProvider2 = class extends HmacProvider { + async onGenerateKey(algorithm2, extractable, keyUsages) { + const length3 = (algorithm2.length || this.getDefaultLength(algorithm2.hash.name)) >> 3 << 3; + const key = new HmacCryptoKey(); + key.algorithm = { + ...algorithm2, + length: length3, + name: this.name + }; + key.extractable = extractable; + key.usages = keyUsages; + key.data = exports6.randomBytes(length3 >> 3); + return setCryptoKey(key); + } + async onSign(algorithm2, key, data) { + const cryptoAlg = ShaCrypto.getAlgorithmName(key.algorithm.hash); + const hmac = exports6.createHmac(cryptoAlg, getCryptoKey(key).data).update(Buffer.from(data)).digest(); + return new Uint8Array(hmac).buffer; + } + async onVerify(algorithm2, key, signature, data) { + const cryptoAlg = ShaCrypto.getAlgorithmName(key.algorithm.hash); + const hmac = exports6.createHmac(cryptoAlg, getCryptoKey(key).data).update(Buffer.from(data)).digest(); + return hmac.compare(Buffer.from(signature)) === 0; + } + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + let key; + switch (format16.toLowerCase()) { + case "jwk": + key = JsonParser.fromJSON(keyData, { targetSchema: HmacCryptoKey }); + break; + case "raw": + key = new HmacCryptoKey(); + key.data = Buffer.from(keyData); + break; + default: + throw new OperationError("format: Must be 'jwk' or 'raw'"); + } + key.algorithm = { + hash: { name: algorithm2.hash.name }, + name: this.name, + length: key.data.length << 3 + }; + key.extractable = extractable; + key.usages = keyUsages; + return setCryptoKey(key); + } + async onExportKey(format16, key) { + switch (format16.toLowerCase()) { + case "jwk": + return JsonSerializer.toJSON(getCryptoKey(key)); + case "raw": + return new Uint8Array(getCryptoKey(key).data).buffer; + default: + throw new OperationError("format: Must be 'jwk' or 'raw'"); + } + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + if (!(getCryptoKey(key) instanceof HmacCryptoKey)) { + throw new TypeError("key: Is not HMAC CryptoKey"); + } + } + }; + var HkdfCryptoKey = class extends CryptoKey2 { + }; + var HkdfProvider2 = class extends HkdfProvider { + async onImportKey(format16, keyData, algorithm2, extractable, keyUsages) { + if (format16.toLowerCase() !== "raw") { + throw new OperationError("Operation not supported"); + } + const key = new HkdfCryptoKey(); + key.data = Buffer.from(keyData); + key.algorithm = { name: this.name }; + key.extractable = extractable; + key.usages = keyUsages; + return setCryptoKey(key); + } + async onDeriveBits(params, baseKey, length3) { + const hash = params.hash.name.replace("-", ""); + const hashLength = exports6.createHash(hash).digest().length; + const byteLength = length3 / 8; + const info3 = import_pvtsutils5.BufferSourceConverter.toUint8Array(params.info); + const PRK = exports6.createHmac(hash, import_pvtsutils5.BufferSourceConverter.toUint8Array(params.salt)).update(import_pvtsutils5.BufferSourceConverter.toUint8Array(getCryptoKey(baseKey).data)).digest(); + const blocks = [Buffer.alloc(0)]; + const blockCount = Math.ceil(byteLength / hashLength) + 1; + for (let i8 = 1; i8 < blockCount; ++i8) { + blocks.push(exports6.createHmac(hash, PRK).update(Buffer.concat([blocks[i8 - 1], info3, Buffer.from([i8])])).digest()); + } + return Buffer.concat(blocks).slice(0, byteLength); + } + checkCryptoKey(key, keyUsage) { + super.checkCryptoKey(key, keyUsage); + if (!(getCryptoKey(key) instanceof HkdfCryptoKey)) { + throw new TypeError("key: Is not HKDF CryptoKey"); + } + } + }; + var ShakeCrypto = class { + static digest(algorithm2, data) { + const hash = exports6.createHash(algorithm2.name.toLowerCase(), { outputLength: algorithm2.length }).update(Buffer.from(data)).digest(); + return new Uint8Array(hash).buffer; + } + }; + var Shake128Provider2 = class extends Shake128Provider { + async onDigest(algorithm2, data) { + return ShakeCrypto.digest(algorithm2, data); + } + }; + var Shake256Provider2 = class extends Shake256Provider { + async onDigest(algorithm2, data) { + return ShakeCrypto.digest(algorithm2, data); + } + }; + var SubtleCrypto2 = class extends SubtleCrypto { + constructor() { + var _a2; + super(); + this.providers.set(new AesCbcProvider2()); + this.providers.set(new AesCtrProvider2()); + this.providers.set(new AesGcmProvider2()); + this.providers.set(new AesCmacProvider2()); + this.providers.set(new AesKwProvider2()); + this.providers.set(new AesEcbProvider2()); + const ciphers = getCiphers(); + if (ciphers.includes("des-cbc")) { + this.providers.set(new DesCbcProvider()); + } + this.providers.set(new DesEde3CbcProvider()); + this.providers.set(new RsaSsaProvider2()); + this.providers.set(new RsaPssProvider2()); + this.providers.set(new RsaOaepProvider2()); + this.providers.set(new RsaEsProvider()); + this.providers.set(new EcdsaProvider2()); + this.providers.set(new EcdhProvider2()); + this.providers.set(new Sha1Provider()); + this.providers.set(new Sha256Provider()); + this.providers.set(new Sha384Provider()); + this.providers.set(new Sha512Provider()); + this.providers.set(new Pbkdf2Provider2()); + this.providers.set(new HmacProvider2()); + this.providers.set(new HkdfProvider2()); + const nodeMajorVersion = (_a2 = /^v(\d+)/.exec(void 0)) === null || _a2 === void 0 ? void 0 : _a2[1]; + if (nodeMajorVersion && parseInt(nodeMajorVersion, 10) >= 12) { + this.providers.set(new Shake128Provider2()); + this.providers.set(new Shake256Provider2()); + } + const hashes2 = getHashes(); + if (hashes2.includes("sha3-256")) { + this.providers.set(new Sha3256Provider()); + } + if (hashes2.includes("sha3-384")) { + this.providers.set(new Sha3384Provider()); + } + if (hashes2.includes("sha3-512")) { + this.providers.set(new Sha3512Provider()); + } + if (nodeMajorVersion && parseInt(nodeMajorVersion, 10) >= 14) { + this.providers.set(new EdDsaProvider2()); + this.providers.set(new EcdhEsProvider2()); + } + } + }; + var Crypto2 = class extends Crypto { + constructor() { + super(...arguments); + this.subtle = new SubtleCrypto2(); + } + getRandomValues(array3) { + if (!ArrayBuffer.isView(array3)) { + throw new TypeError("Failed to execute 'getRandomValues' on 'Crypto': parameter 1 is not of type 'ArrayBufferView'"); + } + const buffer4 = Buffer.from(array3.buffer, array3.byteOffset, array3.byteLength); + exports6.randomFillSync(buffer4); + return array3; + } + }; + + // src/encrypted-block.ts + init_src(); + init_buffer(); + function getCrypto() { + try { + return new Crypto2(); + } catch (e12) { + return null; + } + } + var crypto4 = getCrypto(); + function randomBytes2(size4) { + const bytes2 = Buffer.allocUnsafe(size4); + if (size4 > 0) { + crypto4.getRandomValues(bytes2); + } + return bytes2; + } + var enc32 = (value) => { + value = +value; + const buff = new Uint8Array(4); + buff[3] = value >>> 24; + buff[2] = value >>> 16; + buff[1] = value >>> 8; + buff[0] = value & 255; + return buff; + }; + var readUInt32LE = (buffer4) => { + const offset2 = buffer4.byteLength - 4; + return (buffer4[offset2] | buffer4[offset2 + 1] << 8 | buffer4[offset2 + 2] << 16) + buffer4[offset2 + 3] * 16777216; + }; + var concat5 = (buffers) => { + const uint8Arrays = buffers.map((b6) => b6 instanceof ArrayBuffer ? new Uint8Array(b6) : b6); + const totalLength = uint8Arrays.reduce((sum, arr) => sum + arr.length, 0); + const result = new Uint8Array(totalLength); + let offset2 = 0; + for (const arr of uint8Arrays) { + result.set(arr, offset2); + offset2 += arr.length; + } + return result; + }; + var encode39 = ({ iv, bytes: bytes2 }) => concat5([iv, bytes2]); + var decode45 = (bytes2) => { + const iv = bytes2.subarray(0, 12); + bytes2 = bytes2.slice(12); + return { iv, bytes: bytes2 }; + }; + var code13 = 3145728 + 1337; + async function subtleKey(key) { + return await crypto4.subtle.importKey( + "raw", + // raw or jwk + key, + // raw data + "AES-GCM", + false, + // extractable + ["encrypt", "decrypt"] + ); + } + var decrypt = async ({ key, value }) => { + let { bytes: bytes2, iv } = value; + const cryKey = await subtleKey(key); + const deBytes = await crypto4.subtle.decrypt( + { + name: "AES-GCM", + iv, + tagLength: 128 + }, + cryKey, + bytes2 + ); + bytes2 = new Uint8Array(deBytes); + const len = readUInt32LE(bytes2.subarray(0, 4)); + const cid = CID.decode(bytes2.subarray(4, 4 + len)); + bytes2 = bytes2.subarray(4 + len); + return { cid, bytes: bytes2 }; + }; + var encrypt = async ({ key, cid, bytes: bytes2 }) => { + const len = enc32(cid.bytes.byteLength); + const iv = randomBytes2(12); + const msg = concat5([len, cid.bytes, bytes2]); + try { + const cryKey = await subtleKey(key); + const deBytes = await crypto4.subtle.encrypt( + { + name: "AES-GCM", + iv, + tagLength: 128 + }, + cryKey, + msg + ); + bytes2 = new Uint8Array(deBytes); + } catch (e12) { + console.log("ee", e12); + throw e12; + } + return { value: { bytes: bytes2, iv } }; + }; + var cryptoFn = (key) => { + return { encrypt: (opts) => encrypt({ key, ...opts }), decrypt: (opts) => decrypt({ key, ...opts }) }; + }; + var name13 = "jchris@encrypted-block:aes-gcm"; + + // ../../node_modules/.pnpm/prolly-trees@1.0.4/node_modules/prolly-trees/esm/src/cid-set.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/prolly-trees@1.0.4/node_modules/prolly-trees/esm/src/base.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/prolly-trees@1.0.4/node_modules/prolly-trees/esm/src/utils.js + init_dirname(); + init_buffer2(); + init_process(); + var readUInt32LE2 = (buffer4) => { + const offset2 = buffer4.byteLength - 4; + return (buffer4[offset2] | buffer4[offset2 + 1] << 8 | buffer4[offset2 + 2] << 16) + buffer4[offset2 + 3] * 16777216; + }; + var MAX_UINT32 = 4294967295; + var bf = (factor) => { + const threshold = Math.floor(MAX_UINT32 / factor); + return async (entry) => { + const identity4 = await entry.identity(); + if (typeof identity4 !== "number") { + throw new Error("Identity must be a number"); + } + if (identity4 <= threshold) { + return true; + } + return false; + }; + }; + var simpleCompare = (a8, b6) => { + if (a8 === b6) + return 0; + if (a8 > b6) + return 1; + return -1; + }; + var binaryCompare = (b1, b22) => { + for (let i8 = 0; i8 < b1.byteLength; i8++) { + if (b22.byteLength === i8) + return 1; + const c1 = b1[i8]; + const c22 = b22[i8]; + if (c1 === c22) + continue; + if (c1 > c22) + return 1; + else + return -1; + } + if (b22.byteLength > b1.byteLength) + return -1; + return 0; + }; + var CIDCounter = class { + constructor() { + this._cids = /* @__PURE__ */ new Set(); + } + add(node) { + if (!node.address) { + throw new Error("Cannot add node without address"); + } + if (node.address.then) { + const p8 = node.address.then((cid) => this._cids.add(cid.toString())); + this._cids.add(p8); + p8.then(() => this._cids.delete(p8)); + } else { + this._cids.add(node.address.toString()); + } + } + async all() { + await Promise.all([...this._cids]); + return this._cids; + } + }; + + // ../../node_modules/.pnpm/prolly-trees@1.0.4/node_modules/prolly-trees/esm/src/base.js + var Entry = class { + constructor({ key, address }, opts = {}) { + this.key = key; + this.address = address; + this.codec = opts.codec; + this.hasher = opts.hasher; + } + get isEntry() { + return true; + } + }; + var EntryList = class { + constructor({ entries: entries6, closed }) { + if (typeof closed !== "boolean") + throw new Error('Missing required argument "closed"'); + this.entries = entries6; + this.closed = closed; + this.startKey = entries6[0].key; + } + find(key, compare7) { + const { entries: entries6 } = this; + for (let i8 = entries6.length - 1; i8 > -1; i8--) { + const entry = entries6[i8]; + const comp = compare7(key, entry.key); + if (comp > -1) { + return [ + i8, + entry + ]; + } + } + return null; + } + findMany(keys2, compare7, sorted = false, strict2 = false) { + const { entries: entries6 } = this; + const results = /* @__PURE__ */ new Map(); + if (!sorted) { + keys2 = keys2.sort(compare7); + } else { + keys2 = [...keys2]; + } + for (let i8 = entries6.length - 1; i8 > -1; i8--) { + if (!keys2.length) + break; + const entry = entries6[i8]; + const found = []; + while (keys2.length) { + let key = keys2[keys2.length - 1]; + key = key.key ? key.key : key; + const comp = compare7(key, entry.key); + if (!strict2) { + if (comp > -1) { + found.push(keys2.pop()); + } else { + break; + } + } else { + if (comp === 0) { + found.push(keys2.pop()); + } else if (comp > 0) { + keys2.pop(); + } else { + break; + } + } + } + if (found.length) { + results.set(i8, [ + entry, + found + ]); + } + } + return results; + } + findRange(start, end, compare7) { + const { entries: entries6 } = this; + let last2; + let first = 0; + for (let i8 = entries6.length - 1; i8 > -1; i8--) { + const entry = entries6[i8]; + const comp = compare7(end, entry.key); + if (comp > 0) { + last2 = i8; + break; + } + } + for (let i8 = 0; i8 < entries6.length; i8++) { + const entry = entries6[i8]; + const comp = compare7(start, entry.key); + if (comp === 0) { + first = i8; + break; + } else if (comp < 0) { + break; + } + first = i8; + } + return { + first, + last: last2, + entries: entries6.slice(first, last2 + 1) + }; + } + }; + var stringKey = (key) => typeof key === "string" ? key : JSON.stringify(key); + function sortBulk(bulk, opts) { + return bulk.sort(({ key: a8 }, { key: b6 }) => opts.compare(a8, b6)); + } + async function filterLeftmostInserts(first, bulk, compare7) { + const inserts = []; + for (const b6 of bulk) { + const { key, del: del2 } = b6; + if (compare7(key, first) < 0) { + if (!del2) + inserts.push(b6); + } else { + break; + } + } + return inserts; + } + async function generateNewLeaves(inserts, opts, { chunker: chunker2, compare: compare7 }) { + return await Node2.from({ + entries: inserts.map((insert) => new opts.LeafEntryClass(insert, opts)).sort((a8, b6) => compare7(a8.key, b6.key)), + chunker: chunker2, + NodeClass: opts.LeafClass, + distance: 0, + opts + }); + } + async function generateBranchEntries(that, newLeaves, results, opts) { + return await Promise.all(newLeaves.map(async (node) => { + const block = await node.encode(); + results.blocks.push({ + block, + node + }); + that.cache.set(node); + const newBranchEntry = new opts.BranchEntryClass({ + key: node.key, + address: await node.address + }, opts); + return newBranchEntry; + })); + } + async function processRoot(that, results, bulk, nodeOptions) { + const root3 = results.root; + results.blocks.push({ + block: await root3.encode(), + node: root3 + }); + that.cache.set(root3); + const opts = nodeOptions.opts; + const distance = root3.distance; + const first = root3.entryList.startKey; + const inserts = await filterLeftmostInserts(first, bulk, that.compare); + if (inserts.length) { + const newLeaves = await generateNewLeaves(inserts, opts, that); + const branchEntries = await generateBranchEntries(that, newLeaves, results, opts); + const firstRootEntry = new opts.BranchEntryClass({ + key: root3.entryList.startKey, + address: await root3.address + }, opts); + const newBranchEntries = [ + firstRootEntry, + ...branchEntries + ].sort(({ key: a8 }, { key: b6 }) => opts.compare(a8, b6)); + let newBranches = await Node2.from({ + ...nodeOptions, + entries: newBranchEntries, + chunker: that.chunker, + NodeClass: opts.BranchClass, + distance: distance + 1 + }); + let allBranches = [...newBranches]; + while (newBranches.length > 1) { + const newBranchEntries2 = await Promise.all(newBranches.map(async (l8) => new opts.BranchEntryClass({ + key: l8.key, + address: await l8.address + }, opts))); + newBranches = await Node2.from({ + ...nodeOptions, + entries: newBranchEntries2.sort(({ key: a8 }, { key: b6 }) => opts.compare(a8, b6)), + chunker: that.chunker, + NodeClass: opts.BranchClass, + distance: distance + 1 + }); + allBranches = [ + ...allBranches, + ...newBranches + ]; + } + await Promise.all(allBranches.map(async (m7) => { + const block = await m7.encode(); + that.cache.set(m7); + results.blocks.push({ + block, + node: m7 + }); + })); + results.root = newBranches[0]; + results.nodes = [ + ...results.nodes, + ...allBranches + ]; + } + } + var Node2 = class _Node { + constructor({ entryList, chunker: chunker2, distance, getNode, compare: compare7, cache: cache3 }) { + this.entryList = entryList; + this.chunker = chunker2; + this.distance = distance; + this.getNode = getNode; + this.compare = compare7; + this.cache = cache3; + } + get closed() { + return this.entryList.closed; + } + get key() { + return this.entryList.startKey; + } + async getEntry(key, cids = new CIDCounter()) { + const result = await this._getEntry(key, cids); + return { + result, + cids + }; + } + async _getEntry(key, cids) { + cids.add(this); + let node = this; + while (!node.isLeaf) { + const result2 = node.entryList.find(key, this.compare); + if (result2 === null) + throw new Error("Not found"); + const [, entry2] = result2; + node = await this.getNode(await entry2.address); + cids.add(node); + } + const result = node.entryList.find(key, this.compare); + if (result === null || result[1].key.toString() !== key.toString()) + throw new Error("Not found"); + const [, entry] = result; + return entry; + } + async getAllEntries(cids = new CIDCounter()) { + const result = await this._getAllEntries(cids); + return { + result, + cids + }; + } + _getAllEntries(cids) { + cids.add(this); + if (this.isLeaf) { + return this.entryList.entries; + } else { + const { entries: entries6 } = this.entryList; + const mapper = async (entry) => this.getNode(await entry.address).then((node) => node._getAllEntries(cids)).catch(async (err) => { + throw err; + }); + return Promise.all(entries6.map(mapper)).then((results) => results.flat()); + } + } + async *vis(cids = /* @__PURE__ */ new Set()) { + const renderNodeLabel = async (node) => { + if (node.isLeaf) { + const entries6 = node.entryList.entries.map((e12) => `[${e12.key},${JSON.stringify(e12.value).replace(/"/g, "'")}]`).join(", "); + return `Leaf [${entries6}]`; + } else { + const entries6 = node.entryList.entries.map((e12) => `[${e12.key}]`).join(", "); + return `Branch [${entries6}]`; + } + }; + const shortCid = (cid) => cid.toString().slice(0, 4) + cid.toString().slice(-4); + const visit = async function* (node, parentId, cids2) { + const nodeId = await node.address; + if (!cids2.has(nodeId)) { + cids2.add(nodeId); + const nodeLabel = await renderNodeLabel(node); + yield ` node [shape=ellipse fontname="Courier"]; ${shortCid(nodeId)} [label="${nodeLabel}"];`; + yield ` ${shortCid(parentId)} -> ${shortCid(nodeId)};`; + for (const entry of node.entryList.entries) { + if (entry.address) { + const entryId = await entry.address; + try { + const childNode = await node.getNode(entryId); + yield* await visit(childNode, nodeId, cids2); + } catch (err) { + yield ` ${shortCid(nodeId)} -> ${shortCid(entryId)};`; + yield ` node [shape=ellipse fontname="Courier"]; ${shortCid(entryId)} [label="Error: ${err.message}"];`; + } + } + } + } + }; + yield "digraph tree {"; + yield ' node [shape=ellipse fontname="Courier"]; rootnode;'; + for await (const line of visit(this, "rootnode", cids)) { + yield line; + } + yield "}"; + } + async getEntries(keys2, sorted = false, cids = new CIDCounter()) { + const result = await this._getEntries(keys2, sorted, cids); + return { + result, + cids + }; + } + async _getEntries(keys2, sorted, cids) { + cids.add(this); + if (!sorted) + keys2 = keys2.sort(this.compare); + const results = this.entryList.findMany(keys2, this.compare, true, this.isLeaf); + if (this.isLeaf) { + return [...results.values()].map(([entry]) => entry); + } + let entries6 = []; + for (const [entry, keys3] of [...results.values()].reverse()) { + const p8 = this.getNode(await entry.address); + entries6.push(p8.then((node) => node._getEntries(keys3.reverse(), true, cids))); + } + entries6 = await Promise.all(entries6); + return entries6.flat(); + } + async getRangeEntries(start, end, cids = new CIDCounter()) { + const result = await this._getRangeEntries(start, end, cids); + return { + result, + cids + }; + } + _getRangeEntries(start, end, cids) { + cids.add(this); + const { entries: entries6 } = this.entryList.findRange(start, end, this.compare); + if (this.isLeaf) { + return entries6.filter((entry) => { + const s7 = this.compare(start, entry.key); + const e12 = this.compare(end, entry.key); + if (s7 <= 0 && e12 >= 0) + return true; + return false; + }); + } + if (!entries6.length) + return []; + const thenRange = async (entry) => this.getNode(await entry.address).then((node) => node._getRangeEntries(start, end, cids)); + const results = [thenRange(entries6.shift())]; + if (!entries6.length) + return results[0]; + const last2 = thenRange(entries6.pop()); + while (entries6.length) { + const thenAll = async (entry) => this.getNode(await entry.address).then(async (node) => node._getAllEntries(cids)); + results.push(thenAll(entries6.shift())); + } + results.push(last2); + return Promise.all(results).then((results2) => results2.flat()); + } + async transaction(bulk, opts = {}) { + opts = { + codec: this.codec, + hasher: this.hasher, + getNode: this.getNode, + compare: this.compare, + cache: this.cache, + ...opts + }; + const nodeOptions = { + chunker: this.chunker, + opts + }; + const results = this.entryList.findMany(bulk, opts.compare, true, this.isLeaf); + if (this.isLeaf) { + return await this.transactionLeaf(bulk, opts, nodeOptions, results); + } else { + return await this.transactionBranch(bulk, opts, nodeOptions, results); + } + } + async transactionLeaf(bulk, opts, nodeOptions, results) { + const { LeafClass: LeafClass2, LeafEntryClass } = opts; + const { entries: entries6, previous } = this.processLeafEntries(bulk, results, LeafEntryClass, opts); + const _opts = { + ...nodeOptions, + entries: entries6, + NodeClass: LeafClass2, + distance: 0 + }; + const nodes = await _Node.from(_opts); + return { + nodes, + previous, + blocks: await Promise.all(nodes.map(async (n9) => { + const block = await n9.encode(); + this.cache.set(n9); + return { + block, + node: n9 + }; + })), + distance: 0 + }; + } + processLeafEntries(bulk, results, LeafEntryClass, opts) { + const previous = []; + let entries6 = []; + const changes = {}; + const deletes = /* @__PURE__ */ new Map(); + for (const { key, del: del2, value } of bulk) { + const skey = stringKey(key); + if (del2) { + if (typeof changes[skey] === "undefined") + deletes.set(skey, null); + } else { + changes[skey] = { + key, + value + }; + deletes.delete(skey); + } + } + entries6 = [...this.entryList.entries]; + for (const [i8, [entry]] of results) { + previous.push(entry); + const skey = stringKey(entry.key); + if (deletes.has(skey)) { + deletes.set(skey, i8); + } else { + entries6[i8] = new LeafEntryClass(changes[skey], opts); + delete changes[skey]; + } + } + let count = 0; + for (const [, i8] of deletes) { + if (i8 !== null) + entries6.splice(i8 - count++, 1); + } + const appends = Object.values(changes).map((obj) => new LeafEntryClass(obj, opts)); + entries6 = entries6.concat(appends).sort(({ key: a8 }, { key: b6 }) => opts.compare(a8, b6)); + return { + entries: entries6, + previous + }; + } + async transactionBranch(bulk, opts, nodeOptions, results) { + const { BranchClass: BranchClass2, BranchEntryClass } = opts; + let distance = 0; + for (const [i8, [entry, keys2]] of results) { + const p8 = this.getNode(await entry.address).then((node) => node.transaction(keys2.reverse(), { + ...opts, + sorted: true + })).then((r10) => ({ + entry, + keys: keys2, + distance, + ...r10 + })); + results.set(i8, p8); + } + let entries6 = [...this.entryList.entries]; + const final = { + previous: [], + blocks: [], + nodes: [] + }; + for (const [i8, p8] of results) { + const { + nodes, + previous, + blocks, + distance: _distance + } = await p8; + distance = _distance; + entries6[i8] = nodes; + if (previous.length) + final.previous = final.previous.concat(previous); + if (blocks.length) + final.blocks = final.blocks.concat(blocks); + if (nodes.length) + final.nodes = final.nodes.concat(nodes); + } + entries6 = entries6.flat(); + const newEntries = await this.handlePrepend(entries6, opts, nodeOptions, final, distance); + distance++; + const toEntry = async (branch) => { + if (branch.isEntry) + return branch; + const block = await branch.encode(); + final.blocks.push({ + block, + node: branch + }); + this.cache.set(branch); + return new BranchEntryClass(branch, opts); + }; + entries6 = await Promise.all(newEntries.map(toEntry)); + const _opts = { + ...nodeOptions, + entries: entries6, + NodeClass: BranchClass2, + distance + }; + const newNodes = await _Node.from(_opts); + await Promise.all(newNodes.map(async (n9) => { + const block = await n9.encode(); + final.blocks.push({ + block, + node: n9 + }); + this.cache.set(n9); + })); + final.nodes = newNodes; + return { + ...final, + distance + }; + } + async handlePrepend(entries6, opts, nodeOptions, final, distance) { + const { BranchClass: BranchClass2, LeafClass: LeafClass2 } = opts; + let newEntries = []; + let prepend = null; + for (const entry of entries6) { + if (prepend) { + const mergeEntries = await this.mergeFirstLeftEntries(entry, prepend, nodeOptions, final, distance); + prepend = null; + const NodeClass = !mergeEntries[0].address ? LeafClass2 : BranchClass2; + const _opts = { + ...nodeOptions, + entries: mergeEntries.sort(({ key: a8 }, { key: b6 }) => opts.compare(a8, b6)), + NodeClass, + distance + }; + const nodes = await _Node.from(_opts); + if (!nodes[nodes.length - 1].closed) { + prepend = nodes.pop(); + } + if (nodes.length) { + newEntries = newEntries.concat(nodes); + } + } else { + if (!entry.isEntry && !entry.closed) { + prepend = entry; + } else { + newEntries.push(entry); + } + } + } + if (prepend) { + newEntries.push(prepend); + } + return newEntries; + } + async getNodeFirstFromBlocks(blocks, addr) { + for (const { block, node } of blocks) { + if (await block.cid === addr) + return node; + } + return await this.getNode(addr); + } + async mergeFirstLeftEntries(entry, prepend, nodeOptions, final, distance) { + const opts = nodeOptions.opts; + const { LeafClass: LeafClass2, BranchClass: BranchClass2, BranchEntryClass } = opts; + if (entry.isEntry) { + const addr = await entry.address; + entry = await this.getNodeFirstFromBlocks(final.blocks, addr); + } + const es = entry.entryList.entries; + if (!es.length) + throw new Error("unreachable no entries"); + const basicMerge = (entries1, entries22) => { + return entries1.concat(entries22); + }; + const processNodesAndCreateEntries = async (nodes, final2, opts2) => { + return await Promise.all(nodes.map(async (l8) => { + final2.blocks.push({ + block: await l8.encode(), + node: l8 + }); + this.cache.set(l8); + return new BranchEntryClass({ + key: l8.key, + address: await l8.address + }, opts2); + })); + }; + if (es[0].constructor.name === prepend.entryList.entries[0].constructor.name) { + return await basicMerge(prepend.entryList.entries, es); + } else { + const leftEntry = es.shift(); + if (!leftEntry) + throw new Error("unreachable no left entry"); + if (!leftEntry.address) + throw new Error("unreachable existing leaf, no leftEntry.address"); + const mergeLeftEntries = await this.mergeFirstLeftEntries(leftEntry, prepend, nodeOptions, final, distance - 1); + const esf = es.shift(); + if (!esf) { + return mergeLeftEntries; + } + if (!esf.address) + throw new Error("unreachable existing leaf, no esf.address"); + const oldFront = await this.getNodeFirstFromBlocks(final.blocks, await esf.address); + if (!oldFront.entryList.entries[0].address) { + const leftLeafEntries = await basicMerge(mergeLeftEntries, oldFront.entryList.entries); + const leftLeafNodes = await _Node.from({ + ...nodeOptions, + entries: leftLeafEntries.sort(({ key: a8 }, { key: b6 }) => opts.compare(a8, b6)), + NodeClass: LeafClass2, + distance + }); + const leftBranches = await processNodesAndCreateEntries(leftLeafNodes, final, opts); + return await basicMerge(leftBranches, es); + } else { + if (mergeLeftEntries[0].address) { + return mergeLeftEntries.concat(oldFront.entryList.entries); + } else { + const mergeLeftNodes = await _Node.from({ + ...nodeOptions, + entries: mergeLeftEntries.sort(({ key: a8 }, { key: b6 }) => opts.compare(a8, b6)), + NodeClass: LeafClass2, + distance + }); + const mergeLeftBranchEntries = await processNodesAndCreateEntries(mergeLeftNodes, final, opts); + const newFirstNodes = await _Node.from({ + ...nodeOptions, + entries: [ + ...oldFront.entryList.entries, + ...mergeLeftBranchEntries, + ...es + ].sort(({ key: a8 }, { key: b6 }) => opts.compare(a8, b6)), + NodeClass: BranchClass2, + distance + }); + const newBranchEntries = await processNodesAndCreateEntries(newFirstNodes, final, opts); + return newBranchEntries; + } + } + } + } + async bulk(bulk, opts = {}, isRoot = true) { + const { BranchClass: BranchClass2 } = opts; + opts = { + codec: this.codec, + hasher: this.hasher, + getNode: this.getNode, + compare: this.compare, + cache: this.cache, + ...opts + }; + if (!opts.sorted) { + bulk = sortBulk(bulk, opts); + opts.sorted = true; + } + const nodeOptions = { + chunker: this.chunker, + opts + }; + const results = await this.transaction(bulk, opts); + while (results.nodes.length > 1) { + const newDistance = results.nodes[0].distance + 1; + const branchEntries = await Promise.all(results.nodes.map(async (node) => { + const block = await node.encode(); + results.blocks.push({ + block, + node + }); + this.cache.set(node); + return new opts.BranchEntryClass(node, opts); + })); + const newNodes = await _Node.from({ + ...nodeOptions, + entries: branchEntries, + NodeClass: BranchClass2, + distance: newDistance + }); + await Promise.all(newNodes.map(async (node) => { + const block = await node.encode(); + this.cache.set(node); + results.blocks.push({ + block, + node + }); + })); + results.nodes = newNodes; + } + results.root = results.nodes[0]; + if (isRoot && results.root) { + await processRoot(this, results, bulk, nodeOptions); + } + results.blocks = results.blocks.map(({ block }) => block); + return results; + } + static async from({ entries: entries6, chunker: chunker2, NodeClass, distance, opts }) { + if (!entries6.every((entry) => entry.constructor.name === entries6[0].constructor.name)) + throw new Error("all entries must be of the same type"); + const parts = []; + let chunk = []; + for (const entry of entries6) { + chunk.push(entry); + if (await chunker2(entry, distance)) { + parts.push(new EntryList({ + entries: chunk, + closed: true + })); + chunk = []; + } + } + if (chunk.length) { + parts.push(new EntryList({ + entries: chunk, + closed: false + })); + } + return parts.map((entryList) => new NodeClass({ + entryList, + chunker: chunker2, + distance, + ...opts + })); + } + }; + var IPLDNode = class extends Node2 { + constructor({ codec, hasher, block, ...opts }) { + super(opts); + this.codec = codec; + this.hasher = hasher; + if (!block) { + this.block = this.encode(); + this.address = this.block.then((block2) => block2.cid); + } else { + this.block = block; + this.address = block.cid; + } + } + async get(key) { + const { + result: entry, + cids + } = await this.getEntry(key); + return { + result: entry.key, + cids + }; + } + async encode() { + if (this.block) + return this.block; + const value = await this.encodeNode(); + const opts = { + codec: this.codec, + hasher: this.hasher, + value + }; + this.block = await encode37(opts); + return this.block; + } + }; + var IPLDBranch = class extends IPLDNode { + async encodeNode() { + const { entries: entries6 } = this.entryList; + const mapper = async (entry) => { + if (!entry.address) + throw new Error("entry.address required"); + return [ + entry.key, + await entry.address + ]; + }; + const list10 = await Promise.all(entries6.map(mapper)); + return { + branch: [ + this.distance, + list10 + ], + closed: this.closed + }; + } + get isBranch() { + return true; + } + }; + var IPLDLeaf = class extends IPLDNode { + async encodeNode() { + const list10 = await Promise.all(this.entryList.entries.map(async (entry) => await entry.encodeNode())); + return { + leaf: list10, + closed: this.closed + }; + } + get isLeaf() { + return true; + } + }; + var create17 = async function* (obj) { + let { LeafClass: LeafClass2, LeafEntryClass, BranchClass: BranchClass2, BranchEntryClass, list: list10, chunker: chunker2, compare: compare7, ...opts } = obj; + list10 = list10.map((value) => new LeafEntryClass(value, opts)); + opts.compare = compare7; + let nodes = await Node2.from({ + entries: list10, + chunker: chunker2, + NodeClass: LeafClass2, + distance: 0, + opts + }); + yield* nodes; + let distance = 1; + while (nodes.length > 1) { + const mapper = async (node) => new BranchEntryClass({ + key: node.key, + address: await node.address + }, opts); + const entries6 = await Promise.all(nodes.map(mapper)); + nodes = await Node2.from({ + entries: entries6, + chunker: chunker2, + NodeClass: BranchClass2, + distance, + opts + }); + yield* nodes; + distance++; + } + }; + + // ../../node_modules/.pnpm/prolly-trees@1.0.4/node_modules/prolly-trees/esm/src/cid-set.js + var compare4 = ({ bytes: a8 }, { bytes: b6 }) => binaryCompare(a8, b6); + var CIDEntry = class extends Entry { + constructor(cid) { + super({ + address: cid, + key: cid + }); + this.cid = cid; + } + encodeNode() { + return this.cid; + } + identity() { + const buffer4 = this.cid.multihash.bytes; + return readUInt32LE2(buffer4); + } + }; + var CIDNodeEntry = class extends Entry { + async identity() { + const { + multihash: { bytes: bytes2 } + } = await this.address; + return readUInt32LE2(bytes2); + } + }; + var CIDSetBranch = class extends IPLDBranch { + }; + var CIDSetLeaf = class extends IPLDLeaf { + }; + var createGetNode = (get17, cache3, chunker2, codec, hasher) => { + const decoder4 = (block) => { + const { value } = block; + const opts = { + chunker: chunker2, + cache: cache3, + block, + getNode, + codec, + hasher, + compare: compare4 + }; + let entries6; + let CLS; + if (value.leaf) { + entries6 = value.leaf.map((cid) => new CIDEntry(cid)); + CLS = CIDSetLeaf; + } else if (value.branch) { + const [distance, _entries] = value.branch; + opts.distance = distance; + entries6 = _entries.map(([key, address]) => new CIDNodeEntry({ + key, + address + })); + CLS = CIDSetBranch; + } else { + throw new Error("Unknown block data, does not match schema"); + } + const entryList = new EntryList({ + entries: entries6, + closed: value.closed + }); + const node = new CLS({ + entryList, + ...opts + }); + cache3.set(node); + return node; + }; + const getNode = (cid) => { + if (cache3.has(cid)) + return cache3.get(cid); + return get17(cid).then((block) => decoder4(block)); + }; + return getNode; + }; + var create18 = ({ get: get17, cache: cache3, chunker: chunker2, list: list10, codec, hasher, sorted }) => { + if (!sorted) + list10 = list10.sort(compare4); + const getNode = createGetNode(get17, cache3, chunker2, codec, hasher); + const opts = { + list: list10, + codec, + hasher, + chunker: chunker2, + getNode, + sorted, + compare: compare4, + cache: cache3, + LeafClass: CIDSetLeaf, + LeafEntryClass: CIDEntry, + BranchClass: CIDSetBranch, + BranchEntryClass: CIDNodeEntry + }; + return create17(opts); + }; + var load = ({ cid, get: get17, cache: cache3, chunker: chunker2, codec, hasher, ...opts }) => { + const getNode = createGetNode(get17, cache3, chunker2, codec, hasher, opts); + return getNode(cid); + }; + + // src/crypto.ts + init_src(); + var encrypt2 = async function* ({ + get: get17, + cids, + hasher, + key, + cache: cache3, + chunker: chunker2, + root: root3 + }) { + const set5 = /* @__PURE__ */ new Set(); + let eroot; + for (const cid of cids) { + const unencrypted = await get17(cid); + if (!unencrypted) + throw new Error("missing cid: " + cid.toString()); + const encrypted = await encrypt({ ...unencrypted, key }); + const block2 = await encode37({ ...encrypted, codec: encrypted_block_exports, hasher }); + yield block2; + set5.add(block2.cid.toString()); + if (unencrypted.cid.equals(root3)) + eroot = block2.cid; + } + if (!eroot) + throw new Error("cids does not include root"); + const list10 = [...set5].map((s7) => CID.parse(s7)); + let last2; + for await (const node of create18({ list: list10, get: get17, cache: cache3, chunker: chunker2, hasher, codec: src_exports })) { + const block2 = await node.block; + yield block2; + last2 = block2; + } + if (!last2) + throw new Error("missing last block"); + const head2 = [eroot, last2.cid]; + const block = await encode37({ value: head2, codec: src_exports, hasher }); + yield block; + }; + var decrypt2 = async function* ({ root: root3, get: get17, key, cache: cache3, chunker: chunker2, hasher }) { + const getWithDecode = async (cid) => get17(cid).then(async (block) => { + if (!block) + return; + const decoded = await decode43({ ...block, codec: src_exports, hasher }); + return decoded; + }); + const getWithDecrypt = async (cid) => get17(cid).then(async (block) => { + if (!block) + return; + const decoded = await decode43({ ...block, codec: encrypted_block_exports, hasher }); + return decoded; + }); + const decodedRoot = await getWithDecode(root3); + if (!decodedRoot) + throw new Error("missing root"); + if (!decodedRoot.bytes) + throw new Error("missing bytes"); + const { value: [eroot, tree3] } = decodedRoot; + const rootBlock = await get17(eroot); + if (!rootBlock) + throw new Error("missing root block"); + const cidset = await load({ cid: tree3, get: getWithDecode, cache: cache3, chunker: chunker2, codec: encrypted_block_exports, hasher }); + const { result: nodes } = await cidset.getAllEntries(); + const unwrap2 = async (eblock) => { + if (!eblock) + throw new Error("missing block"); + if (!eblock.value) { + eblock = await decode43({ ...eblock, codec: encrypted_block_exports, hasher }); + } + const { bytes: bytes2, cid } = await decrypt({ ...eblock, key }).catch((e12) => { + throw e12; + }); + const block = await create16({ cid, bytes: bytes2, hasher, codec: encrypted_block_exports }); + return block; + }; + const promises3 = []; + for (const { cid } of nodes) { + if (!rootBlock.cid.equals(cid)) + promises3.push(getWithDecrypt(cid).then(unwrap2)); + } + yield* promises3; + yield unwrap2(rootBlock); + }; + + // src/encrypt-helpers.ts + init_buffer(); + + // ../../node_modules/.pnpm/prolly-trees@1.0.4/node_modules/prolly-trees/esm/src/cache.js + init_dirname(); + init_buffer2(); + init_process(); + var nocache = { + has: () => false, + get: () => { + throw new Error("Cannot ask for entries from nocache"); + }, + set: () => { + } + }; + + // src/encrypt-helpers.ts + var chunker = bf(30); + async function encryptedMakeCarFile(key, fp, t9) { + const { cid, bytes: bytes2 } = await encodeCarHeader(fp); + await t9.put(cid, bytes2); + return encryptedEncodeCarFile(key, cid, t9); + } + async function encryptedEncodeCarFile(key, rootCid, t9) { + const encryptionKeyBuffer = Buffer.from(key, "hex"); + const encryptionKey = encryptionKeyBuffer.buffer.slice(encryptionKeyBuffer.byteOffset, encryptionKeyBuffer.byteOffset + encryptionKeyBuffer.byteLength); + const encryptedBlocks = new MemoryBlockstore(); + const cidsToEncrypt = []; + for (const { cid } of t9.entries()) { + cidsToEncrypt.push(cid); + } + let last2 = null; + for await (const block of encrypt2({ + cids: cidsToEncrypt, + get: t9.get.bind(t9), + key: encryptionKey, + hasher: sha2562, + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + chunker, + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + cache: nocache, + root: rootCid + })) { + await encryptedBlocks.put(block.cid, block.bytes); + last2 = block; + } + if (!last2) + throw new Error("no blocks encrypted"); + const encryptedCar = await encodeCarFile(last2.cid, encryptedBlocks); + return encryptedCar; + } + async function decodeEncryptedCar(key, reader2) { + const roots = await reader2.getRoots(); + const root3 = roots[0]; + return await decodeCarBlocks(root3, reader2.get.bind(reader2), key); + } + async function decodeCarBlocks(root3, get17, keyMaterial) { + const decryptionKeyBuffer = Buffer.from(keyMaterial, "hex"); + const decryptionKey = decryptionKeyBuffer.buffer.slice(decryptionKeyBuffer.byteOffset, decryptionKeyBuffer.byteOffset + decryptionKeyBuffer.byteLength); + const decryptedBlocks = new MemoryBlockstore(); + let last2 = null; + for await (const block of decrypt2({ + root: root3, + get: get17, + key: decryptionKey, + hasher: sha2562, + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + chunker, + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + cache: nocache + })) { + await decryptedBlocks.put(block.cid, block.bytes); + last2 = block; + } + if (!last2) + throw new Error("no blocks decrypted"); + return { blocks: decryptedBlocks, root: last2.cid }; + } + + // src/store-remote.ts + init_dirname(); + init_buffer2(); + init_process(); + init_store(); + var RemoteDataStore = class extends DataStore { + constructor(loader, connection3, type3 = "data") { + super(loader); + __publicField(this, "tag", "car-browser-s3"); + __publicField(this, "connection"); + __publicField(this, "type"); + this.connection = connection3; + this.type = type3; + } + prefix() { + return `fp.${this.loader.name}.${this.STORAGE_VERSION}.${this.loader.keyId}`; + } + async load(carCid) { + const bytes2 = await this.connection.download({ + type: this.type, + name: this.prefix(), + car: carCid.toString() + }); + if (!bytes2) + throw new Error(`missing remote car ${carCid.toString()}`); + return { cid: carCid, bytes: bytes2 }; + } + async save(car) { + const uploadParams = { + type: this.type, + name: this.prefix(), + car: car.cid.toString(), + size: car.bytes.length.toString() + }; + await this.connection.upload(car.bytes, uploadParams); + } + // eslint-disable-next-line @typescript-eslint/require-await + async remove(_cid) { + throw new Error("not implemented"); + } + }; + var RemoteMetaStore = class extends MetaStore { + constructor(name15, connection3) { + super(name15); + __publicField(this, "tag", "header-browser-ls"); + __publicField(this, "connection"); + this.connection = connection3; + } + prefix() { + return `fp.${this.name}.${this.STORAGE_VERSION}`; + } + // eslint-disable-next-line @typescript-eslint/require-await + async load(branch = "main") { + const bytes2 = await this.connection.download({ + type: "meta", + name: this.prefix(), + branch + }); + if (!bytes2) + return null; + try { + return this.parseHeader(new TextDecoder().decode(bytes2)); + } catch (e12) { + return null; + } + } + // eslint-disable-next-line @typescript-eslint/require-await + async save(meta, branch = "main") { + const bytes2 = new TextEncoder().encode(this.makeHeader(meta)); + const uploadParams = { + type: "meta", + name: this.prefix(), + branch, + size: bytes2.length.toString() + }; + await this.connection.upload(bytes2, uploadParams); + } + }; + + // src/loader.ts + init_src(); + function cidListIncludes(list10, cid) { + return list10.some((c8) => c8.equals(cid)); + } + function uniqueCids(list10) { + const byString = /* @__PURE__ */ new Map(); + for (const cid of list10) { + byString.set(cid.toString(), cid); + } + return [...byString.values()]; + } + var Loader = class { + constructor(name15, opts) { + __publicField(this, "name"); + __publicField(this, "opts", {}); + __publicField(this, "remoteMetaLoading"); + __publicField(this, "remoteMetaStore"); + __publicField(this, "remoteCarStore"); + __publicField(this, "metaStore"); + __publicField(this, "carStore"); + __publicField(this, "carLog", []); + __publicField(this, "carReaders", /* @__PURE__ */ new Map()); + __publicField(this, "ready"); + __publicField(this, "key"); + __publicField(this, "keyId"); + __publicField(this, "getBlockCache", /* @__PURE__ */ new Map()); + this.name = name15; + this.opts = opts || this.opts; + this.ready = this.initializeStores().then(async () => { + if (!this.metaStore || !this.carStore) + throw new Error("stores not initialized"); + const meta = await this.metaStore.load("main"); + if (meta) { + await this.mergeMetaFromRemote(meta); + } + }); + } + connectRemoteMeta(connection3) { + const remote = new RemoteMetaStore(this.name, connection3); + this.remoteMetaStore = remote; + this.remoteMetaLoading = this.remoteMetaStore.load("main").then(async (meta) => { + if (meta) { + await this.mergeMetaFromRemote(meta); + } + }); + connection3.ready = Promise.all([this.remoteMetaLoading]).then(() => { + }); + connection3.refresh = async () => { + await remote.load("main").then(async (meta) => { + if (meta) { + await this.mergeMetaFromRemote(meta); + } + }); + }; + return connection3; + } + connectRemoteStorage(connection3) { + this.remoteCarStore = new RemoteDataStore(this, connection3); + return connection3; + } + connectRemote(connection3) { + this.connectRemoteMeta(connection3); + this.connectRemoteStorage(connection3); + connection3.ready = Promise.all([this.ready, this.remoteMetaLoading]).then(() => { + }); + return connection3; + } + async snapToCar(carCid) { + await this.ready; + if (typeof carCid === "string") { + carCid = CID.parse(carCid); + } + const carHeader = await this.loadCarHeaderFromMeta({ car: carCid, key: this.key || null }); + this.carLog = [carCid, ...carHeader.cars]; + void this.getMoreReaders(carHeader.cars); + await this._applyCarHeader(carHeader, true); + } + async mergeMetaFromRemote(meta) { + if (meta.key) { + await this.setKey(meta.key); + } + if (cidListIncludes(this.carLog, meta.car)) { + return; + } + const carHeader = await this.loadCarHeaderFromMeta(meta); + const remoteCarLog = [meta.car, ...carHeader.cars]; + if (this.carLog.length === 0 || cidListIncludes(remoteCarLog, this.carLog[0])) { + this.carLog = [...uniqueCids([meta.car, ...this.carLog, ...carHeader.cars])]; + void this.getMoreReaders(carHeader.cars); + await this._applyCarHeader(carHeader); + } else { + const newCarLog = [...uniqueCids([meta.car, ...this.carLog, ...carHeader.cars])]; + this.carLog = newCarLog; + void this.getMoreReaders(carHeader.cars); + await this._applyCarHeader(carHeader); + } + } + async ingestKeyFromMeta(meta) { + const { key } = meta; + if (key) { + await this.setKey(key); + } + } + async loadCarHeaderFromMeta({ car: cid }) { + const reader2 = await this.loadCar(cid); + return await parseCarFile(reader2); + } + // eslint-disable-next-line @typescript-eslint/require-await + async _getKey() { + if (this.key) + return this.key; + if (!this.opts.public) { + if (getCrypto()) { + await this.setKey(randomBytes2(32).toString("hex")); + } else { + console.warn("missing crypto module, using public mode"); + } + } + return this.key; + } + async commit(t9, done, compact = false) { + await this.ready; + const fp = this.makeCarHeader(done, this.carLog, compact); + const theKey = await this._getKey(); + const { cid, bytes: bytes2 } = theKey ? await encryptedMakeCarFile(theKey, fp, t9) : await clearMakeCarFile(fp, t9); + if (isFileResult(done)) { + const dbLoader = this; + await dbLoader.fileStore.save({ cid, bytes: bytes2 }); + dbLoader.remoteFileStore?.save({ cid, bytes: bytes2 }).catch((e12) => { + console.error("Failed to save remote file", done, e12); + }); + return cid; + } + await this.carStore.save({ cid, bytes: bytes2 }); + + this.remoteMetaLoading = this.remoteCarStore?.save({ cid, bytes: bytes2 }).then(async () => { + + await this.remoteMetaStore?.save({ car: cid, key: theKey || null }); + }).catch((e12) => { + console.error("Failed to save remote car or meta", e12); + }); + await this.metaStore.save({ car: cid, key: theKey || null }); + if (compact) { + for (const cid2 of this.carLog) { + await this.carStore.remove(cid2); + } + this.carLog = [cid]; + } else { + this.carLog.unshift(cid); + } + return cid; + } + async getBlock(cid) { + await this.ready; + const sCid = cid.toString(); + if (this.getBlockCache.has(sCid)) + return this.getBlockCache.get(sCid); + const got = await Promise.any(this.carLog.map(async (carCid) => { + const reader2 = await this.loadCar(carCid); + if (!reader2) { + throw new Error(`missing car reader ${carCid.toString()}`); + } + const block = await reader2.get(cid); + if (block) { + return block; + } + throw new Error(`block not in reader: ${cid.toString()}`); + })).catch(() => void 0); + if (got) { + this.getBlockCache.set(sCid, got); + } + return got; + } + async initializeStores() { + const isBrowser = typeof window !== "undefined"; + const module3 = isBrowser ? await (init_store_browser(), __toCommonJS(store_browser_exports)) : await (init_store_fs(), __toCommonJS(store_fs_exports)); + if (module3) { + this.metaStore = new module3.MetaStore(this.name); + this.carStore = new module3.DataStore(this); + } else { + throw new Error("Failed to initialize stores."); + } + } + async loadCar(cid) { + if (!this.carStore) + throw new Error("car store not initialized"); + return await this.storesLoadCar(cid, this.carStore, this.remoteCarStore); + } + async storesLoadCar(cid, local, remote) { + const cidString = cid.toString(); + if (!this.carReaders.has(cidString)) { + this.carReaders.set(cidString, (async () => { + let loadedCar = null; + try { + loadedCar = await local.load(cid); + } catch (e12) { + if (remote) { + const remoteCar = await remote.load(cid); + if (remoteCar) { + await local.save(remoteCar); + loadedCar = remoteCar; + } + } + } + if (!loadedCar) + throw new Error(`missing car file ${cidString}`); + const rawReader = await CarReader.fromBytes(loadedCar.bytes); + const readerP = this.ensureDecryptedReader(rawReader); + this.carReaders.set(cidString, readerP); + return readerP; + })().catch((e12) => { + this.carReaders.delete(cidString); + throw e12; + })); + } + return this.carReaders.get(cidString); + } + async ensureDecryptedReader(reader2) { + const theKey = await this._getKey(); + if (!theKey) + return reader2; + const { blocks, root: root3 } = await decodeEncryptedCar(theKey, reader2); + return { + getRoots: () => [root3], + get: blocks.get.bind(blocks) + }; + } + async setKey(key) { + if (this.key && this.key !== key) + throw new Error("key mismatch"); + this.key = key; + const crypto5 = getCrypto(); + if (!crypto5) + throw new Error("missing crypto module"); + const subtle = crypto5.subtle; + const encoder4 = new TextEncoder(); + const data = encoder4.encode(key); + const hashBuffer = await subtle.digest("SHA-256", data); + const hashArray = Array.from(new Uint8Array(hashBuffer)); + this.keyId = hashArray.map((b6) => b6.toString(16).padStart(2, "0")).join(""); + } + async getMoreReaders(cids) { + await Promise.all(cids.map((cid) => this.loadCar(cid))); + } + }; + __publicField(Loader, "defaultHeader"); + + // src/index.ts + init_dirname(); + init_buffer2(); + init_process(); + + // src/indexer-helpers.ts + init_dirname(); + init_buffer2(); + init_process(); + var import_charwise = __toESM(require_charwise(), 1); + + // ../../node_modules/.pnpm/prolly-trees@1.0.4/node_modules/prolly-trees/esm/src/db-index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/prolly-trees@1.0.4/node_modules/prolly-trees/esm/src/map.js + init_dirname(); + init_buffer2(); + init_process(); + var MapEntry = class extends Entry { + async identity() { + const encoded = await this.codec.encode(await this.encodeNode()); + const hash = await this.hasher.encode(encoded); + return readUInt32LE2(hash); + } + }; + var MapLeafEntry = class extends MapEntry { + constructor(node, opts) { + super(node, opts); + this.value = node.value; + } + encodeNode() { + return [ + this.key, + this.value + ]; + } + }; + var MapBranchEntry = class extends MapEntry { + constructor(node, opts) { + if (!node.address) + throw new Error("Cannot create MapBranchEntry without address"); + super(node, opts); + } + async encodeNode() { + return [ + this.key, + await this.address + ]; + } + }; + var getValue = async (node, key) => { + const { + result: entry, + cids + } = await node.getEntry(key); + return { + result: entry.value, + cids + }; + }; + var getManyValues = async (node, keys2) => { + const { + result: entries6, + cids + } = await node.getEntries(keys2); + return { + result: entries6.map((entry) => entry.value), + cids + }; + }; + var MapLeaf = class extends IPLDLeaf { + get(key) { + return getValue(this, key); + } + getMany(keys2) { + return getManyValues(this, keys2); + } + bulk(bulk, opts = {}, isRoot = true) { + return super.bulk(bulk, { + ...classes, + ...opts + }, isRoot); + } + }; + var MapBranch = class extends IPLDBranch { + get(key) { + return getValue(this, key); + } + getMany(keys2) { + return getManyValues(this, keys2); + } + bulk(bulk, opts = {}, isRoot = true) { + return super.bulk(bulk, { + ...classes, + ...opts + }, isRoot); + } + }; + var classes = { + LeafClass: MapLeaf, + LeafEntryClass: MapLeafEntry, + BranchClass: MapBranch, + BranchEntryClass: MapBranchEntry + }; + var createGetNode2 = (get17, cache3, chunker2, codec, hasher, compare7, opts) => { + const LeafClass2 = opts.LeafClass || MapLeaf; + const LeafEntryClass = opts.LeafEntryClass || MapLeafEntry; + const BranchClass2 = opts.BranchClass || MapBranch; + const BranchEntryClass = opts.BranchEntryClass || MapBranchEntry; + const getNode = async (cid) => { + if (cache3.has(cid)) + return cache3.get(cid); + return get17(cid).then((block) => decoder4(block)); + }; + const decoder4 = makeDecoder({ + chunker: chunker2, + cache: cache3, + getNode, + codec, + hasher, + compare: compare7, + LeafEntryClass, + LeafClass: LeafClass2, + BranchEntryClass, + BranchClass: BranchClass2 + }); + return getNode; + }; + var create19 = ({ get: get17, cache: cache3, chunker: chunker2, list: list10, codec, hasher, sorted, compare: compare7, ...opts }) => { + if (!sorted) + list10 = list10.sort(({ key: a8 }, { key: b6 }) => compare7(a8, b6)); + const getNode = createGetNode2(get17, cache3, chunker2, codec, hasher, compare7, opts); + const _opts = { + list: list10, + codec, + hasher, + chunker: chunker2, + getNode, + sorted, + compare: compare7, + cache: cache3, + LeafClass: opts.LeafClass || MapLeaf, + LeafEntryClass: opts.LeafEntryClass || MapLeafEntry, + BranchClass: opts.BranchClass || MapBranch, + BranchEntryClass: opts.BranchEntryClass || MapBranchEntry + }; + return create17(_opts); + }; + var load2 = ({ cid, get: get17, cache: cache3, chunker: chunker2, codec, hasher, compare: compare7, ...opts }) => { + const getNode = createGetNode2(get17, cache3, chunker2, codec, hasher, compare7, opts); + return getNode(cid); + }; + function makeDecoder({ chunker: chunker2, cache: cache3, getNode, codec, hasher, compare: compare7, LeafEntryClass, LeafClass: LeafClass2, BranchEntryClass, BranchClass: BranchClass2 }) { + const entryOpts = { + codec, + hasher + }; + return (block) => { + const { value } = block; + const opts = { + chunker: chunker2, + cache: cache3, + block, + getNode, + codec, + hasher, + compare: compare7 + }; + let entries6; + let CLS; + if (value.leaf) { + entries6 = value.leaf.map(([key, value2]) => new LeafEntryClass({ + key, + value: value2 + }, entryOpts)); + CLS = LeafClass2; + } else if (value.branch) { + const [distance, _entries] = value.branch; + opts.distance = distance; + entries6 = _entries.map(([key, address]) => new BranchEntryClass({ + key, + address + }, entryOpts)); + CLS = BranchClass2; + } else { + throw new Error("Unknown block data, does not match schema"); + } + const entryList = new EntryList({ + entries: entries6, + closed: value.closed + }); + const node = new CLS({ + entryList, + ...opts + }); + cache3.set(node); + return node; + }; + } + + // ../../node_modules/.pnpm/prolly-trees@1.0.4/node_modules/prolly-trees/esm/src/db-index.js + var compare5 = (a8, b6) => { + const [aKey, aRef] = a8; + const [bKey, bRef] = b6; + const comp = simpleCompare(aKey, bKey); + if (comp !== 0) + return comp; + return refCompare(aRef, bRef); + }; + var refCompare = (aRef, bRef) => { + if (Number.isNaN(aRef)) + return -1; + if (Number.isNaN(bRef)) + throw new Error("ref may not be Infinity or NaN"); + if (!Number.isFinite(aRef)) + return 1; + return simpleCompare(aRef, bRef); + }; + var getIndex = async (node, key) => { + const start = [ + key, + NaN + ]; + const end = [ + key, + Infinity + ]; + const { + result: entries6, + cids + } = await node.getRangeEntries(start, end); + return { + result: entries6.map((entry) => { + const [key2, id] = entry.key; + return { + id, + key: key2, + row: entry.value + }; + }), + cids + }; + }; + var getRange = async (node, start, end) => { + start = [ + start, + NaN + ]; + end = [ + end, + Infinity + ]; + const { + result: entries6, + cids + } = await node.getRangeEntries(start, end); + const result = entries6.map((entry) => { + const [key, id] = entry.key; + return { + id, + key, + row: entry.value + }; + }); + return { + result, + cids + }; + }; + var DBIndexLeaf = class extends MapLeaf { + get(key) { + return getIndex(this, key); + } + range(start, end) { + return getRange(this, start, end); + } + bulk(bulk, opts = {}, isRoot = true) { + return super.bulk(bulk, { + ...classes2, + ...opts + }, isRoot); + } + }; + var DBIndexBranch = class extends MapBranch { + get(key) { + return getIndex(this, key); + } + range(start, end) { + return getRange(this, start, end); + } + bulk(bulk, opts = {}, isRoot = true) { + return super.bulk(bulk, { + ...classes2, + ...opts + }, isRoot); + } + }; + var LeafClass = DBIndexLeaf; + var BranchClass = DBIndexBranch; + var classes2 = { + LeafClass, + BranchClass, + LeafEntryClass: MapLeafEntry, + BranchEntryClass: MapBranchEntry + }; + var defaults5 = { + ...classes2, + compare: compare5 + }; + var create20 = (opts) => { + opts = { + ...defaults5, + ...opts + }; + return create19(opts); + }; + var load3 = (opts) => { + opts = { + ...defaults5, + ...opts + }; + return load2(opts); + }; + + // src/indexer-helpers.ts + var IndexTree = class { + constructor() { + __publicField(this, "cid", null); + __publicField(this, "root", null); + } + }; + var refCompare2 = (aRef, bRef) => { + if (Number.isNaN(aRef)) + return -1; + if (Number.isNaN(bRef)) + throw new Error("ref may not be Infinity or NaN"); + if (aRef === Infinity) + return 1; + return simpleCompare(aRef, bRef); + }; + var compare6 = (a8, b6) => { + const [aKey, aRef] = a8; + const [bKey, bRef] = b6; + const comp = simpleCompare(aKey, bKey); + if (comp !== 0) + return comp; + return refCompare2(aRef, bRef); + }; + var byKeyOpts = { cache: nocache, chunker: bf(30), codec: src_exports, hasher: sha2562, compare: compare6 }; + var byIdOpts = { cache: nocache, chunker: bf(30), codec: src_exports, hasher: sha2562, compare: simpleCompare }; + function indexEntriesForChanges(changes, mapFn) { + const indexEntries = []; + changes.forEach(({ key: _id, value, del: del2 }) => { + if (del2 || !value) + return; + let mapCalled = false; + const mapReturn = mapFn({ _id, ...value }, (k5, v7) => { + mapCalled = true; + if (typeof k5 === "undefined") + return; + indexEntries.push({ + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + key: [import_charwise.default.encode(k5), _id], + value: v7 || null + }); + }); + if (!mapCalled && mapReturn) { + indexEntries.push({ + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + key: [import_charwise.default.encode(mapReturn), _id], + value: null + }); + } + }); + return indexEntries; + } + function makeProllyGetBlock(blocks) { + return async (address) => { + const block = await blocks.get(address); + if (!block) + throw new Error(`Missing block ${address.toString()}`); + const { cid, bytes: bytes2 } = block; + return create16({ cid, bytes: bytes2, hasher: sha2562, codec: src_exports }); + }; + } + async function bulkIndex(tblocks, inIndex, indexEntries, opts) { + if (!indexEntries.length) + return inIndex; + if (!inIndex.root) { + if (!inIndex.cid) { + let returnRootBlock = null; + let returnNode = null; + for await (const node of await create20({ get: makeProllyGetBlock(tblocks), list: indexEntries, ...opts })) { + const block = await node.block; + await tblocks.put(block.cid, block.bytes); + returnRootBlock = block; + returnNode = node; + } + if (!returnNode || !returnRootBlock) + throw new Error("failed to create index"); + return { root: returnNode, cid: returnRootBlock.cid }; + } else { + inIndex.root = await load3({ cid: inIndex.cid, get: makeProllyGetBlock(tblocks), ...opts }); + } + } + const { root: root3, blocks: newBlocks } = await inIndex.root.bulk(indexEntries); + if (root3) { + for await (const block of newBlocks) { + await tblocks.put(block.cid, block.bytes); + } + return { root: root3, cid: (await root3.block).cid }; + } else { + return { root: null, cid: null }; + } + } + async function loadIndex(tblocks, cid, opts) { + return await load3({ cid, get: makeProllyGetBlock(tblocks), ...opts }); + } + async function applyQuery(crdt, resp, query) { + if (query.descending) { + resp.result = resp.result.reverse(); + } + if (query.limit) { + resp.result = resp.result.slice(0, query.limit); + } + if (query.includeDocs) { + resp.result = await Promise.all( + resp.result.map(async (row) => { + const val = await crdt.get(row.id); + const doc = val ? { _id: row.id, ...val.doc } : null; + return { ...row, doc }; + }) + ); + } + return { + rows: resp.result.map((row) => { + row.key = import_charwise.default.decode(row.key); + return row; + }) + }; + } + function encodeRange(range) { + return range.map((key) => import_charwise.default.encode(key)); + } + function encodeKey(key) { + return import_charwise.default.encode(key); + } + + // src/index.ts + function index({ _crdt }, name15, mapFn, meta) { + if (mapFn && meta) + throw new Error("cannot provide both mapFn and meta"); + if (mapFn && mapFn.constructor.name !== "Function") + throw new Error("mapFn must be a function"); + if (_crdt.indexers.has(name15)) { + const idx = _crdt.indexers.get(name15); + idx.applyMapFn(name15, mapFn, meta); + } else { + const idx = new Index(_crdt, name15, mapFn, meta); + _crdt.indexers.set(name15, idx); + } + return _crdt.indexers.get(name15); + } + var Index = class { + constructor(crdt, name15, mapFn, meta) { + __publicField(this, "blocks"); + __publicField(this, "crdt"); + __publicField(this, "name", null); + __publicField(this, "mapFn", null); + __publicField(this, "mapFnString", ""); + __publicField(this, "byKey", new IndexTree()); + __publicField(this, "byId", new IndexTree()); + __publicField(this, "indexHead"); + __publicField(this, "includeDocsDefault", false); + __publicField(this, "initError", null); + __publicField(this, "ready"); + this.blocks = crdt.indexBlocks; + this.crdt = crdt; + this.applyMapFn(name15, mapFn, meta); + if (!(this.mapFnString || this.initError)) + throw new Error("missing mapFnString"); + this.ready = this.blocks.ready.then(() => { + }); + } + applyMapFn(name15, mapFn, meta) { + if (mapFn && meta) + throw new Error("cannot provide both mapFn and meta"); + if (this.name && this.name !== name15) + throw new Error("cannot change name"); + this.name = name15; + try { + if (meta) { + if (this.indexHead && this.indexHead.map((c8) => c8.toString()).join() !== meta.head.map((c8) => c8.toString()).join()) { + throw new Error("cannot apply meta to existing index"); + } + this.byId.cid = meta.byId; + this.byKey.cid = meta.byKey; + this.indexHead = meta.head; + if (this.mapFnString) { + if (this.mapFnString !== meta.map) + throw new Error("cannot apply different mapFn meta"); + } else { + this.mapFnString = meta.map; + } + } else { + if (this.mapFn) { + if (mapFn) { + if (this.mapFn.toString() !== mapFn.toString()) + throw new Error("cannot apply different mapFn app2"); + } + } else { + if (!mapFn) { + mapFn = makeMapFnFromName(name15); + } + if (this.mapFnString) { + if (this.mapFnString !== mapFn.toString()) + throw new Error("cannot apply different mapFn app"); + } else { + this.mapFnString = mapFn.toString(); + } + this.mapFn = mapFn; + } + } + const matches = /=>\s*(.*)/.test(this.mapFnString); + this.includeDocsDefault = matches; + } catch (e12) { + this.initError = e12; + } + } + async query(opts = {}) { + await this._updateIndex(); + await this._hydrateIndex(); + if (!this.byKey.root) + return await applyQuery(this.crdt, { result: [] }, opts); + if (this.includeDocsDefault && opts.includeDocs === void 0) + opts.includeDocs = true; + if (opts.range) { + const { result: result2, ...all8 } = await this.byKey.root.range(...encodeRange(opts.range)); + return await applyQuery(this.crdt, { result: result2, ...all8 }, opts); + } + if (opts.key) { + const encodedKey = encodeKey(opts.key); + return await applyQuery(this.crdt, await this.byKey.root.get(encodedKey), opts); + } + if (opts.prefix) { + if (!Array.isArray(opts.prefix)) + opts.prefix = [opts.prefix]; + const start = [...opts.prefix, NaN]; + const end = [...opts.prefix, Infinity]; + const encodedR = encodeRange([start, end]); + return await applyQuery(this.crdt, await this.byKey.root.range(...encodedR), opts); + } + const { result, ...all7 } = await this.byKey.root.getAllEntries(); + return await applyQuery(this.crdt, { + result: result.map(({ key: [k5, id], value }) => ({ key: k5, id, value })), + ...all7 + }, opts); + } + _resetIndex() { + this.byId = new IndexTree(); + this.byKey = new IndexTree(); + this.indexHead = void 0; + } + async _hydrateIndex() { + if (this.byId.root && this.byKey.root) + return; + if (!this.byId.cid || !this.byKey.cid) + return; + this.byId.root = await loadIndex(this.blocks, this.byId.cid, byIdOpts); + this.byKey.root = await loadIndex(this.blocks, this.byKey.cid, byKeyOpts); + } + async _updateIndex() { + await this.ready; + if (this.initError) + throw this.initError; + if (!this.mapFn) + throw new Error("No map function defined"); + const { result, head: head2 } = await this.crdt.changes(this.indexHead); + if (result.length === 0) { + this.indexHead = head2; + return { byId: this.byId, byKey: this.byKey }; + } + let staleKeyIndexEntries = []; + let removeIdIndexEntries = []; + if (this.byId.root) { + const removeIds = result.map(({ key }) => key); + const { result: oldChangeEntries } = await this.byId.root.getMany(removeIds); + staleKeyIndexEntries = oldChangeEntries.map((key) => ({ key, del: true })); + removeIdIndexEntries = oldChangeEntries.map((key) => ({ key: key[1], del: true })); + } + const indexEntries = indexEntriesForChanges(result, this.mapFn); + const byIdIndexEntries = indexEntries.map(({ key }) => ({ key: key[1], value: key })); + const indexerMeta = /* @__PURE__ */ new Map(); + for (const [name15, indexer] of this.crdt.indexers) { + if (indexer.indexHead) { + indexerMeta.set(name15, { + byId: indexer.byId.cid, + byKey: indexer.byKey.cid, + head: indexer.indexHead, + map: indexer.mapFnString, + name: indexer.name + }); + } + } + return await this.blocks.transaction(async (tblocks) => { + this.byId = await bulkIndex( + tblocks, + this.byId, + removeIdIndexEntries.concat(byIdIndexEntries), + byIdOpts + ); + this.byKey = await bulkIndex(tblocks, this.byKey, staleKeyIndexEntries.concat(indexEntries), byKeyOpts); + this.indexHead = head2; + return { byId: this.byId.cid, byKey: this.byKey.cid, head: head2, map: this.mapFnString, name: this.name }; + }, indexerMeta); + } + }; + function makeMapFnFromName(name15) { + return (doc) => { + if (doc[name15]) + return doc[name15]; + }; + } + + // src/loaders.ts + var _IdxLoader = class _IdxLoader extends Loader { + constructor(name15, crdt, opts) { + super(name15, opts); + // declare ready: Promise + __publicField(this, "crdt"); + __publicField(this, "defaultHeader", _IdxLoader.defaultHeader); + this.crdt = crdt; + } + // eslint-disable-next-line @typescript-eslint/require-await + async _applyCarHeader(header) { + for (const [name15, idx] of Object.entries(header.indexes)) { + index({ _crdt: this.crdt }, name15, void 0, idx); + } + } + makeCarHeader({ indexes }, cars, compact = false) { + return compact ? { indexes, cars: [], compact: cars } : { indexes, cars, compact: [] }; + } + }; + __publicField(_IdxLoader, "defaultHeader", { cars: [], compact: [], indexes: /* @__PURE__ */ new Map() }); + var IdxLoader = _IdxLoader; + var _DbLoader = class _DbLoader extends Loader { + constructor(name15, clock2, opts) { + super(name15, opts); + __publicField(this, "defaultHeader", _DbLoader.defaultHeader); + __publicField(this, "clock"); + __publicField(this, "remoteFileStore"); + __publicField(this, "fileStore"); + this.clock = clock2; + } + async initializeStores() { + await super.initializeStores(); + const isBrowser = typeof window !== "undefined"; + const module3 = isBrowser ? await (init_store_browser(), __toCommonJS(store_browser_exports)) : await (init_store_fs(), __toCommonJS(store_fs_exports)); + if (module3) { + this.fileStore = new module3.DataStore(this); + } else { + throw new Error("Failed to initialize stores."); + } + } + connectRemote(connection3) { + super.connectRemote(connection3); + this.remoteFileStore = new RemoteDataStore(this, connection3, "file"); + return connection3; + } + async loadFileCar(cid) { + if (!this.fileStore) + throw new Error("missing fileStore"); + return await this.storesLoadCar(cid, this.fileStore, this.remoteFileStore); + } + async _applyCarHeader(carHeader, snap = false) { + if (snap) { + await this.clock.applyHead(null, carHeader.head, this.clock.head); + } else { + await this.clock.applyHead(null, carHeader.head, []); + } + } + makeCarHeader(result, cars, compact = false) { + if (isFileResult(result)) { + const files = /* @__PURE__ */ new Map(); + for (const [name15, meta] of Object.entries(result.files)) { + files.set(name15, { + cid: meta.cid, + size: meta.size, + type: meta.type + }); + } + return { files }; + } else { + const { head: head2 } = result; + return compact ? { head: head2, cars: [], compact: cars } : { head: head2, cars, compact: [] }; + } + } + }; + // declare ready: Promise // todo this will be a map of headers by branch name + __publicField(_DbLoader, "defaultHeader", { cars: [], compact: [], head: [] }); + var DbLoader = _DbLoader; + function isFileResult(result) { + return result && result.files !== void 0; + } + + // src/transaction.ts + var Transaction = class extends MemoryBlockstore { + constructor(parent) { + super(); + __publicField(this, "parent"); + this.parent = parent; + } + async get(cid) { + return this.parent.get(cid); + } + async superGet(cid) { + return super.get(cid); + } + }; + var FireproofBlockstore = class { + constructor(name15, loader, opts) { + __publicField(this, "ready"); + __publicField(this, "name", null); + __publicField(this, "loader", null); + __publicField(this, "opts", {}); + __publicField(this, "transactions", /* @__PURE__ */ new Set()); + this.opts = opts || this.opts; + if (name15) { + this.name = name15; + if (!loader) + throw new Error("missing loader"); + this.loader = loader; + this.ready = this.loader.ready; + } else { + this.ready = Promise.resolve(); + } + } + // eslint-disable-next-line @typescript-eslint/require-await + async put() { + throw new Error("use a transaction to put"); + } + async get(cid) { + if (!cid) + throw new Error("required cid"); + for (const f9 of this.transactions) { + const v7 = await f9.superGet(cid); + if (v7) + return v7; + } + if (!this.loader) + return; + return await this.loader.getBlock(cid); + } + async commitCompaction(t9, head2) { + this.transactions.clear(); + this.transactions.add(t9); + return await this.loader?.commit(t9, { head: head2 }, true); + } + async *entries() { + const seen = /* @__PURE__ */ new Set(); + for (const t9 of this.transactions) { + for await (const blk of t9.entries()) { + if (seen.has(blk.cid.toString())) + continue; + seen.add(blk.cid.toString()); + yield blk; + } + } + } + async executeTransaction(fn, commitHandler) { + const t9 = new Transaction(this); + this.transactions.add(t9); + const done = await fn(t9); + const { car, done: result } = await commitHandler(t9, done); + return car ? { ...result, car } : result; + } + }; + var IndexBlockstore = class extends FireproofBlockstore { + // declare ready: Promise + constructor(name15, crdt, opts) { + if (name15) { + super(name15, new IdxLoader(name15, crdt, opts), opts); + } else { + super(null); + } + } + async transaction(fn, indexes) { + return this.executeTransaction(fn, async (t9, done) => { + indexes.set(done.name, done); + const car = await this.loader?.commit(t9, { indexes }); + return { car, done }; + }); + } + }; + var TransactionBlockstore = class extends FireproofBlockstore { + // declare ready: Promise + constructor(name15, clock2, opts) { + if (name15) { + super(name15, new DbLoader(name15, clock2, opts), opts); + } else { + super(null); + } + } + async transaction(fn) { + return this.executeTransaction(fn, async (t9, done) => { + const car = await this.loader?.commit(t9, done); + return { car, done }; + }); + } + }; + + // src/crdt-helpers.ts + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@alanshaw+pail@0.3.3/node_modules/@alanshaw/pail/src/crdt.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@alanshaw+pail@0.3.3/node_modules/@alanshaw/pail/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/@alanshaw+pail@0.3.3/node_modules/@alanshaw/pail/src/shard.js + init_dirname(); + init_buffer2(); + init_process(); + var ShardBlock = class extends Block { + /** + * @param {object} config + * @param {ShardLink} config.cid + * @param {Shard} config.value + * @param {Uint8Array} config.bytes + * @param {string} config.prefix + */ + constructor({ cid, value, bytes: bytes2, prefix }) { + super({ cid, value, bytes: bytes2 }); + this.prefix = prefix; + } + static create() { + return encodeShardBlock([]); + } + }; + async function encodeShardBlock(value, prefix) { + const { cid, bytes: bytes2 } = await encode30({ value, codec: src_exports, hasher: sha256 }); + return new ShardBlock({ cid, value, bytes: bytes2, prefix: prefix ?? "" }); + } + async function decodeShardBlock(bytes2, prefix) { + const { cid, value } = await decode37({ bytes: bytes2, codec: src_exports, hasher: sha256 }); + if (!Array.isArray(value)) + throw new Error(`invalid shard: ${cid}`); + return new ShardBlock({ cid, value, bytes: bytes2, prefix: prefix ?? "" }); + } + var ShardFetcher = class { + /** @param {import('./block').BlockFetcher} blocks */ + constructor(blocks) { + this._blocks = blocks; + } + /** + * @param {ShardLink} link + * @param {string} [prefix] + * @returns {Promise} + */ + async get(link10, prefix = "") { + const block = await this._blocks.get(link10); + if (!block) + throw new Error(`missing block: ${link10}`); + return decodeShardBlock(block.bytes, prefix); + } + }; + function putEntry(target, entry) { + if (!target.length) + return [entry]; + const shard = []; + for (const [i8, [k5, v7]] of target.entries()) { + if (entry[0] === k5) { + if (Array.isArray(entry[1])) { + if (Array.isArray(v7) && v7[1] != null && entry[1][1] == null) { + shard.push([k5, [entry[1][0], v7[1]]]); + } else { + shard.push(entry); + } + } else { + const newEntry = Array.isArray(v7) ? [k5, [v7[0], entry[1]]] : entry; + shard.push(newEntry); + } + for (let j5 = i8 + 1; j5 < target.length; j5++) { + shard.push(target[j5]); + } + return shard; + } + if (i8 === 0 && entry[0] < k5) { + shard.push(entry); + for (let j5 = i8; j5 < target.length; j5++) { + shard.push(target[j5]); + } + return shard; + } + if (i8 > 0 && entry[0] > target[i8 - 1][0] && entry[0] < k5) { + shard.push(entry); + for (let j5 = i8; j5 < target.length; j5++) { + shard.push(target[j5]); + } + return shard; + } + shard.push([k5, v7]); + } + shard.push(entry); + return shard; + } + function findCommonPrefix(shard, skey) { + const startidx = shard.findIndex(([k5]) => skey === k5); + if (startidx === -1) + throw new Error(`key not found in shard: ${skey}`); + let i8 = startidx; + let pfx; + while (true) { + pfx = shard[i8][0].slice(0, -1); + if (pfx.length) { + while (true) { + const matches = shard.filter((entry) => entry[0].startsWith(pfx)); + if (matches.length > 1) + return { prefix: pfx, matches }; + pfx = pfx.slice(0, -1); + if (!pfx.length) + break; + } + } + i8++; + if (i8 >= shard.length) { + i8 = 0; + } + if (i8 === startidx) { + return; + } + } + } + + // ../../node_modules/.pnpm/@alanshaw+pail@0.3.3/node_modules/@alanshaw/pail/src/index.js + var MaxKeyLength = 64; + var MaxShardSize = 512 * 1024; + async function put(blocks, root3, key, value, options = {}) { + const shards = new ShardFetcher(blocks); + const rshard = await shards.get(root3); + const path2 = await traverse(shards, rshard, key); + const target = path2[path2.length - 1]; + const skey = key.slice(target.prefix.length); + let entry = [skey, value]; + const additions = []; + if (skey.length > MaxKeyLength) { + const pfxskeys = Array.from(Array(Math.ceil(skey.length / MaxKeyLength)), (_5, i8) => { + const start = i8 * MaxKeyLength; + return { + prefix: target.prefix + skey.slice(0, start), + skey: skey.slice(start, start + MaxKeyLength) + }; + }); + let child2 = await encodeShardBlock([[pfxskeys[pfxskeys.length - 1].skey, value]], pfxskeys[pfxskeys.length - 1].prefix); + additions.push(child2); + for (let i8 = pfxskeys.length - 2; i8 > 0; i8--) { + child2 = await encodeShardBlock([[pfxskeys[i8].skey, [child2.cid]]], pfxskeys[i8].prefix); + additions.push(child2); + } + entry = [pfxskeys[0].skey, [child2.cid]]; + } + let shard = putEntry(target.value, entry); + let child = await encodeShardBlock(shard, target.prefix); + if (child.bytes.length > (options.maxShardSize ?? MaxShardSize)) { + const common = findCommonPrefix(shard, entry[0]); + if (!common) + throw new Error("shard limit reached"); + const { prefix, matches } = common; + const block = await encodeShardBlock( + matches.filter(([k5]) => k5 !== prefix).map(([k5, v7]) => [k5.slice(prefix.length), v7]), + target.prefix + prefix + ); + additions.push(block); + let value2; + const pfxmatch = matches.find(([k5]) => k5 === prefix); + if (pfxmatch) { + if (Array.isArray(pfxmatch[1])) { + throw new Error(`expected "${prefix}" to be a shard value but found a shard link`); + } + value2 = [block.cid, pfxmatch[1]]; + } else { + value2 = [block.cid]; + } + shard = shard.filter((e12) => matches.every((m7) => e12[0] !== m7[0])); + shard = putEntry(shard, [prefix, value2]); + child = await encodeShardBlock(shard, target.prefix); + } + additions.push(child); + for (let i8 = path2.length - 2; i8 >= 0; i8--) { + const parent = path2[i8]; + const key2 = child.prefix.slice(parent.prefix.length); + const value2 = parent.value.map((entry2) => { + const [k5, v7] = entry2; + if (k5 !== key2) + return entry2; + if (!Array.isArray(v7)) + throw new Error(`"${key2}" is not a shard link in: ${parent.cid}`); + return ( + /** @type {import('./shard').ShardEntry} */ + v7[1] == null ? [k5, [child.cid]] : [k5, [child.cid, v7[1]]] + ); + }); + child = await encodeShardBlock(value2, parent.prefix); + additions.push(child); + } + return { root: additions[additions.length - 1].cid, additions, removals: path2 }; + } + async function get15(blocks, root3, key) { + const shards = new ShardFetcher(blocks); + const rshard = await shards.get(root3); + const path2 = await traverse(shards, rshard, key); + const target = path2[path2.length - 1]; + const skey = key.slice(target.prefix.length); + const entry = target.value.find(([k5]) => k5 === skey); + if (!entry) + return; + return Array.isArray(entry[1]) ? entry[1][1] : entry[1]; + } + async function del(blocks, root3, key) { + const shards = new ShardFetcher(blocks); + const rshard = await shards.get(root3); + const path2 = await traverse(shards, rshard, key); + const target = path2[path2.length - 1]; + const skey = key.slice(target.prefix.length); + const entryidx = target.value.findIndex(([k5]) => k5 === skey); + if (entryidx === -1) + return { root: root3, additions: [], removals: [] }; + const entry = target.value[entryidx]; + if (Array.isArray(entry[1]) && entry[1][1] == null) + return { root: root3, additions: [], removals: [] }; + const additions = []; + const removals = [...path2]; + let shard = [...target.value]; + if (Array.isArray(entry[1])) { + shard[entryidx] = [entry[0], [entry[1][0]]]; + } else { + shard.splice(entryidx, 1); + while (!shard.length) { + const child2 = path2[path2.length - 1]; + const parent = path2[path2.length - 2]; + if (!parent) + break; + path2.pop(); + shard = parent.value.filter((e12) => { + if (!Array.isArray(e12[1])) + return true; + return e12[1][0].toString() !== child2.cid.toString(); + }); + } + } + let child = await encodeShardBlock(shard, path2[path2.length - 1].prefix); + additions.push(child); + for (let i8 = path2.length - 2; i8 >= 0; i8--) { + const parent = path2[i8]; + const key2 = child.prefix.slice(parent.prefix.length); + const value = parent.value.map((entry2) => { + const [k5, v7] = entry2; + if (k5 !== key2) + return entry2; + if (!Array.isArray(v7)) + throw new Error(`"${key2}" is not a shard link in: ${parent.cid}`); + return ( + /** @type {import('./shard').ShardEntry} */ + v7[1] == null ? [k5, [child.cid]] : [k5, [child.cid, v7[1]]] + ); + }); + child = await encodeShardBlock(value, parent.prefix); + additions.push(child); + } + return { root: additions[additions.length - 1].cid, additions, removals }; + } + async function* entries4(blocks, root3, options = {}) { + const { prefix } = options; + const shards = new ShardFetcher(blocks); + const rshard = await shards.get(root3); + yield* ( + /** @returns {AsyncIterableIterator} */ + async function* ents(shard) { + for (const entry of shard.value) { + const key = shard.prefix + entry[0]; + if (Array.isArray(entry[1])) { + if (entry[1][1]) { + if (!prefix || prefix && key.startsWith(prefix)) { + yield [key, entry[1][1]]; + } + } + if (prefix) { + if (prefix.length <= key.length && !key.startsWith(prefix)) { + continue; + } + if (prefix.length > key.length && !prefix.startsWith(key)) { + continue; + } + } + yield* ents(await shards.get(entry[1][0], key)); + } else { + if (prefix && !key.startsWith(prefix)) { + continue; + } + yield [key, entry[1]]; + } + } + }(rshard) + ); + } + async function traverse(shards, shard, key) { + for (const [k5, v7] of shard.value) { + if (key === k5) + return [shard]; + if (key.startsWith(k5) && Array.isArray(v7)) { + const path2 = await traverse(shards, await shards.get(v7[0], shard.prefix + k5), key.slice(k5.length)); + return [shard, ...path2]; + } + } + return [shard]; + } + + // ../../node_modules/.pnpm/@alanshaw+pail@0.3.3/node_modules/@alanshaw/pail/src/crdt.js + async function put2(blocks, head2, key, value, options) { + const mblocks = new MemoryBlockstore(); + blocks = new MultiBlockFetcher(mblocks, blocks); + if (!head2.length) { + const shard = await ShardBlock.create(); + mblocks.putSync(shard.cid, shard.bytes); + const result2 = await put(blocks, shard.cid, key, value, options); + const data2 = { type: "put", root: result2.root, key, value }; + const event2 = await EventBlock.create(data2, head2); + head2 = await advance3(blocks, head2, event2.cid); + return { + root: result2.root, + additions: [shard, ...result2.additions], + removals: result2.removals, + head: head2, + event: event2 + }; + } + const events = new EventFetcher(blocks); + const ancestor = await findCommonAncestor(events, head2); + if (!ancestor) + throw new Error("failed to find common ancestor event"); + const aevent = await events.get(ancestor); + let { root: root3 } = aevent.value.data; + const sorted = await findSortedEvents(events, head2, ancestor); + const additions = /* @__PURE__ */ new Map(); + const removals = /* @__PURE__ */ new Map(); + for (const { value: event2 } of sorted) { + if (!["put", "del"].includes(event2.data.type)) { + throw new Error(`unknown event type: ${event2.data.type}`); + } + const result2 = event2.data.type === "put" ? await put(blocks, root3, event2.data.key, event2.data.value) : await del(blocks, root3, event2.data.key); + root3 = result2.root; + for (const a8 of result2.additions) { + mblocks.putSync(a8.cid, a8.bytes); + additions.set(a8.cid.toString(), a8); + } + for (const r10 of result2.removals) { + removals.set(r10.cid.toString(), r10); + } + } + const result = await put(blocks, root3, key, value, options); + for (const a8 of result.additions) { + mblocks.putSync(a8.cid, a8.bytes); + additions.set(a8.cid.toString(), a8); + } + for (const r10 of result.removals) { + removals.set(r10.cid.toString(), r10); + } + const data = { type: "put", root: result.root, key, value }; + const event = await EventBlock.create(data, head2); + mblocks.putSync(event.cid, event.bytes); + head2 = await advance3(blocks, head2, event.cid); + const rootCidString = result.root.toString(); + for (const k5 of removals.keys()) { + if (additions.has(k5) && k5 !== rootCidString) { + additions.delete(k5); + removals.delete(k5); + } + } + return { + root: result.root, + additions: [...additions.values()], + removals: [...removals.values()], + head: head2, + event + }; + } + async function root(blocks, head2) { + if (!head2.length) + throw new Error("cannot determine root of headless clock"); + const mblocks = new MemoryBlockstore(); + blocks = new MultiBlockFetcher(mblocks, blocks); + const events = new EventFetcher(blocks); + if (head2.length === 1) { + const event = await events.get(head2[0]); + const { root: root4 } = event.value.data; + return { root: root4, additions: [], removals: [] }; + } + const ancestor = await findCommonAncestor(events, head2); + if (!ancestor) + throw new Error("failed to find common ancestor event"); + const aevent = await events.get(ancestor); + let { root: root3 } = aevent.value.data; + const sorted = await findSortedEvents(events, head2, ancestor); + const additions = /* @__PURE__ */ new Map(); + const removals = /* @__PURE__ */ new Map(); + for (const { value: event } of sorted) { + if (!["put", "del"].includes(event.data.type)) { + throw new Error(`unknown event type: ${event.data.type}`); + } + const result = event.data.type === "put" ? await put(blocks, root3, event.data.key, event.data.value) : await del(blocks, root3, event.data.key); + root3 = result.root; + for (const a8 of result.additions) { + mblocks.putSync(a8.cid, a8.bytes); + additions.set(a8.cid.toString(), a8); + } + for (const r10 of result.removals) { + removals.set(r10.cid.toString(), r10); + } + } + for (const k5 of removals.keys()) { + if (additions.has(k5)) { + additions.delete(k5); + removals.delete(k5); + } + } + return { + root: root3, + additions: [...additions.values()], + removals: [...removals.values()] + }; + } + async function get16(blocks, head2, key) { + if (!head2.length) + return; + const result = await root(blocks, head2); + if (result.additions.length) { + blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks); + } + return get15(blocks, result.root, key); + } + async function* entries5(blocks, head2, options) { + if (!head2.length) + return; + const result = await root(blocks, head2); + if (result.additions.length) { + blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks); + } + yield* entries4(blocks, result.root, options); + } + async function findCommonAncestor(events, children) { + if (!children.length) + return; + const candidates = children.map((c8) => [c8]); + while (true) { + let changed = false; + for (const c8 of candidates) { + const candidate = await findAncestorCandidate(events, c8[c8.length - 1]); + if (!candidate) + continue; + changed = true; + c8.push(candidate); + const ancestor = findCommonString(candidates); + if (ancestor) + return ancestor; + } + if (!changed) + return; + } + } + async function findAncestorCandidate(events, root3) { + const { value: event } = await events.get(root3); + if (!event.parents.length) + return root3; + return event.parents.length === 1 ? event.parents[0] : findCommonAncestor(events, event.parents); + } + function findCommonString(arrays) { + arrays = arrays.map((a8) => [...a8]); + for (const arr of arrays) { + for (const item of arr) { + let matched = true; + for (const other of arrays) { + if (arr === other) + continue; + matched = other.some((i8) => String(i8) === String(item)); + if (!matched) + break; + } + if (matched) + return item; + } + } + } + async function findSortedEvents(events, head2, tail) { + const weights = /* @__PURE__ */ new Map(); + const all7 = await Promise.all(head2.map((h9) => findEvents(events, h9, tail))); + for (const arr of all7) { + for (const { event, depth } of arr) { + const info3 = weights.get(event.cid.toString()); + if (info3) { + info3.weight += depth; + } else { + weights.set(event.cid.toString(), { event, weight: depth }); + } + } + } + const buckets = /* @__PURE__ */ new Map(); + for (const { event, weight } of weights.values()) { + const bucket = buckets.get(weight); + if (bucket) { + bucket.push(event); + } else { + buckets.set(weight, [event]); + } + } + return Array.from(buckets).sort((a8, b6) => b6[0] - a8[0]).flatMap(([, es]) => es.sort((a8, b6) => String(a8.cid) < String(b6.cid) ? -1 : 1)); + } + async function findEvents(events, start, end, depth = 0) { + const event = await events.get(start); + const acc = [{ event, depth }]; + const { parents } = event.value; + if (parents.length === 1 && String(parents[0]) === String(end)) + return acc; + const rest = await Promise.all(parents.map((p8) => findEvents(events, p8, end, depth + 1))); + return acc.concat(...rest); + } + + // src/files.ts + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + var import_err_code9 = __toESM(require_err_code(), 1); + + // ../../node_modules/.pnpm/it-last@3.0.3/node_modules/it-last/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + function isAsyncIterable(thing) { + return thing[Symbol.asyncIterator] != null; + } + function last(source) { + if (isAsyncIterable(source)) { + return (async () => { + let res2; + for await (const entry of source) { + res2 = entry; + } + return res2; + })(); + } + let res; + for (const entry of source) { + res = entry; + } + return res; + } + var src_default = last; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/index.js + init_cid(); + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/index.js + init_dirname(); + init_buffer2(); + init_process(); + var import_err_code8 = __toESM(require_err_code(), 1); + + // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/hashes/identity.js + init_dirname(); + init_buffer2(); + init_process(); + init_bytes2(); + init_digest(); + var code14 = 0; + var name14 = "identity"; + var encode40 = coerce; + var digest2 = (input) => create(code14, encode40(input)); + var identity3 = { code: code14, name: name14, encode: encode40, digest: digest2 }; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js + init_dirname(); + init_buffer2(); + init_process(); + var import_err_code = __toESM(require_err_code(), 1); + init_cid(); + var resolve3 = async (cid, name15, path2, toResolve, resolve7, depth, blockstore, options) => { + const block = await blockstore.get(cid, options); + const object = decode6(block); + let subObject = object; + let subPath = path2; + while (toResolve.length > 0) { + const prop = toResolve[0]; + if (prop in subObject) { + toResolve.shift(); + subPath = `${subPath}/${prop}`; + const subObjectCid = CID.asCID(subObject[prop]); + if (subObjectCid != null) { + return { + entry: { + type: "object", + name: name15, + path: path2, + cid, + node: block, + depth, + size: BigInt(block.length), + content: async function* () { + yield object; + } + }, + next: { + cid: subObjectCid, + name: prop, + path: subPath, + toResolve + } + }; + } + subObject = subObject[prop]; + } else { + throw (0, import_err_code.default)(new Error(`No property named ${prop} found in cbor node ${cid}`), "ERR_NO_PROP"); + } + } + return { + entry: { + type: "object", + name: name15, + path: path2, + cid, + node: block, + depth, + size: BigInt(block.length), + content: async function* () { + yield object; + } + } + }; + }; + var dag_cbor_default = resolve3; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/identity.js + init_dirname(); + init_buffer2(); + init_process(); + var import_err_code3 = __toESM(require_err_code(), 1); + init_digest(); + + // ../../node_modules/.pnpm/progress-events@1.0.0/node_modules/progress-events/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + var CustomProgressEvent = class extends Event { + constructor(type3, detail) { + super(type3); + this.detail = detail; + } + }; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js + init_dirname(); + init_buffer2(); + init_process(); + function extractDataFromBlock(block, blockStart, requestedStart, requestedEnd) { + const blockLength2 = BigInt(block.length); + const blockEnd = BigInt(blockStart + blockLength2); + if (requestedStart >= blockEnd || requestedEnd < blockStart) { + return new Uint8Array(0); + } + if (requestedEnd >= blockStart && requestedEnd < blockEnd) { + block = block.subarray(0, Number(requestedEnd - blockStart)); + } + if (requestedStart >= blockStart && requestedStart < blockEnd) { + block = block.subarray(Number(requestedStart - blockStart)); + } + return block; + } + var extract_data_from_block_default = extractDataFromBlock; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js + init_dirname(); + init_buffer2(); + init_process(); + var import_err_code2 = __toESM(require_err_code(), 1); + var validateOffsetAndLength = (size4, offset2 = 0, length3 = size4) => { + const fileSize = BigInt(size4); + const start = BigInt(offset2 ?? 0); + let end = BigInt(length3); + if (end !== fileSize) { + end = start + end; + } + if (end > fileSize) { + end = fileSize; + } + if (start < 0n) { + throw (0, import_err_code2.default)(new Error("Offset must be greater than or equal to 0"), "ERR_INVALID_PARAMS"); + } + if (start > fileSize) { + throw (0, import_err_code2.default)(new Error("Offset must be less than the file size"), "ERR_INVALID_PARAMS"); + } + if (end < 0n) { + throw (0, import_err_code2.default)(new Error("Length must be greater than or equal to 0"), "ERR_INVALID_PARAMS"); + } + if (end > fileSize) { + throw (0, import_err_code2.default)(new Error("Length must be less than the file size"), "ERR_INVALID_PARAMS"); + } + return { + start, + end + }; + }; + var validate_offset_and_length_default = validateOffsetAndLength; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/identity.js + var rawContent = (node) => { + async function* contentGenerator(options = {}) { + const { start, end } = validate_offset_and_length_default(node.length, options.offset, options.length); + const buf3 = extract_data_from_block_default(node, 0n, start, end); + options.onProgress?.(new CustomProgressEvent("unixfs:exporter:progress:identity", { + bytesRead: BigInt(buf3.byteLength), + totalBytes: end - start, + fileSize: BigInt(node.byteLength) + })); + yield buf3; + } + return contentGenerator; + }; + var resolve4 = async (cid, name15, path2, toResolve, resolve7, depth, blockstore, options) => { + if (toResolve.length > 0) { + throw (0, import_err_code3.default)(new Error(`No link named ${path2} found in raw node ${cid}`), "ERR_NOT_FOUND"); + } + const buf3 = decode4(cid.multihash.bytes); + return { + entry: { + type: "identity", + name: name15, + path: path2, + cid, + content: rawContent(buf3.digest), + depth, + size: BigInt(buf3.digest.length), + node: buf3.digest + } + }; + }; + var identity_default = resolve4; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/raw.js + init_dirname(); + init_buffer2(); + init_process(); + var import_err_code4 = __toESM(require_err_code(), 1); + var rawContent2 = (node) => { + async function* contentGenerator(options = {}) { + const { start, end } = validate_offset_and_length_default(node.length, options.offset, options.length); + const buf3 = extract_data_from_block_default(node, 0n, start, end); + options.onProgress?.(new CustomProgressEvent("unixfs:exporter:progress:raw", { + bytesRead: BigInt(buf3.byteLength), + totalBytes: end - start, + fileSize: BigInt(node.byteLength) + })); + yield buf3; + } + return contentGenerator; + }; + var resolve5 = async (cid, name15, path2, toResolve, resolve7, depth, blockstore, options) => { + if (toResolve.length > 0) { + throw (0, import_err_code4.default)(new Error(`No link named ${path2} found in raw node ${cid}`), "ERR_NOT_FOUND"); + } + const block = await blockstore.get(cid, options); + return { + entry: { + type: "raw", + name: name15, + path: path2, + cid, + content: rawContent2(block), + depth, + size: BigInt(block.length), + node: block + } + }; + }; + var raw_default = resolve5; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js + init_dirname(); + init_buffer2(); + init_process(); + var import_err_code7 = __toESM(require_err_code(), 1); + + // ../../node_modules/.pnpm/ipfs-unixfs@11.0.2/node_modules/ipfs-unixfs/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + var import_err_code5 = __toESM(require_err_code(), 1); + + // ../../node_modules/.pnpm/ipfs-unixfs@11.0.2/node_modules/ipfs-unixfs/dist/src/unixfs.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/decode.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/utils.js + init_dirname(); + init_buffer2(); + init_process(); + var import_reader3 = __toESM(require_reader(), 1); + var import_reader_buffer = __toESM(require_reader_buffer(), 1); + var import_minimal2 = __toESM(require_minimal(), 1); + var import_writer2 = __toESM(require_writer(), 1); + var import_writer_buffer = __toESM(require_writer_buffer(), 1); + function configure6() { + import_minimal2.default._configure(); + import_reader3.default._configure(import_reader_buffer.default); + import_writer2.default._configure(import_writer_buffer.default); + } + configure6(); + var methods = [ + "uint64", + "int64", + "sint64", + "fixed64", + "sfixed64" + ]; + function patchReader(obj) { + for (const method of methods) { + if (obj[method] == null) { + continue; + } + const original = obj[method]; + obj[method] = function() { + return BigInt(original.call(this).toString()); + }; + } + return obj; + } + function reader(buf3) { + return patchReader(new import_reader3.default(buf3)); + } + function patchWriter(obj) { + for (const method of methods) { + if (obj[method] == null) { + continue; + } + const original = obj[method]; + obj[method] = function(val) { + return original.call(this, val.toString()); + }; + } + return obj; + } + function writer() { + return patchWriter(import_writer2.default.create()); + } + + // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/decode.js + function decodeMessage(buf3, codec) { + const r10 = reader(buf3 instanceof Uint8Array ? buf3 : buf3.subarray()); + return codec.decode(r10); + } + + // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/encode.js + init_dirname(); + init_buffer2(); + init_process(); + function encodeMessage(message2, codec) { + const w5 = writer(); + codec.encode(message2, w5, { + lengthDelimited: false + }); + return w5.finish(); + } + + // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codecs/enum.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codec.js + init_dirname(); + init_buffer2(); + init_process(); + var CODEC_TYPES; + (function(CODEC_TYPES2) { + CODEC_TYPES2[CODEC_TYPES2["VARINT"] = 0] = "VARINT"; + CODEC_TYPES2[CODEC_TYPES2["BIT64"] = 1] = "BIT64"; + CODEC_TYPES2[CODEC_TYPES2["LENGTH_DELIMITED"] = 2] = "LENGTH_DELIMITED"; + CODEC_TYPES2[CODEC_TYPES2["START_GROUP"] = 3] = "START_GROUP"; + CODEC_TYPES2[CODEC_TYPES2["END_GROUP"] = 4] = "END_GROUP"; + CODEC_TYPES2[CODEC_TYPES2["BIT32"] = 5] = "BIT32"; + })(CODEC_TYPES || (CODEC_TYPES = {})); + function createCodec2(name15, type3, encode41, decode46) { + return { + name: name15, + type: type3, + encode: encode41, + decode: decode46 + }; + } + + // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codecs/enum.js + function enumeration(v7) { + function findValue(val) { + if (v7[val.toString()] == null) { + throw new Error("Invalid enum value"); + } + return v7[val]; + } + const encode41 = function enumEncode(val, writer2) { + const enumValue = findValue(val); + writer2.int32(enumValue); + }; + const decode46 = function enumDecode(reader2) { + const val = reader2.int32(); + return findValue(val); + }; + return createCodec2("enum", CODEC_TYPES.VARINT, encode41, decode46); + } + + // ../../node_modules/.pnpm/protons-runtime@5.0.2/node_modules/protons-runtime/dist/src/codecs/message.js + init_dirname(); + init_buffer2(); + init_process(); + function message(encode41, decode46) { + return createCodec2("message", CODEC_TYPES.LENGTH_DELIMITED, encode41, decode46); + } + + // ../../node_modules/.pnpm/ipfs-unixfs@11.0.2/node_modules/ipfs-unixfs/dist/src/unixfs.js + var Data2; + (function(Data3) { + let DataType; + (function(DataType2) { + DataType2["Raw"] = "Raw"; + DataType2["Directory"] = "Directory"; + DataType2["File"] = "File"; + DataType2["Metadata"] = "Metadata"; + DataType2["Symlink"] = "Symlink"; + DataType2["HAMTShard"] = "HAMTShard"; + })(DataType = Data3.DataType || (Data3.DataType = {})); + let __DataTypeValues; + (function(__DataTypeValues2) { + __DataTypeValues2[__DataTypeValues2["Raw"] = 0] = "Raw"; + __DataTypeValues2[__DataTypeValues2["Directory"] = 1] = "Directory"; + __DataTypeValues2[__DataTypeValues2["File"] = 2] = "File"; + __DataTypeValues2[__DataTypeValues2["Metadata"] = 3] = "Metadata"; + __DataTypeValues2[__DataTypeValues2["Symlink"] = 4] = "Symlink"; + __DataTypeValues2[__DataTypeValues2["HAMTShard"] = 5] = "HAMTShard"; + })(__DataTypeValues || (__DataTypeValues = {})); + (function(DataType2) { + DataType2.codec = () => { + return enumeration(__DataTypeValues); + }; + })(DataType = Data3.DataType || (Data3.DataType = {})); + let _codec; + Data3.codec = () => { + if (_codec == null) { + _codec = message((obj, w5, opts = {}) => { + if (opts.lengthDelimited !== false) { + w5.fork(); + } + if (obj.Type != null) { + w5.uint32(8); + Data3.DataType.codec().encode(obj.Type, w5); + } + if (obj.Data != null) { + w5.uint32(18); + w5.bytes(obj.Data); + } + if (obj.filesize != null) { + w5.uint32(24); + w5.uint64(obj.filesize); + } + if (obj.blocksizes != null) { + for (const value of obj.blocksizes) { + w5.uint32(32); + w5.uint64(value); + } + } + if (obj.hashType != null) { + w5.uint32(40); + w5.uint64(obj.hashType); + } + if (obj.fanout != null) { + w5.uint32(48); + w5.uint64(obj.fanout); + } + if (obj.mode != null) { + w5.uint32(56); + w5.uint32(obj.mode); + } + if (obj.mtime != null) { + w5.uint32(66); + UnixTime2.codec().encode(obj.mtime, w5); + } + if (opts.lengthDelimited !== false) { + w5.ldelim(); + } + }, (reader2, length3) => { + const obj = { + blocksizes: [] + }; + const end = length3 == null ? reader2.len : reader2.pos + length3; + while (reader2.pos < end) { + const tag2 = reader2.uint32(); + switch (tag2 >>> 3) { + case 1: + obj.Type = Data3.DataType.codec().decode(reader2); + break; + case 2: + obj.Data = reader2.bytes(); + break; + case 3: + obj.filesize = reader2.uint64(); + break; + case 4: + obj.blocksizes.push(reader2.uint64()); + break; + case 5: + obj.hashType = reader2.uint64(); + break; + case 6: + obj.fanout = reader2.uint64(); + break; + case 7: + obj.mode = reader2.uint32(); + break; + case 8: + obj.mtime = UnixTime2.codec().decode(reader2, reader2.uint32()); + break; + default: + reader2.skipType(tag2 & 7); + break; + } + } + return obj; + }); + } + return _codec; + }; + Data3.encode = (obj) => { + return encodeMessage(obj, Data3.codec()); + }; + Data3.decode = (buf3) => { + return decodeMessage(buf3, Data3.codec()); + }; + })(Data2 || (Data2 = {})); + var UnixTime2; + (function(UnixTime3) { + let _codec; + UnixTime3.codec = () => { + if (_codec == null) { + _codec = message((obj, w5, opts = {}) => { + if (opts.lengthDelimited !== false) { + w5.fork(); + } + if (obj.Seconds != null) { + w5.uint32(8); + w5.int64(obj.Seconds); + } + if (obj.FractionalNanoseconds != null) { + w5.uint32(21); + w5.fixed32(obj.FractionalNanoseconds); + } + if (opts.lengthDelimited !== false) { + w5.ldelim(); + } + }, (reader2, length3) => { + const obj = {}; + const end = length3 == null ? reader2.len : reader2.pos + length3; + while (reader2.pos < end) { + const tag2 = reader2.uint32(); + switch (tag2 >>> 3) { + case 1: + obj.Seconds = reader2.int64(); + break; + case 2: + obj.FractionalNanoseconds = reader2.fixed32(); + break; + default: + reader2.skipType(tag2 & 7); + break; + } + } + return obj; + }); + } + return _codec; + }; + UnixTime3.encode = (obj) => { + return encodeMessage(obj, UnixTime3.codec()); + }; + UnixTime3.decode = (buf3) => { + return decodeMessage(buf3, UnixTime3.codec()); + }; + })(UnixTime2 || (UnixTime2 = {})); + var Metadata2; + (function(Metadata3) { + let _codec; + Metadata3.codec = () => { + if (_codec == null) { + _codec = message((obj, w5, opts = {}) => { + if (opts.lengthDelimited !== false) { + w5.fork(); + } + if (obj.MimeType != null) { + w5.uint32(10); + w5.string(obj.MimeType); + } + if (opts.lengthDelimited !== false) { + w5.ldelim(); + } + }, (reader2, length3) => { + const obj = {}; + const end = length3 == null ? reader2.len : reader2.pos + length3; + while (reader2.pos < end) { + const tag2 = reader2.uint32(); + switch (tag2 >>> 3) { + case 1: + obj.MimeType = reader2.string(); + break; + default: + reader2.skipType(tag2 & 7); + break; + } + } + return obj; + }); + } + return _codec; + }; + Metadata3.encode = (obj) => { + return encodeMessage(obj, Metadata3.codec()); + }; + Metadata3.decode = (buf3) => { + return decodeMessage(buf3, Metadata3.codec()); + }; + })(Metadata2 || (Metadata2 = {})); + + // ../../node_modules/.pnpm/ipfs-unixfs@11.0.2/node_modules/ipfs-unixfs/dist/src/index.js + var types3 = { + Raw: "raw", + Directory: "directory", + File: "file", + Metadata: "metadata", + Symlink: "symlink", + HAMTShard: "hamt-sharded-directory" + }; + var dirTypes = [ + "directory", + "hamt-sharded-directory" + ]; + var DEFAULT_FILE_MODE2 = parseInt("0644", 8); + var DEFAULT_DIRECTORY_MODE2 = parseInt("0755", 8); + var UnixFS = class _UnixFS { + constructor(options = { + type: "file" + }) { + __publicField(this, "type"); + __publicField(this, "data"); + __publicField(this, "blockSizes"); + __publicField(this, "hashType"); + __publicField(this, "fanout"); + __publicField(this, "mtime"); + __publicField(this, "_mode"); + __publicField(this, "_originalMode"); + const { type: type3, data, blockSizes, hashType, fanout, mtime, mode } = options; + if (type3 != null && !Object.values(types3).includes(type3)) { + throw (0, import_err_code5.default)(new Error("Type: " + type3 + " is not valid"), "ERR_INVALID_TYPE"); + } + this.type = type3 ?? "file"; + this.data = data; + this.hashType = hashType; + this.fanout = fanout; + this.blockSizes = blockSizes ?? []; + this._originalMode = 0; + this.mode = mode; + this.mtime = mtime; + } + /** + * Decode from protobuf https://github.com/ipfs/specs/blob/master/UNIXFS.md + */ + static unmarshal(marshaled) { + const message2 = Data2.decode(marshaled); + const data = new _UnixFS({ + type: types3[message2.Type != null ? message2.Type.toString() : "File"], + data: message2.Data, + blockSizes: message2.blocksizes, + mode: message2.mode, + mtime: message2.mtime != null ? { + secs: message2.mtime.Seconds ?? 0n, + nsecs: message2.mtime.FractionalNanoseconds + } : void 0 + }); + data._originalMode = message2.mode ?? 0; + return data; + } + set mode(mode) { + if (mode == null) { + this._mode = this.isDirectory() ? DEFAULT_DIRECTORY_MODE2 : DEFAULT_FILE_MODE2; + } else { + this._mode = mode & 4095; + } + } + get mode() { + return this._mode; + } + isDirectory() { + return dirTypes.includes(this.type); + } + addBlockSize(size4) { + this.blockSizes.push(size4); + } + removeBlockSize(index2) { + this.blockSizes.splice(index2, 1); + } + /** + * Returns `0n` for directories or `data.length + sum(blockSizes)` for everything else + */ + fileSize() { + if (this.isDirectory()) { + return 0n; + } + let sum = 0n; + this.blockSizes.forEach((size4) => { + sum += size4; + }); + if (this.data != null) { + sum += BigInt(this.data.length); + } + return sum; + } + /** + * encode to protobuf Uint8Array + */ + marshal() { + let type3; + switch (this.type) { + case "raw": + type3 = Data2.DataType.Raw; + break; + case "directory": + type3 = Data2.DataType.Directory; + break; + case "file": + type3 = Data2.DataType.File; + break; + case "metadata": + type3 = Data2.DataType.Metadata; + break; + case "symlink": + type3 = Data2.DataType.Symlink; + break; + case "hamt-sharded-directory": + type3 = Data2.DataType.HAMTShard; + break; + default: + throw (0, import_err_code5.default)(new Error(`Type: ${type3} is not valid`), "ERR_INVALID_TYPE"); + } + let data = this.data; + if (this.data == null || this.data.length === 0) { + data = void 0; + } + let mode; + if (this.mode != null) { + mode = this._originalMode & 4294963200 | (this.mode ?? 0); + if (mode === DEFAULT_FILE_MODE2 && !this.isDirectory()) { + mode = void 0; + } + if (mode === DEFAULT_DIRECTORY_MODE2 && this.isDirectory()) { + mode = void 0; + } + } + let mtime; + if (this.mtime != null) { + mtime = { + Seconds: this.mtime.secs, + FractionalNanoseconds: this.mtime.nsecs + }; + } + return Data2.encode({ + Type: type3, + Data: data, + filesize: this.isDirectory() ? void 0 : this.fileSize(), + blocksizes: this.blockSizes, + hashType: this.hashType, + fanout: this.fanout, + mode, + mtime + }); + } + }; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/hamt-sharding@3.0.2/node_modules/hamt-sharding/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/hamt-sharding@3.0.2/node_modules/hamt-sharding/dist/src/bucket.js + init_dirname(); + init_buffer2(); + init_process(); + var import_sparse_array = __toESM(require_sparse_array(), 1); + var Bucket = class _Bucket { + constructor(options, parent, posAtParent = 0) { + this._options = options; + this._popCount = 0; + this._parent = parent; + this._posAtParent = posAtParent; + this._children = new import_sparse_array.default(); + this.key = null; + } + async put(key, value) { + const place = await this._findNewBucketAndPos(key); + await place.bucket._putAt(place, key, value); + } + async get(key) { + const child = await this._findChild(key); + if (child != null) { + return child.value; + } + } + async del(key) { + const place = await this._findPlace(key); + const child = place.bucket._at(place.pos); + if (child != null && child.key === key) { + place.bucket._delAt(place.pos); + } + } + leafCount() { + const children = this._children.compactArray(); + return children.reduce((acc, child) => { + if (child instanceof _Bucket) { + return acc + child.leafCount(); + } + return acc + 1; + }, 0); + } + childrenCount() { + return this._children.length; + } + onlyChild() { + return this._children.get(0); + } + *eachLeafSeries() { + const children = this._children.compactArray(); + for (const child of children) { + if (child instanceof _Bucket) { + yield* child.eachLeafSeries(); + } else { + yield child; + } + } + } + serialize(map2, reduce) { + const acc = []; + return reduce(this._children.reduce((acc2, child, index2) => { + if (child != null) { + if (child instanceof _Bucket) { + acc2.push(child.serialize(map2, reduce)); + } else { + acc2.push(map2(child, index2)); + } + } + return acc2; + }, acc)); + } + async asyncTransform(asyncMap, asyncReduce) { + return await asyncTransformBucket(this, asyncMap, asyncReduce); + } + toJSON() { + return this.serialize(mapNode, reduceNodes); + } + prettyPrint() { + return JSON.stringify(this.toJSON(), null, " "); + } + tableSize() { + return Math.pow(2, this._options.bits); + } + async _findChild(key) { + const result = await this._findPlace(key); + const child = result.bucket._at(result.pos); + if (child instanceof _Bucket) { + return void 0; + } + if (child != null && child.key === key) { + return child; + } + } + async _findPlace(key) { + const hashValue = this._options.hash(typeof key === "string" ? fromString5(key) : key); + const index2 = await hashValue.take(this._options.bits); + const child = this._children.get(index2); + if (child instanceof _Bucket) { + return await child._findPlace(hashValue); + } + return { + bucket: this, + pos: index2, + hash: hashValue, + existingChild: child + }; + } + async _findNewBucketAndPos(key) { + const place = await this._findPlace(key); + if (place.existingChild != null && place.existingChild.key !== key) { + const bucket = new _Bucket(this._options, place.bucket, place.pos); + place.bucket._putObjectAt(place.pos, bucket); + const newPlace = await bucket._findPlace(place.existingChild.hash); + newPlace.bucket._putAt(newPlace, place.existingChild.key, place.existingChild.value); + return await bucket._findNewBucketAndPos(place.hash); + } + return place; + } + _putAt(place, key, value) { + this._putObjectAt(place.pos, { + key, + value, + hash: place.hash + }); + } + _putObjectAt(pos, object) { + if (this._children.get(pos) == null) { + this._popCount++; + } + this._children.set(pos, object); + } + _delAt(pos) { + if (pos === -1) { + throw new Error("Invalid position"); + } + if (this._children.get(pos) != null) { + this._popCount--; + } + this._children.unset(pos); + this._level(); + } + _level() { + if (this._parent != null && this._popCount <= 1) { + if (this._popCount === 1) { + const onlyChild = this._children.find(exists2); + if (onlyChild != null && !(onlyChild instanceof _Bucket)) { + const hash = onlyChild.hash; + hash.untake(this._options.bits); + const place = { + pos: this._posAtParent, + hash, + bucket: this._parent + }; + this._parent._putAt(place, onlyChild.key, onlyChild.value); + } + } else { + this._parent._delAt(this._posAtParent); + } + } + } + _at(index2) { + return this._children.get(index2); + } + }; + function exists2(o9) { + return Boolean(o9); + } + function mapNode(node, _5) { + return node.key; + } + function reduceNodes(nodes) { + return nodes; + } + async function asyncTransformBucket(bucket, asyncMap, asyncReduce) { + const output = []; + for (const child of bucket._children.compactArray()) { + if (child instanceof Bucket) { + await asyncTransformBucket(child, asyncMap, asyncReduce); + } else { + const mappedChildren = await asyncMap(child); + output.push({ + bitField: bucket._children.bitField(), + children: mappedChildren + }); + } + } + return await asyncReduce(output); + } + + // ../../node_modules/.pnpm/hamt-sharding@3.0.2/node_modules/hamt-sharding/dist/src/consumable-hash.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/hamt-sharding@3.0.2/node_modules/hamt-sharding/dist/src/consumable-buffer.js + init_dirname(); + init_buffer2(); + init_process(); + var START_MASKS = [ + 255, + 254, + 252, + 248, + 240, + 224, + 192, + 128 + ]; + var STOP_MASKS = [ + 1, + 3, + 7, + 15, + 31, + 63, + 127, + 255 + ]; + var ConsumableBuffer = class { + constructor(value) { + this._value = value; + this._currentBytePos = value.length - 1; + this._currentBitPos = 7; + } + availableBits() { + return this._currentBitPos + 1 + this._currentBytePos * 8; + } + totalBits() { + return this._value.length * 8; + } + take(bits) { + let pendingBits = bits; + let result = 0; + while (pendingBits > 0 && this._haveBits()) { + const byte = this._value[this._currentBytePos]; + const availableBits = this._currentBitPos + 1; + const taking = Math.min(availableBits, pendingBits); + const value = byteBitsToInt(byte, availableBits - taking, taking); + result = (result << taking) + value; + pendingBits -= taking; + this._currentBitPos -= taking; + if (this._currentBitPos < 0) { + this._currentBitPos = 7; + this._currentBytePos--; + } + } + return result; + } + untake(bits) { + this._currentBitPos += bits; + while (this._currentBitPos > 7) { + this._currentBitPos -= 8; + this._currentBytePos += 1; + } + } + _haveBits() { + return this._currentBytePos >= 0; + } + }; + function byteBitsToInt(byte, start, length3) { + const mask2 = maskFor(start, length3); + return (byte & mask2) >>> start; + } + function maskFor(start, length3) { + return START_MASKS[start] & STOP_MASKS[Math.min(length3 + start - 1, 7)]; + } + + // ../../node_modules/.pnpm/hamt-sharding@3.0.2/node_modules/hamt-sharding/dist/src/consumable-hash.js + function wrapHash(hashFn2) { + function hashing(value) { + if (value instanceof InfiniteHash) { + return value; + } else { + return new InfiniteHash(value, hashFn2); + } + } + return hashing; + } + var InfiniteHash = class { + constructor(value, hashFn2) { + if (!(value instanceof Uint8Array)) { + throw new Error("can only hash Uint8Arrays"); + } + this._value = value; + this._hashFn = hashFn2; + this._depth = -1; + this._availableBits = 0; + this._currentBufferIndex = 0; + this._buffers = []; + } + async take(bits) { + let pendingBits = bits; + while (this._availableBits < pendingBits) { + await this._produceMoreBits(); + } + let result = 0; + while (pendingBits > 0) { + const hash = this._buffers[this._currentBufferIndex]; + const available = Math.min(hash.availableBits(), pendingBits); + const took = hash.take(available); + result = (result << available) + took; + pendingBits -= available; + this._availableBits -= available; + if (hash.availableBits() === 0) { + this._currentBufferIndex++; + } + } + return result; + } + untake(bits) { + let pendingBits = bits; + while (pendingBits > 0) { + const hash = this._buffers[this._currentBufferIndex]; + const availableForUntake = Math.min(hash.totalBits() - hash.availableBits(), pendingBits); + hash.untake(availableForUntake); + pendingBits -= availableForUntake; + this._availableBits += availableForUntake; + if (this._currentBufferIndex > 0 && hash.totalBits() === hash.availableBits()) { + this._depth--; + this._currentBufferIndex--; + } + } + } + async _produceMoreBits() { + this._depth++; + const value = this._depth > 0 ? concat3([this._value, Uint8Array.from([this._depth])]) : this._value; + const hashValue = await this._hashFn(value); + const buffer4 = new ConsumableBuffer(hashValue); + this._buffers.push(buffer4); + this._availableBits += buffer4.availableBits(); + } + }; + + // ../../node_modules/.pnpm/hamt-sharding@3.0.2/node_modules/hamt-sharding/dist/src/index.js + function createHAMT(options) { + if (options == null || options.hashFn == null) { + throw new Error("please define an options.hashFn"); + } + const bucketOptions = { + bits: options.bits ?? 8, + hash: wrapHash(options.hashFn) + }; + return new Bucket(bucketOptions); + } + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js + var hashFn = async function(buf3) { + return (await murmur3128.encode(buf3)).slice(0, 8).reverse(); + }; + var addLinksToHamtBucket = async (links4, bucket, rootBucket) => { + await Promise.all(links4.map(async (link10) => { + if (link10.Name == null) { + throw new Error("Unexpected Link without a Name"); + } + if (link10.Name.length === 2) { + const pos = parseInt(link10.Name, 16); + bucket._putObjectAt(pos, new Bucket({ + hash: rootBucket._options.hash, + bits: rootBucket._options.bits + }, bucket, pos)); + return; + } + await rootBucket.put(link10.Name.substring(2), true); + })); + }; + var toPrefix = (position) => { + return position.toString(16).toUpperCase().padStart(2, "0").substring(0, 2); + }; + var toBucketPath = (position) => { + let bucket = position.bucket; + const path2 = []; + while (bucket._parent != null) { + path2.push(bucket); + bucket = bucket._parent; + } + path2.push(bucket); + return path2.reverse(); + }; + var findShardCid = async (node, name15, blockstore, context2, options) => { + if (context2 == null) { + const rootBucket = createHAMT({ + hashFn + }); + context2 = { + rootBucket, + hamtDepth: 1, + lastBucket: rootBucket + }; + } + await addLinksToHamtBucket(node.Links, context2.lastBucket, context2.rootBucket); + const position = await context2.rootBucket._findNewBucketAndPos(name15); + let prefix = toPrefix(position.pos); + const bucketPath = toBucketPath(position); + if (bucketPath.length > context2.hamtDepth) { + context2.lastBucket = bucketPath[context2.hamtDepth]; + prefix = toPrefix(context2.lastBucket._posAtParent); + } + const link10 = node.Links.find((link11) => { + if (link11.Name == null) { + return false; + } + const entryPrefix = link11.Name.substring(0, 2); + const entryName = link11.Name.substring(2); + if (entryPrefix !== prefix) { + return false; + } + if (entryName !== "" && entryName !== name15) { + return false; + } + return true; + }); + if (link10 == null) { + return; + } + if (link10.Name != null && link10.Name.substring(2) === name15) { + return link10.Hash; + } + context2.hamtDepth++; + const block = await blockstore.get(link10.Hash, options); + node = decode35(block); + return findShardCid(node, name15, blockstore, context2, options); + }; + var find_cid_in_shard_default = findShardCid; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/it-filter@3.0.3/node_modules/it-filter/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/it-peekable@3.0.2/node_modules/it-peekable/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + function peekable(iterable) { + const [iterator, symbol] = iterable[Symbol.asyncIterator] != null ? [iterable[Symbol.asyncIterator](), Symbol.asyncIterator] : [iterable[Symbol.iterator](), Symbol.iterator]; + const queue = []; + return { + peek: () => { + return iterator.next(); + }, + push: (value) => { + queue.push(value); + }, + next: () => { + if (queue.length > 0) { + return { + done: false, + value: queue.shift() + }; + } + return iterator.next(); + }, + [symbol]() { + return this; + } + }; + } + var src_default2 = peekable; + + // ../../node_modules/.pnpm/it-filter@3.0.3/node_modules/it-filter/dist/src/index.js + function isAsyncIterable2(thing) { + return thing[Symbol.asyncIterator] != null; + } + function filter(source, fn) { + if (isAsyncIterable2(source)) { + return async function* () { + for await (const entry of source) { + if (await fn(entry)) { + yield entry; + } + } + }(); + } + const peekable2 = src_default2(source); + const { value, done } = peekable2.next(); + if (done === true) { + return /* @__PURE__ */ function* () { + }(); + } + const res = fn(value); + if (typeof res.then === "function") { + return async function* () { + if (await res) { + yield value; + } + for await (const entry of peekable2) { + if (await fn(entry)) { + yield entry; + } + } + }(); + } + const func = fn; + return function* () { + if (res === true) { + yield value; + } + for (const entry of peekable2) { + if (func(entry)) { + yield entry; + } + } + }(); + } + var src_default3 = filter; + + // ../../node_modules/.pnpm/it-map@3.0.4/node_modules/it-map/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + function isAsyncIterable3(thing) { + return thing[Symbol.asyncIterator] != null; + } + function map(source, func) { + if (isAsyncIterable3(source)) { + return async function* () { + for await (const val of source) { + yield func(val); + } + }(); + } + const peekable2 = src_default2(source); + const { value, done } = peekable2.next(); + if (done === true) { + return /* @__PURE__ */ function* () { + }(); + } + const res = func(value); + if (typeof res.then === "function") { + return async function* () { + yield await res; + for await (const val of peekable2) { + yield func(val); + } + }(); + } + const fn = func; + return function* () { + yield res; + for (const val of peekable2) { + yield fn(val); + } + }(); + } + var src_default4 = map; + + // ../../node_modules/.pnpm/it-parallel@3.0.4/node_modules/it-parallel/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + var CustomEvent = globalThis.CustomEvent ?? Event; + async function* parallel(source, options = {}) { + let concurrency = options.concurrency ?? Infinity; + if (concurrency < 1) { + concurrency = Infinity; + } + const ordered = options.ordered == null ? false : options.ordered; + const emitter = new EventTarget(); + const ops = []; + let slotAvailable = pDefer(); + let resultAvailable = pDefer(); + let sourceFinished = false; + let sourceErr; + let opErred = false; + emitter.addEventListener("task-complete", () => { + resultAvailable.resolve(); + }); + void Promise.resolve().then(async () => { + try { + for await (const task of source) { + if (ops.length === concurrency) { + slotAvailable = pDefer(); + await slotAvailable.promise; + } + if (opErred) { + break; + } + const op = { + done: false + }; + ops.push(op); + task().then((result) => { + op.done = true; + op.ok = true; + op.value = result; + emitter.dispatchEvent(new CustomEvent("task-complete")); + }, (err) => { + op.done = true; + op.err = err; + emitter.dispatchEvent(new CustomEvent("task-complete")); + }); + } + sourceFinished = true; + emitter.dispatchEvent(new CustomEvent("task-complete")); + } catch (err) { + sourceErr = err; + emitter.dispatchEvent(new CustomEvent("task-complete")); + } + }); + function valuesAvailable() { + if (ordered) { + return ops[0]?.done; + } + return Boolean(ops.find((op) => op.done)); + } + function* yieldOrderedValues() { + while (ops.length > 0 && ops[0].done) { + const op = ops[0]; + ops.shift(); + if (op.ok) { + yield op.value; + } else { + opErred = true; + slotAvailable.resolve(); + throw op.err; + } + slotAvailable.resolve(); + } + } + function* yieldUnOrderedValues() { + while (valuesAvailable()) { + for (let i8 = 0; i8 < ops.length; i8++) { + if (ops[i8].done) { + const op = ops[i8]; + ops.splice(i8, 1); + i8--; + if (op.ok) { + yield op.value; + } else { + opErred = true; + slotAvailable.resolve(); + throw op.err; + } + slotAvailable.resolve(); + } + } + } + } + while (true) { + if (!valuesAvailable()) { + resultAvailable = pDefer(); + await resultAvailable.promise; + } + if (sourceErr != null) { + throw sourceErr; + } + if (ordered) { + yield* yieldOrderedValues(); + } else { + yield* yieldUnOrderedValues(); + } + if (sourceFinished && ops.length === 0) { + break; + } + } + } + + // ../../node_modules/.pnpm/it-pipe@3.0.1/node_modules/it-pipe/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/it-pushable@3.2.1/node_modules/it-pushable/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + + // ../../node_modules/.pnpm/it-pushable@3.2.1/node_modules/it-pushable/dist/src/fifo.js + init_dirname(); + init_buffer2(); + init_process(); + var FixedFIFO = class { + constructor(hwm) { + __publicField(this, "buffer"); + __publicField(this, "mask"); + __publicField(this, "top"); + __publicField(this, "btm"); + __publicField(this, "next"); + if (!(hwm > 0) || (hwm - 1 & hwm) !== 0) { + throw new Error("Max size for a FixedFIFO should be a power of two"); + } + this.buffer = new Array(hwm); + this.mask = hwm - 1; + this.top = 0; + this.btm = 0; + this.next = null; + } + push(data) { + if (this.buffer[this.top] !== void 0) { + return false; + } + this.buffer[this.top] = data; + this.top = this.top + 1 & this.mask; + return true; + } + shift() { + const last2 = this.buffer[this.btm]; + if (last2 === void 0) { + return void 0; + } + this.buffer[this.btm] = void 0; + this.btm = this.btm + 1 & this.mask; + return last2; + } + isEmpty() { + return this.buffer[this.btm] === void 0; + } + }; + var FIFO = class { + constructor(options = {}) { + __publicField(this, "size"); + __publicField(this, "hwm"); + __publicField(this, "head"); + __publicField(this, "tail"); + this.hwm = options.splitLimit ?? 16; + this.head = new FixedFIFO(this.hwm); + this.tail = this.head; + this.size = 0; + } + calculateSize(obj) { + if (obj?.byteLength != null) { + return obj.byteLength; + } + return 1; + } + push(val) { + if (val?.value != null) { + this.size += this.calculateSize(val.value); + } + if (!this.head.push(val)) { + const prev = this.head; + this.head = prev.next = new FixedFIFO(2 * this.head.buffer.length); + this.head.push(val); + } + } + shift() { + let val = this.tail.shift(); + if (val === void 0 && this.tail.next != null) { + const next = this.tail.next; + this.tail.next = null; + this.tail = next; + val = this.tail.shift(); + } + if (val?.value != null) { + this.size -= this.calculateSize(val.value); + } + return val; + } + isEmpty() { + return this.head.isEmpty(); + } + }; + + // ../../node_modules/.pnpm/it-pushable@3.2.1/node_modules/it-pushable/dist/src/index.js + var AbortError6 = class extends Error { + constructor(message2, code15) { + super(message2 ?? "The operation was aborted"); + __publicField(this, "type"); + __publicField(this, "code"); + this.type = "aborted"; + this.code = code15 ?? "ABORT_ERR"; + } + }; + function pushable(options = {}) { + const getNext = (buffer4) => { + const next = buffer4.shift(); + if (next == null) { + return { done: true }; + } + if (next.error != null) { + throw next.error; + } + return { + done: next.done === true, + // @ts-expect-error if done is false, value will be present + value: next.value + }; + }; + return _pushable(getNext, options); + } + function _pushable(getNext, options) { + options = options ?? {}; + let onEnd = options.onEnd; + let buffer4 = new FIFO(); + let pushable2; + let onNext; + let ended; + let drain = pDefer(); + const waitNext = async () => { + try { + if (!buffer4.isEmpty()) { + return getNext(buffer4); + } + if (ended) { + return { done: true }; + } + return await new Promise((resolve7, reject) => { + onNext = (next) => { + onNext = null; + buffer4.push(next); + try { + resolve7(getNext(buffer4)); + } catch (err) { + reject(err); + } + return pushable2; + }; + }); + } finally { + if (buffer4.isEmpty()) { + queueMicrotask(() => { + drain.resolve(); + drain = pDefer(); + }); + } + } + }; + const bufferNext = (next) => { + if (onNext != null) { + return onNext(next); + } + buffer4.push(next); + return pushable2; + }; + const bufferError = (err) => { + buffer4 = new FIFO(); + if (onNext != null) { + return onNext({ error: err }); + } + buffer4.push({ error: err }); + return pushable2; + }; + const push2 = (value) => { + if (ended) { + return pushable2; + } + if (options?.objectMode !== true && value?.byteLength == null) { + throw new Error("objectMode was not true but tried to push non-Uint8Array value"); + } + return bufferNext({ done: false, value }); + }; + const end = (err) => { + if (ended) + return pushable2; + ended = true; + return err != null ? bufferError(err) : bufferNext({ done: true }); + }; + const _return = () => { + buffer4 = new FIFO(); + end(); + return { done: true }; + }; + const _throw = (err) => { + end(err); + return { done: true }; + }; + pushable2 = { + [Symbol.asyncIterator]() { + return this; + }, + next: waitNext, + return: _return, + throw: _throw, + push: push2, + end, + get readableLength() { + return buffer4.size; + }, + onEmpty: async (options2) => { + const signal = options2?.signal; + signal?.throwIfAborted(); + if (buffer4.isEmpty()) { + return; + } + let cancel; + let listener; + if (signal != null) { + cancel = new Promise((resolve7, reject) => { + listener = () => { + reject(new AbortError6()); + }; + signal.addEventListener("abort", listener); + }); + } + try { + await Promise.race([ + drain.promise, + cancel + ]); + } finally { + if (listener != null && signal != null) { + signal?.removeEventListener("abort", listener); + } + } + } + }; + if (onEnd == null) { + return pushable2; + } + const _pushable2 = pushable2; + pushable2 = { + [Symbol.asyncIterator]() { + return this; + }, + next() { + return _pushable2.next(); + }, + throw(err) { + _pushable2.throw(err); + if (onEnd != null) { + onEnd(err); + onEnd = void 0; + } + return { done: true }; + }, + return() { + _pushable2.return(); + if (onEnd != null) { + onEnd(); + onEnd = void 0; + } + return { done: true }; + }, + push: push2, + end(err) { + _pushable2.end(err); + if (onEnd != null) { + onEnd(err); + onEnd = void 0; + } + return pushable2; + }, + get readableLength() { + return _pushable2.readableLength; + } + }; + return pushable2; + } + + // ../../node_modules/.pnpm/it-merge@3.0.2/node_modules/it-merge/dist/src/index.js + init_dirname(); + init_buffer2(); + init_process(); + function isAsyncIterable4(thing) { + return thing[Symbol.asyncIterator] != null; + } + function merge(...sources) { + const syncSources = []; + for (const source of sources) { + if (!isAsyncIterable4(source)) { + syncSources.push(source); + } + } + if (syncSources.length === sources.length) { + return function* () { + for (const source of syncSources) { + yield* source; + } + }(); + } + return async function* () { + const output = pushable({ + objectMode: true + }); + void Promise.resolve().then(async () => { + try { + await Promise.all(sources.map(async (source) => { + for await (const item of source) { + output.push(item); + } + })); + output.end(); + } catch (err) { + output.end(err); + } + }); + yield* output; + }(); + } + var src_default5 = merge; + + // ../../node_modules/.pnpm/it-pipe@3.0.1/node_modules/it-pipe/dist/src/index.js + function pipe(first, ...rest) { + if (first == null) { + throw new Error("Empty pipeline"); + } + if (isDuplex(first)) { + const duplex = first; + first = () => duplex.source; + } else if (isIterable(first) || isAsyncIterable5(first)) { + const source = first; + first = () => source; + } + const fns = [first, ...rest]; + if (fns.length > 1) { + if (isDuplex(fns[fns.length - 1])) { + fns[fns.length - 1] = fns[fns.length - 1].sink; + } + } + if (fns.length > 2) { + for (let i8 = 1; i8 < fns.length - 1; i8++) { + if (isDuplex(fns[i8])) { + fns[i8] = duplexPipelineFn(fns[i8]); + } + } + } + return rawPipe(...fns); + } + var rawPipe = (...fns) => { + let res; + while (fns.length > 0) { + res = fns.shift()(res); + } + return res; + }; + var isAsyncIterable5 = (obj) => { + return obj?.[Symbol.asyncIterator] != null; + }; + var isIterable = (obj) => { + return obj?.[Symbol.iterator] != null; + }; + var isDuplex = (obj) => { + if (obj == null) { + return false; + } + return obj.sink != null && obj.source != null; + }; + var duplexPipelineFn = (duplex) => { + return (source) => { + const p8 = duplex.sink(source); + if (p8?.then != null) { + const stream2 = pushable({ + objectMode: true + }); + p8.then(() => { + stream2.end(); + }, (err) => { + stream2.end(err); + }); + let sourceWrap; + const source2 = duplex.source; + if (isAsyncIterable5(source2)) { + sourceWrap = async function* () { + yield* source2; + stream2.end(); + }; + } else if (isIterable(source2)) { + sourceWrap = function* () { + yield* source2; + stream2.end(); + }; + } else { + throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable"); + } + return src_default5(stream2, sourceWrap()); + } + return duplex.source; + }; + }; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js + var directoryContent = (cid, node, unixfs, path2, resolve7, depth, blockstore) => { + async function* yieldDirectoryContent(options = {}) { + const offset2 = options.offset ?? 0; + const length3 = options.length ?? node.Links.length; + const links4 = node.Links.slice(offset2, length3); + options.onProgress?.(new CustomProgressEvent("unixfs:exporter:walk:directory", { + cid + })); + yield* pipe(links4, (source) => src_default4(source, (link10) => { + return async () => { + const linkName = link10.Name ?? ""; + const linkPath = `${path2}/${linkName}`; + const result = await resolve7(link10.Hash, linkName, linkPath, [], depth + 1, blockstore, options); + return result.entry; + }; + }), (source) => parallel(source, { ordered: true }), (source) => src_default3(source, (entry) => entry != null)); + } + return yieldDirectoryContent; + }; + var directory_default = directoryContent; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js + init_dirname(); + init_buffer2(); + init_process(); + var import_err_code6 = __toESM(require_err_code(), 1); + async function walkDAG(blockstore, node, queue, streamPosition, start, end, options) { + if (node instanceof Uint8Array) { + const buf3 = extract_data_from_block_default(node, streamPosition, start, end); + queue.push(buf3); + return; + } + if (node.Data == null) { + throw (0, import_err_code6.default)(new Error("no data in PBNode"), "ERR_NOT_UNIXFS"); + } + let file; + try { + file = UnixFS.unmarshal(node.Data); + } catch (err) { + throw (0, import_err_code6.default)(err, "ERR_NOT_UNIXFS"); + } + if (file.data != null) { + const data = file.data; + const buf3 = extract_data_from_block_default(data, streamPosition, start, end); + queue.push(buf3); + streamPosition += BigInt(buf3.byteLength); + } + const childOps = []; + if (node.Links.length !== file.blockSizes.length) { + throw (0, import_err_code6.default)(new Error("Inconsistent block sizes and dag links"), "ERR_NOT_UNIXFS"); + } + for (let i8 = 0; i8 < node.Links.length; i8++) { + const childLink = node.Links[i8]; + const childStart = streamPosition; + const childEnd = childStart + file.blockSizes[i8]; + if (start >= childStart && start < childEnd || // child has offset byte + end >= childStart && end <= childEnd || // child has end byte + start < childStart && end > childEnd) { + childOps.push({ + link: childLink, + blockStart: streamPosition + }); + } + streamPosition = childEnd; + if (streamPosition > end) { + break; + } + } + await pipe(childOps, (source) => src_default4(source, (op) => { + return async () => { + const block = await blockstore.get(op.link.Hash, options); + return { + ...op, + block + }; + }; + }), (source) => parallel(source, { + ordered: true + }), async (source) => { + for await (const { link: link10, block, blockStart } of source) { + let child; + switch (link10.Hash.code) { + case code9: + child = decode35(block); + break; + case code12: + child = block; + break; + default: + queue.end((0, import_err_code6.default)(new Error(`Unsupported codec: ${link10.Hash.code}`), "ERR_NOT_UNIXFS")); + return; + } + const childQueue = new PQueue({ + concurrency: 1 + }); + childQueue.on("error", (error7) => { + queue.end(error7); + }); + void childQueue.add(async () => { + options.onProgress?.(new CustomProgressEvent("unixfs:exporter:walk:file", { + cid: link10.Hash + })); + await walkDAG(blockstore, child, queue, blockStart, start, end, options); + }); + await childQueue.onIdle(); + } + }); + if (streamPosition >= end) { + queue.end(); + } + } + var fileContent = (cid, node, unixfs, path2, resolve7, depth, blockstore) => { + async function* yieldFileContent(options = {}) { + const fileSize = unixfs.fileSize(); + if (fileSize === void 0) { + throw new Error("File was a directory"); + } + const { start, end } = validate_offset_and_length_default(fileSize, options.offset, options.length); + if (end === 0n) { + return; + } + let read13 = 0n; + const wanted = end - start; + const queue = pushable(); + options.onProgress?.(new CustomProgressEvent("unixfs:exporter:walk:file", { + cid + })); + void walkDAG(blockstore, node, queue, 0n, start, end, options).catch((err) => { + queue.end(err); + }); + for await (const buf3 of queue) { + if (buf3 == null) { + continue; + } + read13 += BigInt(buf3.byteLength); + if (read13 > wanted) { + queue.end(); + throw (0, import_err_code6.default)(new Error("Read too many bytes - the file size reported by the UnixFS data in the root node may be incorrect"), "ERR_OVER_READ"); + } + if (read13 === wanted) { + queue.end(); + } + options.onProgress?.(new CustomProgressEvent("unixfs:exporter:progress:unixfs:file", { + bytesRead: read13, + totalBytes: wanted, + fileSize + })); + yield buf3; + } + if (read13 < wanted) { + throw (0, import_err_code6.default)(new Error("Traversed entire DAG but did not read enough bytes"), "ERR_UNDER_READ"); + } + } + return yieldFileContent; + }; + var file_default = fileContent; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js + init_dirname(); + init_buffer2(); + init_process(); + var hamtShardedDirectoryContent = (cid, node, unixfs, path2, resolve7, depth, blockstore) => { + function yieldHamtDirectoryContent(options = {}) { + options.onProgress?.(new CustomProgressEvent("unixfs:exporter:walk:hamt-sharded-directory", { + cid + })); + return listDirectory(node, path2, resolve7, depth, blockstore, options); + } + return yieldHamtDirectoryContent; + }; + async function* listDirectory(node, path2, resolve7, depth, blockstore, options) { + const links4 = node.Links; + const results = pipe(links4, (source) => src_default4(source, (link10) => { + return async () => { + const name15 = link10.Name != null ? link10.Name.substring(2) : null; + if (name15 != null && name15 !== "") { + const result = await resolve7(link10.Hash, name15, `${path2}/${name15}`, [], depth + 1, blockstore, options); + return { entries: result.entry == null ? [] : [result.entry] }; + } else { + const block = await blockstore.get(link10.Hash, options); + node = decode35(block); + options.onProgress?.(new CustomProgressEvent("unixfs:exporter:walk:hamt-sharded-directory", { + cid: link10.Hash + })); + return { entries: listDirectory(node, path2, resolve7, depth, blockstore, options) }; + } + }; + }), (source) => parallel(source, { ordered: true })); + for await (const { entries: entries6 } of results) { + yield* entries6; + } + } + var hamt_sharded_directory_default = hamtShardedDirectoryContent; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js + var findLinkCid = (node, name15) => { + const link10 = node.Links.find((link11) => link11.Name === name15); + return link10?.Hash; + }; + var contentExporters = { + raw: file_default, + file: file_default, + directory: directory_default, + "hamt-sharded-directory": hamt_sharded_directory_default, + metadata: (cid, node, unixfs, path2, resolve7, depth, blockstore) => { + return () => []; + }, + symlink: (cid, node, unixfs, path2, resolve7, depth, blockstore) => { + return () => []; + } + }; + var unixFsResolver = async (cid, name15, path2, toResolve, resolve7, depth, blockstore, options) => { + const block = await blockstore.get(cid, options); + const node = decode35(block); + let unixfs; + let next; + if (name15 == null) { + name15 = cid.toString(); + } + if (node.Data == null) { + throw (0, import_err_code7.default)(new Error("no data in PBNode"), "ERR_NOT_UNIXFS"); + } + try { + unixfs = UnixFS.unmarshal(node.Data); + } catch (err) { + throw (0, import_err_code7.default)(err, "ERR_NOT_UNIXFS"); + } + if (path2 == null) { + path2 = name15; + } + if (toResolve.length > 0) { + let linkCid; + if (unixfs?.type === "hamt-sharded-directory") { + linkCid = await find_cid_in_shard_default(node, toResolve[0], blockstore); + } else { + linkCid = findLinkCid(node, toResolve[0]); + } + if (linkCid == null) { + throw (0, import_err_code7.default)(new Error("file does not exist"), "ERR_NOT_FOUND"); + } + const nextName = toResolve.shift(); + const nextPath = `${path2}/${nextName}`; + next = { + cid: linkCid, + toResolve, + name: nextName ?? "", + path: nextPath + }; + } + const content = contentExporters[unixfs.type](cid, node, unixfs, path2, resolve7, depth, blockstore); + if (content == null) { + throw (0, import_err_code7.default)(new Error("could not find content exporter"), "ERR_NOT_FOUND"); + } + if (unixfs.isDirectory()) { + return { + entry: { + type: "directory", + name: name15, + path: path2, + cid, + content, + unixfs, + depth, + node, + size: unixfs.fileSize() + }, + next + }; + } + return { + entry: { + type: "file", + name: name15, + path: path2, + cid, + content, + unixfs, + depth, + node, + size: unixfs.fileSize() + }, + next + }; + }; + var unixfs_v1_default = unixFsResolver; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/index.js + var resolvers = { + [code9]: unixfs_v1_default, + [code12]: raw_default, + [code]: dag_cbor_default, + [identity3.code]: identity_default + }; + var resolve6 = async (cid, name15, path2, toResolve, depth, blockstore, options) => { + const resolver = resolvers[cid.code]; + if (resolver == null) { + throw (0, import_err_code8.default)(new Error(`No resolver for code ${cid.code}`), "ERR_NO_RESOLVER"); + } + return resolver(cid, name15, path2, toResolve, resolve6, depth, blockstore, options); + }; + var resolvers_default = resolve6; + + // ../../node_modules/.pnpm/ipfs-unixfs-exporter@13.1.7/node_modules/ipfs-unixfs-exporter/dist/src/index.js + var toPathComponents = (path2 = "") => { + return (path2.trim().match(/([^\\^/]|\\\/)+/g) ?? []).filter(Boolean); + }; + var cidAndRest = (path2) => { + if (path2 instanceof Uint8Array) { + return { + cid: CID.decode(path2), + toResolve: [] + }; + } + const cid = CID.asCID(path2); + if (cid != null) { + return { + cid, + toResolve: [] + }; + } + if (typeof path2 === "string") { + if (path2.indexOf("/ipfs/") === 0) { + path2 = path2.substring(6); + } + const output = toPathComponents(path2); + return { + cid: CID.parse(output[0]), + toResolve: output.slice(1) + }; + } + throw (0, import_err_code9.default)(new Error(`Unknown path type ${path2}`), "ERR_BAD_PATH"); + }; + async function* walkPath(path2, blockstore, options = {}) { + let { cid, toResolve } = cidAndRest(path2); + let name15 = cid.toString(); + let entryPath = name15; + const startingDepth = toResolve.length; + while (true) { + const result = await resolvers_default(cid, name15, entryPath, toResolve, startingDepth, blockstore, options); + if (result.entry == null && result.next == null) { + throw (0, import_err_code9.default)(new Error(`Could not resolve ${path2}`), "ERR_NOT_FOUND"); + } + if (result.entry != null) { + yield result.entry; + } + if (result.next == null) { + return; + } + toResolve = result.next.toResolve; + cid = result.next.cid; + name15 = result.next.name; + entryPath = result.next.path; + } + } + async function exporter(path2, blockstore, options = {}) { + const result = await src_default(walkPath(path2, blockstore, options)); + if (result == null) { + throw (0, import_err_code9.default)(new Error(`Could not resolve ${path2}`), "ERR_NOT_FOUND"); + } + return result; + } + + // src/files.ts + var queuingStrategy2 = withCapacity(); + var settings2 = configure({ + fileChunkEncoder: raw_exports2, + smallFileEncoder: raw_exports2, + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call + chunker: withMaxChunkSize(1024 * 1024), + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call + fileLayout: withWidth(1024) + }); + async function encodeFile2(blob) { + const readable = createFileEncoderStream2(blob); + const blocks = await collect2(readable); + return { cid: blocks.at(-1).cid, blocks }; + } + async function decodeFile(blocks, cid, meta) { + const entry = await exporter(cid.toString(), blocks, { length: meta.size }); + const chunks = []; + for await (const chunk of entry.content()) + chunks.push(chunk); + return new File(chunks, entry.name, { type: entry.type, lastModified: 0 }); + } + function createFileEncoderStream2(blob) { + const { readable, writable } = new TransformStream({}, queuingStrategy2); + const unixfsWriter = createWriter3({ writable, settings: settings2 }); + const fileBuilder = new UnixFSFileBuilder2("", blob); + void (async () => { + await fileBuilder.finalize(unixfsWriter); + await unixfsWriter.close(); + })(); + return readable; + } + async function collect2(collectable) { + const chunks = []; + await collectable.pipeTo( + new WritableStream({ + write(chunk) { + chunks.push(chunk); + } + }) + ); + return chunks; + } + var _file2; + var UnixFSFileBuilder2 = class { + constructor(name15, file) { + __privateAdd(this, _file2, void 0); + __publicField(this, "name"); + this.name = name15; + __privateSet(this, _file2, file); + } + async finalize(writer2) { + const unixfsFileWriter = create8(writer2); + await __privateGet(this, _file2).stream().pipeTo( + new WritableStream({ + async write(chunk) { + await unixfsFileWriter.write(chunk); + } + }) + ); + return await unixfsFileWriter.close(); + } + }; + _file2 = new WeakMap(); + + // src/crdt-helpers.ts + async function applyBulkUpdateToCrdt(tblocks, head2, updates, options) { + let result; + for (const update2 of updates) { + const link10 = await makeLinkForDoc(tblocks, update2); + result = await put2(tblocks, head2, update2.key, link10, options); + const resRoot = result.root.toString(); + const isReturned = result.additions.some((a8) => a8.cid.toString() === resRoot); + if (!isReturned) { + const hasRoot = await tblocks.get(result.root); + if (!hasRoot) { + console.error(`missing root in additions: ${result.additions.length} ${resRoot} keys: ${updates.map((u8) => u8.key).toString()}`); + result.head = head2; + } + } + for (const { cid, bytes: bytes2 } of [...result.additions, ...result.removals, result.event]) { + tblocks.putSync(cid, bytes2); + } + head2 = result.head; + } + return { head: head2 }; + } + async function makeLinkForDoc(blocks, update2) { + let value; + if (update2.del) { + value = { del: true }; + } else { + await processFiles(blocks, update2.value); + value = { doc: update2.value }; + } + const block = await encode37({ value, hasher: sha2562, codec: src_exports }); + blocks.putSync(block.cid, block.bytes); + return block.cid; + } + async function processFiles(blocks, doc) { + if (doc._files) { + const dbBlockstore = blocks.parent; + const t9 = new Transaction(dbBlockstore); + dbBlockstore.transactions.add(t9); + const didPut = []; + for (const filename in doc._files) { + if (File === doc._files[filename].constructor) { + const file = doc._files[filename]; + const { cid, blocks: fileBlocks } = await encodeFile2(file); + didPut.push(filename); + for (const block of fileBlocks) { + t9.putSync(block.cid, block.bytes); + } + doc._files[filename] = { cid, type: file.type, size: file.size }; + } + } + if (didPut.length) { + const car = await dbBlockstore.loader?.commit(t9, { files: doc._files }); + if (car) { + for (const name15 of didPut) { + doc._files[name15] = { car, ...doc._files[name15] }; + } + } + } + } + } + async function getValueFromCrdt(blocks, head2, key) { + if (!head2.length) + throw new Error("Getting from an empty database"); + const link10 = await get16(blocks, head2, key); + if (!link10) + throw new Error(`Missing key ${key}`); + return await getValueFromLink(blocks, link10); + } + function readFiles(blocks, { doc }) { + if (doc && doc._files) { + for (const filename in doc._files) { + const fileMeta = doc._files[filename]; + if (fileMeta.cid) { + if (!blocks.loader) + throw new Error("Missing loader"); + if (fileMeta.car && blocks.loader) { + const ld = blocks.loader; + fileMeta.file = async () => await decodeFile({ + get: async (cid) => { + const reader2 = await ld.loadFileCar(fileMeta.car); + const block = await reader2.get(cid); + if (!block) + throw new Error(`Missing block ${cid.toString()}`); + return block.bytes; + } + }, fileMeta.cid, fileMeta); + } + } + doc._files[filename] = fileMeta; + } + } + } + async function getValueFromLink(blocks, link10) { + const block = await blocks.get(link10); + if (!block) + throw new Error(`Missing linked block ${link10.toString()}`); + const { value } = await decode43({ bytes: block.bytes, hasher: sha2562, codec: src_exports }); + readFiles(blocks, value); + return value; + } + var DirtyEventFetcher = class extends EventFetcher { + // @ts-ignore + async get(link10) { + try { + return await super.get(link10); + } catch (e12) { + console.error("missing event", link10.toString(), e12); + return { value: null }; + } + } + }; + async function clockChangesSince(blocks, head2, since, opts) { + const eventsFetcher = opts.dirty ? new DirtyEventFetcher(blocks) : new EventFetcher(blocks); + const keys2 = /* @__PURE__ */ new Set(); + const updates = await gatherUpdates(blocks, eventsFetcher, head2, since, [], keys2, opts.limit || Infinity); + return { result: updates.reverse(), head: head2 }; + } + async function gatherUpdates(blocks, eventsFetcher, head2, since, updates = [], keys2, limit) { + if (limit <= 0) + return updates; + const sHead = head2.map((l8) => l8.toString()); + for (const link10 of since) { + if (sHead.includes(link10.toString())) { + return updates; + } + } + for (const link10 of head2) { + const { value: event } = await eventsFetcher.get(link10); + if (!event) + continue; + const { key, value } = event.data; + if (keys2.has(key)) { + if (event.parents) { + updates = await gatherUpdates(blocks, eventsFetcher, event.parents, since, updates, keys2, limit); + } + } else { + keys2.add(key); + const docValue = await getValueFromLink(blocks, value); + updates.push({ key, value: docValue.doc, del: docValue.del }); + limit--; + if (event.parents) { + updates = await gatherUpdates(blocks, eventsFetcher, event.parents, since, updates, keys2, limit); + } + } + } + return updates; + } + async function doCompact(blocks, head2) { + const blockLog = new LoggingFetcher(blocks); + const newBlocks = new Transaction(blocks); + for await (const [, link10] of entries5(blockLog, head2)) { + const bl = await blocks.get(link10); + if (!bl) + throw new Error("Missing block: " + link10.toString()); + await newBlocks.put(link10, bl.bytes); + } + for await (const _line of vis(blockLog, head2)) { + } + for (const cid of blockLog.cids) { + const bl = await blocks.get(cid); + if (!bl) + throw new Error("Missing block: " + cid.toString()); + await newBlocks.put(cid, bl.bytes); + } + await blocks.commitCompaction(newBlocks, head2); + } + var LoggingFetcher = class { + constructor(blocks) { + __publicField(this, "blocks"); + __publicField(this, "cids", /* @__PURE__ */ new Set()); + this.blocks = blocks; + } + async get(cid) { + this.cids.add(cid); + return await this.blocks.get(cid); + } + }; + + // src/crdt-clock.ts + init_dirname(); + init_buffer2(); + init_process(); + var CRDTClock = class { + constructor() { + // todo: keep the clock of remote and local changes separate, merge on read + // that way we can drop the whole remote if we need to + // should go with making sure the local clock only references locally available blocks on write + __publicField(this, "head", []); + __publicField(this, "zoomers", /* @__PURE__ */ new Set()); + __publicField(this, "watchers", /* @__PURE__ */ new Set()); + __publicField(this, "blocks", null); + } + setHead(head2) { + this.head = head2; + } + async applyHead(tblocks, newHead, prevHead, updates = []) { + const ogHead = this.head.sort((a8, b6) => a8.toString().localeCompare(b6.toString())); + newHead = newHead.sort((a8, b6) => a8.toString().localeCompare(b6.toString())); + if (ogHead.toString() === newHead.toString()) { + this.watchers.forEach((fn) => fn(updates)); + return; + } + const ogPrev = prevHead.sort((a8, b6) => a8.toString().localeCompare(b6.toString())); + if (ogHead.toString() === ogPrev.toString()) { + this.setHead(newHead); + this.watchers.forEach((fn) => fn(updates)); + return; + } + if (updates.length > 0) { + throw new Error("if we are here we expected to be in a merge, and we should not have updates"); + } + const withBlocks = async (tblocks2, fn) => { + if (tblocks2 instanceof Transaction) + return await fn(tblocks2); + if (!this.blocks) + throw new Error("missing blocks"); + return await this.blocks.transaction(fn); + }; + const { head: head2 } = await withBlocks(tblocks, async (tblocks2) => { + let head3 = this.head; + for (const cid of newHead) { + head3 = await advance3(tblocks2, this.head, cid); + } + const result = await root(tblocks2, head3); + for (const { cid, bytes: bytes2 } of [...result.additions, ...result.removals]) { + tblocks2.putSync(cid, bytes2); + } + return { head: head3 }; + }); + this.setHead(head2); + this.zoomers.forEach((fn) => fn()); + this.watchers.forEach((fn) => fn(updates)); + } + onTick(fn) { + this.watchers.add(fn); + } + onZoom(fn) { + this.zoomers.add(fn); + } + }; + + // src/crdt.ts + var CRDT = class { + constructor(name15, opts) { + __publicField(this, "name"); + __publicField(this, "opts", {}); + __publicField(this, "ready"); + __publicField(this, "blocks"); + __publicField(this, "indexBlocks"); + __publicField(this, "indexers", /* @__PURE__ */ new Map()); + __publicField(this, "clock", new CRDTClock()); + this.name = name15 || null; + this.opts = opts || this.opts; + this.blocks = new TransactionBlockstore(this.name, this.clock, this.opts); + this.clock.blocks = this.blocks; + this.indexBlocks = new IndexBlockstore(this.name ? this.name + ".idx" : null, this, this.opts); + this.ready = Promise.all([this.blocks.ready, this.indexBlocks.ready]).then(() => { + }); + this.clock.onZoom(() => { + for (const idx of this.indexers.values()) { + idx._resetIndex(); + } + }); + } + async bulk(updates, options) { + await this.ready; + return await this.blocks.transaction(async (tblocks) => { + const prevHead = [...this.clock.head]; + const { head: head2 } = await applyBulkUpdateToCrdt(tblocks, this.clock.head, updates, options); + updates = updates.map(({ key, value, del: del2 }) => { + readFiles(this.blocks, { doc: value }); + return { key, value, del: del2 }; + }); + await this.clock.applyHead(tblocks, head2, prevHead, updates); + return { head: head2 }; + }); + } + // async getAll(rootCache: any = null): Promise<{root: any, cids: CIDCounter, clockCIDs: CIDCounter, result: T[]}> { + async get(key) { + await this.ready; + const result = await getValueFromCrdt(this.blocks, this.clock.head, key); + if (result.del) + return null; + return result; + } + async changes(since = [], opts = {}) { + await this.ready; + return await clockChangesSince(this.blocks, this.clock.head, since, opts); + } + async compact() { + await this.ready; + return await doCompact(this.blocks, this.clock.head); + } + }; + + // src/database.ts + var Database = class { + constructor(name15, opts) { + __publicField(this, "name"); + __publicField(this, "opts", {}); + __publicField(this, "_listeners", /* @__PURE__ */ new Set()); + __publicField(this, "_crdt"); + __publicField(this, "_writeQueue"); + this.name = name15 || null; + this.opts = opts || this.opts; + this._crdt = new CRDT(name15, this.opts); + this._crdt.clock.onTick((updates) => { + void this._notify(updates); + }); + this._writeQueue = writeQueue(async (updates) => { + return await this._crdt.bulk(updates); + }); + } + async get(id) { + const got = await this._crdt.get(id).catch((e12) => { + e12.message = `Not found: ${id} - ` + e12.message; + throw e12; + }); + if (!got) + throw new Error(`Not found: ${id}`); + const { doc } = got; + return { _id: id, ...doc }; + } + async put(doc) { + const { _id, ...value } = doc; + const docId = _id || uuidv7(); + const result = await this._writeQueue.push({ key: docId, value }); + return { id: docId, clock: result?.head }; + } + async del(id) { + const result = await this._writeQueue.push({ key: id, del: true }); + return { id, clock: result?.head }; + } + async changes(since = [], opts = {}) { + const { result, head: head2 } = await this._crdt.changes(since, opts); + const rows = result.map(({ key, value, del: del2 }) => ({ + key, + value: del2 ? { _id: key, _deleted: true } : { _id: key, ...value } + })); + return { rows, clock: head2 }; + } + subscribe(listener) { + this._listeners.add(listener); + return () => { + this._listeners.delete(listener); + }; + } + async query(field, opts = {}) { + const idx = typeof field === "string" ? index({ _crdt: this._crdt }, field) : index({ _crdt: this._crdt }, makeName(field.toString())); + return await idx.query(opts); + } + async compact() { + await this._crdt.compact(); + } + async _notify(updates) { + if (this._listeners.size) { + const docs = updates.map(({ key, value }) => ({ _id: key, ...value })); + for (const listener of this._listeners) { + await (async () => await listener(docs))().catch((e12) => { + console.error("listener error", e12); + }); + } + } + } + }; + __publicField(Database, "databases", /* @__PURE__ */ new Map()); + function fireproof(name15, opts) { + if (!Database.databases.has(name15)) { + const db = new Database(name15, opts); + ["get", "put", "del", "changes", "subscribe", "query"].forEach((fn) => { + db[fn] = db[fn].bind(db); + }); + Database.databases.set(name15, db); + } + return Database.databases.get(name15); + } + function makeName(fnString) { + const regex = /\(([^,()]+,\s*[^,()]+|\[[^\]]+\],\s*[^,()]+)\)/g; + let found = null; + const matches = Array.from(fnString.matchAll(regex), (match10) => match10[1].trim()); + if (matches.length === 0) { + found = /=>\s*(.*)/.exec(fnString); + } + if (!found) { + return fnString; + } else { + return found[1]; + } + } + return __toCommonJS(fireproof_exports); +})(); +/*! Bundled license information: + +@jspm/core/nodelibs/browser/buffer.js: + (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) + +@jspm/core/nodelibs/browser/chunk-44e51b61.js: + (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) + +@jspm/core/nodelibs/browser/assert.js: + (*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + *) + +pvtsutils/build/index.js: + (*! + * MIT License + * + * Copyright (c) 2017-2022 Peculiar Ventures, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *) + +@jspm/core/nodelibs/browser/crypto.js: + (*! safe-buffer. MIT License. Feross Aboukhadijeh *) + +@noble/ed25519/lib/esm/index.js: + (*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *) + +uuidv7/dist/index.js: + (** + * uuidv7: An experimental implementation of the proposed UUID Version 7 + * + * @license Apache-2.0 + * @copyright 2021-2023 LiosK + * @packageDocumentation + *) + +pvutils/build/utils.es.js: + (*! + Copyright (c) Peculiar Ventures, LLC + *) + +asn1js/build/index.es.js: + (*! + * Copyright (c) 2014, GMO GlobalSign + * Copyright (c) 2015-2022, Peculiar Ventures + * All rights reserved. + * + * Author 2014-2019, Yury Strozhevsky + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *) + +webcrypto-core/build/webcrypto-core.es.js: + (*! + Copyright (c) Peculiar Ventures, LLC + *) + +@peculiar/webcrypto/build/webcrypto.es.js: + (*! + Copyright (c) Peculiar Ventures, LLC + *) +*/ +//# sourceMappingURL=fireproof.iife.js.map diff --git a/docs/dist/stable_diffusion.js b/docs/dist/stable_diffusion.js index 3444bb5..54688c7 100644 --- a/docs/dist/stable_diffusion.js +++ b/docs/dist/stable_diffusion.js @@ -370,6 +370,7 @@ class StableDiffusionPipeline { this.tvm.withNewScope(() => { const image = this.vaeToImage(latents, this.vaeParams); this.tvm.showImage(this.imageToRGBA(image)); + writeImage({prompt, negPrompt}) }); await this.device.sync(); } @@ -385,6 +386,9 @@ class StableDiffusionPipeline { this.tvm.withNewScope(() => { const image = this.vaeToImage(latents, this.vaeParams); this.tvm.showImage(this.imageToRGBA(image)); + writeImage({prompt, negPrompt}).then(() => { + redrawHistory() + }) }); latents.dispose(); await this.device.sync(); @@ -563,6 +567,7 @@ class StableDiffusionInstance { }); this.tvm.registerAsyncServerFunc("showImage", async (data) => { this.tvm.showImage(data); + writeImage({prompt, negPrompt}) }); this.tvm.endScope(); } diff --git a/docs/index.html b/docs/index.html index 233f650..da117f9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -162,6 +162,7 @@

Demo

+

Notes

@@ -181,6 +182,258 @@

Disclaimer

+ + + +